diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModel.java index 7ade2cae69c..16f3b95ae45 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModel.java @@ -3,6 +3,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.dhis2.composetable.model.DropdownOption; + import java.util.List; public abstract class FieldViewModel { @@ -59,6 +61,9 @@ public abstract class FieldViewModel { @NonNull public abstract List options(); + @NonNull + public abstract List optionsList(); + @NonNull public abstract String storeBy(); diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactory.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactory.java index 5a84cb1a9cd..10d2e546bdd 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactory.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactory.java @@ -3,6 +3,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.dhis2.composetable.model.DropdownOption; import org.hisp.dhis.android.core.common.ValueType; import org.hisp.dhis.android.core.program.SectionRenderingType; @@ -28,5 +29,6 @@ FieldViewModel create(@NonNull String id, @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, - @Nullable String catCombo); + @Nullable String catCombo, + @Nullable List options); } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactoryImpl.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactoryImpl.java index b48a0546fa3..42c07287b2c 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactoryImpl.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/FieldViewModelFactoryImpl.java @@ -3,6 +3,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.age.AgeViewModel; import org.dhis2.data.forms.dataentry.tablefields.coordinate.CoordinateViewModel; import org.dhis2.data.forms.dataentry.tablefields.datetime.DateTimeViewModel; @@ -42,19 +43,19 @@ public FieldViewModel create(@NonNull String id, @NonNull String label, @NonNull @NonNull Boolean mandatory, @Nullable String optionSet, @Nullable String value, @Nullable String section, @Nullable Boolean allowFutureDates, @NonNull Boolean editable, @Nullable SectionRenderingType renderingType, @Nullable String description, @Nullable String dataElement, @Nullable List listCategoryOption, @Nullable String storeBy, - @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, String catCombo) { + @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, String catCombo, @Nullable List options) { isNull(type, "type must be supplied"); if (!isEmpty(optionSet)) { if (renderingType == null || renderingType == SectionRenderingType.LISTING) - return SpinnerViewModel.create(id, label, hintFilterOptions, mandatory, optionSet, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + return SpinnerViewModel.create(id, label, hintFilterOptions, mandatory, optionSet, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, options); else - return ImageViewModel.create(id, label, optionSet, value, section, editable, mandatory, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); //transforms option set into image option selector + return ImageViewModel.create(id, label, optionSet, value, section, editable, mandatory, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo,options); //transforms option set into image option selector } switch (type) { case AGE: - return AgeViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + return AgeViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, options); case TEXT: case EMAIL: case LETTER: @@ -68,24 +69,24 @@ public FieldViewModel create(@NonNull String id, @NonNull String label, @NonNull case INTEGER_ZERO_OR_POSITIVE: case UNIT_INTERVAL: case URL: - return EditTextViewModel.create(id, label, mandatory, value, hintEnterText, 1, type, section, editable, description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo); + return EditTextViewModel.create(id, label, mandatory, value, hintEnterText, 1, type, section, editable, description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo, options); case TIME: case DATE: case DATETIME: - return DateTimeViewModel.create(id, label, mandatory, type, value, section, allowFutureDates, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + return DateTimeViewModel.create(id, label, mandatory, type, value, section, allowFutureDates, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, options); case COORDINATE: - return CoordinateViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + return CoordinateViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, options); case BOOLEAN: case TRUE_ONLY: - return RadioButtonViewModel.fromRawValue(id, label, type, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + return RadioButtonViewModel.fromRawValue(id, label, type, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, options); case ORGANISATION_UNIT: //return OrgUnitViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); case IMAGE: case TRACKER_ASSOCIATE: case USERNAME: - return UnsupportedViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + return UnsupportedViewModel.create(id, label, mandatory, value, section, editable, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, options); default: - return EditTextViewModel.create(id, label, mandatory, value, hintEnterText, 1, type, section, editable, description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo); + return EditTextViewModel.create(id, label, mandatory, value, hintEnterText, 1, type, section, editable, description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo, options); } } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/age/AgeViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/age/AgeViewModel.java index 20fb6bb2b99..f3299ed601d 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/age/AgeViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/age/AgeViewModel.java @@ -5,6 +5,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @@ -15,7 +16,7 @@ */ @AutoValue -public abstract class AgeViewModel extends FieldViewModel { +public abstract class AgeViewModel extends FieldViewModel { @NonNull public abstract Boolean mandatory(); @@ -23,35 +24,35 @@ public abstract class AgeViewModel extends FieldViewModel { @Nullable public abstract String value(); - public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, @NonNull String dataElement, @NonNull List listCategoryOption, @NonNull String storeBy, @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, String catCombo) { - return new AutoValue_AgeViewModel(id, label, section, null, editable, null, null, null, description,dataElement, listCategoryOption, storeBy , row, column, categoryOptionCombo, catCombo, mandatory, value); + public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, @NonNull String dataElement, @NonNull List listCategoryOption, @NonNull String storeBy, @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, String catCombo, @Nullable List options) { + return new AutoValue_AgeViewModel(id, label, section, null, editable, null, null, null, description,dataElement, listCategoryOption, options, storeBy , row, column, categoryOptionCombo, catCombo, mandatory, value); } @Override public FieldViewModel setMandatory() { - return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), true, value()); + return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), true, value()); } @Override public FieldViewModel setValue(String value) { - return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), mandatory(), value); + return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), mandatory(), value); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { - return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error, description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), mandatory(), value()); + return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error, description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), mandatory(), value()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { - return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning, error(), description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), mandatory(), value()); + return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning, error(), description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), mandatory(), value()); } @NonNull @Override public FieldViewModel withValue(String data) { - return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), mandatory(), data); + return new AutoValue_AgeViewModel(uid(), label(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), mandatory(), data); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/coordinate/CoordinateViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/coordinate/CoordinateViewModel.java index 381548e3ca2..c6faeaa1aaf 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/coordinate/CoordinateViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/coordinate/CoordinateViewModel.java @@ -5,6 +5,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @@ -15,35 +16,35 @@ @AutoValue public abstract class CoordinateViewModel extends FieldViewModel { - public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, @NonNull String dataElement, @NonNull List listCategoryOption, @NonNull String storeBy, @Nullable int row, @Nullable int column, String categoryOptionCombo, String catCombo) { - return new AutoValue_CoordinateViewModel(id, label, mandatory, value, section, null, editable, null, null, null,description,dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo); + public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, @NonNull String dataElement, @NonNull List listCategoryOption, @NonNull String storeBy, @Nullable int row, @Nullable int column, String categoryOptionCombo, String catCombo, @NonNull List options) { + return new AutoValue_CoordinateViewModel(id, label, mandatory, value, section, null, editable, null, null, null,description,dataElement, listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo); } @Override public FieldViewModel setMandatory() { - return new AutoValue_CoordinateViewModel(uid(), label(), true, value(), programStageSection(), null, editable(), null, warning(), error(),description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo()); + return new AutoValue_CoordinateViewModel(uid(), label(), true, value(), programStageSection(), null, editable(), null, warning(), error(),description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo()); } @Override public FieldViewModel setValue(String value) { - return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), value, programStageSection(), null, editable(), null, warning(), error(),description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo()); + return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), value, programStageSection(), null, editable(), null, warning(), error(),description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { - return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), value(), programStageSection(), null, editable(), null, warning, error(),description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), value(), programStageSection(), null, editable(), null, warning, error(),description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { - return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), value(), programStageSection(), null, editable(), null, warning(), error,description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), value(), programStageSection(), null, editable(), null, warning(), error,description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withValue(String data) { - return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), data, programStageSection(), null, editable(), null, warning(), error(),description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_CoordinateViewModel(uid(), label(), mandatory(), data, programStageSection(), null, editable(), null, warning(), error(),description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/DateTimeViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/DateTimeViewModel.java index 467caed3d46..525279ff722 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/DateTimeViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/datetime/DateTimeViewModel.java @@ -5,6 +5,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import org.hisp.dhis.android.core.common.ValueType; @@ -17,37 +18,37 @@ public abstract class DateTimeViewModel extends FieldViewModel { public abstract ValueType valueType(); public static FieldViewModel create(String id, String label, Boolean mandatory, ValueType type, String value, String section, Boolean allowFutureDates, Boolean editable, String description, - @Nullable String dataElement, @Nullable List listCategoryOption, @Nullable String storeBy, @Nullable int row, @Nullable int column, String categoryOptionCombo, String catCombo) { - return new AutoValue_DateTimeViewModel(id, label, mandatory, value,section, allowFutureDates,editable,null,null,null,description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo,catCombo, type); + @Nullable String dataElement, @Nullable List listCategoryOption, @Nullable String storeBy, @Nullable int row, @Nullable int column, String categoryOptionCombo, String catCombo, @Nullable List options) { + return new AutoValue_DateTimeViewModel(id, label, mandatory, value,section, allowFutureDates,editable,null,null,null,description, dataElement, listCategoryOption, options, storeBy, row, column, categoryOptionCombo,catCombo, type); } @Override public FieldViewModel setMandatory() { return new AutoValue_DateTimeViewModel(uid(),label(),true,value(),programStageSection(), - allowFutureDate(),editable(),optionSet(),warning(),error(),description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), valueType()); + allowFutureDate(),editable(),optionSet(),warning(),error(),description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), valueType()); } @Override public FieldViewModel setValue(String value) { return new AutoValue_DateTimeViewModel(uid(),label(),mandatory(),value,programStageSection(), - allowFutureDate(),editable(),optionSet(),warning(),error(),description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), valueType()); + allowFutureDate(),editable(),optionSet(),warning(),error(),description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), valueType()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { return new AutoValue_DateTimeViewModel(uid(),label(),mandatory(),value(),programStageSection(), - allowFutureDate(),editable(),optionSet(),warning(),error,description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), valueType()); } + allowFutureDate(),editable(),optionSet(),warning(),error,description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), valueType()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { return new AutoValue_DateTimeViewModel(uid(),label(),mandatory(),value(),programStageSection(), - allowFutureDate(),editable(),optionSet(),warning,error(),description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), valueType()); } + allowFutureDate(),editable(),optionSet(),warning,error(),description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), valueType()); } @NonNull @Override public FieldViewModel withValue(String data) { return new AutoValue_DateTimeViewModel(uid(),label(),mandatory(),data,programStageSection(), - allowFutureDate(), editable(),optionSet(),warning(),error(),description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), valueType()); } + allowFutureDate(), editable(),optionSet(),warning(),error(),description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), valueType()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/edittext/EditTextViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/edittext/EditTextViewModel.java index 3b94699eb50..d3557731a42 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/edittext/EditTextViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/edittext/EditTextViewModel.java @@ -6,6 +6,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import org.hisp.dhis.android.core.common.ValueType; @@ -18,42 +19,43 @@ public abstract class EditTextViewModel extends EditTextModel { public static EditTextViewModel create(@NonNull String uid, @NonNull String label, @NonNull Boolean mandatory, @Nullable String value, @NonNull String hint, @NonNull Integer lines, @NonNull ValueType valueType, @Nullable String section, @NonNull Boolean editable, @Nullable String description, - @Nullable String dataElement, @Nullable List listCategoryOption, @Nullable String storeBy, @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, @Nullable String catCombo) { + @Nullable String dataElement, @Nullable List listCategoryOption, @Nullable String storeBy, @Nullable int row, @Nullable int column, @Nullable String categoryOptionCombo, @Nullable String catCombo, + @Nullable List options) { return new AutoValue_EditTextViewModel(uid, label, mandatory, - value, section, null, editable, null, description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo, hint, lines, InputType.TYPE_CLASS_TEXT, valueType, null, null); + value, section, null, editable, null, description, dataElement, listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo, hint, lines, InputType.TYPE_CLASS_TEXT, valueType, null, null); } @NonNull @Override public EditTextViewModel withWarning(@NonNull String warning) { return new AutoValue_EditTextViewModel(uid(), label(), mandatory(), - value(), programStageSection(), null, true, null, description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), inputType(), valueType(), warning, error()); + value(), programStageSection(), null, true, null, description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), inputType(), valueType(), warning, error()); } @Override public FieldViewModel setValue(String value) { return new AutoValue_EditTextViewModel(uid(), label(), mandatory(), - value, programStageSection(), null, true, null, description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), inputType(), valueType(), warning(), error()); + value, programStageSection(), null, true, null, description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), inputType(), valueType(), warning(), error()); } @NonNull @Override public EditTextViewModel withError(@NonNull String error) { return new AutoValue_EditTextViewModel(uid(), label(), mandatory(), - value(), programStageSection(), null, true, null, description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), inputType(), valueType(), warning(), error); + value(), programStageSection(), null, true, null, description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), inputType(), valueType(), warning(), error); } @NonNull @Override public FieldViewModel setMandatory() { return new AutoValue_EditTextViewModel(uid(), label(), true, - value(), programStageSection(), null, editable(), null, description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), InputType.TYPE_CLASS_TEXT, valueType(), warning(), error()); + value(), programStageSection(), null, editable(), null, description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(),hint(), maxLines(), InputType.TYPE_CLASS_TEXT, valueType(), warning(), error()); } @NonNull @Override public FieldViewModel withValue(String data) { return new AutoValue_EditTextViewModel(uid(), label(), mandatory(), - data, programStageSection(), null, editable(), null, description(), dataElement(), options(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), hint(), maxLines(), InputType.TYPE_CLASS_TEXT, valueType(), warning(), error()); + data, programStageSection(), null, editable(), null, description(), dataElement(), options(), optionsList(), storeBy(),row(), column(), categoryOptionCombo(),catCombo(), hint(), maxLines(), InputType.TYPE_CLASS_TEXT, valueType(), warning(), error()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/file/FileViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/file/FileViewModel.java index 1c107bd2afe..eed70d13b44 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/file/FileViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/file/FileViewModel.java @@ -1,9 +1,11 @@ package org.dhis2.data.forms.dataentry.tablefields.file; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @@ -11,41 +13,41 @@ @AutoValue public abstract class FileViewModel extends FieldViewModel { public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, String description, - String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo) { + String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo, @Nullable List options) { return new AutoValue_FileViewModel(id, label, mandatory, value, section, null, - true, null, null, null,description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo); + true, null, null, null,description, dataElement, listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo); } @Override public FieldViewModel setMandatory() { return new AutoValue_FileViewModel(uid(), label(), true, value(), programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @Override public FieldViewModel setValue(String value) { return new AutoValue_FileViewModel(uid(), label(), mandatory(), value, programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { return new AutoValue_FileViewModel(uid(), label(), mandatory(), value(), programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error,description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error,description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { return new AutoValue_FileViewModel(uid(), label(), mandatory(), value(), programStageSection(), - allowFutureDate(), editable(), optionSet(), warning, error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning, error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withValue(String data) { return new AutoValue_FileViewModel(uid(), label(), mandatory(), data, programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/image/ImageViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/image/ImageViewModel.java index bac0051aa61..24dbc358126 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/image/ImageViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/image/ImageViewModel.java @@ -4,6 +4,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @@ -11,39 +12,39 @@ @AutoValue public abstract class ImageViewModel extends FieldViewModel { - public static ImageViewModel create(String id, String label, String optionSet, String value, String section, Boolean editable, Boolean mandatory, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo) { - return new AutoValue_ImageViewModel(id, label, mandatory, value, section, true, editable, optionSet, null, null, description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo); + public static ImageViewModel create(String id, String label, String optionSet, String value, String section, Boolean editable, Boolean mandatory, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo, List options) { + return new AutoValue_ImageViewModel(id, label, mandatory, value, section, true, editable, optionSet, null, null, description, dataElement, listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo); } @Override public FieldViewModel setMandatory() { return new AutoValue_ImageViewModel(uid(), label(), true, value(), programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @Override public FieldViewModel setValue(String value) { return new AutoValue_ImageViewModel(uid(), label(), mandatory(), value, programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { return new AutoValue_ImageViewModel(uid(), label(), mandatory(), value(), programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error,description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning(), error,description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { return new AutoValue_ImageViewModel(uid(), label(), mandatory(), value(), programStageSection(), - allowFutureDate(), editable(), optionSet(), warning, error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + allowFutureDate(), editable(), optionSet(), warning, error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withValue(String data) { return new AutoValue_ImageViewModel(uid(), label(), mandatory(), data, programStageSection(), - allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } + allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/orgUnit/OrgUnitViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/orgUnit/OrgUnitViewModel.java index a20f30f10f4..fc90c8ffa90 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/orgUnit/OrgUnitViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/orgUnit/OrgUnitViewModel.java @@ -4,6 +4,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @@ -11,35 +12,35 @@ @AutoValue public abstract class OrgUnitViewModel extends FieldViewModel { - public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo) { - return new AutoValue_OrgUnitViewModel(id, label, mandatory, value,section, null,editable,null,null,null,description, dataElement, listCategoryOption, storeBy, row, column, categoryOptionCombo, catCombo); + public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo, List options) { + return new AutoValue_OrgUnitViewModel(id, label, mandatory, value,section, null,editable,null,null,null,description, dataElement, listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo); } @Override public FieldViewModel setMandatory() { - return new AutoValue_OrgUnitViewModel(uid(),label(),true,value(),programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_OrgUnitViewModel(uid(),label(),true,value(),programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @Override public FieldViewModel setValue(String value) { - return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),value,programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),value,programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { - return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error,description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error,description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { - return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),optionSet(),warning,error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),optionSet(),warning,error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withValue(String data) { - return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),data,programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error(),description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_OrgUnitViewModel(uid(),label(),mandatory(),data,programStageSection(),allowFutureDate(),editable(),optionSet(),warning(),error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/radiobutton/RadioButtonViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/radiobutton/RadioButtonViewModel.java index d8464cadb99..1b272592484 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/radiobutton/RadioButtonViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/radiobutton/RadioButtonViewModel.java @@ -5,6 +5,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import org.hisp.dhis.android.core.common.ValueType; @@ -40,15 +41,15 @@ public String toString() { @NonNull public static RadioButtonViewModel fromRawValue(@NonNull String id, @NonNull String label, @NonNull ValueType type, @NonNull Boolean mandatory, @Nullable String value, @Nullable String section, Boolean editable, @Nullable String description - , String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo) { + , String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo, @Nullable List options) { if (value == null) { - return new AutoValue_RadioButtonViewModel(id, label, null, section, null, editable, null, null, null, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); + return new AutoValue_RadioButtonViewModel(id, label, null, section, null, editable, null, null, null, description,dataElement,listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); } else if (value.toLowerCase(Locale.US).equals(Value.CHECKED.toString())) { - return new AutoValue_RadioButtonViewModel(id, label, Value.CHECKED.toString(), section, null, editable, null, null, null, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); + return new AutoValue_RadioButtonViewModel(id, label, Value.CHECKED.toString(), section, null, editable, null, null, null, description,dataElement,listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); } else if (value.toLowerCase(Locale.US).equals(Value.UNCHECKED.toString())) { - return new AutoValue_RadioButtonViewModel(id, label, Value.UNCHECKED.toString(), section, null, editable, null, null, null, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); + return new AutoValue_RadioButtonViewModel(id, label, Value.UNCHECKED.toString(), section, null, editable, null, null, null, description,dataElement,listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); } else if (value.toLowerCase(Locale.US).equals(Value.CHECKED_NO.toString())) { - return new AutoValue_RadioButtonViewModel(id, label, Value.CHECKED_NO.toString(), section, null, editable, null, null, null, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); + return new AutoValue_RadioButtonViewModel(id, label, Value.CHECKED_NO.toString(), section, null, editable, null, null, null, description,dataElement,listCategoryOption,options, storeBy, row, column, categoryOptionCombo, catCombo, mandatory, type); } else { throw new IllegalArgumentException("Unsupported value: " + value); } @@ -56,29 +57,29 @@ public static RadioButtonViewModel fromRawValue(@NonNull String id, @NonNull Str @Override public FieldViewModel setMandatory() { - return new AutoValue_RadioButtonViewModel(uid(), label(), value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), true, valueType()); + return new AutoValue_RadioButtonViewModel(uid(), label(), value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), true, valueType()); } @Override public FieldViewModel setValue(String value) { - return new AutoValue_RadioButtonViewModel(uid(), label(), value, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), mandatory(), valueType()); + return new AutoValue_RadioButtonViewModel(uid(), label(), value, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(), dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo(), mandatory(), valueType()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { - return new AutoValue_RadioButtonViewModel(uid(), label(), value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error, description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), mandatory(), valueType()); + return new AutoValue_RadioButtonViewModel(uid(), label(), value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error, description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), mandatory(), valueType()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { - return new AutoValue_RadioButtonViewModel(uid(), label(), value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning, error(), description(),dataElement(), options(), storeBy(), row(), column(),categoryOptionCombo(),catCombo(), mandatory(), valueType()); + return new AutoValue_RadioButtonViewModel(uid(), label(), value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning, error(), description(),dataElement(), options(), optionsList(), storeBy(), row(), column(),categoryOptionCombo(),catCombo(), mandatory(), valueType()); } @NonNull @Override public FieldViewModel withValue(String data) { - return new AutoValue_RadioButtonViewModel(uid(), label(), data, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(),dataElement(), options(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), mandatory(), valueType()); + return new AutoValue_RadioButtonViewModel(uid(), label(), data, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(), description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), mandatory(), valueType()); } } diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/spinner/SpinnerViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/spinner/SpinnerViewModel.java index 549eb4d5d90..f44f0b21984 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/spinner/SpinnerViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/spinner/SpinnerViewModel.java @@ -4,6 +4,7 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @@ -20,36 +21,36 @@ public abstract class SpinnerViewModel extends FieldViewModel { @NonNull public abstract String optionSet(); - public static SpinnerViewModel create(String id, String label, String hintFilterOptions, Boolean mandatory, String optionSet, String value, String section, Boolean editable, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo) { - return new AutoValue_SpinnerViewModel(id, label, mandatory, value, section, null, editable,null,null, description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo,catCombo, hintFilterOptions, optionSet); + public static SpinnerViewModel create(String id, String label, String hintFilterOptions, Boolean mandatory, String optionSet, String value, String section, Boolean editable, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo, List options) { + return new AutoValue_SpinnerViewModel(id, label, mandatory, value, section, null, editable,null,null, description,dataElement,listCategoryOption, options, storeBy, row, column, categoryOptionCombo,catCombo, hintFilterOptions, optionSet); } @Override public FieldViewModel setMandatory() { - return new AutoValue_SpinnerViewModel(uid(),label(),true,value(),programStageSection(),allowFutureDate(),editable(),warning(),error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); + return new AutoValue_SpinnerViewModel(uid(),label(),true,value(),programStageSection(),allowFutureDate(),editable(),warning(),error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); } @Override public FieldViewModel setValue(String value) { - return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),value,programStageSection(),allowFutureDate(),editable(),warning(),error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); + return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),value,programStageSection(),allowFutureDate(),editable(),warning(),error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { - return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),warning(),error,description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); + return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),warning(),error,description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { - return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),warning,error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); + return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),value(),programStageSection(),allowFutureDate(),editable(),warning,error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(),catCombo(), hint(),optionSet()); } @NonNull @Override public FieldViewModel withValue(String data) { - return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),data,programStageSection(),allowFutureDate(),editable(),warning(),error(),description(),dataElement(), options(),storeBy(), row(), column(),categoryOptionCombo(), catCombo(),hint(),optionSet()); + return new AutoValue_SpinnerViewModel(uid(),label(),mandatory(),data,programStageSection(),allowFutureDate(),editable(),warning(),error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(),categoryOptionCombo(), catCombo(),hint(),optionSet()); } public void setOptionsToHide(List optionsToHide, List optionsGroupsToHide) { diff --git a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/unsupported/UnsupportedViewModel.java b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/unsupported/UnsupportedViewModel.java index a3bd57641ff..13d26c08fb8 100644 --- a/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/unsupported/UnsupportedViewModel.java +++ b/app/src/main/java/org/dhis2/data/forms/dataentry/tablefields/unsupported/UnsupportedViewModel.java @@ -4,41 +4,42 @@ import com.google.auto.value.AutoValue; +import org.dhis2.composetable.model.DropdownOption; import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel; import java.util.List; @AutoValue public abstract class UnsupportedViewModel extends FieldViewModel { - public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo) { - return new AutoValue_UnsupportedViewModel(id, label, false, value, section, null, editable, null, null, null,description,dataElement,listCategoryOption,storeBy, row, column, categoryOptionCombo, catCombo); + public static FieldViewModel create(String id, String label, Boolean mandatory, String value, String section, Boolean editable, String description, String dataElement, List listCategoryOption, String storeBy, int row, int column, String categoryOptionCombo, String catCombo, List options) { + return new AutoValue_UnsupportedViewModel(id, label, false, value, section, null, editable, null, null, null,description,dataElement,listCategoryOption, options, storeBy, row, column, categoryOptionCombo, catCombo); } @Override public FieldViewModel setMandatory() { - return new AutoValue_UnsupportedViewModel(uid(), label(), false, value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_UnsupportedViewModel(uid(), label(), false, value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @Override public FieldViewModel setValue(String value) { - return new AutoValue_UnsupportedViewModel(uid(), label(), false, value, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_UnsupportedViewModel(uid(), label(), false, value, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withError(@NonNull String error) { - return new AutoValue_UnsupportedViewModel(uid(), label(), false, value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error,description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_UnsupportedViewModel(uid(), label(), false, value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error,description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withWarning(@NonNull String warning) { - return new AutoValue_UnsupportedViewModel(uid(), label(), false, value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning, error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_UnsupportedViewModel(uid(), label(), false, value(), programStageSection(), allowFutureDate(), editable(), optionSet(), warning, error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } @NonNull @Override public FieldViewModel withValue(String data) { - return new AutoValue_UnsupportedViewModel(uid(), label(), false, data, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(),storeBy(), row(), column(), categoryOptionCombo(), catCombo()); + return new AutoValue_UnsupportedViewModel(uid(), label(), false, data, programStageSection(), allowFutureDate(), editable(), optionSet(), warning(), error(),description(),dataElement(), options(), optionsList(), storeBy(), row(), column(), categoryOptionCombo(), catCombo()); } } diff --git a/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/DataValueRepository.kt b/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/DataValueRepository.kt index 20bca865b67..7626819deff 100644 --- a/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/DataValueRepository.kt +++ b/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/DataValueRepository.kt @@ -8,13 +8,14 @@ import io.reactivex.Single import org.dhis2.bindings.decimalFormat import org.dhis2.commons.bindings.dataValueConflicts import org.dhis2.commons.data.tuples.Pair +import org.dhis2.commons.date.DateUtils +import org.dhis2.composetable.model.DropdownOption import org.dhis2.composetable.model.TableCell import org.dhis2.data.dhislogic.AUTH_DATAVALUE_ADD import org.dhis2.data.forms.dataentry.tablefields.FieldViewModel import org.dhis2.data.forms.dataentry.tablefields.FieldViewModelFactoryImpl import org.dhis2.data.forms.dataentry.tablefields.spinner.SpinnerViewModel import org.dhis2.usescases.datasets.dataSetTable.DataSetTableModel -import org.dhis2.utils.DateUtils import org.hisp.dhis.android.core.D2 import org.hisp.dhis.android.core.arch.helpers.UidsHelper import org.hisp.dhis.android.core.arch.repositories.scope.RepositoryScope @@ -647,12 +648,13 @@ class DataValueRepository( null, dataElement.displayDescription(), dataElement.uid(), - options, + ArrayList(), "android", row, column, categoryOptionCombo.uid(), dataTableModel.catCombo?.uid(), + options, ) val valueStateSyncState = d2.dataValueModule().dataValues() @@ -866,6 +868,7 @@ class DataValueRepository( column, "", "", + ArrayList(), ), ) values.add(totalRow.decimalFormat) @@ -927,6 +930,7 @@ class DataValueRepository( columnPos, "", "", + ArrayList(), ), ) @@ -1005,12 +1009,13 @@ class DataValueRepository( null, dataElement.displayDescription(), dataElement.uid(), - getOptionsForOptionSet(dataElement.optionSetUid()), + ArrayList(), "android", 0, 0, cell.id!!.split("_")[1], dataElement.categoryComboUid(), + getOptionsForOptionSet(dataElement.optionSetUid()), ) } @@ -1035,6 +1040,11 @@ class DataValueRepository( .byOptionSetUid().eq(it) .orderBySortOrder(RepositoryScope.OrderByDirection.ASC) .blockingGet() - .map { option -> "${option.code()}_${option.displayName()}" } + .map { option -> + DropdownOption( + option.code() ?: "", + option.displayName() ?: "", + ) + } } ?: emptyList() } diff --git a/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/TableDataToTableModelMapper.kt b/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/TableDataToTableModelMapper.kt index 6ab3f171d15..8c7cc293484 100644 --- a/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/TableDataToTableModelMapper.kt +++ b/app/src/main/java/org/dhis2/usescases/datasets/dataSetTable/dataSetSection/TableDataToTableModelMapper.kt @@ -56,7 +56,7 @@ class TableDataToTableModelMapper(val mapFieldValueToUser: MapFieldValueToUser) }.toMap(), isLastRow = rowIndex == (tableData.rows()!!.size - 1), maxLines = 3, - dropDownOptions = tableData.fieldViewModels[rowIndex][0].options(), + dropDownOptions = tableData.fieldViewModels[rowIndex][0].optionsList(), ) } ?: emptyList() diff --git a/commons/src/main/java/org/dhis2/commons/date/DateUtils.java b/commons/src/main/java/org/dhis2/commons/date/DateUtils.java index 362c9b89eb3..35c3cd6c0c3 100644 --- a/commons/src/main/java/org/dhis2/commons/date/DateUtils.java +++ b/commons/src/main/java/org/dhis2/commons/date/DateUtils.java @@ -9,6 +9,7 @@ import org.dhis2.commons.dialogs.calendarpicker.CalendarPicker; import org.dhis2.commons.dialogs.calendarpicker.OnDatePickerListener; import org.dhis2.commons.filters.FilterManager; +import org.hisp.dhis.android.core.dataset.DataInputPeriod; import org.hisp.dhis.android.core.event.EventStatus; import org.hisp.dhis.android.core.period.DatePeriod; import org.hisp.dhis.android.core.period.PeriodType; @@ -880,4 +881,23 @@ public List getDatePeriodListFor(List selectedDates, Period p } return datePeriods; } + + public Boolean isInsideInputPeriod(DataInputPeriod dataInputPeriodModel) { + if (dataInputPeriodModel.openingDate() == null && dataInputPeriodModel.closingDate() != null) + return Calendar.getInstance().getTime().getTime() < dataInputPeriodModel.closingDate().getTime(); + + if (dataInputPeriodModel.openingDate() != null && dataInputPeriodModel.closingDate() == null) + return dataInputPeriodModel.openingDate().getTime() < Calendar.getInstance().getTime().getTime(); + + if (dataInputPeriodModel.openingDate() == null && dataInputPeriodModel.closingDate() == null) + return true; + + return dataInputPeriodModel.openingDate().getTime() < Calendar.getInstance().getTime().getTime() + && Calendar.getInstance().getTime().getTime() < dataInputPeriodModel.closingDate().getTime(); + } + + public Boolean isDataSetExpired(int expiredDays, Date periodInitialDate) { + return Calendar.getInstance().getTime().getTime() > periodInitialDate.getTime() + TimeUnit.DAYS.toMillis(expiredDays); + } + } diff --git a/compose-table/src/main/java/org/dhis2/composetable/model/DropdownOption.kt b/compose-table/src/main/java/org/dhis2/composetable/model/DropdownOption.kt new file mode 100644 index 00000000000..20b2147e870 --- /dev/null +++ b/compose-table/src/main/java/org/dhis2/composetable/model/DropdownOption.kt @@ -0,0 +1,9 @@ +package org.dhis2.composetable.model + +import kotlinx.serialization.Serializable + +@Serializable +data class DropdownOption( + val code: String, + val name: String, +) diff --git a/compose-table/src/main/java/org/dhis2/composetable/model/TableRowModel.kt b/compose-table/src/main/java/org/dhis2/composetable/model/TableRowModel.kt index f010ebd193f..5d9c32b9c65 100644 --- a/compose-table/src/main/java/org/dhis2/composetable/model/TableRowModel.kt +++ b/compose-table/src/main/java/org/dhis2/composetable/model/TableRowModel.kt @@ -8,5 +8,5 @@ data class TableRowModel( val values: Map, val isLastRow: Boolean = false, val maxLines: Int = 3, - val dropDownOptions: List? = null, + val dropDownOptions: List? = null, ) diff --git a/compose-table/src/main/java/org/dhis2/composetable/ui/DropDownOptions.kt b/compose-table/src/main/java/org/dhis2/composetable/ui/DropDownOptions.kt index 02058820631..65e64f6fa1f 100644 --- a/compose-table/src/main/java/org/dhis2/composetable/ui/DropDownOptions.kt +++ b/compose-table/src/main/java/org/dhis2/composetable/ui/DropDownOptions.kt @@ -4,11 +4,12 @@ import androidx.compose.material.DropdownMenu import androidx.compose.material.DropdownMenuItem import androidx.compose.material.Text import androidx.compose.runtime.Composable +import org.dhis2.composetable.model.DropdownOption @Composable fun DropDownOptions( expanded: Boolean, - options: List, + options: List, onDismiss: () -> Unit, onSelected: (code: String, label: String) -> Unit, ) { @@ -17,14 +18,12 @@ fun DropDownOptions( onDismissRequest = onDismiss, ) { options.forEach { option -> - val code = option.split("_")[0] - val label = option.split("_")[1] DropdownMenuItem( onClick = { - onSelected.invoke(code, label) + onSelected.invoke(option.code, option.name) }, ) { - Text(text = label) + Text(text = option.name) } } } diff --git a/compose-table/src/main/java/org/dhis2/composetable/ui/ItemValues.kt b/compose-table/src/main/java/org/dhis2/composetable/ui/ItemValues.kt index 414bd52edcb..801d0ed4df0 100644 --- a/compose-table/src/main/java/org/dhis2/composetable/ui/ItemValues.kt +++ b/compose-table/src/main/java/org/dhis2/composetable/ui/ItemValues.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.runtime.key import androidx.compose.ui.Modifier +import org.dhis2.composetable.model.DropdownOption import org.dhis2.composetable.model.TableCell import org.dhis2.composetable.model.TableHeader import org.dhis2.composetable.ui.semantics.CELL_TEST_TAG @@ -20,7 +21,7 @@ fun ItemValues( cellValues: Map, overridenValues: Map, tableHeaderModel: TableHeader, - options: List, + options: List, headerLabel: String, ) { Row( diff --git a/compose-table/src/main/java/org/dhis2/composetable/ui/MultiOptionSelector.kt b/compose-table/src/main/java/org/dhis2/composetable/ui/MultiOptionSelector.kt index 37a55f5ddf6..64d38ed6f80 100644 --- a/compose-table/src/main/java/org/dhis2/composetable/ui/MultiOptionSelector.kt +++ b/compose-table/src/main/java/org/dhis2/composetable/ui/MultiOptionSelector.kt @@ -3,13 +3,14 @@ package org.dhis2.composetable.ui import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import org.dhis2.composetable.R +import org.dhis2.composetable.model.DropdownOption import org.dhis2.composetable.model.TableCell import org.hisp.dhis.mobile.ui.designsystem.component.CheckBoxData import org.hisp.dhis.mobile.ui.designsystem.component.MultiSelectBottomSheet @Composable fun MultiOptionSelector( - options: List, + options: List, cell: TableCell, title: String, onSave: (String, String) -> Unit, @@ -17,13 +18,11 @@ fun MultiOptionSelector( ) { MultiSelectBottomSheet( items = options.map { option -> - val code = option.split("_")[0] - val label = option.split("_")[1] CheckBoxData( - uid = code, - checked = cell.value?.split(", ")?.contains(label) == true, + uid = option.code, + checked = cell.value?.split(", ")?.contains(option.name) == true, enabled = cell.editable, - textInput = label, + textInput = option.name, ) }, title = title, diff --git a/compose-table/src/main/java/org/dhis2/composetable/ui/TableCell.kt b/compose-table/src/main/java/org/dhis2/composetable/ui/TableCell.kt index 7df1f905d04..f48a6bb9667 100644 --- a/compose-table/src/main/java/org/dhis2/composetable/ui/TableCell.kt +++ b/compose-table/src/main/java/org/dhis2/composetable/ui/TableCell.kt @@ -36,6 +36,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import kotlinx.coroutines.launch import org.dhis2.composetable.R +import org.dhis2.composetable.model.DropdownOption import org.dhis2.composetable.model.TableCell import org.dhis2.composetable.ui.compositions.LocalCurrentCellValue import org.dhis2.composetable.ui.compositions.LocalInteraction @@ -57,7 +58,7 @@ fun TableCell( cell: TableCell, maxLines: Int, headerExtraSize: Int, - options: List, + options: List, headerLabel: String, ) { val localInteraction = LocalInteraction.current