From 352f4b2d0c7e18b52f9a780d034ae6cbdf7848dc Mon Sep 17 00:00:00 2001 From: FerdyRod Date: Thu, 11 Jul 2024 14:03:53 +0200 Subject: [PATCH 1/3] Correctly shows options value when code or name include special characters --- .../dataentry/tablefields/FieldViewModel.java | 5 +++++ .../tablefields/FieldViewModelFactory.java | 4 +++- .../FieldViewModelFactoryImpl.java | 21 ++++++++++--------- .../tablefields/age/AgeViewModel.java | 17 ++++++++------- .../coordinate/CoordinateViewModel.java | 15 ++++++------- .../datetime/DateTimeViewModel.java | 15 ++++++------- .../edittext/EditTextViewModel.java | 16 +++++++------- .../tablefields/file/FileViewModel.java | 16 +++++++------- .../tablefields/image/ImageViewModel.java | 15 ++++++------- .../tablefields/orgUnit/OrgUnitViewModel.java | 15 ++++++------- .../radiobutton/RadioButtonViewModel.java | 21 ++++++++++--------- .../tablefields/spinner/SpinnerViewModel.java | 15 ++++++------- .../unsupported/UnsupportedViewModel.java | 15 ++++++------- .../dataSetSection/DataValueRepository.kt | 16 +++++++++++--- .../TableDataToTableModelMapper.kt | 2 +- .../org/dhis2/commons/date/DateUtils.java | 1 + .../composetable/model/DropdownOption.kt | 9 ++++++++ .../dhis2/composetable/model/TableRowModel.kt | 2 +- .../dhis2/composetable/ui/DropDownOptions.kt | 9 ++++---- .../org/dhis2/composetable/ui/ItemValues.kt | 3 ++- .../composetable/ui/MultiOptionSelector.kt | 11 +++++----- .../org/dhis2/composetable/ui/TableCell.kt | 3 ++- 22 files changed, 143 insertions(+), 103 deletions(-) create mode 100644 compose-table/src/main/java/org/dhis2/composetable/model/DropdownOption.kt 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 7ade2cae69..16f3b95ae4 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 5a84cb1a9c..10d2e546bd 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 b48a0546fa..42c07287b2 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 20fb6bb2b9..f3299ed601 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 381548e3ca..c6faeaa1aa 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 467caed3d4..525279ff72 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 3b94699eb5..d3557731a4 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 1c107bd2af..eed70d13b4 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 bac0051aa6..24dbc35812 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 a20f30f10f..fc90c8ffa9 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 d8464cadb9..1b27259248 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 549eb4d5d9..f44f0b2198 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 a3bd57641f..13d26c08fb 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 280a6bdc93..4da96acd03 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 @@ -9,6 +9,7 @@ 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 @@ -608,12 +609,13 @@ class DataValueRepository( null, dataElement.displayDescription(), dataElement.uid(), - options, + ArrayList(), "android", row, column, categoryOptionCombo.uid(), dataTableModel.catCombo?.uid(), + options, ) val valueStateSyncState = d2.dataValueModule().dataValues() @@ -832,6 +834,7 @@ class DataValueRepository( column, "", "", + ArrayList(), ), ) values.add(totalRow.decimalFormat) @@ -893,6 +896,7 @@ class DataValueRepository( columnPos, "", "", + ArrayList(), ), ) @@ -971,12 +975,13 @@ class DataValueRepository( null, dataElement.displayDescription(), dataElement.uid(), - getOptionsForOptionSet(dataElement.optionSetUid()), + ArrayList(), "android", 0, 0, cell.id!!.split("_")[1], dataElement.categoryComboUid(), + getOptionsForOptionSet(dataElement.optionSetUid()), ) } @@ -1001,6 +1006,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 6ab3f171d1..8c7cc29348 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 ce004f962a..20dd02ab2c 100644 --- a/commons/src/main/java/org/dhis2/commons/date/DateUtils.java +++ b/commons/src/main/java/org/dhis2/commons/date/DateUtils.java @@ -10,6 +10,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; 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 0000000000..20b2147e87 --- /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 f010ebd193..5d9c32b9c6 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 0205882063..65e64f6fa1 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 414bd52edc..801d0ed4df 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 37a55f5ddf..64d38ed6f8 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 7df1f905d0..f48a6bb966 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 From 3d4e9b892c0e32c1fc332cb0873c72af5089ee53 Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 16 Jul 2024 11:03:20 +0200 Subject: [PATCH 2/3] fix tests Signed-off-by: Pablo --- .../dhis2/usescases/datasets/MapFieldValueToUserTest.kt | 8 ++++++++ .../usescases/datasets/TableDataToTableModelMapperTest.kt | 1 + 2 files changed, 9 insertions(+) diff --git a/app/src/test/java/org/dhis2/usescases/datasets/MapFieldValueToUserTest.kt b/app/src/test/java/org/dhis2/usescases/datasets/MapFieldValueToUserTest.kt index 6b339a59b9..0adcf5c96b 100644 --- a/app/src/test/java/org/dhis2/usescases/datasets/MapFieldValueToUserTest.kt +++ b/app/src/test/java/org/dhis2/usescases/datasets/MapFieldValueToUserTest.kt @@ -49,6 +49,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) val dataElement = DataElement.builder().uid(DATAELEMENT_UID).valueType(ValueType.BOOLEAN).build() @@ -79,6 +80,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) val dataElement = DataElement.builder().uid(DATAELEMENT_UID).valueType(ValueType.ORGANISATION_UNIT) @@ -109,6 +111,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) whenever(resources.getString(any())) doReturn UNSUPPORTED_VALUES val dataElement = @@ -139,6 +142,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) val dataElement = DataElement.builder().uid(DATAELEMENT_UID).valueType(ValueType.FILE_RESOURCE).build() @@ -167,6 +171,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) whenever(resources.getString(any())) doReturn UNSUPPORTED_VALUES val dataElement = @@ -197,6 +202,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) whenever(resources.getString(any())) doReturn UNSUPPORTED_VALUES val dataElement = @@ -226,6 +232,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) whenever(resources.getString(any())) doReturn UNSUPPORTED_VALUES val dataElement = @@ -255,6 +262,7 @@ class MapFieldValueToUserTest { 1, "1", "", + emptyList(), ) whenever(resources.getString(any())) doReturn UNSUPPORTED_VALUES val dataElement = diff --git a/app/src/test/java/org/dhis2/usescases/datasets/TableDataToTableModelMapperTest.kt b/app/src/test/java/org/dhis2/usescases/datasets/TableDataToTableModelMapperTest.kt index d14c01b5b6..7b6e51ba96 100644 --- a/app/src/test/java/org/dhis2/usescases/datasets/TableDataToTableModelMapperTest.kt +++ b/app/src/test/java/org/dhis2/usescases/datasets/TableDataToTableModelMapperTest.kt @@ -140,6 +140,7 @@ class TableDataToTableModelMapperTest { 1, "1", "", + emptyList(), ) } From 8cedff84add5c68112891e2ce9c96f52bd529405 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 17 Jul 2024 07:30:51 +0200 Subject: [PATCH 3/3] remove duplicated import Signed-off-by: Pablo --- commons/src/main/java/org/dhis2/commons/date/DateUtils.java | 1 - 1 file changed, 1 deletion(-) 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 20dd02ab2c..ce004f962a 100644 --- a/commons/src/main/java/org/dhis2/commons/date/DateUtils.java +++ b/commons/src/main/java/org/dhis2/commons/date/DateUtils.java @@ -10,7 +10,6 @@ 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;