From 5065726163971fd2d1dfccb5dc7a33f10d0365c4 Mon Sep 17 00:00:00 2001 From: rajey Date: Fri, 9 Sep 2022 19:49:49 +0300 Subject: [PATCH 1/4] feat: add attribute column on attribute option table --- .../program/entities/attribute_option.entity.dart | 5 +++++ .../program_tracked_entity_attribute.entity.dart | 8 +++++--- pubspec.lock | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/modules/metadata/program/entities/attribute_option.entity.dart b/lib/modules/metadata/program/entities/attribute_option.entity.dart index 9233066e..ced2bced 100644 --- a/lib/modules/metadata/program/entities/attribute_option.entity.dart +++ b/lib/modules/metadata/program/entities/attribute_option.entity.dart @@ -5,6 +5,8 @@ import 'package:d2_touch/shared/entities/base_entity.dart'; @AnnotationReflectable @Entity(tableName: 'attributeoption', apiResourceName: 'attributeOptions') class AttributeOption extends BaseEntity { + @Column() + String attribute; @ManyToOne( table: ProgramTrackedEntityAttribute, joinColumnName: 'programTrackedEntityAttribute') @@ -15,6 +17,7 @@ class AttributeOption extends BaseEntity { required String name, required String code, required this.programTrackedEntityAttribute, + required this.attribute, required bool dirty}) : super(id: id, name: name, code: code, dirty: dirty); @@ -25,6 +28,7 @@ class AttributeOption extends BaseEntity { code: jsonData['code'], programTrackedEntityAttribute: jsonData['programTrackedEntityAttribute'], + attribute: jsonData['attribute'], dirty: jsonData['dirty']); } @@ -34,6 +38,7 @@ class AttributeOption extends BaseEntity { data['name'] = this.name; data['code'] = this.code; data['programTrackedEntityAttribute'] = this.programTrackedEntityAttribute; + data['attribute'] = this.attribute; data['dirty'] = this.dirty; return data; } diff --git a/lib/modules/metadata/program/entities/program_tracked_entity_attribute.entity.dart b/lib/modules/metadata/program/entities/program_tracked_entity_attribute.entity.dart index 4d743d75..ddf26bad 100644 --- a/lib/modules/metadata/program/entities/program_tracked_entity_attribute.entity.dart +++ b/lib/modules/metadata/program/entities/program_tracked_entity_attribute.entity.dart @@ -75,10 +75,11 @@ class ProgramTrackedEntityAttribute extends BaseEntity { Map jsonData) { final optionSetValueCount = jsonData['trackedEntityAttribute']?['optionSet']?['options']?.length; + final attribute = + jsonData['attribute'] ?? jsonData['trackedEntityAttribute']?['id']; return ProgramTrackedEntityAttribute( id: jsonData['id'], - attribute: - jsonData['attribute'] ?? jsonData['trackedEntityAttribute']?['id'], + attribute: attribute, renderOptionsAsRadio: jsonData['renderOptionsAsRadio'], name: jsonData['trackedEntityAttribute']?['name'] ?? jsonData['name'], displayName: jsonData['trackedEntityAttribute']?['displayName'] ?? @@ -105,8 +106,9 @@ class ProgramTrackedEntityAttribute extends BaseEntity { []) .map((option) => AttributeOption.fromJson({ ...option, - 'id': '${option['id']}_${jsonData['id']}}', + 'id': '${option['id']}_${jsonData['id']}_$attribute', 'programTrackedEntityAttribute': jsonData['id'], + 'attribute': attribute, 'dirty': false })) .toList(), diff --git a/pubspec.lock b/pubspec.lock index b8c99339..9c11d08d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -296,6 +296,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -608,7 +615,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" timing: dependency: transitive description: From 8f647d4529e8fc5c3ce42b9c70ecfbf5f392b062 Mon Sep 17 00:00:00 2001 From: Bennett Benedict Date: Fri, 9 Sep 2022 19:55:24 +0300 Subject: [PATCH 2/4] add option to include additional search params --- lib/shared/queries/base.query.dart | 8 ++- lib/shared/utilities/query_filter.util.dart | 60 ++++++++++++++++----- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/lib/shared/queries/base.query.dart b/lib/shared/queries/base.query.dart index 4a529589..0ba80b03 100644 --- a/lib/shared/queries/base.query.dart +++ b/lib/shared/queries/base.query.dart @@ -96,12 +96,16 @@ class BaseQuery { ilike( {required String attribute, required dynamic value, - String? filterCondition}) { + String? filterCondition, + String? key, + String? keyValue}) { this.filters?.add(QueryFilter( attribute: attribute, condition: QueryCondition.Ilike, value: value, - filterCondition: filterCondition)); + filterCondition: filterCondition, + key: key, + keyValue: keyValue)); return this; } diff --git a/lib/shared/utilities/query_filter.util.dart b/lib/shared/utilities/query_filter.util.dart index af03bc62..15e11371 100644 --- a/lib/shared/utilities/query_filter.util.dart +++ b/lib/shared/utilities/query_filter.util.dart @@ -6,11 +6,15 @@ class QueryFilter { QueryCondition condition; dynamic value; String? filterCondition; + String? key; + String? keyValue; QueryFilter( {required this.attribute, required this.condition, required this.value, - this.filterCondition}); + this.filterCondition, + this.key, + this.keyValue}); static String? getWhereParameters( List columns, List? filters) { @@ -35,7 +39,7 @@ class QueryFilter { return '${filter.attribute} LIKE ${QueryFilter.getTypedValue(attributeColumn, filter.value)}'; case QueryCondition.Ilike: - return '${filter.attribute} LIKE ${QueryFilter.getTypedValue(attributeColumn, filter.value, isLikeFilter: true, filterCondition: filter.filterCondition)}'; + return '${filter.attribute} LIKE ${QueryFilter.getTypedValue(attributeColumn, filter.value, isLikeFilter: true, filterCondition: filter.filterCondition, key: filter.key, keyValue: filter.keyValue)}'; case QueryCondition.LessThan: return '${filter.attribute} < ${QueryFilter.getTypedValue(attributeColumn, filter.value)}'; @@ -109,11 +113,17 @@ class QueryFilter { } static getTypedValue(Column attributeColumn, dynamic value, - {bool? isLikeFilter, String? filterCondition}) { + {bool? isLikeFilter, + String? filterCondition, + String? key, + String? keyValue}) { switch (attributeColumn.columnType) { case 'TEXT': return getTextFiler(value, - isLikeFilter: isLikeFilter, filterCondition: filterCondition); + isLikeFilter: isLikeFilter, + filterCondition: filterCondition, + key: key, + keyValue: keyValue); case 'BOOLEAN': return value == true ? 1 : 0; default: @@ -122,19 +132,41 @@ class QueryFilter { } static getTextFiler(dynamic value, - {bool? isLikeFilter, String? filterCondition}) { + {bool? isLikeFilter, + String? filterCondition, + String? key, + String? keyValue}) { if (isLikeFilter == false || isLikeFilter == null) { return '"$value"'; } - switch (filterCondition) { - case 'startsWith': - return '"$value%"'; - case 'endsWith': - return '"%$value"'; - case 'includes': - return '"%$value%"'; - default: - return '"%$value%"'; + if (key != null && keyValue != null) { + return filterWithAdditionalAttributes(value, + key: key, keyValue: keyValue); + } else { + switch (filterCondition) { + case 'startsWith': + return '"$value%"'; + case 'endsWith': + return '"%$value"'; + case 'includes': + return '"%$value%"'; + default: + return '"%$value%"'; + } } } } + +filterWithAdditionalAttributes(dynamic value, + {String? filterCondition, String? key, String? keyValue}) { + switch (filterCondition) { + case 'startsWith': + return '"$value%" AND $key = "$keyValue"'; + case 'endsWith': + return '"%$value" AND "$key" = "$keyValue"'; + case 'includes': + return '"%$value%" AND $key = "$keyValue"'; + default: + return '"%$value%" AND $key = "$keyValue"'; + } +} From e2d055866737faaf04192d2a20494dded1209691 Mon Sep 17 00:00:00 2001 From: Bennett Benedict Date: Fri, 9 Sep 2022 20:26:23 +0300 Subject: [PATCH 3/4] bump flutter version --- CHANGELOG.md | 9 ++++++++- pubspec.lock | 18 +++++++++--------- pubspec.yaml | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e77447da..5cba270e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ -## [1.0.0-beta.1] - 01/04/2022 +## [1.0.0-beta.11] - 09/09/2022 + +- Add attribute column on attribute option table +- Add attribute column on attribute option table +- Improve datavalue set sync +- Add option to include additional search params + +## [1.0.0-beta.11] - 01/04/2022 - Support validation rule execution - Bug fixes and improvement diff --git a/pubspec.lock b/pubspec.lock index f41e6bc1..7695d6fe 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -133,7 +133,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -175,7 +175,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -274,7 +274,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -302,7 +302,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -330,7 +330,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider: dependency: "direct main" description: @@ -538,7 +538,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" sqflite: dependency: "direct main" description: @@ -615,7 +615,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" timing: dependency: transitive description: @@ -636,7 +636,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" watcher: dependency: transitive description: @@ -687,5 +687,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.15.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.8.1" diff --git a/pubspec.yaml b/pubspec.yaml index 95459cbe..a0656d24 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: d2_touch description: DHIS2 Flutter SDK -version: 1.0.0-beta.11 +version: 1.0.0-beta.12 homepage: repository: https://github.com/udsm-dhis2-lab/d2-touch From 204e5e55da1571dabdaf6de795df79e5747284b0 Mon Sep 17 00:00:00 2001 From: Bennett Benedict Date: Fri, 9 Sep 2022 20:28:38 +0300 Subject: [PATCH 4/4] bump flutter version --- CHANGELOG.md | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cba270e..5aa5551c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.0.0-beta.11] - 09/09/2022 +## [1.0.0-beta.13] - 09/09/2022 - Add attribute column on attribute option table - Add attribute column on attribute option table diff --git a/pubspec.yaml b/pubspec.yaml index a0656d24..c070013e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: d2_touch description: DHIS2 Flutter SDK -version: 1.0.0-beta.12 +version: 1.0.0-beta.13 homepage: repository: https://github.com/udsm-dhis2-lab/d2-touch