From 43084180a946ecb43068a343bd57761627297b2e Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Mon, 25 Nov 2024 17:10:45 +0530 Subject: [PATCH 01/19] added pagination for household_overview --- .../household_overview.dart | 90 +- .../household_overview.freezed.dart | 171 ++- .../repositories/local/household_member.dart | 3 + .../lib/models/entities/household_member.dart | 4 + .../entities/household_member.mapper.dart | 8 + .../pages/beneficiary/household_overview.dart | 1245 +++++++++-------- 6 files changed, 866 insertions(+), 655 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart index 96fc6d58b..21c8437c7 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart @@ -67,14 +67,24 @@ class HouseholdOverviewBloc emit(state.copyWith(loading: true)); // Retrieve household members based on certain criteria. - final members = await householdMemberRepository.search( - HouseholdMemberSearchModel( - householdClientReferenceId: - state.householdMemberWrapper.household != null + final members = event.limit != null + ? await householdMemberRepository.search( + HouseholdMemberSearchModel( + householdClientReferenceId: state + .householdMemberWrapper.household != + null + ? [state.householdMemberWrapper.household!.clientReferenceId] + : [], + limit: event.limit, + offset: event.offset, + ), + ) + : await householdMemberRepository.search(HouseholdMemberSearchModel( + householdClientReferenceId: state + .householdMemberWrapper.household != + null ? [state.householdMemberWrapper.household!.clientReferenceId] - : [], - ), - ); + : [])); // Group household members by household ID. final groupedHouseholds = members.groupListsBy( @@ -120,7 +130,9 @@ class HouseholdOverviewBloc // Search for individuals based on their client reference IDs. final individuals = await individualRepository.search( - IndividualSearchModel(clientReferenceId: individualIds), + IndividualSearchModel( + clientReferenceId: individualIds, + ), ); // Search for project beneficiaries based on specified criteria. @@ -164,14 +176,6 @@ class HouseholdOverviewBloc ?.individualClientReferenceId, ); - // Check if a head of household was found. - if (head == null) { - // If no head of household was found, stop loading and return. - emit(state.copyWith(loading: false)); - - return; - } - // Search for tasks associated with project beneficiaries. var tasks = await taskDataRepository.search(TaskSearchModel( projectBeneficiaryClientReferenceId: @@ -197,6 +201,48 @@ class HouseholdOverviewBloc beneficiaryIndividuals.sort((a, b) => (a.clientAuditDetails?.createdTime ?? 0) .compareTo(b.clientAuditDetails?.createdTime ?? 0)); + + // Check if a head of household was found. + if (head == null) { + // If head is not found, append the new data to the existing state. + + emit(state.copyWith( + loading: false, + offset: members.isNotEmpty && members.length == (event.limit ?? 10) + ? (event.offset ?? 0) + (event.limit ?? 10) + : null, + householdMemberWrapper: state.householdMemberWrapper.copyWith( + members: (event.projectBeneficiaryType == BeneficiaryType.individual) + ? [ + ...state.householdMemberWrapper.members ?? [], + ...beneficiaryIndividuals, + ] + : [ + ...state.householdMemberWrapper.members ?? [], + ...individuals, + ], + projectBeneficiaries: [ + ...state.householdMemberWrapper.projectBeneficiaries ?? [], + ...projectBeneficiaries, + ], + tasks: [ + ...?state.householdMemberWrapper.tasks, + ...tasks, + ], + sideEffects: [ + ...?state.householdMemberWrapper.sideEffects, + ...sideEffects, + ], + referrals: [ + ...?state.householdMemberWrapper.referrals, + ...referrals, + ], + ), + )); + + return; + } + // Update the state with the loaded data and stop loading. emit( state.copyWith( @@ -212,6 +258,7 @@ class HouseholdOverviewBloc referrals: referrals, ), loading: false, + offset: members.isNotEmpty ? (event.offset ?? 10) : null, ), ); } @@ -393,10 +440,11 @@ class HouseholdOverviewEvent with _$HouseholdOverviewEvent { required IndividualModel individualModel, }) = HouseholdOverviewSelectIndividualEvent; - const factory HouseholdOverviewEvent.reload({ - required String projectId, - required BeneficiaryType projectBeneficiaryType, - }) = HouseholdOverviewReloadEvent; + const factory HouseholdOverviewEvent.reload( + {required String projectId, + required BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit}) = HouseholdOverviewReloadEvent; } @freezed @@ -405,5 +453,7 @@ class HouseholdOverviewState with _$HouseholdOverviewState { @Default(false) bool loading, required HouseholdMemberWrapper householdMemberWrapper, IndividualModel? selectedIndividual, + int? offset, + int? limit, }) = _HouseholdOverviewState; } diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart index cbaabf425..ad05e9a9b 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart @@ -39,8 +39,8 @@ mixin _$HouseholdOverviewEvent { setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function( - String projectId, BeneficiaryType projectBeneficiaryType) + required TResult Function(String projectId, + BeneficiaryType projectBeneficiaryType, int? offset, int? limit) reload, }) => throw _privateConstructorUsedError; @@ -66,7 +66,8 @@ mixin _$HouseholdOverviewEvent { BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, }) => throw _privateConstructorUsedError; @@ -92,7 +93,8 @@ mixin _$HouseholdOverviewEvent { BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, required TResult orElse(), }) => @@ -306,8 +308,8 @@ class _$HouseholdOverviewDeleteHouseholdEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function( - String projectId, BeneficiaryType projectBeneficiaryType) + required TResult Function(String projectId, + BeneficiaryType projectBeneficiaryType, int? offset, int? limit) reload, }) { return deleteHousehold(projectId, householdModel, members, @@ -337,7 +339,8 @@ class _$HouseholdOverviewDeleteHouseholdEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, }) { return deleteHousehold?.call(projectId, householdModel, members, @@ -367,7 +370,8 @@ class _$HouseholdOverviewDeleteHouseholdEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, required TResult orElse(), }) { @@ -578,8 +582,8 @@ class _$HouseholdOverviewDeleteIndividualEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function( - String projectId, BeneficiaryType projectBeneficiaryType) + required TResult Function(String projectId, + BeneficiaryType projectBeneficiaryType, int? offset, int? limit) reload, }) { return deleteIndividual( @@ -609,7 +613,8 @@ class _$HouseholdOverviewDeleteIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, }) { return deleteIndividual?.call( @@ -639,7 +644,8 @@ class _$HouseholdOverviewDeleteIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, required TResult orElse(), }) { @@ -847,8 +853,8 @@ class _$HouseholdOverviewSetAsHeadEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function( - String projectId, BeneficiaryType projectBeneficiaryType) + required TResult Function(String projectId, + BeneficiaryType projectBeneficiaryType, int? offset, int? limit) reload, }) { return setAsHead( @@ -878,7 +884,8 @@ class _$HouseholdOverviewSetAsHeadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, }) { return setAsHead?.call( @@ -908,7 +915,8 @@ class _$HouseholdOverviewSetAsHeadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, required TResult orElse(), }) { @@ -1082,8 +1090,8 @@ class _$HouseholdOverviewSelectIndividualEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function( - String projectId, BeneficiaryType projectBeneficiaryType) + required TResult Function(String projectId, + BeneficiaryType projectBeneficiaryType, int? offset, int? limit) reload, }) { return selectedIndividual(individualModel); @@ -1112,7 +1120,8 @@ class _$HouseholdOverviewSelectIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, }) { return selectedIndividual?.call(individualModel); @@ -1141,7 +1150,8 @@ class _$HouseholdOverviewSelectIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, required TResult orElse(), }) { @@ -1221,7 +1231,11 @@ abstract class _$$HouseholdOverviewReloadEventImplCopyWith<$Res> { $Res Function(_$HouseholdOverviewReloadEventImpl) then) = __$$HouseholdOverviewReloadEventImplCopyWithImpl<$Res>; @useResult - $Res call({String projectId, BeneficiaryType projectBeneficiaryType}); + $Res call( + {String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit}); } /// @nodoc @@ -1239,6 +1253,8 @@ class __$$HouseholdOverviewReloadEventImplCopyWithImpl<$Res> $Res call({ Object? projectId = null, Object? projectBeneficiaryType = null, + Object? offset = freezed, + Object? limit = freezed, }) { return _then(_$HouseholdOverviewReloadEventImpl( projectId: null == projectId @@ -1249,6 +1265,14 @@ class __$$HouseholdOverviewReloadEventImplCopyWithImpl<$Res> ? _value.projectBeneficiaryType : projectBeneficiaryType // ignore: cast_nullable_to_non_nullable as BeneficiaryType, + offset: freezed == offset + ? _value.offset + : offset // ignore: cast_nullable_to_non_nullable + as int?, + limit: freezed == limit + ? _value.limit + : limit // ignore: cast_nullable_to_non_nullable + as int?, )); } } @@ -1258,16 +1282,23 @@ class __$$HouseholdOverviewReloadEventImplCopyWithImpl<$Res> class _$HouseholdOverviewReloadEventImpl implements HouseholdOverviewReloadEvent { const _$HouseholdOverviewReloadEventImpl( - {required this.projectId, required this.projectBeneficiaryType}); + {required this.projectId, + required this.projectBeneficiaryType, + this.offset, + this.limit}); @override final String projectId; @override final BeneficiaryType projectBeneficiaryType; + @override + final int? offset; + @override + final int? limit; @override String toString() { - return 'HouseholdOverviewEvent.reload(projectId: $projectId, projectBeneficiaryType: $projectBeneficiaryType)'; + return 'HouseholdOverviewEvent.reload(projectId: $projectId, projectBeneficiaryType: $projectBeneficiaryType, offset: $offset, limit: $limit)'; } @override @@ -1278,12 +1309,14 @@ class _$HouseholdOverviewReloadEventImpl (identical(other.projectId, projectId) || other.projectId == projectId) && (identical(other.projectBeneficiaryType, projectBeneficiaryType) || - other.projectBeneficiaryType == projectBeneficiaryType)); + other.projectBeneficiaryType == projectBeneficiaryType) && + (identical(other.offset, offset) || other.offset == offset) && + (identical(other.limit, limit) || other.limit == limit)); } @override - int get hashCode => - Object.hash(runtimeType, projectId, projectBeneficiaryType); + int get hashCode => Object.hash( + runtimeType, projectId, projectBeneficiaryType, offset, limit); @JsonKey(ignore: true) @override @@ -1317,11 +1350,11 @@ class _$HouseholdOverviewReloadEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function( - String projectId, BeneficiaryType projectBeneficiaryType) + required TResult Function(String projectId, + BeneficiaryType projectBeneficiaryType, int? offset, int? limit) reload, }) { - return reload(projectId, projectBeneficiaryType); + return reload(projectId, projectBeneficiaryType, offset, limit); } @override @@ -1347,10 +1380,11 @@ class _$HouseholdOverviewReloadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, }) { - return reload?.call(projectId, projectBeneficiaryType); + return reload?.call(projectId, projectBeneficiaryType, offset, limit); } @override @@ -1376,12 +1410,13 @@ class _$HouseholdOverviewReloadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType)? + TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, + int? offset, int? limit)? reload, required TResult orElse(), }) { if (reload != null) { - return reload(projectId, projectBeneficiaryType); + return reload(projectId, projectBeneficiaryType, offset, limit); } return orElse(); } @@ -1438,12 +1473,15 @@ class _$HouseholdOverviewReloadEventImpl abstract class HouseholdOverviewReloadEvent implements HouseholdOverviewEvent { const factory HouseholdOverviewReloadEvent( - {required final String projectId, - required final BeneficiaryType projectBeneficiaryType}) = - _$HouseholdOverviewReloadEventImpl; + {required final String projectId, + required final BeneficiaryType projectBeneficiaryType, + final int? offset, + final int? limit}) = _$HouseholdOverviewReloadEventImpl; String get projectId; BeneficiaryType get projectBeneficiaryType; + int? get offset; + int? get limit; @JsonKey(ignore: true) _$$HouseholdOverviewReloadEventImplCopyWith< _$HouseholdOverviewReloadEventImpl> @@ -1456,6 +1494,8 @@ mixin _$HouseholdOverviewState { HouseholdMemberWrapper get householdMemberWrapper => throw _privateConstructorUsedError; IndividualModel? get selectedIndividual => throw _privateConstructorUsedError; + int? get offset => throw _privateConstructorUsedError; + int? get limit => throw _privateConstructorUsedError; @JsonKey(ignore: true) $HouseholdOverviewStateCopyWith get copyWith => @@ -1471,7 +1511,9 @@ abstract class $HouseholdOverviewStateCopyWith<$Res> { $Res call( {bool loading, HouseholdMemberWrapper householdMemberWrapper, - IndividualModel? selectedIndividual}); + IndividualModel? selectedIndividual, + int? offset, + int? limit}); $HouseholdMemberWrapperCopyWith<$Res> get householdMemberWrapper; } @@ -1493,6 +1535,8 @@ class _$HouseholdOverviewStateCopyWithImpl<$Res, Object? loading = null, Object? householdMemberWrapper = null, Object? selectedIndividual = freezed, + Object? offset = freezed, + Object? limit = freezed, }) { return _then(_value.copyWith( loading: null == loading @@ -1507,6 +1551,14 @@ class _$HouseholdOverviewStateCopyWithImpl<$Res, ? _value.selectedIndividual : selectedIndividual // ignore: cast_nullable_to_non_nullable as IndividualModel?, + offset: freezed == offset + ? _value.offset + : offset // ignore: cast_nullable_to_non_nullable + as int?, + limit: freezed == limit + ? _value.limit + : limit // ignore: cast_nullable_to_non_nullable + as int?, ) as $Val); } @@ -1532,7 +1584,9 @@ abstract class _$$HouseholdOverviewStateImplCopyWith<$Res> $Res call( {bool loading, HouseholdMemberWrapper householdMemberWrapper, - IndividualModel? selectedIndividual}); + IndividualModel? selectedIndividual, + int? offset, + int? limit}); @override $HouseholdMemberWrapperCopyWith<$Res> get householdMemberWrapper; @@ -1554,6 +1608,8 @@ class __$$HouseholdOverviewStateImplCopyWithImpl<$Res> Object? loading = null, Object? householdMemberWrapper = null, Object? selectedIndividual = freezed, + Object? offset = freezed, + Object? limit = freezed, }) { return _then(_$HouseholdOverviewStateImpl( loading: null == loading @@ -1568,6 +1624,14 @@ class __$$HouseholdOverviewStateImplCopyWithImpl<$Res> ? _value.selectedIndividual : selectedIndividual // ignore: cast_nullable_to_non_nullable as IndividualModel?, + offset: freezed == offset + ? _value.offset + : offset // ignore: cast_nullable_to_non_nullable + as int?, + limit: freezed == limit + ? _value.limit + : limit // ignore: cast_nullable_to_non_nullable + as int?, )); } } @@ -1578,7 +1642,9 @@ class _$HouseholdOverviewStateImpl implements _HouseholdOverviewState { const _$HouseholdOverviewStateImpl( {this.loading = false, required this.householdMemberWrapper, - this.selectedIndividual}); + this.selectedIndividual, + this.offset, + this.limit}); @override @JsonKey() @@ -1587,10 +1653,14 @@ class _$HouseholdOverviewStateImpl implements _HouseholdOverviewState { final HouseholdMemberWrapper householdMemberWrapper; @override final IndividualModel? selectedIndividual; + @override + final int? offset; + @override + final int? limit; @override String toString() { - return 'HouseholdOverviewState(loading: $loading, householdMemberWrapper: $householdMemberWrapper, selectedIndividual: $selectedIndividual)'; + return 'HouseholdOverviewState(loading: $loading, householdMemberWrapper: $householdMemberWrapper, selectedIndividual: $selectedIndividual, offset: $offset, limit: $limit)'; } @override @@ -1602,12 +1672,14 @@ class _$HouseholdOverviewStateImpl implements _HouseholdOverviewState { (identical(other.householdMemberWrapper, householdMemberWrapper) || other.householdMemberWrapper == householdMemberWrapper) && (identical(other.selectedIndividual, selectedIndividual) || - other.selectedIndividual == selectedIndividual)); + other.selectedIndividual == selectedIndividual) && + (identical(other.offset, offset) || other.offset == offset) && + (identical(other.limit, limit) || other.limit == limit)); } @override - int get hashCode => Object.hash( - runtimeType, loading, householdMemberWrapper, selectedIndividual); + int get hashCode => Object.hash(runtimeType, loading, householdMemberWrapper, + selectedIndividual, offset, limit); @JsonKey(ignore: true) @override @@ -1619,10 +1691,11 @@ class _$HouseholdOverviewStateImpl implements _HouseholdOverviewState { abstract class _HouseholdOverviewState implements HouseholdOverviewState { const factory _HouseholdOverviewState( - {final bool loading, - required final HouseholdMemberWrapper householdMemberWrapper, - final IndividualModel? selectedIndividual}) = - _$HouseholdOverviewStateImpl; + {final bool loading, + required final HouseholdMemberWrapper householdMemberWrapper, + final IndividualModel? selectedIndividual, + final int? offset, + final int? limit}) = _$HouseholdOverviewStateImpl; @override bool get loading; @@ -1631,6 +1704,10 @@ abstract class _HouseholdOverviewState implements HouseholdOverviewState { @override IndividualModel? get selectedIndividual; @override + int? get offset; + @override + int? get limit; + @override @JsonKey(ignore: true) _$$HouseholdOverviewStateImplCopyWith<_$HouseholdOverviewStateImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/registration_delivery/lib/data/repositories/local/household_member.dart b/packages/registration_delivery/lib/data/repositories/local/household_member.dart index 5815eb473..6f4ecd980 100644 --- a/packages/registration_delivery/lib/data/repositories/local/household_member.dart +++ b/packages/registration_delivery/lib/data/repositories/local/household_member.dart @@ -20,6 +20,9 @@ class HouseholdMemberLocalRepository ]) async { return retryLocalCallOperation>(() async { final selectQuery = sql.select(sql.householdMember).join([]); + if (query.limit != null && query.offset != null) { + selectQuery.limit(query.limit!, offset: query.offset); + } final results = await (selectQuery ..where( buildAnd( diff --git a/packages/registration_delivery/lib/models/entities/household_member.dart b/packages/registration_delivery/lib/models/entities/household_member.dart index 740e30753..b832ddbf1 100644 --- a/packages/registration_delivery/lib/models/entities/household_member.dart +++ b/packages/registration_delivery/lib/models/entities/household_member.dart @@ -18,6 +18,8 @@ class HouseholdMemberSearchModel extends EntitySearchModel final bool? isHeadOfHousehold; final List? clientReferenceId; final String? tenantId; + int? offset; + int? limit; HouseholdMemberSearchModel({ this.id, @@ -30,6 +32,8 @@ class HouseholdMemberSearchModel extends EntitySearchModel this.isHeadOfHousehold, this.clientReferenceId, this.tenantId, + this.limit, + this.offset, super.boundaryCode, super.isDeleted, }) : super(); diff --git a/packages/registration_delivery/lib/models/entities/household_member.mapper.dart b/packages/registration_delivery/lib/models/entities/household_member.mapper.dart index 83b8174d6..332394459 100644 --- a/packages/registration_delivery/lib/models/entities/household_member.mapper.dart +++ b/packages/registration_delivery/lib/models/entities/household_member.mapper.dart @@ -85,6 +85,12 @@ class HouseholdMemberSearchModelMapper static const Field _f$additionalFields = Field('additionalFields', _$additionalFields, mode: FieldMode.member); + static int? _$offset(HouseholdMemberSearchModel v) => v.offset; + static const Field _f$offset = + Field('offset', _$offset, mode: FieldMode.member); + static int? _$limit(HouseholdMemberSearchModel v) => v.limit; + static const Field _f$limit = + Field('limit', _$limit, mode: FieldMode.member); @override final MappableFields fields = const { @@ -101,6 +107,8 @@ class HouseholdMemberSearchModelMapper #boundaryCode: _f$boundaryCode, #auditDetails: _f$auditDetails, #additionalFields: _f$additionalFields, + #offset: _f$offset, + #limit: _f$limit, }; @override final bool ignoreNull = true; diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 755e1ca86..88be60211 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -41,16 +41,11 @@ class HouseholdOverviewPage extends LocalizedStatefulWidget { class _HouseholdOverviewPageState extends LocalizedState { + int offset = 0; + int limit = 10; @override void initState() { - final bloc = context.read(); - bloc.add( - HouseholdOverviewReloadEvent( - projectId: RegistrationDeliverySingleton().projectId!, - projectBeneficiaryType: - RegistrationDeliverySingleton().beneficiaryType!, - ), - ); + callReloadEvent(offset: offset, limit: limit); super.initState(); } @@ -73,80 +68,115 @@ class _HouseholdOverviewPageState return Scaffold( body: state.loading ? const Center(child: CircularProgressIndicator()) - : ScrollableContent( - header: BackNavigationHelpHeaderWidget( - handleBack: (){ - context.read().add(const SearchHouseholdsEvent.clear()); - }, - ), - enableFixedButton: true, - footer: Offstage( - offstage: beneficiaryType == BeneficiaryType.individual || isOutsideProjectDateRange(), - child: BlocBuilder( - builder: (context, serviceDefinitionState) => - BlocBuilder( - builder: (ctx, deliverInterventionState) => DigitCard( - margin: - const EdgeInsets.only(top: spacer2), - padding: const EdgeInsets.all(spacer2), - children: [state.householdMemberWrapper.tasks?.lastOrNull?.status == - Status.administeredSuccess.toValue() - ? Padding( - padding: const EdgeInsets.symmetric( - vertical: spacer2), - child: Button( - label: localizations.translate( - i18.memberCard - .deliverDetailsUpdateLabel, - ), - isDisabled: state.householdMemberWrapper.tasks?.lastOrNull?.status == Status.administeredSuccess.toValue() - ? true : false, - type: ButtonType.secondary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () { - serviceDefinitionState.when( - empty: () {}, - isloading: () {}, - serviceDefinitionFetch: - (value, model) { - if (value - .where((element) => element - .code - .toString() - .contains( - '${RegistrationDeliverySingleton().selectedProject?.name}.${RegistrationDeliveryEnums.iec.toValue()}')) - .toList() - .isEmpty) { - context.router.push( - DeliverInterventionRoute(), - ); - } else { - navigateToChecklist(ctx); - } - }); - }, - ), - ) - : Button( - label: localizations.translate( - i18.householdOverView - .householdOverViewActionText, - ), - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - isDisabled: (state.householdMemberWrapper - .projectBeneficiaries ?? - []) - .isEmpty || - state.householdMemberWrapper.tasks - ?.lastOrNull?.status == - Status.closeHousehold.toValue() - ? true : false, - onPressed: () async { + : NotificationListener( + onNotification: (scrollNotification) { + if (scrollNotification is ScrollUpdateNotification) { + final metrics = scrollNotification.metrics; + if (metrics.atEdge && metrics.pixels != 0) { + callReloadEvent(offset: offset + limit, limit: limit); + offset += limit; + } + } + return true; + }, + child: ScrollableContent( + header: BackNavigationHelpHeaderWidget( + handleBack: () { + context + .read() + .add(const SearchHouseholdsEvent.clear()); + }, + ), + enableFixedButton: true, + footer: Offstage( + offstage: + beneficiaryType == BeneficiaryType.individual || + isOutsideProjectDateRange(), + child: BlocBuilder( + builder: (context, serviceDefinitionState) => + BlocBuilder( + builder: (ctx, deliverInterventionState) => + DigitCard( + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + state.householdMemberWrapper.tasks?.lastOrNull + ?.status == + Status.administeredSuccess.toValue() + ? Padding( + padding: const EdgeInsets.symmetric( + vertical: spacer2), + child: Button( + label: localizations.translate( + i18.memberCard + .deliverDetailsUpdateLabel, + ), + isDisabled: state + .householdMemberWrapper + .tasks + ?.lastOrNull + ?.status == + Status.administeredSuccess + .toValue() + ? true + : false, + type: ButtonType.secondary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () { + serviceDefinitionState.when( + empty: () {}, + isloading: () {}, + serviceDefinitionFetch: + (value, model) { + if (value + .where((element) => element + .code + .toString() + .contains( + '${RegistrationDeliverySingleton().selectedProject?.name}.${RegistrationDeliveryEnums.iec.toValue()}')) + .toList() + .isEmpty) { + context.router.push( + DeliverInterventionRoute(), + ); + } else { + navigateToChecklist(ctx); + } + }); + callReloadEvent( + offset: state + .householdMemberWrapper + .members! + .length, + limit: limit); + }, + ), + ) + : Button( + label: localizations.translate( + i18.householdOverView + .householdOverViewActionText, + ), + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + isDisabled: (state.householdMemberWrapper + .projectBeneficiaries ?? + []) + .isEmpty || + state + .householdMemberWrapper + .tasks + ?.lastOrNull + ?.status == + Status.closeHousehold + .toValue() + ? true + : false, + onPressed: () async { final bloc = ctx .read(); @@ -183,339 +213,32 @@ class _HouseholdOverviewPageState } }); }, - ),] + ), + ]), ), ), ), - ), - slivers: [ - SliverToBoxAdapter( - child: DigitCard( - children: [Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - if ((state.householdMemberWrapper - .projectBeneficiaries ?? - []) - .isNotEmpty) - Align( - alignment: Alignment.centerLeft, - child: Button( - onPressed: () { - final projectId = - RegistrationDeliverySingleton() - .projectId!; - - final bloc = - context.read(); - bloc.add( - HouseholdOverviewReloadEvent( - projectId: projectId, - projectBeneficiaryType: - beneficiaryType, - ), - ); - showDialog( - context: context, - builder: (ctx)=> ActionCard( - actions: [ - Button( - prefixIcon: Icons.edit, - label: localizations.translate( - i18.householdOverView - .householdOverViewEditLabel, - ), - type: ButtonType.secondary, - size: ButtonSize.large, - onPressed: () async { - Navigator.of( - context, - rootNavigator: true, - ).pop(); - - HouseholdMemberWrapper wrapper = - state - .householdMemberWrapper; - - final timestamp = wrapper - .headOfHousehold - ?.clientAuditDetails - ?.createdTime; - final date = DateTime - .fromMillisecondsSinceEpoch( - timestamp ?? - DateTime.now() - .millisecondsSinceEpoch, - ); - - final address = - wrapper.household?.address; - - if (address == null) return; - - final projectBeneficiary = state - .householdMemberWrapper - .projectBeneficiaries - ?.firstWhereOrNull( - (element) => - element - .beneficiaryClientReferenceId == - wrapper.household - ?.clientReferenceId, - ); - - await context.router.root.push( - BeneficiaryRegistrationWrapperRoute( - initialState: - BeneficiaryRegistrationEditHouseholdState( - addressModel: address, - individualModel: state - .householdMemberWrapper - .members ?? - [], - householdModel: state - .householdMemberWrapper - .household!, - registrationDate: date, - projectBeneficiaryModel: - projectBeneficiary, - ), - children: [ - HouseholdLocationRoute(), - ], - ), - ); - }, - ), - ], - ), - ); - }, - label: localizations.translate( - i18.householdOverView - .householdOverViewEditIconText, - ), - type: ButtonType.tertiary, - size: ButtonSize.medium, - prefixIcon: Icons.edit, - ), - ), - // BlocBuilder( - // builder: (ctx, deliverInterventionState) => - // Offstage( - // offstage: beneficiaryType == - // BeneficiaryType.individual, - // child: Align( - // alignment: Alignment.centerLeft, - // child: DigitIconButton( - // icon: getStatusAttributes(state, - // deliverInterventionState)['icon'], - // iconText: localizations.translate( - // getStatusAttributes(state, - // deliverInterventionState)[ - // 'textLabel'], - // ), // [TODO: map task status accordingly based on projectBeneficiaries and tasks] - // iconTextColor: getStatusAttributes(state, - // deliverInterventionState)['color'], - // iconColor: getStatusAttributes(state, - // deliverInterventionState)['color'], - // ), - // ), - // ), - // ), - Padding( - padding: const EdgeInsets.all( - spacer2 - ), - child: Text( - localizations.translate(i18.householdOverView - .householdOverViewLabel), - style: textTheme.headingXl, - ), - ), - Padding( - padding: const EdgeInsets.only( - left: spacer2, - right: spacer2, - ), - child: BlocBuilder( - builder: (ctx, deliverInterventionState) { - - bool shouldShowStatus = beneficiaryType == BeneficiaryType.household; - - return Column( - children: [ - DigitTableCard( - element: { - localizations.translate(i18 - .householdOverView - .householdOverViewHouseholdHeadNameLabel): - state - .householdMemberWrapper - .headOfHousehold - ?.name - ?.givenName ?? - localizations.translate( - i18.common.coreCommonNA), - localizations.translate( - i18.householdLocation - .administrationAreaFormLabel, - ): state.householdMemberWrapper.headOfHousehold?.address?.first.locality?.code, - localizations.translate( - i18.deliverIntervention - .memberCountText, - ): state.householdMemberWrapper - .household?.memberCount, - if(shouldShowStatus) - localizations.translate(i18 - .beneficiaryDetails - .status): localizations.translate( - getStatusAttributes(state, - deliverInterventionState)[ - 'textLabel'], - ) - }, - ), - ], - ); - }), - ), - Column( - children: - (state.householdMemberWrapper.members ?? []) - .map( - (e) { - final isHead = state - .householdMemberWrapper - .headOfHousehold - ?.clientReferenceId == - e.clientReferenceId; - final projectBeneficiaryId = state - .householdMemberWrapper - .projectBeneficiaries - ?.firstWhereOrNull((b) => - b.beneficiaryClientReferenceId == - e.clientReferenceId) - ?.clientReferenceId; - - final projectBeneficiary = state - .householdMemberWrapper - .projectBeneficiaries - ?.where( - (element) => - element - .beneficiaryClientReferenceId == - (RegistrationDeliverySingleton() - .beneficiaryType == - BeneficiaryType.individual - ? e.clientReferenceId - : state - .householdMemberWrapper - .household - ?.clientReferenceId), - ) - .toList(); - - final taskData = (projectBeneficiary ?? []) - .isNotEmpty - ? state.householdMemberWrapper.tasks - ?.where((element) => - element - .projectBeneficiaryClientReferenceId == - projectBeneficiary - ?.first.clientReferenceId) - .toList() - : null; - final referralData = (projectBeneficiary ?? - []) - .isNotEmpty - ? state.householdMemberWrapper.referrals - ?.where((element) => - element - .projectBeneficiaryClientReferenceId == - projectBeneficiary - ?.first.clientReferenceId) - .toList() - : null; - final sideEffectData = taskData != null && - taskData.isNotEmpty - ? state - .householdMemberWrapper.sideEffects - ?.where((element) => - element.taskClientReferenceId == - taskData.lastOrNull?.clientReferenceId) - .toList() - : null; - final ageInYears = e.dateOfBirth != null - ? DigitDateUtils.calculateAge( - DigitDateUtils - .getFormattedDateToDateTime( - e.dateOfBirth!, - ) ?? - DateTime.now(), - ).years - : 0; - final ageInMonths = e.dateOfBirth != null - ? DigitDateUtils.calculateAge( - DigitDateUtils - .getFormattedDateToDateTime( - e.dateOfBirth!, - ) ?? - DateTime.now(), - ).months - : 0; - final currentCycle = - RegistrationDeliverySingleton() - .projectType - ?.cycles - ?.firstWhereOrNull( - (e) => - (e.startDate) < - DateTime.now() - .millisecondsSinceEpoch && - (e.endDate) > - DateTime.now() - .millisecondsSinceEpoch, - ); - - final isBeneficiaryRefused = - checkIfBeneficiaryRefused( - taskData, - ); - final isBeneficiaryReferred = - checkIfBeneficiaryReferred( - referralData, - currentCycle, - ); - - return MemberCard( - isHead: isHead, - individual: e, - projectBeneficiaries: - projectBeneficiary ?? [], - tasks: taskData, - sideEffects: sideEffectData, - editMemberAction: () async { - final bloc = - ctx.read(); - - Navigator.of( - context, - rootNavigator: true, - ).pop(); - - final address = e.address; - if (address == null || - address.isEmpty) { - return; - } - + slivers: [ + SliverToBoxAdapter( + child: DigitCard(children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + if ((state.householdMemberWrapper + .projectBeneficiaries ?? + []) + .isNotEmpty) + Align( + alignment: Alignment.centerLeft, + child: Button( + onPressed: () { final projectId = RegistrationDeliverySingleton() .projectId!; + + final bloc = context + .read(); bloc.add( HouseholdOverviewReloadEvent( projectId: projectId, @@ -523,205 +246,533 @@ class _HouseholdOverviewPageState beneficiaryType, ), ); - - await context.router.root.push( - BeneficiaryRegistrationWrapperRoute( - initialState: - BeneficiaryRegistrationEditIndividualState( - individualModel: e, - householdModel: state - .householdMemberWrapper - .household!, - addressModel: address.first, - projectBeneficiaryModel: state - .householdMemberWrapper - .projectBeneficiaries - ?.firstWhereOrNull( - (element) => - element - .beneficiaryClientReferenceId == - (RegistrationDeliverySingleton() - .beneficiaryType == - BeneficiaryType - .individual - ? e.clientReferenceId - : state + showDialog( + context: context, + builder: (ctx) => ActionCard( + actions: [ + Button( + prefixIcon: Icons.edit, + label: localizations.translate( + i18.householdOverView + .householdOverViewEditLabel, + ), + type: ButtonType.secondary, + size: ButtonSize.large, + onPressed: () async { + Navigator.of( + context, + rootNavigator: true, + ).pop(); + + HouseholdMemberWrapper + wrapper = state + .householdMemberWrapper; + + final timestamp = wrapper + .headOfHousehold + ?.clientAuditDetails + ?.createdTime; + final date = DateTime + .fromMillisecondsSinceEpoch( + timestamp ?? + DateTime.now() + .millisecondsSinceEpoch, + ); + + final address = wrapper + .household?.address; + + if (address == null) return; + + final projectBeneficiary = + state + .householdMemberWrapper + .projectBeneficiaries + ?.firstWhereOrNull( + (element) => + element + .beneficiaryClientReferenceId == + wrapper.household + ?.clientReferenceId, + ); + + await context.router.root + .push( + BeneficiaryRegistrationWrapperRoute( + initialState: + BeneficiaryRegistrationEditHouseholdState( + addressModel: address, + individualModel: state + .householdMemberWrapper + .members ?? + [], + householdModel: state .householdMemberWrapper - .household - ?.clientReferenceId), - ), - ), - children: [ - IndividualDetailsRoute( - isHeadOfHousehold: isHead, + .household!, + registrationDate: date, + projectBeneficiaryModel: + projectBeneficiary, + ), + children: [ + HouseholdLocationRoute(), + ], + ), + ); + callReloadEvent( + offset: 0, limit: 10); + }, ), ], ), ); }, - setAsHeadAction: () { - ctx.read().add( - HouseholdOverviewSetAsHeadEvent( - individualModel: e, - projectId: - RegistrationDeliverySingleton() - .projectId!, - householdModel: state - .householdMemberWrapper - .household!, - projectBeneficiaryType: - beneficiaryType, - ), - ); - - Navigator.of( - context, - rootNavigator: true, - ).pop(); - }, - deleteMemberAction: () { - showPopup( - context: context, - title: localizations.translate(i18 - .householdOverView - .householdOverViewActionCardTitle), - type: PopUpType.simple, - actions: [ - Button( - label: localizations.translate(i18.householdOverView - .householdOverViewPrimaryActionLabel), - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ) - ..pop() - ..pop(); - context - .read< - HouseholdOverviewBloc>() - .add( - HouseholdOverviewEvent - .selectedIndividual( - individualModel: e, - ), - ); - context.router.push( - ReasonForDeletionRoute( - isHousholdDelete: false, - ), - ); - }, - type: ButtonType.primary, - size: ButtonSize.large - ), - Button( - label: localizations.translate(i18.householdOverView - .householdOverViewSecondaryActionLabel), - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ).pop(); - }, - type: ButtonType.tertiary, - size: ButtonSize.large + label: localizations.translate( + i18.householdOverView + .householdOverViewEditIconText, + ), + type: ButtonType.tertiary, + size: ButtonSize.medium, + prefixIcon: Icons.edit, + ), + ), + // BlocBuilder( + // builder: (ctx, deliverInterventionState) => + // Offstage( + // offstage: beneficiaryType == + // BeneficiaryType.individual, + // child: Align( + // alignment: Alignment.centerLeft, + // child: DigitIconButton( + // icon: getStatusAttributes(state, + // deliverInterventionState)['icon'], + // iconText: localizations.translate( + // getStatusAttributes(state, + // deliverInterventionState)[ + // 'textLabel'], + // ), // [TODO: map task status accordingly based on projectBeneficiaries and tasks] + // iconTextColor: getStatusAttributes(state, + // deliverInterventionState)['color'], + // iconColor: getStatusAttributes(state, + // deliverInterventionState)['color'], + // ), + // ), + // ), + // ), + Padding( + padding: const EdgeInsets.all(spacer2), + child: Text( + localizations.translate(i18 + .householdOverView + .householdOverViewLabel), + style: textTheme.headingXl, + ), + ), + Padding( + padding: const EdgeInsets.only( + left: spacer2, + right: spacer2, + ), + child: BlocBuilder( + builder: (ctx, deliverInterventionState) { + bool shouldShowStatus = beneficiaryType == + BeneficiaryType.household; + + return Column( + children: [ + DigitTableCard( + element: { + localizations.translate(i18 + .householdOverView + .householdOverViewHouseholdHeadNameLabel): + state + .householdMemberWrapper + .headOfHousehold + ?.name + ?.givenName ?? + localizations.translate(i18 + .common.coreCommonNA), + localizations.translate( + i18.householdLocation + .administrationAreaFormLabel, + ): state + .householdMemberWrapper + .headOfHousehold + ?.address + ?.first + .locality + ?.code, + localizations.translate( + i18.deliverIntervention + .memberCountText, + ): state.householdMemberWrapper + .household?.memberCount, + if (shouldShowStatus) + localizations.translate(i18 + .beneficiaryDetails + .status): + localizations.translate( + getStatusAttributes(state, + deliverInterventionState)[ + 'textLabel'], ) - ] - ); - }, - isNotEligible: RegistrationDeliverySingleton() - .projectType - ?.cycles != - null - ? !checkEligibilityForAgeAndSideEffect( - DigitDOBAgeConvertor( - years: ageInYears, - months: ageInMonths, - ), - RegistrationDeliverySingleton() - .projectType, - (taskData ?? []).isNotEmpty - ? taskData?.lastOrNull - : null, - sideEffectData, - ) - : false, - name: e.name?.givenName ?? ' - - ', - years: (e.dateOfBirth == null - ? null - : DigitDateUtils.calculateAge( + }, + ), + ], + ); + }), + ), + Column( + children: + (state.householdMemberWrapper.members ?? + []) + .map( + (e) { + final isHead = state + .householdMemberWrapper + .headOfHousehold + ?.clientReferenceId == + e.clientReferenceId; + final projectBeneficiaryId = state + .householdMemberWrapper + .projectBeneficiaries + ?.firstWhereOrNull((b) => + b.beneficiaryClientReferenceId == + e.clientReferenceId) + ?.clientReferenceId; + + final projectBeneficiary = state + .householdMemberWrapper + .projectBeneficiaries + ?.where( + (element) => + element + .beneficiaryClientReferenceId == + (RegistrationDeliverySingleton() + .beneficiaryType == + BeneficiaryType + .individual + ? e.clientReferenceId + : state + .householdMemberWrapper + .household + ?.clientReferenceId), + ) + .toList(); + + final taskData = (projectBeneficiary ?? + []) + .isNotEmpty + ? state.householdMemberWrapper.tasks + ?.where((element) => + element + .projectBeneficiaryClientReferenceId == + projectBeneficiary + ?.first.clientReferenceId) + .toList() + : null; + final referralData = (projectBeneficiary ?? + []) + .isNotEmpty + ? state + .householdMemberWrapper.referrals + ?.where((element) => + element + .projectBeneficiaryClientReferenceId == + projectBeneficiary + ?.first.clientReferenceId) + .toList() + : null; + final sideEffectData = taskData != null && + taskData.isNotEmpty + ? state.householdMemberWrapper + .sideEffects + ?.where((element) => + element + .taskClientReferenceId == + taskData.lastOrNull + ?.clientReferenceId) + .toList() + : null; + final ageInYears = e.dateOfBirth != null + ? DigitDateUtils.calculateAge( DigitDateUtils .getFormattedDateToDateTime( e.dateOfBirth!, ) ?? DateTime.now(), - ).years), - months: (e.dateOfBirth == null - ? null - : DigitDateUtils.calculateAge( + ).years + : 0; + final ageInMonths = e.dateOfBirth != null + ? DigitDateUtils.calculateAge( DigitDateUtils .getFormattedDateToDateTime( e.dateOfBirth!, ) ?? DateTime.now(), - ).months), - gender: e.gender?.name, - isBeneficiaryRefused: - isBeneficiaryRefused && - !checkStatus( - taskData, - currentCycle, + ).months + : 0; + final currentCycle = + RegistrationDeliverySingleton() + .projectType + ?.cycles + ?.firstWhereOrNull( + (e) => + (e.startDate) < + DateTime.now() + .millisecondsSinceEpoch && + (e.endDate) > + DateTime.now() + .millisecondsSinceEpoch, + ); + + final isBeneficiaryRefused = + checkIfBeneficiaryRefused( + taskData, + ); + final isBeneficiaryReferred = + checkIfBeneficiaryReferred( + referralData, + currentCycle, + ); + + return MemberCard( + isHead: isHead, + individual: e, + projectBeneficiaries: + projectBeneficiary ?? [], + tasks: taskData, + sideEffects: sideEffectData, + editMemberAction: () async { + final bloc = + ctx.read(); + + Navigator.of( + context, + rootNavigator: true, + ).pop(); + + final address = e.address; + if (address == null || + address.isEmpty) { + return; + } + + final projectId = + RegistrationDeliverySingleton() + .projectId!; + bloc.add( + HouseholdOverviewReloadEvent( + projectId: projectId, + projectBeneficiaryType: + beneficiaryType, + ), + ); + + await context.router.root.push( + BeneficiaryRegistrationWrapperRoute( + initialState: + BeneficiaryRegistrationEditIndividualState( + individualModel: e, + householdModel: state + .householdMemberWrapper + .household!, + addressModel: address.first, + projectBeneficiaryModel: state + .householdMemberWrapper + .projectBeneficiaries + ?.firstWhereOrNull( + (element) => + element + .beneficiaryClientReferenceId == + (RegistrationDeliverySingleton() + .beneficiaryType == + BeneficiaryType + .individual + ? e.clientReferenceId + : state + .householdMemberWrapper + .household + ?.clientReferenceId), + ), ), - isBeneficiaryReferred: - isBeneficiaryReferred, - isDelivered: taskData == null - ? false - : taskData.isNotEmpty && - !checkStatus( - taskData, - currentCycle, - ) - ? true - : false, - localizations: localizations, - projectBeneficiaryClientReferenceId: - projectBeneficiaryId, - ); - }, - ).toList(), - ), - const SizedBox( - height: spacer2, - ), - Center( - child: Button( - isDisabled: (state.householdMemberWrapper - .projectBeneficiaries ?? - []) - .isEmpty, - onPressed: () => addIndividual( + children: [ + IndividualDetailsRoute( + isHeadOfHousehold: isHead, + ), + ], + ), + ); + callReloadEvent(offset: 0, limit: 10); + }, + setAsHeadAction: () { + ctx.read().add( + HouseholdOverviewSetAsHeadEvent( + individualModel: e, + projectId: + RegistrationDeliverySingleton() + .projectId!, + householdModel: state + .householdMemberWrapper + .household!, + projectBeneficiaryType: + beneficiaryType, + ), + ); + + Navigator.of( context, - state.householdMemberWrapper - .household!, - ), - label: localizations.translate( - i18.householdOverView - .householdOverViewAddActionText, + rootNavigator: true, + ).pop(); + }, + deleteMemberAction: () { + showPopup( + context: context, + title: localizations.translate(i18 + .householdOverView + .householdOverViewActionCardTitle), + type: PopUpType.simple, + actions: [ + Button( + label: localizations + .translate(i18 + .householdOverView + .householdOverViewPrimaryActionLabel), + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ) + ..pop() + ..pop(); + context + .read< + HouseholdOverviewBloc>() + .add( + HouseholdOverviewEvent + .selectedIndividual( + individualModel: + e, + ), + ); + context.router.push( + ReasonForDeletionRoute( + isHousholdDelete: + false, + ), + ); + }, + type: ButtonType.primary, + size: ButtonSize.large), + Button( + label: localizations + .translate(i18 + .householdOverView + .householdOverViewSecondaryActionLabel), + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(); + }, + type: ButtonType.tertiary, + size: ButtonSize.large) + ]); + }, + isNotEligible: + RegistrationDeliverySingleton() + .projectType + ?.cycles != + null + ? !checkEligibilityForAgeAndSideEffect( + DigitDOBAgeConvertor( + years: ageInYears, + months: ageInMonths, + ), + RegistrationDeliverySingleton() + .projectType, + (taskData ?? []).isNotEmpty + ? taskData?.lastOrNull + : null, + sideEffectData, + ) + : false, + name: e.name?.givenName ?? ' - - ', + years: (e.dateOfBirth == null + ? null + : DigitDateUtils.calculateAge( + DigitDateUtils + .getFormattedDateToDateTime( + e.dateOfBirth!, + ) ?? + DateTime.now(), + ).years), + months: (e.dateOfBirth == null + ? null + : DigitDateUtils.calculateAge( + DigitDateUtils + .getFormattedDateToDateTime( + e.dateOfBirth!, + ) ?? + DateTime.now(), + ).months), + gender: e.gender?.name, + isBeneficiaryRefused: + isBeneficiaryRefused && + !checkStatus( + taskData, + currentCycle, + ), + isBeneficiaryReferred: + isBeneficiaryReferred, + isDelivered: taskData == null + ? false + : taskData.isNotEmpty && + !checkStatus( + taskData, + currentCycle, + ) + ? true + : false, + localizations: localizations, + projectBeneficiaryClientReferenceId: + projectBeneficiaryId, + ); + }, + ).toList(), + ), + const SizedBox( + height: spacer2, + ), + Center( + child: Button( + isDisabled: (state.householdMemberWrapper + .projectBeneficiaries ?? + []) + .isEmpty, + onPressed: () => addIndividual( + context, + state.householdMemberWrapper.household!, + ), + label: localizations.translate( + i18.householdOverView + .householdOverViewAddActionText, + ), + prefixIcon: Icons.add_circle, + type: ButtonType.tertiary, + size: ButtonSize.medium, ), - prefixIcon: Icons.add_circle, - type: ButtonType.tertiary, - size: ButtonSize.medium, ), - ), - const SizedBox( - height: spacer2, - ), - ], - ),] + const SizedBox( + height: spacer2, + ), + ], + ), + ]), ), - ), - ], + ], + ), ), ); }, @@ -761,7 +812,7 @@ class _HouseholdOverviewPageState if (project?.startDate != null && project?.endDate != null) { final now = DateTime.now().millisecondsSinceEpoch; final startDate = project!.startDate!; - final endDate = project!.endDate!; + final endDate = project.endDate!; return now < startDate || now > endDate; } @@ -769,7 +820,6 @@ class _HouseholdOverviewPageState return false; } - getStatusAttributes(HouseholdOverviewState state, DeliverInterventionState deliverInterventionState) { var textLabel = @@ -807,4 +857,23 @@ class _HouseholdOverviewPageState void navigateToChecklist(BuildContext ctx) async { await context.router.push(BeneficiaryChecklistRoute()); } + + void callReloadEvent({ + required int offset, + required int limit, + }) { + if (mounted) { + final bloc = context.read(); + + bloc.add( + HouseholdOverviewReloadEvent( + projectId: RegistrationDeliverySingleton().projectId!, + projectBeneficiaryType: + RegistrationDeliverySingleton().beneficiaryType!, + offset: offset, + limit: limit, + ), + ); + } + } } From a0cea61a3b2a13133b07084c50949f5e69c23e2b Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Wed, 27 Nov 2024 14:50:29 +0530 Subject: [PATCH 02/19] added search and filter functionality in household_overview --- .../household_overview.dart | 472 ++++++++++------ .../household_overview.freezed.dart | 224 ++++++-- .../local/individual_global_search.dart | 81 ++- .../beneficiary/beneficiary_wrapper.dart | 11 +- .../pages/beneficiary/household_overview.dart | 513 ++++++++++++------ .../beneficiary_registration_wrapper.dart | 5 + .../lib/utils/global_search_parameters.dart | 25 +- 7 files changed, 930 insertions(+), 401 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart index 21c8437c7..92599b6ed 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart @@ -6,7 +6,10 @@ import 'package:digit_data_model/data_model.dart'; import 'package:digit_data_model/utils/typedefs.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:registration_delivery/registration_delivery.dart'; +import 'package:registration_delivery/utils/global_search_parameters.dart'; +import '../../data/repositories/local/individual_global_search.dart'; import '../../models/entities/household.dart'; import '../../models/entities/household_member.dart'; import '../../models/entities/project_beneficiary.dart'; @@ -30,6 +33,7 @@ class HouseholdOverviewBloc final TaskDataRepository taskDataRepository; final SideEffectDataRepository sideEffectDataRepository; final ReferralDataRepository referralDataRepository; + final IndividualGlobalSearchRepository individualGlobalSearchRepository; HouseholdOverviewBloc( super.initialState, { @@ -41,6 +45,7 @@ class HouseholdOverviewBloc required this.sideEffectDataRepository, required this.referralDataRepository, required this.beneficiaryType, + required this.individualGlobalSearchRepository, }) { on(_handleDeleteHousehold); on(_handleDeleteIndividual); @@ -66,201 +71,344 @@ class HouseholdOverviewBloc // Set the loading state to indicate that data is being loaded. emit(state.copyWith(loading: true)); - // Retrieve household members based on certain criteria. - final members = event.limit != null - ? await householdMemberRepository.search( - HouseholdMemberSearchModel( + if (event.searchByName == null && + (event.selectedFilter == null || event.selectedFilter!.isEmpty)) { + // Retrieve household members based on certain criteria. + final members = event.limit != null + ? await householdMemberRepository.search( + HouseholdMemberSearchModel( + householdClientReferenceId: + state.householdMemberWrapper.household != null + ? [ + state.householdMemberWrapper.household! + .clientReferenceId + ] + : [], + limit: event.limit, + offset: event.offset, + ), + ) + : await householdMemberRepository.search(HouseholdMemberSearchModel( householdClientReferenceId: state .householdMemberWrapper.household != null ? [state.householdMemberWrapper.household!.clientReferenceId] - : [], - limit: event.limit, - offset: event.offset, - ), - ) - : await householdMemberRepository.search(HouseholdMemberSearchModel( - householdClientReferenceId: state - .householdMemberWrapper.household != - null - ? [state.householdMemberWrapper.household!.clientReferenceId] - : [])); - - // Group household members by household ID. - final groupedHouseholds = members.groupListsBy( - (element) => element.householdClientReferenceId, - ); + : [])); - final householdId = - state.householdMemberWrapper.household?.clientReferenceId; + // Group household members by household ID. + final groupedHouseholds = members.groupListsBy( + (element) => element.householdClientReferenceId, + ); - // Check if the current household has any members. - if (!groupedHouseholds.containsKey(householdId)) { - // If there are no members, stop loading and return. - emit(state.copyWith(loading: false)); + final householdId = + state.householdMemberWrapper.household?.clientReferenceId; - return; - } + // Check if the current household has any members. + if (!groupedHouseholds.containsKey(householdId)) { + // If there are no members, stop loading and return. + emit(state.copyWith(loading: false)); - // Retrieve the list of household members for the current household. - final householdMemberList = groupedHouseholds[householdId]!; + return; + } - // Extract individual IDs from the household member list. - final individualIds = householdMemberList - .map((e) => e.individualClientReferenceId) - .whereNotNull() - .toList(); + // Retrieve the list of household members for the current household. + final householdMemberList = groupedHouseholds[householdId]!; - // Search for households with the specified client reference ID. - final households = await householdRepository.search( - HouseholdSearchModel( - clientReferenceId: householdId != null ? [householdId] : []), - ); + // Extract individual IDs from the household member list. + final individualIds = householdMemberList + .map((e) => e.individualClientReferenceId) + .whereNotNull() + .toList(); - // Check if any households were found. - if (households.isEmpty) { - // If no households were found, stop loading and return. - emit(state.copyWith(loading: false)); + // Search for households with the specified client reference ID. + final households = await householdRepository.search( + HouseholdSearchModel( + clientReferenceId: householdId != null ? [householdId] : []), + ); - return; - } + // Check if any households were found. + if (households.isEmpty) { + // If no households were found, stop loading and return. + emit(state.copyWith(loading: false)); - // Retrieve the result household (assuming there's only one). - final resultHousehold = households.first; + return; + } - // Search for individuals based on their client reference IDs. - final individuals = await individualRepository.search( - IndividualSearchModel( - clientReferenceId: individualIds, - ), - ); + // Retrieve the result household (assuming there's only one). + final resultHousehold = households.first; - // Search for project beneficiaries based on specified criteria. - final projectBeneficiaries = await projectBeneficiaryRepository.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: - event.projectBeneficiaryType == BeneficiaryType.individual - ? individualIds - : [resultHousehold.clientReferenceId], - projectId: [event.projectId], - // [TODO] Need to pass as a based on Beneficiary Type - ), - ); + // Search for individuals based on their client reference IDs. + final individuals = await individualRepository.search( + IndividualSearchModel( + clientReferenceId: individualIds, + ), + ); + + // Search for project beneficiaries based on specified criteria. + final projectBeneficiaries = await projectBeneficiaryRepository.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: + event.projectBeneficiaryType == BeneficiaryType.individual + ? individualIds + : [resultHousehold.clientReferenceId], + projectId: [event.projectId], + // [TODO] Need to pass as a based on Beneficiary Type + ), + ); - // Check if any project beneficiaries were found. - if (projectBeneficiaries.isEmpty) { - // If no project beneficiaries were found, stop loading and return. - emit(state.copyWith(loading: false)); + // Check if any project beneficiaries were found. + if (projectBeneficiaries.isEmpty) { + // If no project beneficiaries were found, stop loading and return. + emit(state.copyWith(loading: false)); - return; - } + return; + } - final beneficiaryClientReferenceIds = projectBeneficiaries - .map((e) => e.beneficiaryClientReferenceId) - .toList(); - - final List beneficiaryIndividuals = individuals - .where((element) => - beneficiaryClientReferenceIds.contains(element.clientReferenceId)) - .toList(); - - // Find the head of the household. - final head = (event.projectBeneficiaryType == BeneficiaryType.individual - ? beneficiaryIndividuals - : individuals) - .firstWhereOrNull( - (i) => - i.clientReferenceId == - householdMemberList - .firstWhereOrNull((h) => h.isHeadOfHousehold) - ?.individualClientReferenceId, - ); + final beneficiaryClientReferenceIds = projectBeneficiaries + .map((e) => e.beneficiaryClientReferenceId) + .toList(); - // Search for tasks associated with project beneficiaries. - var tasks = await taskDataRepository.search(TaskSearchModel( - projectBeneficiaryClientReferenceId: - projectBeneficiaries.map((e) => e.clientReferenceId).toList())); + final List beneficiaryIndividuals = individuals + .where((element) => + beneficiaryClientReferenceIds.contains(element.clientReferenceId)) + .toList(); - // Search for adverse events associated with tasks. - final sideEffects = - await sideEffectDataRepository.search(SideEffectSearchModel( - taskClientReferenceId: - tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), - )); + // Find the head of the household. + final head = (event.projectBeneficiaryType == BeneficiaryType.individual + ? beneficiaryIndividuals + : individuals) + .firstWhereOrNull( + (i) => + i.clientReferenceId == + householdMemberList + .firstWhereOrNull((h) => h.isHeadOfHousehold) + ?.individualClientReferenceId, + ); - final referrals = await referralDataRepository.search(ReferralSearchModel( - projectBeneficiaryClientReferenceId: projectBeneficiaries - .map((e) => e.clientReferenceId) - .whereNotNull() - .toList(), - )); + // Search for tasks associated with project beneficiaries. + var tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList())); + + // Search for adverse events associated with tasks. + final sideEffects = + await sideEffectDataRepository.search(SideEffectSearchModel( + taskClientReferenceId: + tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), + )); + + final referrals = await referralDataRepository.search(ReferralSearchModel( + projectBeneficiaryClientReferenceId: projectBeneficiaries + .map((e) => e.clientReferenceId) + .whereNotNull() + .toList(), + )); - individuals.sort((a, b) => (a.clientAuditDetails?.createdTime ?? 0) - .compareTo(b.clientAuditDetails?.createdTime ?? 0)); + individuals.sort((a, b) => (a.clientAuditDetails?.createdTime ?? 0) + .compareTo(b.clientAuditDetails?.createdTime ?? 0)); - beneficiaryIndividuals.sort((a, b) => - (a.clientAuditDetails?.createdTime ?? 0) - .compareTo(b.clientAuditDetails?.createdTime ?? 0)); + beneficiaryIndividuals.sort((a, b) => + (a.clientAuditDetails?.createdTime ?? 0) + .compareTo(b.clientAuditDetails?.createdTime ?? 0)); - // Check if a head of household was found. - if (head == null) { - // If head is not found, append the new data to the existing state. + // Check if a head of household was found. + if (head == null) { + // If head is not found, append the new data to the existing state. + + emit(state.copyWith( + loading: false, + offset: members.isNotEmpty && members.length == (event.limit ?? 10) + ? (event.offset ?? 0) + (event.limit ?? 10) + : null, + householdMemberWrapper: state.householdMemberWrapper.copyWith( + members: + (event.projectBeneficiaryType == BeneficiaryType.individual) + ? [ + ...state.householdMemberWrapper.members ?? [], + ...beneficiaryIndividuals, + ] + : [ + ...state.householdMemberWrapper.members ?? [], + ...individuals, + ], + projectBeneficiaries: [ + ...state.householdMemberWrapper.projectBeneficiaries ?? [], + ...projectBeneficiaries, + ], + tasks: [ + ...?state.householdMemberWrapper.tasks, + ...tasks, + ], + sideEffects: [ + ...?state.householdMemberWrapper.sideEffects, + ...sideEffects, + ], + referrals: [ + ...?state.householdMemberWrapper.referrals, + ...referrals, + ], + ), + )); + + return; + } + + // Update the state with the loaded data and stop loading. + emit( + state.copyWith( + householdMemberWrapper: HouseholdMemberWrapper( + household: resultHousehold, + headOfHousehold: head, + members: (event.projectBeneficiaryType == BeneficiaryType.individual + ? beneficiaryIndividuals + : individuals), + tasks: tasks.isEmpty ? null : tasks, + projectBeneficiaries: projectBeneficiaries, + sideEffects: sideEffects, + referrals: referrals, + ), + loading: false, + offset: members.isNotEmpty + ? (event.offset ?? 0) + (event.limit ?? 10) + : null, + // limit: event.limit, + ), + ); + } else { + final totalResult = await individualGlobalSearchRepository + .individualGlobalSearch(GlobalSearchParameters( + householdClientReferenceId: + state.householdMemberWrapper.household!.clientReferenceId, + isProximityEnabled: false, + projectId: RegistrationDeliverySingleton().projectId, + latitude: null, + longitude: null, + maxRadius: null, + nameSearch: event.searchByName, + offset: event.offset, + limit: event.limit, + filter: event.selectedFilter)); + var result = totalResult['data'].map((e) => e).toList(); + + if (result.isEmpty) { + emit(state.copyWith( + loading: false, + householdMemberWrapper: HouseholdMemberWrapper( + household: state.householdMemberWrapper.household, + headOfHousehold: state.householdMemberWrapper.headOfHousehold, + members: [], + tasks: null, + projectBeneficiaries: null, + sideEffects: null, + referrals: null, + ), + )); + return; + } + + late List individualClientReferenceIds = []; + + result.forEach((e) { + individualClientReferenceIds.add(e.clientReferenceId); + }); + + List individuals = await individualRepository.search( + IndividualSearchModel( + clientReferenceId: individualClientReferenceIds + .map((e) => e.toString()) + .toList())); + + final projectBeneficiaries = await projectBeneficiaryRepository.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: + event.projectBeneficiaryType == BeneficiaryType.individual + ? individualClientReferenceIds + : [state.householdMemberWrapper.household!.clientReferenceId], + projectId: [event.projectId], + ), + ); + + final beneficiaryClientReferenceIds = projectBeneficiaries + .map((e) => e.beneficiaryClientReferenceId) + .toList(); + + final List beneficiaryIndividuals = individuals + .where((element) => + beneficiaryClientReferenceIds.contains(element.clientReferenceId)) + .toList(); + + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + projectId: event.projectId, + )); + + // Search for adverse events associated with tasks. + final sideEffects = + await sideEffectDataRepository.search(SideEffectSearchModel( + taskClientReferenceId: + tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), + )); + + final referrals = await referralDataRepository.search(ReferralSearchModel( + projectBeneficiaryClientReferenceId: projectBeneficiaries + .map((e) => e.clientReferenceId) + .whereNotNull() + .toList(), + )); emit(state.copyWith( loading: false, - offset: members.isNotEmpty && members.length == (event.limit ?? 10) + offset: individuals.isNotEmpty ? (event.offset ?? 0) + (event.limit ?? 10) : null, householdMemberWrapper: state.householdMemberWrapper.copyWith( - members: (event.projectBeneficiaryType == BeneficiaryType.individual) - ? [ - ...state.householdMemberWrapper.members ?? [], - ...beneficiaryIndividuals, - ] + members: event.offset == 0 + ? (event.projectBeneficiaryType == BeneficiaryType.individual) + ? beneficiaryIndividuals + : individuals + : [ + ...{ + ...state.householdMemberWrapper.members ?? [], + ...((event.projectBeneficiaryType == + BeneficiaryType.individual) + ? beneficiaryIndividuals + : individuals), + }, + ], + projectBeneficiaries: event.offset == 0 + ? projectBeneficiaries + : [ + ...{ + ...state.householdMemberWrapper.projectBeneficiaries ?? [], + ...projectBeneficiaries, + }, + ], + tasks: event.offset == 0 + ? tasks + : [ + ...{...?state.householdMemberWrapper.tasks, ...tasks}, + ], + sideEffects: event.offset == 0 + ? sideEffects : [ - ...state.householdMemberWrapper.members ?? [], - ...individuals, + ...{ + ...?state.householdMemberWrapper.sideEffects, + ...sideEffects, + }, + ], + referrals: event.offset == 0 + ? referrals + : [ + ...{ + ...?state.householdMemberWrapper.referrals, + ...referrals, + }, ], - projectBeneficiaries: [ - ...state.householdMemberWrapper.projectBeneficiaries ?? [], - ...projectBeneficiaries, - ], - tasks: [ - ...?state.householdMemberWrapper.tasks, - ...tasks, - ], - sideEffects: [ - ...?state.householdMemberWrapper.sideEffects, - ...sideEffects, - ], - referrals: [ - ...?state.householdMemberWrapper.referrals, - ...referrals, - ], ), + limit: event.limit, )); - - return; } - - // Update the state with the loaded data and stop loading. - emit( - state.copyWith( - householdMemberWrapper: HouseholdMemberWrapper( - household: resultHousehold, - headOfHousehold: head, - members: (event.projectBeneficiaryType == BeneficiaryType.individual - ? beneficiaryIndividuals - : individuals), - tasks: tasks.isEmpty ? null : tasks, - projectBeneficiaries: projectBeneficiaries, - sideEffects: sideEffects, - referrals: referrals, - ), - loading: false, - offset: members.isNotEmpty ? (event.offset ?? 10) : null, - ), - ); } // This function handles the deletion of a household and its associated members and beneficiaries. @@ -444,7 +592,9 @@ class HouseholdOverviewEvent with _$HouseholdOverviewEvent { {required String projectId, required BeneficiaryType projectBeneficiaryType, int? offset, - int? limit}) = HouseholdOverviewReloadEvent; + int? limit, + List? selectedFilter, + String? searchByName}) = HouseholdOverviewReloadEvent; } @freezed diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart index ad05e9a9b..6dead0f03 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.freezed.dart @@ -39,8 +39,13 @@ mixin _$HouseholdOverviewEvent { setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function(String projectId, - BeneficiaryType projectBeneficiaryType, int? offset, int? limit) + required TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName) reload, }) => throw _privateConstructorUsedError; @@ -66,8 +71,13 @@ mixin _$HouseholdOverviewEvent { BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult? Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, }) => throw _privateConstructorUsedError; @@ -93,8 +103,13 @@ mixin _$HouseholdOverviewEvent { BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, required TResult orElse(), }) => @@ -308,8 +323,13 @@ class _$HouseholdOverviewDeleteHouseholdEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function(String projectId, - BeneficiaryType projectBeneficiaryType, int? offset, int? limit) + required TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName) reload, }) { return deleteHousehold(projectId, householdModel, members, @@ -339,8 +359,13 @@ class _$HouseholdOverviewDeleteHouseholdEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult? Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, }) { return deleteHousehold?.call(projectId, householdModel, members, @@ -370,8 +395,13 @@ class _$HouseholdOverviewDeleteHouseholdEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, required TResult orElse(), }) { @@ -582,8 +612,13 @@ class _$HouseholdOverviewDeleteIndividualEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function(String projectId, - BeneficiaryType projectBeneficiaryType, int? offset, int? limit) + required TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName) reload, }) { return deleteIndividual( @@ -613,8 +648,13 @@ class _$HouseholdOverviewDeleteIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult? Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, }) { return deleteIndividual?.call( @@ -644,8 +684,13 @@ class _$HouseholdOverviewDeleteIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, required TResult orElse(), }) { @@ -853,8 +898,13 @@ class _$HouseholdOverviewSetAsHeadEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function(String projectId, - BeneficiaryType projectBeneficiaryType, int? offset, int? limit) + required TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName) reload, }) { return setAsHead( @@ -884,8 +934,13 @@ class _$HouseholdOverviewSetAsHeadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult? Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, }) { return setAsHead?.call( @@ -915,8 +970,13 @@ class _$HouseholdOverviewSetAsHeadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, required TResult orElse(), }) { @@ -1090,8 +1150,13 @@ class _$HouseholdOverviewSelectIndividualEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function(String projectId, - BeneficiaryType projectBeneficiaryType, int? offset, int? limit) + required TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName) reload, }) { return selectedIndividual(individualModel); @@ -1120,8 +1185,13 @@ class _$HouseholdOverviewSelectIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult? Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, }) { return selectedIndividual?.call(individualModel); @@ -1150,8 +1220,13 @@ class _$HouseholdOverviewSelectIndividualEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, required TResult orElse(), }) { @@ -1235,7 +1310,9 @@ abstract class _$$HouseholdOverviewReloadEventImplCopyWith<$Res> { {String projectId, BeneficiaryType projectBeneficiaryType, int? offset, - int? limit}); + int? limit, + List? selectedFilter, + String? searchByName}); } /// @nodoc @@ -1255,6 +1332,8 @@ class __$$HouseholdOverviewReloadEventImplCopyWithImpl<$Res> Object? projectBeneficiaryType = null, Object? offset = freezed, Object? limit = freezed, + Object? selectedFilter = freezed, + Object? searchByName = freezed, }) { return _then(_$HouseholdOverviewReloadEventImpl( projectId: null == projectId @@ -1273,6 +1352,14 @@ class __$$HouseholdOverviewReloadEventImplCopyWithImpl<$Res> ? _value.limit : limit // ignore: cast_nullable_to_non_nullable as int?, + selectedFilter: freezed == selectedFilter + ? _value._selectedFilter + : selectedFilter // ignore: cast_nullable_to_non_nullable + as List?, + searchByName: freezed == searchByName + ? _value.searchByName + : searchByName // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -1285,7 +1372,10 @@ class _$HouseholdOverviewReloadEventImpl {required this.projectId, required this.projectBeneficiaryType, this.offset, - this.limit}); + this.limit, + final List? selectedFilter, + this.searchByName}) + : _selectedFilter = selectedFilter; @override final String projectId; @@ -1295,10 +1385,22 @@ class _$HouseholdOverviewReloadEventImpl final int? offset; @override final int? limit; + final List? _selectedFilter; + @override + List? get selectedFilter { + final value = _selectedFilter; + if (value == null) return null; + if (_selectedFilter is EqualUnmodifiableListView) return _selectedFilter; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + final String? searchByName; @override String toString() { - return 'HouseholdOverviewEvent.reload(projectId: $projectId, projectBeneficiaryType: $projectBeneficiaryType, offset: $offset, limit: $limit)'; + return 'HouseholdOverviewEvent.reload(projectId: $projectId, projectBeneficiaryType: $projectBeneficiaryType, offset: $offset, limit: $limit, selectedFilter: $selectedFilter, searchByName: $searchByName)'; } @override @@ -1311,12 +1413,22 @@ class _$HouseholdOverviewReloadEventImpl (identical(other.projectBeneficiaryType, projectBeneficiaryType) || other.projectBeneficiaryType == projectBeneficiaryType) && (identical(other.offset, offset) || other.offset == offset) && - (identical(other.limit, limit) || other.limit == limit)); + (identical(other.limit, limit) || other.limit == limit) && + const DeepCollectionEquality() + .equals(other._selectedFilter, _selectedFilter) && + (identical(other.searchByName, searchByName) || + other.searchByName == searchByName)); } @override int get hashCode => Object.hash( - runtimeType, projectId, projectBeneficiaryType, offset, limit); + runtimeType, + projectId, + projectBeneficiaryType, + offset, + limit, + const DeepCollectionEquality().hash(_selectedFilter), + searchByName); @JsonKey(ignore: true) @override @@ -1350,11 +1462,17 @@ class _$HouseholdOverviewReloadEventImpl setAsHead, required TResult Function(IndividualModel individualModel) selectedIndividual, - required TResult Function(String projectId, - BeneficiaryType projectBeneficiaryType, int? offset, int? limit) + required TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName) reload, }) { - return reload(projectId, projectBeneficiaryType, offset, limit); + return reload(projectId, projectBeneficiaryType, offset, limit, + selectedFilter, searchByName); } @override @@ -1380,11 +1498,17 @@ class _$HouseholdOverviewReloadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult? Function(IndividualModel individualModel)? selectedIndividual, - TResult? Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult? Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, }) { - return reload?.call(projectId, projectBeneficiaryType, offset, limit); + return reload?.call(projectId, projectBeneficiaryType, offset, limit, + selectedFilter, searchByName); } @override @@ -1410,13 +1534,19 @@ class _$HouseholdOverviewReloadEventImpl BeneficiaryType projectBeneficiaryType)? setAsHead, TResult Function(IndividualModel individualModel)? selectedIndividual, - TResult Function(String projectId, BeneficiaryType projectBeneficiaryType, - int? offset, int? limit)? + TResult Function( + String projectId, + BeneficiaryType projectBeneficiaryType, + int? offset, + int? limit, + List? selectedFilter, + String? searchByName)? reload, required TResult orElse(), }) { if (reload != null) { - return reload(projectId, projectBeneficiaryType, offset, limit); + return reload(projectId, projectBeneficiaryType, offset, limit, + selectedFilter, searchByName); } return orElse(); } @@ -1476,12 +1606,16 @@ abstract class HouseholdOverviewReloadEvent implements HouseholdOverviewEvent { {required final String projectId, required final BeneficiaryType projectBeneficiaryType, final int? offset, - final int? limit}) = _$HouseholdOverviewReloadEventImpl; + final int? limit, + final List? selectedFilter, + final String? searchByName}) = _$HouseholdOverviewReloadEventImpl; String get projectId; BeneficiaryType get projectBeneficiaryType; int? get offset; int? get limit; + List? get selectedFilter; + String? get searchByName; @JsonKey(ignore: true) _$$HouseholdOverviewReloadEventImplCopyWith< _$HouseholdOverviewReloadEventImpl> diff --git a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart index abd395fef..68eb625a0 100644 --- a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart @@ -225,23 +225,44 @@ class IndividualGlobalSearchRepository extends LocalRepository { .select() .join([joinName(sql), joinIndividualAddress(sql)]); await searchByName(selectQuery, params, sql); - selectQuery = selectQuery.join([ - leftOuterJoin( - sql.householdMember, - sql.householdMember.individualClientReferenceId - .equalsExp(sql.individual.clientReferenceId)) - ]) - ..where(sql.householdMember.isHeadOfHousehold.equals(true)); - selectQuery.join([ - leftOuterJoin( - sql.household, - sql.household.clientReferenceId - .equalsExp(sql.householdMember.householdClientReferenceId)), - leftOuterJoin( - sql.projectBeneficiary, - sql.projectBeneficiary.beneficiaryClientReferenceId - .equalsExp(sql.household.clientReferenceId)) - ]); + if (params.householdClientReferenceId != null) { + selectQuery = selectQuery.join([ + leftOuterJoin( + sql.household, + sql.household.clientReferenceId + .equals(params.householdClientReferenceId ?? '')), + leftOuterJoin( + sql.projectBeneficiary, + sql.projectBeneficiary.beneficiaryClientReferenceId + .equalsExp(sql.individual.clientReferenceId)), + ]); + selectQuery = selectQuery.join([ + leftOuterJoin( + sql.householdMember, + sql.householdMember.individualClientReferenceId + .equalsExp(sql.individual.clientReferenceId)) + ]) + ..where(sql.householdMember.householdClientReferenceId + .equals(params.householdClientReferenceId ?? '')); + } else { + selectQuery = selectQuery.join([ + leftOuterJoin( + sql.householdMember, + sql.householdMember.individualClientReferenceId + .equalsExp(sql.individual.clientReferenceId)) + ]) + ..where(sql.householdMember.isHeadOfHousehold.equals(true)); + selectQuery.join([ + leftOuterJoin( + sql.household, + sql.household.clientReferenceId + .equalsExp(sql.householdMember.householdClientReferenceId)), + leftOuterJoin( + sql.projectBeneficiary, + sql.projectBeneficiary.beneficiaryClientReferenceId + .equalsExp(sql.household.clientReferenceId)) + ]); + } } else if (params.nameSearch != null && params.nameSearch!.isNotEmpty && selectQuery != null) { @@ -281,11 +302,33 @@ class IndividualGlobalSearchRepository extends LocalRepository { ..where(filter == Status.registered.name ? sql.projectBeneficiary.beneficiaryClientReferenceId.isNotNull() : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull()); + + if (params.householdClientReferenceId != null) { + selectQuery = selectQuery.join([ + leftOuterJoin( + sql.householdMember, + sql.householdMember.individualClientReferenceId + .equalsExp(sql.individual.clientReferenceId)) + ]) + ..where(sql.householdMember.householdClientReferenceId + .equals(params.householdClientReferenceId ?? '')); + } } else { var filterSearchQuery = await filterTasks(selectQuery, filter, sql, params); selectQuery = filterSearchQuery; + + if (params.householdClientReferenceId != null) { + selectQuery = selectQuery.join([ + leftOuterJoin( + sql.householdMember, + sql.householdMember.individualClientReferenceId + .equalsExp(sql.individual.clientReferenceId)) + ]) + ..where(sql.householdMember.householdClientReferenceId + .equals(params.householdClientReferenceId ?? '')); + } } } else if (selectQuery != null) { if (filter == Status.registered.name || @@ -333,8 +376,8 @@ class IndividualGlobalSearchRepository extends LocalRepository { .equalsExp(sql.task.projectBeneficiaryClientReferenceId)), leftOuterJoin( sql.individual, - sql.individual.clientReferenceId - .equalsExp(sql.projectBeneficiary.beneficiaryClientReferenceId)), + sql.individual.clientReferenceId.equalsExp( + sql.projectBeneficiary.beneficiaryClientReferenceId)), ]) ..where(sql.task.status.equals( statusMap[applyFilter]!.toValue(), diff --git a/packages/registration_delivery/lib/pages/beneficiary/beneficiary_wrapper.dart b/packages/registration_delivery/lib/pages/beneficiary/beneficiary_wrapper.dart index 9b2c4b080..2fe848873 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/beneficiary_wrapper.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/beneficiary_wrapper.dart @@ -10,6 +10,7 @@ import '../../blocs/household_overview/household_overview.dart'; import '../../blocs/referral_management/referral_management.dart'; import '../../blocs/search_households/search_households.dart'; import '../../blocs/side_effects/side_effects.dart'; +import '../../data/repositories/local/individual_global_search.dart'; import '../../models/entities/household.dart'; import '../../models/entities/household_member.dart'; import '../../models/entities/project_beneficiary.dart'; @@ -60,6 +61,9 @@ class BeneficiaryWrapperPage extends StatelessWidget { final serviceDefinationRepo = context.repository(context); + final individualGlobalSearchRepository = + context.read(); + return MultiBlocProvider( providers: [ BlocProvider( @@ -102,6 +106,8 @@ class BeneficiaryWrapperPage extends StatelessWidget { taskDataRepository: task, sideEffectDataRepository: sideEffect, referralDataRepository: referral, + individualGlobalSearchRepository: + individualGlobalSearchRepository, beneficiaryType: RegistrationDeliverySingleton().beneficiaryType!), ), @@ -142,7 +148,10 @@ class BeneficiaryWrapperPage extends StatelessWidget { )..add(DeliverInterventionSearchEvent( taskSearch: TaskSearchModel( projectBeneficiaryClientReferenceId: houseHoldOverviewState - .householdMemberWrapper.projectBeneficiaries?.where((element) => element.projectId == RegistrationDeliverySingleton().projectId) + .householdMemberWrapper.projectBeneficiaries + ?.where((element) => + element.projectId == + RegistrationDeliverySingleton().projectId) .map((e) => e.clientReferenceId) .toList(), ))), diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 88be60211..51e8e874d 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -8,6 +8,9 @@ import 'package:digit_ui_components/theme/spacers.dart'; import 'package:digit_ui_components/utils/date_utils.dart'; import 'package:digit_ui_components/widgets/atoms/digit_action_card.dart'; import 'package:digit_ui_components/widgets/atoms/digit_button.dart'; +import 'package:digit_ui_components/widgets/atoms/digit_chip.dart'; +import 'package:digit_ui_components/widgets/atoms/digit_search_bar.dart'; +import 'package:digit_ui_components/widgets/atoms/pop_up_card.dart'; import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; import 'package:digit_ui_components/widgets/molecules/show_pop_up.dart'; import 'package:digit_ui_components/widgets/scrollable_content.dart'; @@ -30,6 +33,7 @@ import '../../widgets/back_navigation_help_header.dart'; import '../../widgets/localized.dart'; import '../../widgets/member_card/member_card.dart'; import '../../widgets/table_card/table_card.dart'; +import '/widgets/status_filter/status_filter.dart'; @RoutePage() class HouseholdOverviewPage extends LocalizedStatefulWidget { @@ -41,8 +45,14 @@ class HouseholdOverviewPage extends LocalizedStatefulWidget { class _HouseholdOverviewPageState extends LocalizedState { + final TextEditingController searchController = TextEditingController(); int offset = 0; int limit = 10; + + String? householdClientReferenceId; + + List selectedFilters = []; + @override void initState() { callReloadEvent(offset: offset, limit: limit); @@ -73,10 +83,13 @@ class _HouseholdOverviewPageState if (scrollNotification is ScrollUpdateNotification) { final metrics = scrollNotification.metrics; if (metrics.atEdge && metrics.pixels != 0) { - callReloadEvent(offset: offset + limit, limit: limit); - offset += limit; + if (state.offset != null) { + callReloadEvent( + offset: state.offset ?? 0, limit: limit); + } } } + //Return true to allow the notification to continue to be dispatched to further ancestors. return true; }, child: ScrollableContent( @@ -88,136 +101,161 @@ class _HouseholdOverviewPageState }, ), enableFixedButton: true, - footer: Offstage( - offstage: - beneficiaryType == BeneficiaryType.individual || - isOutsideProjectDateRange(), - child: BlocBuilder( - builder: (context, serviceDefinitionState) => - BlocBuilder( - builder: (ctx, deliverInterventionState) => - DigitCard( - margin: const EdgeInsets.only(top: spacer2), - padding: const EdgeInsets.all(spacer2), - children: [ - state.householdMemberWrapper.tasks?.lastOrNull - ?.status == - Status.administeredSuccess.toValue() - ? Padding( - padding: const EdgeInsets.symmetric( - vertical: spacer2), - child: Button( - label: localizations.translate( - i18.memberCard - .deliverDetailsUpdateLabel, - ), - isDisabled: state - .householdMemberWrapper - .tasks - ?.lastOrNull - ?.status == - Status.administeredSuccess - .toValue() - ? true - : false, - type: ButtonType.secondary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () { - serviceDefinitionState.when( - empty: () {}, - isloading: () {}, - serviceDefinitionFetch: - (value, model) { - if (value - .where((element) => element - .code - .toString() - .contains( - '${RegistrationDeliverySingleton().selectedProject?.name}.${RegistrationDeliveryEnums.iec.toValue()}')) - .toList() - .isEmpty) { - context.router.push( - DeliverInterventionRoute(), - ); - } else { - navigateToChecklist(ctx); - } - }); - callReloadEvent( - offset: state - .householdMemberWrapper - .members! - .length, - limit: limit); - }, - ), - ) - : Button( - label: localizations.translate( - i18.householdOverView - .householdOverViewActionText, - ), - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - isDisabled: (state.householdMemberWrapper - .projectBeneficiaries ?? - []) - .isEmpty || - state + footer: DigitCard( + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + Button( + mainAxisSize: MainAxisSize.max, + onPressed: () => addIndividual( + context, + state.householdMemberWrapper.household!, + ), + label: localizations.translate( + i18.householdOverView + .householdOverViewAddActionText, + ), + prefixIcon: Icons.add_circle, + type: ButtonType.secondary, + size: ButtonSize.medium, + ), + Offstage( + offstage: beneficiaryType == + BeneficiaryType.individual || + isOutsideProjectDateRange(), + child: BlocBuilder( + builder: (context, serviceDefinitionState) => + BlocBuilder( + builder: (ctx, deliverInterventionState) => + state.householdMemberWrapper.tasks + ?.lastOrNull?.status == + Status.administeredSuccess + .toValue() + ? Padding( + padding: + const EdgeInsets.symmetric( + vertical: spacer2), + child: Button( + label: localizations.translate( + i18.memberCard + .deliverDetailsUpdateLabel, + ), + isDisabled: state + .householdMemberWrapper + .tasks + ?.lastOrNull + ?.status == + Status + .administeredSuccess + .toValue() + ? true + : false, + type: ButtonType.secondary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () { + serviceDefinitionState.when( + empty: () {}, + isloading: () {}, + serviceDefinitionFetch: + (value, model) { + if (value + .where((element) => + element.code + .toString() + .contains( + '${RegistrationDeliverySingleton().selectedProject?.name}.${RegistrationDeliveryEnums.iec.toValue()}')) + .toList() + .isEmpty) { + context.router.push( + DeliverInterventionRoute(), + ); + } else { + navigateToChecklist( + ctx); + } + }); + callReloadEvent( + offset: state .householdMemberWrapper - .tasks - ?.lastOrNull - ?.status == - Status.closeHousehold - .toValue() - ? true - : false, - onPressed: () async { - final bloc = ctx - .read(); - - final projectId = - RegistrationDeliverySingleton() - .projectId!; - - bloc.add( - HouseholdOverviewReloadEvent( - projectId: projectId, - projectBeneficiaryType: - beneficiaryType, + .members! + .length, + limit: limit); + }, ), - ); - - serviceDefinitionState.when( - empty: () {}, - isloading: () {}, - serviceDefinitionFetch: - (value, model) { - if (value - .where((element) => element - .code - .toString() - .contains( - '${RegistrationDeliverySingleton().selectedProject?.name}.${RegistrationDeliveryEnums.iec.toValue()}')) - .toList() - .isEmpty) { - context.router.push( - DeliverInterventionRoute(), - ); - } else { - navigateToChecklist(ctx); - } - }); - }, - ), - ]), - ), - ), - ), + ) + : Button( + label: localizations.translate( + i18.householdOverView + .householdOverViewActionText, + ), + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + isDisabled: (state.householdMemberWrapper + .projectBeneficiaries ?? + []) + .isEmpty || + state + .householdMemberWrapper + .tasks + ?.lastOrNull + ?.status == + Status.closeHousehold + .toValue() + ? true + : false, + onPressed: () async { + final bloc = ctx.read< + HouseholdOverviewBloc>(); + + final projectId = + RegistrationDeliverySingleton() + .projectId!; + + bloc.add( + HouseholdOverviewReloadEvent( + projectId: projectId, + projectBeneficiaryType: + beneficiaryType, + ), + ); + + serviceDefinitionState.when( + empty: () {}, + isloading: () {}, + serviceDefinitionFetch: + (value, model) { + if (value + .where((element) => + element.code + .toString() + .contains( + '${RegistrationDeliverySingleton().selectedProject?.name}.${RegistrationDeliveryEnums.iec.toValue()}')) + .toList() + .isEmpty) { + context.router.push( + DeliverInterventionRoute(), + ); + } else { + navigateToChecklist( + ctx); + } + }); + callReloadEvent( + offset: state + .householdMemberWrapper + .members! + .length, + limit: limit); + }, + ), + ), + ), + ), + ]), slivers: [ SliverToBoxAdapter( child: DigitCard(children: [ @@ -359,15 +397,56 @@ class _HouseholdOverviewPageState // ), // ), // ), - Padding( - padding: const EdgeInsets.all(spacer2), - child: Text( - localizations.translate(i18 - .householdOverView - .householdOverViewLabel), - style: textTheme.headingXl, - ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(spacer2), + child: Text( + localizations.translate(i18 + .householdOverView + .householdOverViewLabel), + style: textTheme.headingXl, + ), + ), + ), + Column( + children: [ + RegistrationDeliverySingleton() + .searchHouseHoldFilter != + null && + RegistrationDeliverySingleton() + .searchHouseHoldFilter! + .isNotEmpty + ? Align( + alignment: Alignment.topLeft, + child: Padding( + padding: const EdgeInsets.all( + spacer2), + child: Button( + label: + getFilterIconNLabel()[ + 'label'], + size: ButtonSize.medium, + type: ButtonType.tertiary, + suffixIcon: + getFilterIconNLabel()[ + 'icon'], + onPressed: () => + showFilterDialog(), + ), + ), + ) + : const Offstage(), + ], + ), + ], ), + Padding( padding: const EdgeInsets.only( left: spacer2, @@ -423,6 +502,61 @@ class _HouseholdOverviewPageState ); }), ), + Padding( + padding: const EdgeInsets.only( + top: spacer2, bottom: spacer2), + child: DigitSearchBar( + controller: searchController, + hintText: localizations.translate( + i18.common.searchByName, + ), + textCapitalization: + TextCapitalization.words, + onChanged: (value) { + if (value.length >= 3) { + callReloadEvent(offset: 0, limit: 10); + } else if (searchController + .value.text.isEmpty) { + callReloadEvent(offset: 0, limit: 10); + } + }, + ), + ), + selectedFilters.isNotEmpty + ? Align( + alignment: Alignment.topLeft, + child: SizedBox( + height: MediaQuery.of(context) + .size + .height * + 0.06, + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemCount: selectedFilters.length, + itemBuilder: (context, index) { + return Padding( + padding: const EdgeInsets.all( + spacer1), + child: DigitChip( + label: + '${localizations.translate(getStatus(selectedFilters[index]))}' + ' (${state.householdMemberWrapper.members!.length})', + onItemDelete: () { + setState(() { + selectedFilters.remove( + selectedFilters[ + index]); + }); + callReloadEvent( + offset: 0, limit: 10); + }, + ), + ); + }), + ), + ) + : const Offstage(), Column( children: (state.householdMemberWrapper.members ?? @@ -742,31 +876,6 @@ class _HouseholdOverviewPageState }, ).toList(), ), - const SizedBox( - height: spacer2, - ), - Center( - child: Button( - isDisabled: (state.householdMemberWrapper - .projectBeneficiaries ?? - []) - .isEmpty, - onPressed: () => addIndividual( - context, - state.householdMemberWrapper.household!, - ), - label: localizations.translate( - i18.householdOverView - .householdOverViewAddActionText, - ), - prefixIcon: Icons.add_circle, - type: ButtonType.tertiary, - size: ButtonSize.medium, - ), - ), - const SizedBox( - height: spacer2, - ), ], ), ]), @@ -872,8 +981,86 @@ class _HouseholdOverviewPageState RegistrationDeliverySingleton().beneficiaryType!, offset: offset, limit: limit, + searchByName: + searchController.text.isNotEmpty ? searchController.text : null, + selectedFilter: selectedFilters, ), ); } } + + getFilterIconNLabel() { + return { + 'label': localizations.translate( + i18.searchBeneficiary.filterLabel, + ), + 'icon': Icons.filter_alt + }; + } + + showFilterDialog() async { + var filters = await showDialog( + context: context, + builder: (ctx) => Popup( + title: getFilterIconNLabel()['label'], + titleIcon: Icon( + getFilterIconNLabel()['icon'], + color: DigitTheme.instance.colorScheme.primary, + ), + onCrossTap: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(); + }, + additionalWidgets: [ + StatusFilter( + selectedFilters: selectedFilters, + ), + ])); + + if (filters != null && filters.isNotEmpty) { + setState(() { + selectedFilters = []; + }); + setState(() { + selectedFilters.addAll(filters); + }); + callReloadEvent(offset: 0, limit: 10); + } else { + setState(() { + selectedFilters = []; + }); + // blocWrapper.clearEvent(); + callReloadEvent(offset: 0, limit: 10); + } + } + + String getStatus(String selectedFilter) { + final statusMap = { + Status.delivered.toValue(): Status.delivered, + Status.notAdministered.toValue(): Status.notAdministered, + Status.visited.toValue(): Status.visited, + Status.notVisited.toValue(): Status.notVisited, + Status.beneficiaryRefused.toValue(): Status.beneficiaryRefused, + Status.beneficiaryReferred.toValue(): Status.beneficiaryReferred, + Status.administeredSuccess.toValue(): Status.administeredSuccess, + Status.administeredFailed.toValue(): Status.administeredFailed, + Status.inComplete.toValue(): Status.inComplete, + Status.toAdminister.toValue(): Status.toAdminister, + Status.closeHousehold.toValue(): Status.closeHousehold, + Status.registered.toValue(): Status.registered, + Status.notRegistered.toValue(): Status.notRegistered, + }; + + var mappedStatus = statusMap.entries + .where((element) => element.value.name == selectedFilter) + .first + .key; + if (mappedStatus != null) { + return mappedStatus; + } else { + return selectedFilter; + } + } } diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/beneficiary_registration_wrapper.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/beneficiary_registration_wrapper.dart index 09f6adf47..059a523e2 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/beneficiary_registration_wrapper.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/beneficiary_registration_wrapper.dart @@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:digit_data_model/models/entities/individual.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:registration_delivery/data/repositories/local/individual_global_search.dart'; import 'package:registration_delivery/registration_delivery.dart'; import '../../utils/extensions/extensions.dart'; @@ -41,6 +42,9 @@ class BeneficiaryRegistrationWrapperPage extends StatelessWidget final referral = context.repository(context); + final individualGlobalSearch = + context.read(); + return BlocProvider( create: (_) => HouseholdOverviewBloc( HouseholdOverviewState( @@ -89,6 +93,7 @@ class BeneficiaryRegistrationWrapperPage extends StatelessWidget beneficiaryType: RegistrationDeliverySingleton().beneficiaryType!, taskDataRepository: task, sideEffectDataRepository: sideEffect, + individualGlobalSearchRepository: individualGlobalSearch, referralDataRepository: referral) ..add(HouseholdOverviewReloadEvent( projectId: RegistrationDeliverySingleton().selectedProject!.id, diff --git a/packages/registration_delivery/lib/utils/global_search_parameters.dart b/packages/registration_delivery/lib/utils/global_search_parameters.dart index dfee00637..69bfadbba 100644 --- a/packages/registration_delivery/lib/utils/global_search_parameters.dart +++ b/packages/registration_delivery/lib/utils/global_search_parameters.dart @@ -1,4 +1,5 @@ class GlobalSearchParameters { + final String? householdClientReferenceId; final bool isProximityEnabled; final double? latitude; final String? projectId; @@ -10,16 +11,16 @@ class GlobalSearchParameters { final List? filter; final int? totalCount; - GlobalSearchParameters({ - required this.isProximityEnabled, - required this.latitude, - required this.longitude, - required this.maxRadius, - required this.nameSearch, - required this.offset, - required this.limit, - required this.filter, - this.totalCount, - this.projectId - }); + GlobalSearchParameters( + {required this.isProximityEnabled, + required this.latitude, + required this.longitude, + required this.maxRadius, + required this.nameSearch, + required this.offset, + required this.limit, + required this.filter, + this.totalCount, + this.projectId, + this.householdClientReferenceId}); } From 4d1caa7d151cc582cb0db73c6d2f39ebcbd552a4 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 28 Nov 2024 11:00:09 +0530 Subject: [PATCH 03/19] fixed issues with test --- .../test/household_overview_test.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/registration_delivery/test/household_overview_test.dart b/packages/registration_delivery/test/household_overview_test.dart index 23bed6d48..aa5be5c24 100644 --- a/packages/registration_delivery/test/household_overview_test.dart +++ b/packages/registration_delivery/test/household_overview_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:digit_data_model/data_model.dart'; import 'package:registration_delivery/blocs/household_overview/household_overview.dart'; +import 'package:registration_delivery/data/repositories/local/individual_global_search.dart'; import 'package:registration_delivery/models/entities/household.dart'; import 'package:registration_delivery/models/entities/household_member.dart'; import 'package:registration_delivery/models/entities/project_beneficiary.dart'; @@ -34,6 +35,9 @@ class MockSideEffectDataRepository extends Mock class MockReferralDataRepository extends Mock implements ReferralDataRepository {} +class MockIndividualGlobalSearchRepository extends Mock + implements IndividualGlobalSearchRepository {} + void main() { late MockHouseholdDataRepository mockHouseholdDataRepository; late MockIndividualDataRepository mockIndividualDataRepository; @@ -44,6 +48,8 @@ void main() { late MockSideEffectDataRepository mockSideEffectDataRepository; late MockReferralDataRepository mockReferralDataRepository; late HouseholdOverviewBloc householdOverviewBloc; + late MockIndividualGlobalSearchRepository + mockIndividualGlobalSearchRepository; setUp(() { mockHouseholdDataRepository = MockHouseholdDataRepository(); @@ -54,6 +60,8 @@ void main() { mockTaskDataRepository = MockTaskDataRepository(); mockSideEffectDataRepository = MockSideEffectDataRepository(); mockReferralDataRepository = MockReferralDataRepository(); + mockIndividualGlobalSearchRepository = + MockIndividualGlobalSearchRepository(); householdOverviewBloc = HouseholdOverviewBloc( HouseholdOverviewState( householdMemberWrapper: @@ -66,6 +74,7 @@ void main() { sideEffectDataRepository: mockSideEffectDataRepository, referralDataRepository: mockReferralDataRepository, beneficiaryType: BeneficiaryType.individual, + individualGlobalSearchRepository: mockIndividualGlobalSearchRepository, ); }); From 47d0ef9d65ae22b8ab85d344b2a1234c2aaa0f87 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Tue, 19 Nov 2024 12:58:49 +0530 Subject: [PATCH 04/19] hcmpre-1259-added homepage card for institution --- .../lib/pages/home.dart | 35 ++++++++++++++----- .../lib/utils/i18_key_constants.dart | 8 +++-- .../showcase/config/home_showcase.dart | 3 ++ .../pubspec.lock | 9 ++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/pages/home.dart b/apps/health_campaign_field_worker_app/lib/pages/home.dart index 51477d104..b09584a51 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/home.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/home.dart @@ -360,6 +360,15 @@ class _HomePageState extends LocalizedState { }, ), ), + + i18.home.institutionLabel: homeShowcaseData.instituteCampaign.buildWith( + child: HomeItemCard( + icon: Icons.account_balance, + label: i18.home.institutionLabel, + onPressed: () {}, + ), + ), + i18.home.closedHouseHoldLabel: homeShowcaseData.closedHouseHold.buildWith( child: HomeItemCard( icon: Icons.home, @@ -511,7 +520,8 @@ class _HomePageState extends LocalizedState { homeShowcaseData.warehouseManagerManageStock.showcaseKey, i18.home.stockReconciliationLabel: homeShowcaseData.wareHouseManagerStockReconciliation.showcaseKey, - i18.home.mySurveyForm: homeShowcaseData.supervisorMySurveyForm.showcaseKey, + i18.home.mySurveyForm: + homeShowcaseData.supervisorMySurveyForm.showcaseKey, i18.home.fileComplaint: homeShowcaseData.distributorFileComplaint.showcaseKey, i18.home.syncDataLabel: homeShowcaseData.distributorSyncData.showcaseKey, @@ -524,11 +534,13 @@ class _HomePageState extends LocalizedState { i18.home.closedHouseHoldLabel: homeShowcaseData.closedHouseHold.showcaseKey, i18.home.dashboard: homeShowcaseData.dashBoard.showcaseKey, + i18.home.institutionLabel: homeShowcaseData.instituteCampaign.showcaseKey, }; final homeItemsLabel = [ // INFO: Need to add items label of package Here i18.home.beneficiaryLabel, + i18.home.institutionLabel, i18.home.closedHouseHoldLabel, i18.home.manageStockLabel, i18.home.stockReconciliationLabel, @@ -548,7 +560,8 @@ class _HomePageState extends LocalizedState { .map((e) => e.displayName) .toList() .contains(element) || - element == i18.home.db) + element == i18.home.db || + element == i18.home.institutionLabel) .toList(); final showcaseKeys = filteredLabels @@ -725,14 +738,18 @@ void setPackagesSingleton(BuildContext context) { loggedInIndividualId: context.loggedInIndividualId ?? '', loggedInUserUuid: context.loggedInUserUuid, appVersion: Constants().version, - isHealthFacilityWorker: context.loggedInUserRoles.where((role) => role.code == RolesType.healthFacilityWorker.toValue()).toList().isNotEmpty, + isHealthFacilityWorker: context.loggedInUserRoles + .where((role) => + role.code == RolesType.healthFacilityWorker.toValue()) + .toList() + .isNotEmpty, roles: context.read().state.maybeMap( - orElse: () => const Offstage(), - authenticated: (res) { - return res.userModel.roles - .map((e) => e.code.snakeCase.toUpperCase()) - .toList(); - }), + orElse: () => const Offstage(), + authenticated: (res) { + return res.userModel.roles + .map((e) => e.code.snakeCase.toUpperCase()) + .toList(); + }), ); ReferralReconSingleton().setInitialData( diff --git a/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart b/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart index 6e0940612..f36b3b91a 100644 --- a/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart +++ b/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart @@ -203,6 +203,10 @@ class HomeShowcase { String get deleteAll { return 'WAREHOUSE_MANAGER_HOME_SHOWCASE_DELETE_ALL'; } + + String get instituteCampaign { + return "INSTITUTE_CAMPAIGN_SHOWCASE"; + } } class SelectStockShowcase { @@ -510,7 +514,6 @@ class ComplaintsInboxShowcase { } } - class ForgotPassword { const ForgotPassword(); @@ -561,6 +564,8 @@ class Home { String get manageAttendanceLabel => 'HOME_MANAGE_ATTENDANCE_LABEL'; String get closedHouseHoldLabel => 'HOME_CLOSE_HOUSEHOLD_LABEL'; + + String get institutionLabel => "HOME_INSTITUTION_CAMPAIGN_LABEL"; } class AcknowledgementSuccess { @@ -1014,7 +1019,6 @@ class PrivacyPolicy { String get privacyNoticeText => 'PRIVACY_POLICY_TEXT'; String get privacyPolicyLinkText => 'PRIVACY_POLICY_LINK_TEXT'; String get privacyPolicyValidationText => 'PRIVACY_POLICY_VALIDATION_TEXT'; - } class Dashboard { diff --git a/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart b/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart index c5bc7380e..ba804af85 100644 --- a/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart +++ b/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart @@ -105,4 +105,7 @@ class _HomePageShowcaseData { final closedHouseHold = ShowcaseItemBuilder( messageLocalizationKey: i18.home.closedHouseHoldLabel, ); + + final instituteCampaign = ShowcaseItemBuilder( + messageLocalizationKey: i18.homeShowcase.instituteCampaign); } diff --git a/apps/health_campaign_field_worker_app/pubspec.lock b/apps/health_campaign_field_worker_app/pubspec.lock index d096797b2..e49f4e151 100644 --- a/apps/health_campaign_field_worker_app/pubspec.lock +++ b/apps/health_campaign_field_worker_app/pubspec.lock @@ -342,7 +342,7 @@ packages: path: "../../packages/closed_household" relative: true source: path - version: "1.0.1+1" + version: "1.0.2-dev.1" code_builder: dependency: transitive description: @@ -1334,6 +1334,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.1+1" + institution_campaign: + dependency: "direct overridden" + description: + path: "../../packages/institution_campaign" + relative: true + source: path + version: "0.0.1" integration_test: dependency: "direct dev" description: flutter From 0b4ea208edf22756ef1a7a95c518aaf770d78f15 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 28 Nov 2024 16:42:02 +0530 Subject: [PATCH 05/19] added enum householdType for facility based campaign --- .../data/local_store/sql_store/sql_store.dart | 24 +- .../local_store/sql_store/sql_store.g.dart | 50 ++++ .../tables/package_tables/household.dart | 16 +- .../digit_data_model/lib/data_model.init.dart | 144 +++++------ .../lib/models/entities/household_type.dart | 14 ++ .../entities/household_type.mapper.dart | 57 +++++ packages/digit_data_model/pubspec.lock | 236 ++++++++++++++++++ packages/digit_data_model/pubspec.yaml | 1 + .../lib/models/entities/household.dart | 7 + .../lib/models/entities/household.mapper.dart | 19 ++ packages/registration_delivery/pubspec.lock | 14 +- 11 files changed, 497 insertions(+), 85 deletions(-) create mode 100644 packages/digit_data_model/lib/models/entities/household_type.dart create mode 100644 packages/digit_data_model/lib/models/entities/household_type.mapper.dart diff --git a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart index 3bb9ed6c1..ad544fbdf 100644 --- a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart +++ b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart @@ -1,6 +1,7 @@ // Importing necessary packages and files. import 'dart:io'; +import 'package:digit_components/utils/app_logger.dart'; import 'package:digit_data_model/data/local_store/sql_store/tables/localization.dart'; import 'package:drift/drift.dart'; import 'package:drift/native.dart'; @@ -12,6 +13,7 @@ import '../../../models/entities/beneficiary_type.dart'; import '../../../models/entities/blood_group.dart'; import '../../../models/entities/gender.dart'; import '../../../models/entities/pgr_application_status.dart'; +import '../../../models/entities/household_type.dart'; import 'tables/address.dart'; import 'tables/attributes.dart'; import 'tables/boundary.dart'; @@ -108,7 +110,7 @@ class LocalSqlDataStore extends _$LocalSqlDataStore { /// The `schemaVersion` getter returns the schema version of the database. @override - int get schemaVersion => 4; + int get schemaVersion => 5; /// The `_openConnection` method opens a connection to the database. /// It returns a `LazyDatabase` that opens the database when it is first accessed. @@ -123,4 +125,24 @@ class LocalSqlDataStore extends _$LocalSqlDataStore { return NativeDatabase(file, logStatements: true, setup: (data) {}); }); } + + @override + MigrationStrategy get migration { + return MigrationStrategy(onCreate: (Migrator m) async { + await m.createAll(); + }, onUpgrade: (Migrator m, int from, int to) async { + //Add column for householdType for facility based campaign + if (from < 5) { + try { + AppLogger.instance.info('Apply migration $from to $to'); + await m.addColumn(household, household.householdType); + } catch (e) { + AppLogger.instance.error( + title: 'migration', + message: e.toString(), + ); + } + } + }); + } } diff --git a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart index 37daa8c69..7ba3256f8 100644 --- a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart +++ b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart @@ -32927,6 +32927,14 @@ class $HouseholdTable extends Household late final GeneratedColumn rowVersion = GeneratedColumn( 'row_version', aliasedName, true, type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _householdTypeMeta = + const VerificationMeta('householdType'); + @override + late final GeneratedColumnWithTypeConverter + householdType = GeneratedColumn('household_type', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false) + .withConverter( + $HouseholdTable.$converterhouseholdTypen); static const VerificationMeta _additionalFieldsMeta = const VerificationMeta('additionalFields'); @override @@ -32952,6 +32960,7 @@ class $HouseholdTable extends Household tenantId, isDeleted, rowVersion, + householdType, additionalFields ]; @override @@ -33057,6 +33066,7 @@ class $HouseholdTable extends Household rowVersion.isAcceptableOrUnknown( data['row_version']!, _rowVersionMeta)); } + context.handle(_householdTypeMeta, const VerificationResult.success()); if (data.containsKey('additional_fields')) { context.handle( _additionalFieldsMeta, @@ -33106,6 +33116,9 @@ class $HouseholdTable extends Household .read(DriftSqlType.bool, data['${effectivePrefix}is_deleted']), rowVersion: attachedDatabase.typeMapping .read(DriftSqlType.int, data['${effectivePrefix}row_version']), + householdType: $HouseholdTable.$converterhouseholdTypen.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.int, data['${effectivePrefix}household_type'])), additionalFields: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}additional_fields']), ); @@ -33115,6 +33128,12 @@ class $HouseholdTable extends Household $HouseholdTable createAlias(String alias) { return $HouseholdTable(attachedDatabase, alias); } + + static JsonTypeConverter2 $converterhouseholdType = + const EnumIndexConverter(HouseholdType.values); + static JsonTypeConverter2 + $converterhouseholdTypen = + JsonTypeConverter2.asNullable($converterhouseholdType); } class HouseholdData extends DataClass implements Insertable { @@ -33135,6 +33154,7 @@ class HouseholdData extends DataClass implements Insertable { final String? tenantId; final bool? isDeleted; final int? rowVersion; + final HouseholdType? householdType; final String? additionalFields; const HouseholdData( {this.id, @@ -33154,6 +33174,7 @@ class HouseholdData extends DataClass implements Insertable { this.tenantId, this.isDeleted, this.rowVersion, + this.householdType, this.additionalFields}); @override Map toColumns(bool nullToAbsent) { @@ -33207,6 +33228,10 @@ class HouseholdData extends DataClass implements Insertable { if (!nullToAbsent || rowVersion != null) { map['row_version'] = Variable(rowVersion); } + if (!nullToAbsent || householdType != null) { + map['household_type'] = Variable( + $HouseholdTable.$converterhouseholdTypen.toSql(householdType)); + } if (!nullToAbsent || additionalFields != null) { map['additional_fields'] = Variable(additionalFields); } @@ -33262,6 +33287,9 @@ class HouseholdData extends DataClass implements Insertable { rowVersion: rowVersion == null && nullToAbsent ? const Value.absent() : Value(rowVersion), + householdType: householdType == null && nullToAbsent + ? const Value.absent() + : Value(householdType), additionalFields: additionalFields == null && nullToAbsent ? const Value.absent() : Value(additionalFields), @@ -33290,6 +33318,8 @@ class HouseholdData extends DataClass implements Insertable { tenantId: serializer.fromJson(json['tenantId']), isDeleted: serializer.fromJson(json['isDeleted']), rowVersion: serializer.fromJson(json['rowVersion']), + householdType: $HouseholdTable.$converterhouseholdTypen + .fromJson(serializer.fromJson(json['householdType'])), additionalFields: serializer.fromJson(json['additionalFields']), ); } @@ -33314,6 +33344,8 @@ class HouseholdData extends DataClass implements Insertable { 'tenantId': serializer.toJson(tenantId), 'isDeleted': serializer.toJson(isDeleted), 'rowVersion': serializer.toJson(rowVersion), + 'householdType': serializer.toJson( + $HouseholdTable.$converterhouseholdTypen.toJson(householdType)), 'additionalFields': serializer.toJson(additionalFields), }; } @@ -33336,6 +33368,7 @@ class HouseholdData extends DataClass implements Insertable { Value tenantId = const Value.absent(), Value isDeleted = const Value.absent(), Value rowVersion = const Value.absent(), + Value householdType = const Value.absent(), Value additionalFields = const Value.absent()}) => HouseholdData( id: id.present ? id.value : this.id, @@ -33372,6 +33405,8 @@ class HouseholdData extends DataClass implements Insertable { tenantId: tenantId.present ? tenantId.value : this.tenantId, isDeleted: isDeleted.present ? isDeleted.value : this.isDeleted, rowVersion: rowVersion.present ? rowVersion.value : this.rowVersion, + householdType: + householdType.present ? householdType.value : this.householdType, additionalFields: additionalFields.present ? additionalFields.value : this.additionalFields, @@ -33396,6 +33431,7 @@ class HouseholdData extends DataClass implements Insertable { ..write('tenantId: $tenantId, ') ..write('isDeleted: $isDeleted, ') ..write('rowVersion: $rowVersion, ') + ..write('householdType: $householdType, ') ..write('additionalFields: $additionalFields') ..write(')')) .toString(); @@ -33420,6 +33456,7 @@ class HouseholdData extends DataClass implements Insertable { tenantId, isDeleted, rowVersion, + householdType, additionalFields); @override bool operator ==(Object other) => @@ -33442,6 +33479,7 @@ class HouseholdData extends DataClass implements Insertable { other.tenantId == this.tenantId && other.isDeleted == this.isDeleted && other.rowVersion == this.rowVersion && + other.householdType == this.householdType && other.additionalFields == this.additionalFields); } @@ -33463,6 +33501,7 @@ class HouseholdCompanion extends UpdateCompanion { final Value tenantId; final Value isDeleted; final Value rowVersion; + final Value householdType; final Value additionalFields; final Value rowid; const HouseholdCompanion({ @@ -33483,6 +33522,7 @@ class HouseholdCompanion extends UpdateCompanion { this.tenantId = const Value.absent(), this.isDeleted = const Value.absent(), this.rowVersion = const Value.absent(), + this.householdType = const Value.absent(), this.additionalFields = const Value.absent(), this.rowid = const Value.absent(), }); @@ -33504,6 +33544,7 @@ class HouseholdCompanion extends UpdateCompanion { this.tenantId = const Value.absent(), this.isDeleted = const Value.absent(), this.rowVersion = const Value.absent(), + this.householdType = const Value.absent(), this.additionalFields = const Value.absent(), this.rowid = const Value.absent(), }) : clientReferenceId = Value(clientReferenceId); @@ -33525,6 +33566,7 @@ class HouseholdCompanion extends UpdateCompanion { Expression? tenantId, Expression? isDeleted, Expression? rowVersion, + Expression? householdType, Expression? additionalFields, Expression? rowid, }) { @@ -33548,6 +33590,7 @@ class HouseholdCompanion extends UpdateCompanion { if (tenantId != null) 'tenant_id': tenantId, if (isDeleted != null) 'is_deleted': isDeleted, if (rowVersion != null) 'row_version': rowVersion, + if (householdType != null) 'household_type': householdType, if (additionalFields != null) 'additional_fields': additionalFields, if (rowid != null) 'rowid': rowid, }); @@ -33571,6 +33614,7 @@ class HouseholdCompanion extends UpdateCompanion { Value? tenantId, Value? isDeleted, Value? rowVersion, + Value? householdType, Value? additionalFields, Value? rowid}) { return HouseholdCompanion( @@ -33591,6 +33635,7 @@ class HouseholdCompanion extends UpdateCompanion { tenantId: tenantId ?? this.tenantId, isDeleted: isDeleted ?? this.isDeleted, rowVersion: rowVersion ?? this.rowVersion, + householdType: householdType ?? this.householdType, additionalFields: additionalFields ?? this.additionalFields, rowid: rowid ?? this.rowid, ); @@ -33650,6 +33695,10 @@ class HouseholdCompanion extends UpdateCompanion { if (rowVersion.present) { map['row_version'] = Variable(rowVersion.value); } + if (householdType.present) { + map['household_type'] = Variable( + $HouseholdTable.$converterhouseholdTypen.toSql(householdType.value)); + } if (additionalFields.present) { map['additional_fields'] = Variable(additionalFields.value); } @@ -33679,6 +33728,7 @@ class HouseholdCompanion extends UpdateCompanion { ..write('tenantId: $tenantId, ') ..write('isDeleted: $isDeleted, ') ..write('rowVersion: $rowVersion, ') + ..write('householdType: $householdType, ') ..write('additionalFields: $additionalFields, ') ..write('rowid: $rowid') ..write(')')) diff --git a/packages/digit_data_model/lib/data/local_store/sql_store/tables/package_tables/household.dart b/packages/digit_data_model/lib/data/local_store/sql_store/tables/package_tables/household.dart index a0e743bd0..7eae8fa78 100644 --- a/packages/digit_data_model/lib/data/local_store/sql_store/tables/package_tables/household.dart +++ b/packages/digit_data_model/lib/data/local_store/sql_store/tables/package_tables/household.dart @@ -2,6 +2,7 @@ import 'package:drift/drift.dart'; +import '../../../../../models/entities/household_type.dart'; class Household extends Table { TextColumn get id => text().nullable()(); @@ -9,7 +10,8 @@ class Household extends Table { RealColumn get latitude => real().nullable()(); RealColumn get longitude => real().nullable()(); TextColumn get auditCreatedBy => text().nullable()(); - BoolColumn get nonRecoverableError => boolean().nullable().withDefault(const Constant(false))(); + BoolColumn get nonRecoverableError => + boolean().nullable().withDefault(const Constant(false))(); IntColumn get auditCreatedTime => integer().nullable()(); IntColumn get clientCreatedTime => integer().nullable()(); TextColumn get clientModifiedBy => text().nullable()(); @@ -19,11 +21,15 @@ class Household extends Table { IntColumn get auditModifiedTime => integer().nullable()(); TextColumn get clientReferenceId => text()(); TextColumn get tenantId => text().nullable()(); - BoolColumn get isDeleted => boolean().nullable().withDefault(const Constant(false))(); + BoolColumn get isDeleted => + boolean().nullable().withDefault(const Constant(false))(); IntColumn get rowVersion => integer().nullable()(); - + IntColumn get householdType => intEnum().nullable()(); TextColumn get additionalFields => text().nullable()(); @override - Set get primaryKey => { auditCreatedBy, clientReferenceId, }; -} \ No newline at end of file + Set get primaryKey => { + auditCreatedBy, + clientReferenceId, + }; +} diff --git a/packages/digit_data_model/lib/data_model.init.dart b/packages/digit_data_model/lib/data_model.init.dart index b1d6fe772..f7068b0a2 100644 --- a/packages/digit_data_model/lib/data_model.init.dart +++ b/packages/digit_data_model/lib/data_model.init.dart @@ -13,23 +13,24 @@ import 'models/entities/boundary.dart' as p6; import 'models/entities/document.dart' as p7; import 'models/entities/facility.dart' as p8; import 'models/entities/gender.dart' as p9; -import 'models/entities/identifier.dart' as p10; -import 'models/entities/individual.dart' as p11; -import 'models/entities/locality.dart' as p12; -import 'models/entities/name.dart' as p13; -import 'models/entities/pgr_application_status.dart' as p14; -import 'models/entities/product.dart' as p15; -import 'models/entities/product_variant.dart' as p16; -import 'models/entities/project.dart' as p17; -import 'models/entities/project_facility.dart' as p18; -import 'models/entities/project_product_variant.dart' as p19; -import 'models/entities/project_resource.dart' as p20; -import 'models/entities/project_staff.dart' as p21; -import 'models/entities/project_type.dart' as p22; -import 'models/entities/target.dart' as p23; -import 'models/entities/user.dart' as p24; -import 'models/entities/user_action.dart' as p25; -import 'models/oplog/oplog_entry.dart' as p26; +import 'models/entities/household_type.dart' as p10; +import 'models/entities/identifier.dart' as p11; +import 'models/entities/individual.dart' as p12; +import 'models/entities/locality.dart' as p13; +import 'models/entities/name.dart' as p14; +import 'models/entities/pgr_application_status.dart' as p15; +import 'models/entities/product.dart' as p16; +import 'models/entities/product_variant.dart' as p17; +import 'models/entities/project.dart' as p18; +import 'models/entities/project_facility.dart' as p19; +import 'models/entities/project_product_variant.dart' as p20; +import 'models/entities/project_resource.dart' as p21; +import 'models/entities/project_staff.dart' as p22; +import 'models/entities/project_type.dart' as p23; +import 'models/entities/target.dart' as p24; +import 'models/entities/user.dart' as p25; +import 'models/entities/user_action.dart' as p26; +import 'models/oplog/oplog_entry.dart' as p27; void initializeMappers() { p0.EntityModelMapper.ensureInitialized(); @@ -56,58 +57,59 @@ void initializeMappers() { p8.FacilityModelMapper.ensureInitialized(); p8.FacilityAdditionalFieldsMapper.ensureInitialized(); p9.GenderMapper.ensureInitialized(); - p10.IdentifierSearchModelMapper.ensureInitialized(); - p10.IdentifierModelMapper.ensureInitialized(); - p10.IdentifierAdditionalFieldsMapper.ensureInitialized(); - p11.IndividualSearchModelMapper.ensureInitialized(); - p11.IndividualModelMapper.ensureInitialized(); - p11.IndividualAdditionalFieldsMapper.ensureInitialized(); - p12.LocalitySearchModelMapper.ensureInitialized(); - p12.LocalityModelMapper.ensureInitialized(); - p12.LocalityAdditionalFieldsMapper.ensureInitialized(); - p13.NameSearchModelMapper.ensureInitialized(); - p13.NameModelMapper.ensureInitialized(); - p13.NameAdditionalFieldsMapper.ensureInitialized(); - p14.PgrServiceApplicationStatusMapper.ensureInitialized(); - p15.ProductSearchModelMapper.ensureInitialized(); - p15.ProductModelMapper.ensureInitialized(); - p15.ProductAdditionalFieldsMapper.ensureInitialized(); - p16.ProductVariantSearchModelMapper.ensureInitialized(); - p16.ProductVariantModelMapper.ensureInitialized(); - p16.ProductVariantAdditionalFieldsMapper.ensureInitialized(); - p17.ProjectSearchModelMapper.ensureInitialized(); - p17.ProjectModelMapper.ensureInitialized(); - p17.ProjectAdditionalFieldsMapper.ensureInitialized(); - p17.ProjectAdditionalDetailsMapper.ensureInitialized(); - p18.ProjectFacilitySearchModelMapper.ensureInitialized(); - p18.ProjectFacilityModelMapper.ensureInitialized(); - p18.ProjectFacilityAdditionalFieldsMapper.ensureInitialized(); - p19.ProjectProductVariantSearchModelMapper.ensureInitialized(); - p19.ProjectProductVariantModelMapper.ensureInitialized(); - p19.ProjectProductVariantAdditionalFieldsMapper.ensureInitialized(); - p20.ProjectResourceSearchModelMapper.ensureInitialized(); - p20.ProjectResourceModelMapper.ensureInitialized(); - p20.ProjectResourceAdditionalFieldsMapper.ensureInitialized(); - p21.ProjectStaffSearchModelMapper.ensureInitialized(); - p21.ProjectStaffModelMapper.ensureInitialized(); - p21.ProjectStaffAdditionalFieldsMapper.ensureInitialized(); - p22.ProjectTypeModelMapper.ensureInitialized(); - p22.ProjectTypeAdditionalFieldsMapper.ensureInitialized(); - p22.ProjectCycleMapper.ensureInitialized(); - p22.ProjectCycleDeliveryMapper.ensureInitialized(); - p22.DeliveryDoseCriteriaMapper.ensureInitialized(); - p22.DeliveryProductVariantMapper.ensureInitialized(); - p23.TargetSearchModelMapper.ensureInitialized(); - p23.TargetModelMapper.ensureInitialized(); - p23.TargetAdditionalFieldsMapper.ensureInitialized(); - p24.UserSearchModelMapper.ensureInitialized(); - p24.UserModelMapper.ensureInitialized(); - p24.UserAdditionalFieldsMapper.ensureInitialized(); - p25.UserActionSearchModelMapper.ensureInitialized(); - p25.UserActionModelMapper.ensureInitialized(); - p25.UserActionAdditionalFieldsMapper.ensureInitialized(); - p26.OpLogEntryMapper.ensureInitialized(); - p26.AdditionalIdMapper.ensureInitialized(); - p26.DataOperationMapper.ensureInitialized(); - p26.ApiOperationMapper.ensureInitialized(); + p10.HouseholdTypeMapper.ensureInitialized(); + p11.IdentifierSearchModelMapper.ensureInitialized(); + p11.IdentifierModelMapper.ensureInitialized(); + p11.IdentifierAdditionalFieldsMapper.ensureInitialized(); + p12.IndividualSearchModelMapper.ensureInitialized(); + p12.IndividualModelMapper.ensureInitialized(); + p12.IndividualAdditionalFieldsMapper.ensureInitialized(); + p13.LocalitySearchModelMapper.ensureInitialized(); + p13.LocalityModelMapper.ensureInitialized(); + p13.LocalityAdditionalFieldsMapper.ensureInitialized(); + p14.NameSearchModelMapper.ensureInitialized(); + p14.NameModelMapper.ensureInitialized(); + p14.NameAdditionalFieldsMapper.ensureInitialized(); + p15.PgrServiceApplicationStatusMapper.ensureInitialized(); + p16.ProductSearchModelMapper.ensureInitialized(); + p16.ProductModelMapper.ensureInitialized(); + p16.ProductAdditionalFieldsMapper.ensureInitialized(); + p17.ProductVariantSearchModelMapper.ensureInitialized(); + p17.ProductVariantModelMapper.ensureInitialized(); + p17.ProductVariantAdditionalFieldsMapper.ensureInitialized(); + p18.ProjectSearchModelMapper.ensureInitialized(); + p18.ProjectModelMapper.ensureInitialized(); + p18.ProjectAdditionalFieldsMapper.ensureInitialized(); + p18.ProjectAdditionalDetailsMapper.ensureInitialized(); + p19.ProjectFacilitySearchModelMapper.ensureInitialized(); + p19.ProjectFacilityModelMapper.ensureInitialized(); + p19.ProjectFacilityAdditionalFieldsMapper.ensureInitialized(); + p20.ProjectProductVariantSearchModelMapper.ensureInitialized(); + p20.ProjectProductVariantModelMapper.ensureInitialized(); + p20.ProjectProductVariantAdditionalFieldsMapper.ensureInitialized(); + p21.ProjectResourceSearchModelMapper.ensureInitialized(); + p21.ProjectResourceModelMapper.ensureInitialized(); + p21.ProjectResourceAdditionalFieldsMapper.ensureInitialized(); + p22.ProjectStaffSearchModelMapper.ensureInitialized(); + p22.ProjectStaffModelMapper.ensureInitialized(); + p22.ProjectStaffAdditionalFieldsMapper.ensureInitialized(); + p23.ProjectTypeModelMapper.ensureInitialized(); + p23.ProjectTypeAdditionalFieldsMapper.ensureInitialized(); + p23.ProjectCycleMapper.ensureInitialized(); + p23.ProjectCycleDeliveryMapper.ensureInitialized(); + p23.DeliveryDoseCriteriaMapper.ensureInitialized(); + p23.DeliveryProductVariantMapper.ensureInitialized(); + p24.TargetSearchModelMapper.ensureInitialized(); + p24.TargetModelMapper.ensureInitialized(); + p24.TargetAdditionalFieldsMapper.ensureInitialized(); + p25.UserSearchModelMapper.ensureInitialized(); + p25.UserModelMapper.ensureInitialized(); + p25.UserAdditionalFieldsMapper.ensureInitialized(); + p26.UserActionSearchModelMapper.ensureInitialized(); + p26.UserActionModelMapper.ensureInitialized(); + p26.UserActionAdditionalFieldsMapper.ensureInitialized(); + p27.OpLogEntryMapper.ensureInitialized(); + p27.AdditionalIdMapper.ensureInitialized(); + p27.DataOperationMapper.ensureInitialized(); + p27.ApiOperationMapper.ensureInitialized(); } diff --git a/packages/digit_data_model/lib/models/entities/household_type.dart b/packages/digit_data_model/lib/models/entities/household_type.dart new file mode 100644 index 000000000..2e6d1b21c --- /dev/null +++ b/packages/digit_data_model/lib/models/entities/household_type.dart @@ -0,0 +1,14 @@ +import 'package:dart_mappable/dart_mappable.dart'; + +part 'household_type.mapper.dart'; + +@MappableEnum(caseStyle: CaseStyle.upperCase) +enum HouseholdType { + @MappableValue("FAMILY") + family, + @MappableValue("COMMUNITY") + community, + @MappableValue("OTHER") + other, + ; +} diff --git a/packages/digit_data_model/lib/models/entities/household_type.mapper.dart b/packages/digit_data_model/lib/models/entities/household_type.mapper.dart new file mode 100644 index 000000000..30ea5cb89 --- /dev/null +++ b/packages/digit_data_model/lib/models/entities/household_type.mapper.dart @@ -0,0 +1,57 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'household_type.dart'; + +class HouseholdTypeMapper extends EnumMapper { + HouseholdTypeMapper._(); + + static HouseholdTypeMapper? _instance; + static HouseholdTypeMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = HouseholdTypeMapper._()); + } + return _instance!; + } + + static HouseholdType fromValue(dynamic value) { + ensureInitialized(); + return MapperContainer.globals.fromValue(value); + } + + @override + HouseholdType decode(dynamic value) { + switch (value) { + case "FAMILY": + return HouseholdType.family; + case "COMMUNITY": + return HouseholdType.community; + case "OTHER": + return HouseholdType.other; + default: + throw MapperException.unknownEnumValue(value); + } + } + + @override + dynamic encode(HouseholdType self) { + switch (self) { + case HouseholdType.family: + return "FAMILY"; + case HouseholdType.community: + return "COMMUNITY"; + case HouseholdType.other: + return "OTHER"; + } + } +} + +extension HouseholdTypeMapperExtension on HouseholdType { + dynamic toValue() { + HouseholdTypeMapper.ensureInitialized(); + return MapperContainer.globals.toValue(this); + } +} diff --git a/packages/digit_data_model/pubspec.lock b/packages/digit_data_model/pubspec.lock index cafc857b1..638fab2f7 100644 --- a/packages/digit_data_model/pubspec.lock +++ b/packages/digit_data_model/pubspec.lock @@ -33,6 +33,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + archive: + dependency: transitive + description: + name: archive + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" + source: hosted + version: "3.6.1" args: dependency: transitive description: @@ -217,6 +225,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + cupertino_icons: + dependency: transitive + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" dart_mappable: dependency: "direct main" description: @@ -266,6 +282,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.1" + digit_components: + dependency: "direct main" + description: + path: "../digit_components" + relative: true + source: path + version: "1.0.2+1" dio: dependency: "direct main" description: @@ -298,6 +321,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.15.0" + easy_stepper: + dependency: transitive + description: + name: easy_stepper + sha256: "77f3ab4ee3c867b5a2236bf712abb08fed2b1c533cf24cf3fcd46c2821072ffd" + url: "https://pub.dev" + source: hosted + version: "0.5.2+1" fake_async: dependency: transitive description: @@ -343,6 +374,62 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.5" + flutter_focus_watcher: + dependency: transitive + description: + name: flutter_focus_watcher + sha256: a72ee539ae0237961308a25839887ca93a0b1cb6f87b0d492b139c8fccff8e79 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility: + dependency: transitive + description: + name: flutter_keyboard_visibility + sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + url: "https://pub.dev" + source: hosted + version: "5.4.1" + flutter_keyboard_visibility_linux: + dependency: transitive + description: + name: flutter_keyboard_visibility_linux + sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + flutter_keyboard_visibility_macos: + dependency: transitive + description: + name: flutter_keyboard_visibility_macos + sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_windows: + dependency: transitive + description: + name: flutter_keyboard_visibility_windows + sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 + url: "https://pub.dev" + source: hosted + version: "1.0.0" flutter_lints: dependency: "direct dev" description: @@ -351,11 +438,40 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + flutter_spinkit: + dependency: transitive + description: + name: flutter_spinkit + sha256: d2696eed13732831414595b98863260e33e8882fc069ee80ec35d4ac9ddb0472 + url: "https://pub.dev" + source: hosted + version: "5.2.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_typeahead: + dependency: transitive + description: + name: flutter_typeahead + sha256: b9942bd5b7611a6ec3f0730c477146cffa4cd4b051077983ba67ddfc9e7ee818 + url: "https://pub.dev" + source: hosted + version: "4.8.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + fluttertoast: + dependency: transitive + description: + name: fluttertoast + sha256: "81b68579e23fcbcada2db3d50302813d2371664afe6165bc78148050ab94bf66" + url: "https://pub.dev" + source: hosted + version: "8.2.5" freezed: dependency: "direct dev" description: @@ -388,6 +504,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + google_fonts: + dependency: transitive + description: + name: google_fonts + sha256: "2776c66b3e97c6cdd58d1bd3281548b074b64f1fd5c8f82391f7456e38849567" + url: "https://pub.dev" + source: hosted + version: "4.0.5" graphs: dependency: transitive description: @@ -396,6 +520,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.1" + horizontal_data_table: + dependency: transitive + description: + name: horizontal_data_table + sha256: c8ab5256bbced698a729f3e0ff2cb0e8e97416cdbb082860370eaf883badf722 + url: "https://pub.dev" + source: hosted + version: "4.3.1" + http: + dependency: transitive + description: + name: http + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba + url: "https://pub.dev" + source: hosted + version: "1.2.0" http_multi_server: dependency: transitive description: @@ -412,6 +552,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" io: dependency: transitive description: @@ -476,6 +624,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + location: + dependency: transitive + description: + name: location + sha256: "06be54f682c9073cbfec3899eb9bc8ed90faa0e17735c9d9fa7fe426f5be1dd1" + url: "https://pub.dev" + source: hosted + version: "5.0.3" + location_platform_interface: + dependency: transitive + description: + name: location_platform_interface + sha256: "8aa1d34eeecc979d7c9fe372931d84f6d2ebbd52226a54fe1620de6fdc0753b1" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + location_web: + dependency: transitive + description: + name: location_web + sha256: ec484c66e8a4ff1ee5d044c203f4b6b71e3a0556a97b739a5bc9616de672412b + url: "https://pub.dev" + source: hosted + version: "4.2.0" logging: dependency: transitive description: @@ -484,6 +656,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + lottie: + dependency: transitive + description: + name: lottie + sha256: a93542cc2d60a7057255405f62252533f8e8956e7e06754955669fd32fb4b216 + url: "https://pub.dev" + source: hosted + version: "2.7.0" matcher: dependency: transitive description: @@ -540,6 +720,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + overlay_builder: + dependency: transitive + description: + name: overlay_builder + sha256: "58b97bc5f67a2e2bb7006dd88e697ac757dfffc9dbd1e7dfc1917fb510a4b5c8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" package_config: dependency: transitive description: @@ -548,6 +736,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: transitive + description: + name: package_info_plus + sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79" + url: "https://pub.dev" + source: hosted + version: "5.0.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6" + url: "https://pub.dev" + source: hosted + version: "2.0.1" path: dependency: "direct main" description: @@ -620,6 +824,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + pointer_interceptor: + dependency: transitive + description: + name: pointer_interceptor + sha256: adf7a637f97c077041d36801b43be08559fd4322d2127b3f20bb7be1b9eebc22 + url: "https://pub.dev" + source: hosted + version: "0.9.3+7" pool: dependency: transitive description: @@ -652,6 +864,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.3" + reactive_flutter_typeahead: + dependency: transitive + description: + name: reactive_flutter_typeahead + sha256: ef91627df8cef70e603e8a6458749d8a99a385b78854332602fd08ad905cdab8 + url: "https://pub.dev" + source: hosted + version: "0.8.1" + reactive_forms: + dependency: transitive + description: + name: reactive_forms + sha256: "5aa9c48a0626c20d00a005e597cb10efbdebbfeecb9c4227b03a5945fbb91ec4" + url: "https://pub.dev" + source: hosted + version: "14.3.0" recase: dependency: "direct main" description: @@ -660,6 +888,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + remove_emoji_input_formatter: + dependency: transitive + description: + name: remove_emoji_input_formatter + sha256: "82d195984f890de7a8fea936c698848e78c1a67ccefe18db3baf9f7a3bc0177f" + url: "https://pub.dev" + source: hosted + version: "0.0.1+1" shelf: dependency: transitive description: diff --git a/packages/digit_data_model/pubspec.yaml b/packages/digit_data_model/pubspec.yaml index f0a627dfc..7f37b835f 100644 --- a/packages/digit_data_model/pubspec.yaml +++ b/packages/digit_data_model/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: dio: ^5.1.2 mocktail: ^1.0.2 collection: ^1.16.0 + digit_components: ^1.0.2 dev_dependencies: flutter_test: diff --git a/packages/registration_delivery/lib/models/entities/household.dart b/packages/registration_delivery/lib/models/entities/household.dart index 28e2c6adb..34ac9de94 100644 --- a/packages/registration_delivery/lib/models/entities/household.dart +++ b/packages/registration_delivery/lib/models/entities/household.dart @@ -1,6 +1,7 @@ // Generated using mason. Do not modify by hand import 'package:dart_mappable/dart_mappable.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:drift/drift.dart'; part 'household.mapper.dart'; @@ -16,6 +17,7 @@ class HouseholdSearchModel extends EntitySearchModel final bool? isProximityEnabled; final List? clientReferenceId; final String? tenantId; + final HouseholdType? householdType; HouseholdSearchModel({ this.id, @@ -26,6 +28,7 @@ class HouseholdSearchModel extends EntitySearchModel this.isProximityEnabled, this.clientReferenceId, this.tenantId, + this.householdType, super.boundaryCode, super.isDeleted, }) : super(); @@ -40,6 +43,7 @@ class HouseholdSearchModel extends EntitySearchModel this.isProximityEnabled, this.clientReferenceId, this.tenantId, + this.householdType, super.boundaryCode, }) : super(isDeleted: false); } @@ -58,6 +62,7 @@ class HouseholdModel extends EntityModel with HouseholdModelMappable { final int? rowVersion; final AddressModel? address; final HouseholdAdditionalFields? additionalFields; + final HouseholdType? householdType; HouseholdModel({ this.additionalFields, @@ -70,6 +75,7 @@ class HouseholdModel extends EntityModel with HouseholdModelMappable { this.tenantId, this.rowVersion, this.address, + this.householdType, super.auditDetails, super.clientAuditDetails, super.isDeleted = false, @@ -95,6 +101,7 @@ class HouseholdModel extends EntityModel with HouseholdModelMappable { clientReferenceId: Value(clientReferenceId), tenantId: Value(tenantId), rowVersion: Value(rowVersion), + householdType: Value(householdType), ); } } diff --git a/packages/registration_delivery/lib/models/entities/household.mapper.dart b/packages/registration_delivery/lib/models/entities/household.mapper.dart index 17d2a4ef9..62496bee3 100644 --- a/packages/registration_delivery/lib/models/entities/household.mapper.dart +++ b/packages/registration_delivery/lib/models/entities/household.mapper.dart @@ -47,6 +47,10 @@ class HouseholdSearchModelMapper static String? _$tenantId(HouseholdSearchModel v) => v.tenantId; static const Field _f$tenantId = Field('tenantId', _$tenantId, opt: true); + static HouseholdType? _$householdType(HouseholdSearchModel v) => + v.householdType; + static const Field _f$householdType = + Field('householdType', _$householdType, opt: true); static String? _$boundaryCode(HouseholdSearchModel v) => v.boundaryCode; static const Field _f$boundaryCode = Field('boundaryCode', _$boundaryCode, opt: true); @@ -69,6 +73,7 @@ class HouseholdSearchModelMapper #isProximityEnabled: _f$isProximityEnabled, #clientReferenceId: _f$clientReferenceId, #tenantId: _f$tenantId, + #householdType: _f$householdType, #boundaryCode: _f$boundaryCode, #auditDetails: _f$auditDetails, #additionalFields: _f$additionalFields, @@ -94,6 +99,7 @@ class HouseholdSearchModelMapper isProximityEnabled: data.dec(_f$isProximityEnabled), clientReferenceId: data.dec(_f$clientReferenceId), tenantId: data.dec(_f$tenantId), + householdType: data.dec(_f$householdType), boundaryCode: data.dec(_f$boundaryCode)); } @@ -169,6 +175,7 @@ abstract class HouseholdSearchModelCopyWith< bool? isProximityEnabled, List? clientReferenceId, String? tenantId, + HouseholdType? householdType, String? boundaryCode}); HouseholdSearchModelCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( Then<$Out2, $R2> t); @@ -206,6 +213,7 @@ class _HouseholdSearchModelCopyWithImpl<$R, $Out> Object? isProximityEnabled = $none, Object? clientReferenceId = $none, Object? tenantId = $none, + Object? householdType = $none, Object? boundaryCode = $none}) => $apply(FieldCopyWithData({ if (id != $none) #id: id, @@ -217,6 +225,7 @@ class _HouseholdSearchModelCopyWithImpl<$R, $Out> #isProximityEnabled: isProximityEnabled, if (clientReferenceId != $none) #clientReferenceId: clientReferenceId, if (tenantId != $none) #tenantId: tenantId, + if (householdType != $none) #householdType: householdType, if (boundaryCode != $none) #boundaryCode: boundaryCode })); @override @@ -232,6 +241,7 @@ class _HouseholdSearchModelCopyWithImpl<$R, $Out> clientReferenceId: data.get(#clientReferenceId, or: $value.clientReferenceId), tenantId: data.get(#tenantId, or: $value.tenantId), + householdType: data.get(#householdType, or: $value.householdType), boundaryCode: data.get(#boundaryCode, or: $value.boundaryCode)); @override @@ -287,6 +297,9 @@ class HouseholdModelMapper extends SubClassMapperBase { static AddressModel? _$address(HouseholdModel v) => v.address; static const Field _f$address = Field('address', _$address, opt: true); + static HouseholdType? _$householdType(HouseholdModel v) => v.householdType; + static const Field _f$householdType = + Field('householdType', _$householdType, opt: true); static AuditDetails? _$auditDetails(HouseholdModel v) => v.auditDetails; static const Field _f$auditDetails = Field('auditDetails', _$auditDetails, opt: true); @@ -310,6 +323,7 @@ class HouseholdModelMapper extends SubClassMapperBase { #tenantId: _f$tenantId, #rowVersion: _f$rowVersion, #address: _f$address, + #householdType: _f$householdType, #auditDetails: _f$auditDetails, #clientAuditDetails: _f$clientAuditDetails, #isDeleted: _f$isDeleted, @@ -337,6 +351,7 @@ class HouseholdModelMapper extends SubClassMapperBase { tenantId: data.dec(_f$tenantId), rowVersion: data.dec(_f$rowVersion), address: data.dec(_f$address), + householdType: data.dec(_f$householdType), auditDetails: data.dec(_f$auditDetails), clientAuditDetails: data.dec(_f$clientAuditDetails), isDeleted: data.dec(_f$isDeleted)); @@ -417,6 +432,7 @@ abstract class HouseholdModelCopyWith<$R, $In extends HouseholdModel, $Out> String? tenantId, int? rowVersion, AddressModel? address, + HouseholdType? householdType, AuditDetails? auditDetails, ClientAuditDetails? clientAuditDetails, bool? isDeleted}); @@ -459,6 +475,7 @@ class _HouseholdModelCopyWithImpl<$R, $Out> Object? tenantId = $none, Object? rowVersion = $none, Object? address = $none, + Object? householdType = $none, Object? auditDetails = $none, Object? clientAuditDetails = $none, Object? isDeleted = $none}) => @@ -474,6 +491,7 @@ class _HouseholdModelCopyWithImpl<$R, $Out> if (tenantId != $none) #tenantId: tenantId, if (rowVersion != $none) #rowVersion: rowVersion, if (address != $none) #address: address, + if (householdType != $none) #householdType: householdType, if (auditDetails != $none) #auditDetails: auditDetails, if (clientAuditDetails != $none) #clientAuditDetails: clientAuditDetails, @@ -494,6 +512,7 @@ class _HouseholdModelCopyWithImpl<$R, $Out> tenantId: data.get(#tenantId, or: $value.tenantId), rowVersion: data.get(#rowVersion, or: $value.rowVersion), address: data.get(#address, or: $value.address), + householdType: data.get(#householdType, or: $value.householdType), auditDetails: data.get(#auditDetails, or: $value.auditDetails), clientAuditDetails: data.get(#clientAuditDetails, or: $value.clientAuditDetails), diff --git a/packages/registration_delivery/pubspec.lock b/packages/registration_delivery/pubspec.lock index f43c0acdf..589a63578 100644 --- a/packages/registration_delivery/pubspec.lock +++ b/packages/registration_delivery/pubspec.lock @@ -413,10 +413,9 @@ packages: digit_data_model: dependency: "direct main" description: - name: digit_data_model - sha256: "63c878bfe49e3e8db190dd5cd35d7a7b93b2e3b6663cebaaee25ff0089c1112b" - url: "https://pub.dev" - source: hosted + path: "../digit_data_model" + relative: true + source: path version: "1.0.5-dev.1" digit_scanner: dependency: "direct main" @@ -1486,10 +1485,9 @@ packages: survey_form: dependency: "direct main" description: - name: survey_form - sha256: "52532fb3fae06883828d22f870045587bf7122f67cb4de236c82ad4d6de1d7d7" - url: "https://pub.dev" - source: hosted + path: "../survey_form" + relative: true + source: path version: "0.0.1-dev.2" synchronized: dependency: transitive From 8592a363d3814722ea2a7c093256009c8ca0e8cf Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Tue, 3 Dec 2024 10:47:56 +0530 Subject: [PATCH 06/19] hcmpre-1421: ui changes for search and overview page --- .../lib/pages/home.dart | 19 +++-- .../lib/utils/i18_key_constants.dart | 6 +- .../showcase/config/home_showcase.dart | 3 +- .../pages/beneficiary/household_overview.dart | 76 +++++++++++++++---- .../lib/pages/search_beneficiary.dart | 57 ++++++++------ 5 files changed, 112 insertions(+), 49 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/pages/home.dart b/apps/health_campaign_field_worker_app/lib/pages/home.dart index b09584a51..017cf43ca 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/home.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/home.dart @@ -31,6 +31,7 @@ import 'package:referral_reconciliation/router/referral_reconciliation_router.gm import 'package:registration_delivery/registration_delivery.dart'; import 'package:registration_delivery/router/registration_delivery_router.gm.dart'; import 'package:survey_form/router/survey_form_router.gm.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import '../blocs/app_initialization/app_initialization.dart'; import '../blocs/auth/auth.dart'; @@ -356,16 +357,22 @@ class _HomePageState extends LocalizedState { icon: Icons.all_inbox, label: i18.home.beneficiaryLabel, onPressed: () async { + RegistrationDeliverySingleton() + .setHouseholdType(HouseholdType.family); await context.router.push(const RegistrationDeliveryWrapperRoute()); }, ), ), - i18.home.institutionLabel: homeShowcaseData.instituteCampaign.buildWith( + i18.home.clfLabel: homeShowcaseData.clf.buildWith( child: HomeItemCard( icon: Icons.account_balance, - label: i18.home.institutionLabel, - onPressed: () {}, + label: i18.home.clfLabel, + onPressed: () async { + RegistrationDeliverySingleton() + .setHouseholdType(HouseholdType.community); + await context.router.push(const RegistrationDeliveryWrapperRoute()); + }, ), ), @@ -534,13 +541,13 @@ class _HomePageState extends LocalizedState { i18.home.closedHouseHoldLabel: homeShowcaseData.closedHouseHold.showcaseKey, i18.home.dashboard: homeShowcaseData.dashBoard.showcaseKey, - i18.home.institutionLabel: homeShowcaseData.instituteCampaign.showcaseKey, + i18.home.clfLabel: homeShowcaseData.clf.showcaseKey, }; final homeItemsLabel = [ // INFO: Need to add items label of package Here i18.home.beneficiaryLabel, - i18.home.institutionLabel, + i18.home.clfLabel, i18.home.closedHouseHoldLabel, i18.home.manageStockLabel, i18.home.stockReconciliationLabel, @@ -561,7 +568,7 @@ class _HomePageState extends LocalizedState { .toList() .contains(element) || element == i18.home.db || - element == i18.home.institutionLabel) + element == i18.home.clfLabel) .toList(); final showcaseKeys = filteredLabels diff --git a/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart b/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart index f36b3b91a..f9495640e 100644 --- a/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart +++ b/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart @@ -204,8 +204,8 @@ class HomeShowcase { return 'WAREHOUSE_MANAGER_HOME_SHOWCASE_DELETE_ALL'; } - String get instituteCampaign { - return "INSTITUTE_CAMPAIGN_SHOWCASE"; + String get clf { + return "COMMUNAL_LIVING_FACILITY_SHOWCASE"; } } @@ -565,7 +565,7 @@ class Home { String get closedHouseHoldLabel => 'HOME_CLOSE_HOUSEHOLD_LABEL'; - String get institutionLabel => "HOME_INSTITUTION_CAMPAIGN_LABEL"; + String get clfLabel => "HOME_COMMUNAL_LIVING_FACILITIES_LABEL"; } class AcknowledgementSuccess { diff --git a/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart b/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart index ba804af85..ca0f302f0 100644 --- a/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart +++ b/apps/health_campaign_field_worker_app/lib/widgets/showcase/config/home_showcase.dart @@ -106,6 +106,5 @@ class _HomePageShowcaseData { messageLocalizationKey: i18.home.closedHouseHoldLabel, ); - final instituteCampaign = ShowcaseItemBuilder( - messageLocalizationKey: i18.homeShowcase.instituteCampaign); + final clf = ShowcaseItemBuilder(messageLocalizationKey: i18.homeShowcase.clf); } diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 51e8e874d..2f68a7998 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -1,6 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:collection/collection.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/enum/app_enums.dart'; import 'package:digit_ui_components/theme/digit_extended_theme.dart'; import 'package:digit_ui_components/theme/digit_theme.dart'; @@ -407,9 +408,18 @@ class _HouseholdOverviewPageState child: Padding( padding: const EdgeInsets.all(spacer2), child: Text( - localizations.translate(i18 - .householdOverView - .householdOverViewLabel), + RegistrationDeliverySingleton() + .householdType != + null && + RegistrationDeliverySingleton() + .householdType == + HouseholdType.community + ? localizations.translate(i18 + .householdOverView + .clfOverviewLabel) + : localizations.translate(i18 + .householdOverView + .householdOverViewLabel), style: textTheme.headingXl, ), ), @@ -458,6 +468,49 @@ class _HouseholdOverviewPageState bool shouldShowStatus = beneficiaryType == BeneficiaryType.household; + if (RegistrationDeliverySingleton() + .householdType != + null && + RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) { + return Column( + children: [ + DigitTableCard(element: { + localizations.translate(i18 + .householdOverView + .instituteNameLabel): state + .householdMemberWrapper + .headOfHousehold + ?.name + ?.givenName ?? + localizations.translate( + i18.common.coreCommonNA), + localizations.translate(i18 + .householdOverView + .instituteTypeLabel): + RegistrationDeliverySingleton() + .householdType, + localizations.translate( + i18.deliverIntervention + .memberCountText, + ): state.householdMemberWrapper + .household?.memberCount, + localizations.translate( + i18.householdLocation + .administrationAreaFormLabel, + ): state + .householdMemberWrapper + .headOfHousehold + ?.address + ?.first + .locality + ?.code, + }), + ], + ); + } + return Column( children: [ DigitTableCard( @@ -543,11 +596,9 @@ class _HouseholdOverviewPageState '${localizations.translate(getStatus(selectedFilters[index]))}' ' (${state.householdMemberWrapper.members!.length})', onItemDelete: () { - setState(() { - selectedFilters.remove( - selectedFilters[ - index]); - }); + selectedFilters.remove( + selectedFilters[ + index]); callReloadEvent( offset: 0, limit: 10); }, @@ -1020,18 +1071,13 @@ class _HouseholdOverviewPageState ])); if (filters != null && filters.isNotEmpty) { - setState(() { - selectedFilters = []; - }); - setState(() { - selectedFilters.addAll(filters); - }); + selectedFilters.addAll(filters); callReloadEvent(offset: 0, limit: 10); } else { setState(() { selectedFilters = []; }); - // blocWrapper.clearEvent(); + callReloadEvent(offset: 0, limit: 10); } } diff --git a/packages/registration_delivery/lib/pages/search_beneficiary.dart b/packages/registration_delivery/lib/pages/search_beneficiary.dart index cb2a671a7..47a246b2e 100644 --- a/packages/registration_delivery/lib/pages/search_beneficiary.dart +++ b/packages/registration_delivery/lib/pages/search_beneficiary.dart @@ -1,5 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_scanner/blocs/scanner.dart'; import 'package:digit_scanner/pages/qr_scanner.dart'; import 'package:digit_ui_components/blocs/fetch_location_bloc.dart'; @@ -109,11 +110,19 @@ class _SearchBeneficiaryPageState alignment: Alignment.topLeft, child: Text( localizations.translate( - RegistrationDeliverySingleton().beneficiaryType != - BeneficiaryType.individual - ? i18.searchBeneficiary.statisticsLabelText - : i18.searchBeneficiary - .searchIndividualLabelText, + RegistrationDeliverySingleton().householdType != + null && + RegistrationDeliverySingleton() + .householdType == + HouseholdType.community + ? i18.searchBeneficiary.searchCLFLabel + : RegistrationDeliverySingleton() + .beneficiaryType != + BeneficiaryType.individual + ? i18 + .searchBeneficiary.statisticsLabelText + : i18.searchBeneficiary + .searchIndividualLabelText, ), style: textTheme.headingXl, textAlign: TextAlign.left, @@ -489,31 +498,33 @@ class _SearchBeneficiaryPageState limit: isPagination ? blocWrapper.individualGlobalSearchBloc.state.limit : limit, + householdType: RegistrationDeliverySingleton().householdType, ))); } } else { if (isProximityEnabled || selectedFilters.isNotEmpty || searchController.text.isNotEmpty) { - blocWrapper.houseHoldGlobalSearchBloc - .add(SearchHouseholdsEvent.houseHoldGlobalSearch( + blocWrapper.houseHoldGlobalSearchBloc.add( + SearchHouseholdsEvent.houseHoldGlobalSearch( globalSearchParams: GlobalSearchParameters( - isProximityEnabled: isProximityEnabled, - latitude: lat, - longitude: long, - projectId: RegistrationDeliverySingleton().projectId!, - maxRadius: RegistrationDeliverySingleton().maxRadius, - nameSearch: searchController.text.trim().length > 2 - ? searchController.text.trim() - : blocWrapper.searchHouseholdsBloc.state.searchQuery, - filter: selectedFilters, - offset: isPagination - ? blocWrapper.houseHoldGlobalSearchBloc.state.offset - : offset, - limit: isPagination - ? blocWrapper.houseHoldGlobalSearchBloc.state.limit - : limit, - ))); + isProximityEnabled: isProximityEnabled, + latitude: lat, + longitude: long, + projectId: RegistrationDeliverySingleton().projectId!, + maxRadius: RegistrationDeliverySingleton().maxRadius, + nameSearch: searchController.text.trim().length > 2 + ? searchController.text.trim() + : blocWrapper.searchHouseholdsBloc.state.searchQuery, + filter: selectedFilters, + offset: isPagination + ? blocWrapper.houseHoldGlobalSearchBloc.state.offset + : offset, + limit: isPagination + ? blocWrapper.houseHoldGlobalSearchBloc.state.limit + : limit, + householdType: + RegistrationDeliverySingleton().householdType))); } } } From 72d22f97fbc53e7936144a56e1af80d6f08a9cb3 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Tue, 3 Dec 2024 10:48:56 +0530 Subject: [PATCH 07/19] localization code added --- .../lib/utils/i18_key_constants.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/registration_delivery/lib/utils/i18_key_constants.dart b/packages/registration_delivery/lib/utils/i18_key_constants.dart index 880ce5f22..c8e4c62b0 100644 --- a/packages/registration_delivery/lib/utils/i18_key_constants.dart +++ b/packages/registration_delivery/lib/utils/i18_key_constants.dart @@ -125,6 +125,8 @@ class Common { class SearchBeneficiary { const SearchBeneficiary(); + String get searchCLFLabel => 'BENEFICIARY_SEARCH_CLF_LABEL_TEXT'; + String get statisticsLabelText => 'BENEFICIARY_STATISTICS_LABEL_TEXT'; String get searchIndividualLabelText => @@ -405,6 +407,12 @@ class HouseholdOverView { String get householdOverViewLabel => 'HOUSEHOLD_OVER_VIEW_LABEL'; + String get instituteNameLabel => 'HOUSEHOLD_OVER_VIEW_INSTITUTE_NAME_LABEL'; + + String get instituteTypeLabel => 'HOUSEHOLD_OVER_VIEW_INSTITUTE_TYPE_LABEL'; + + String get clfOverviewLabel => 'HOUSEHOLD_OVER_VIEW_CLF_LABEL'; + String get householdOverViewEditLabel => 'HOUSEHOLD_OVER_VIEW_EDIT_ICON_LABEL'; From 589c6f5ab0e392835ba3b27735bdfefcca344912 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Tue, 3 Dec 2024 11:14:16 +0530 Subject: [PATCH 08/19] hcmpre-1249: mapping search query based on the household type --- .../household_overview.dart | 427 ++++++++++++++---- .../individual_global_search.dart | 1 + .../local/household_global_search.dart | 23 +- .../local/individual_global_search.dart | 17 +- .../house_details.dart | 289 ++++++------ .../lib/utils/global_search_parameters.dart | 6 +- .../lib/utils/utils.dart | 12 +- 7 files changed, 535 insertions(+), 240 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart index 92599b6ed..897f2ea7a 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart @@ -15,6 +15,7 @@ import '../../models/entities/household_member.dart'; import '../../models/entities/project_beneficiary.dart'; import '../../models/entities/referral.dart'; import '../../models/entities/side_effect.dart'; +import '../../models/entities/status.dart'; import '../../models/entities/task.dart'; import '../../utils/typedefs.dart'; import '../search_households/search_households.dart'; @@ -305,109 +306,351 @@ class HouseholdOverviewBloc )); return; } + if (event.selectedFilter!.contains(Status.registered.name) || + event.selectedFilter!.contains(Status.notRegistered.name)) { + late List individualClientReferenceIds = []; + + result.forEach((e) { + individualClientReferenceIds.add(e.clientReferenceId); + }); + + List individuals = await individualRepository.search( + IndividualSearchModel( + clientReferenceId: individualClientReferenceIds + .map((e) => e.toString()) + .toList())); + + final projectBeneficiaries = await projectBeneficiaryRepository.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: event.projectBeneficiaryType == + BeneficiaryType.individual + ? individualClientReferenceIds + : [state.householdMemberWrapper.household!.clientReferenceId], + projectId: [event.projectId], + ), + ); + + final beneficiaryClientReferenceIds = projectBeneficiaries + .map((e) => e.beneficiaryClientReferenceId) + .toList(); + + final List beneficiaryIndividuals = individuals + .where((element) => beneficiaryClientReferenceIds + .contains(element.clientReferenceId)) + .toList(); + + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + projectId: event.projectId, + )); + + // Search for adverse events associated with tasks. + final sideEffects = + await sideEffectDataRepository.search(SideEffectSearchModel( + taskClientReferenceId: + tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), + )); + + final referrals = + await referralDataRepository.search(ReferralSearchModel( + projectBeneficiaryClientReferenceId: projectBeneficiaries + .map((e) => e.clientReferenceId) + .whereNotNull() + .toList(), + )); + + emit(state.copyWith( + loading: false, + offset: individuals.isNotEmpty + ? (event.offset ?? 0) + (event.limit ?? 10) + : null, + householdMemberWrapper: state.householdMemberWrapper.copyWith( + members: event.offset == 0 + ? (event.projectBeneficiaryType == BeneficiaryType.individual) + ? beneficiaryIndividuals + : individuals + : [ + ...{ + ...state.householdMemberWrapper.members ?? [], + ...((event.projectBeneficiaryType == + BeneficiaryType.individual) + ? beneficiaryIndividuals + : individuals), + }, + ], + projectBeneficiaries: event.offset == 0 + ? projectBeneficiaries + : [ + ...{ + ...state.householdMemberWrapper.projectBeneficiaries ?? + [], + ...projectBeneficiaries, + }, + ], + tasks: event.offset == 0 + ? tasks + : [ + ...{...?state.householdMemberWrapper.tasks, ...tasks}, + ], + sideEffects: event.offset == 0 + ? sideEffects + : [ + ...{ + ...?state.householdMemberWrapper.sideEffects, + ...sideEffects, + }, + ], + referrals: event.offset == 0 + ? referrals + : [ + ...{ + ...?state.householdMemberWrapper.referrals, + ...referrals, + }, + ], + ), + limit: event.limit, + )); + } else if (event.selectedFilter != null && + event.selectedFilter!.isNotEmpty) { + late List listOfBeneficiaries = []; + for (var e in result) { + !listOfBeneficiaries.contains(e.projectBeneficiaryClientReferenceId) + ? listOfBeneficiaries.add(e.projectBeneficiaryClientReferenceId) + : null; + } + + List projectBeneficiariesList = + await projectBeneficiaryRepository.search( + ProjectBeneficiarySearchModel(projectId: [ + RegistrationDeliverySingleton().projectId.toString() + ], clientReferenceId: listOfBeneficiaries)); + + late List listOfMembers = []; + + listOfMembers = projectBeneficiariesList + .map((e) => e.beneficiaryClientReferenceId.toString()) + .toList(); - late List individualClientReferenceIds = []; + List householdMemberList = + await householdMemberRepository.search(HouseholdMemberSearchModel( + individualClientReferenceId: listOfMembers)); - result.forEach((e) { - individualClientReferenceIds.add(e.clientReferenceId); - }); + final List individualClientReferenceIds = householdMemberList + .map((e) => e.individualClientReferenceId.toString()) + .toList(); - List individuals = await individualRepository.search( + final List individualsList = + await individualRepository.search( IndividualSearchModel( - clientReferenceId: individualClientReferenceIds - .map((e) => e.toString()) - .toList())); + clientReferenceId: individualClientReferenceIds), + ); - final projectBeneficiaries = await projectBeneficiaryRepository.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: - event.projectBeneficiaryType == BeneficiaryType.individual - ? individualClientReferenceIds - : [state.householdMemberWrapper.household!.clientReferenceId], - projectId: [event.projectId], - ), - ); + late List householdClientReferenceIds = []; - final beneficiaryClientReferenceIds = projectBeneficiaries - .map((e) => e.beneficiaryClientReferenceId) - .toList(); + householdClientReferenceIds = householdMemberList + .map((e) => e.householdClientReferenceId.toString()) + .toList(); - final List beneficiaryIndividuals = individuals - .where((element) => - beneficiaryClientReferenceIds.contains(element.clientReferenceId)) - .toList(); + final projectBeneficiaries = await projectBeneficiaryRepository.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: event.projectBeneficiaryType == + BeneficiaryType.individual + ? individualClientReferenceIds + : [state.householdMemberWrapper.household!.clientReferenceId], + projectId: [event.projectId], + ), + ); - final tasks = await taskDataRepository.search(TaskSearchModel( - projectBeneficiaryClientReferenceId: - projectBeneficiaries.map((e) => e.clientReferenceId).toList(), - projectId: event.projectId, - )); + final beneficiaryClientReferenceIds = projectBeneficiaries + .map((e) => e.beneficiaryClientReferenceId) + .toList(); - // Search for adverse events associated with tasks. - final sideEffects = - await sideEffectDataRepository.search(SideEffectSearchModel( - taskClientReferenceId: - tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), - )); + final List beneficiaryIndividuals = individualsList + .where((element) => beneficiaryClientReferenceIds + .contains(element.clientReferenceId)) + .toList(); - final referrals = await referralDataRepository.search(ReferralSearchModel( - projectBeneficiaryClientReferenceId: projectBeneficiaries - .map((e) => e.clientReferenceId) - .whereNotNull() - .toList(), - )); + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + projectId: event.projectId, + )); - emit(state.copyWith( - loading: false, - offset: individuals.isNotEmpty - ? (event.offset ?? 0) + (event.limit ?? 10) - : null, - householdMemberWrapper: state.householdMemberWrapper.copyWith( - members: event.offset == 0 - ? (event.projectBeneficiaryType == BeneficiaryType.individual) - ? beneficiaryIndividuals - : individuals - : [ - ...{ - ...state.householdMemberWrapper.members ?? [], - ...((event.projectBeneficiaryType == - BeneficiaryType.individual) - ? beneficiaryIndividuals - : individuals), - }, - ], - projectBeneficiaries: event.offset == 0 - ? projectBeneficiaries - : [ - ...{ - ...state.householdMemberWrapper.projectBeneficiaries ?? [], - ...projectBeneficiaries, - }, - ], - tasks: event.offset == 0 - ? tasks - : [ - ...{...?state.householdMemberWrapper.tasks, ...tasks}, - ], - sideEffects: event.offset == 0 - ? sideEffects - : [ - ...{ - ...?state.householdMemberWrapper.sideEffects, - ...sideEffects, - }, - ], - referrals: event.offset == 0 - ? referrals - : [ - ...{ - ...?state.householdMemberWrapper.referrals, - ...referrals, - }, - ], - ), - limit: event.limit, - )); + // Search for adverse events associated with tasks. + final sideEffects = + await sideEffectDataRepository.search(SideEffectSearchModel( + taskClientReferenceId: + tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), + )); + + final referrals = + await referralDataRepository.search(ReferralSearchModel( + projectBeneficiaryClientReferenceId: projectBeneficiaries + .map((e) => e.clientReferenceId) + .whereNotNull() + .toList(), + )); + + emit(state.copyWith( + loading: false, + offset: individualsList.isNotEmpty + ? (event.offset ?? 0) + (event.limit ?? 10) + : null, + householdMemberWrapper: state.householdMemberWrapper.copyWith( + members: event.offset == 0 + ? (event.projectBeneficiaryType == BeneficiaryType.individual) + ? beneficiaryIndividuals + : individualsList + : [ + ...{ + ...state.householdMemberWrapper.members ?? [], + ...((event.projectBeneficiaryType == + BeneficiaryType.individual) + ? beneficiaryIndividuals + : individualsList), + }, + ], + projectBeneficiaries: event.offset == 0 + ? projectBeneficiaries + : [ + ...{ + ...state.householdMemberWrapper.projectBeneficiaries ?? + [], + ...projectBeneficiaries, + }, + ], + tasks: event.offset == 0 + ? tasks + : [ + ...{...?state.householdMemberWrapper.tasks, ...tasks}, + ], + sideEffects: event.offset == 0 + ? sideEffects + : [ + ...{ + ...?state.householdMemberWrapper.sideEffects, + ...sideEffects, + }, + ], + referrals: event.offset == 0 + ? referrals + : [ + ...{ + ...?state.householdMemberWrapper.referrals, + ...referrals, + }, + ], + ), + limit: event.limit, + )); + } else { + late List individualClientReferenceIds = []; + + result.forEach((e) { + individualClientReferenceIds.add(e.clientReferenceId); + }); + + List individuals = await individualRepository.search( + IndividualSearchModel( + clientReferenceId: individualClientReferenceIds + .map((e) => e.toString()) + .toList())); + + final projectBeneficiaries = await projectBeneficiaryRepository.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: event.projectBeneficiaryType == + BeneficiaryType.individual + ? individualClientReferenceIds + : [state.householdMemberWrapper.household!.clientReferenceId], + projectId: [event.projectId], + ), + ); + + final beneficiaryClientReferenceIds = projectBeneficiaries + .map((e) => e.beneficiaryClientReferenceId) + .toList(); + + final List beneficiaryIndividuals = individuals + .where((element) => beneficiaryClientReferenceIds + .contains(element.clientReferenceId)) + .toList(); + + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + projectId: event.projectId, + )); + + // Search for adverse events associated with tasks. + final sideEffects = + await sideEffectDataRepository.search(SideEffectSearchModel( + taskClientReferenceId: + tasks.map((e) => e.clientReferenceId).whereNotNull().toList(), + )); + + final referrals = + await referralDataRepository.search(ReferralSearchModel( + projectBeneficiaryClientReferenceId: projectBeneficiaries + .map((e) => e.clientReferenceId) + .whereNotNull() + .toList(), + )); + + emit(state.copyWith( + loading: false, + offset: individuals.isNotEmpty + ? (event.offset ?? 0) + (event.limit ?? 10) + : null, + householdMemberWrapper: state.householdMemberWrapper.copyWith( + members: event.offset == 0 + ? (event.projectBeneficiaryType == BeneficiaryType.individual) + ? beneficiaryIndividuals + : individuals + : [ + ...{ + ...state.householdMemberWrapper.members ?? [], + ...((event.projectBeneficiaryType == + BeneficiaryType.individual) + ? beneficiaryIndividuals + : individuals), + }, + ], + projectBeneficiaries: event.offset == 0 + ? projectBeneficiaries + : [ + ...{ + ...state.householdMemberWrapper.projectBeneficiaries ?? + [], + ...projectBeneficiaries, + }, + ], + tasks: event.offset == 0 + ? tasks + : [ + ...{...?state.householdMemberWrapper.tasks, ...tasks}, + ], + sideEffects: event.offset == 0 + ? sideEffects + : [ + ...{ + ...?state.householdMemberWrapper.sideEffects, + ...sideEffects, + }, + ], + referrals: event.offset == 0 + ? referrals + : [ + ...{ + ...?state.householdMemberWrapper.referrals, + ...referrals, + }, + ], + ), + limit: event.limit, + )); + } } } diff --git a/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart b/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart index 696df872e..a474b4c65 100644 --- a/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart +++ b/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart @@ -61,6 +61,7 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { offset: event.globalSearchParams.offset, limit: event.globalSearchParams.limit, totalCount: state.totalResults, + householdType: event.globalSearchParams.householdType, ), ); diff --git a/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart index 26ffbd225..b3945bb11 100644 --- a/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart @@ -196,6 +196,7 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { params.maxRadius != null) sql.address.longitude.isNotNull(), sql.address.latitude.isNotNull(), + sql.household.householdType.equalsValue(params.householdType) ])) ..orderBy([ if (params.latitude != null && @@ -245,7 +246,7 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { sql.projectBeneficiary, sql.projectBeneficiary.beneficiaryClientReferenceId .equalsExp(sql.household.clientReferenceId)) - ]); + ]).where(sql.household.householdType.equalsValue(params.householdType)); } else if (params.nameSearch != null && params.nameSearch!.isNotEmpty && selectQuery != null) { @@ -283,9 +284,13 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { sql.projectBeneficiary.beneficiaryClientReferenceId .equalsExp(sql.household.clientReferenceId)) ]) - ..where(filter == Status.registered.name - ? sql.projectBeneficiary.beneficiaryClientReferenceId.isNotNull() - : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull()); + ..where(buildAnd([ + sql.household.householdType.equalsValue(params.householdType), + filter == Status.registered.name + ? sql.projectBeneficiary.beneficiaryClientReferenceId + .isNotNull() + : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull() + ])); } else { var filterSearchQuery = await filterTasks(selectQuery, filter, sql, params); @@ -341,9 +346,12 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { sql.household.clientReferenceId .equalsExp(sql.projectBeneficiary.beneficiaryClientReferenceId)) ]) - ..where(sql.task.status.equals( - statusMap[applyFilter]!.toValue(), - )); + ..where(buildAnd([ + sql.household.householdType.equalsValue(params.householdType), + sql.task.status.equals( + statusMap[applyFilter]!.toValue(), + ) + ])); if (!(params.filter!.contains(Status.notRegistered.name))) { selectQuery .where(sql.projectBeneficiary.projectId.equals(params.projectId!)); @@ -409,6 +417,7 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { final address = e.readTableOrNull(sql.address); return HouseholdModel( + householdType: household.householdType, id: household.id, tenantId: household.tenantId, clientReferenceId: household.clientReferenceId, diff --git a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart index 68eb625a0..c1729bb28 100644 --- a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart @@ -169,6 +169,12 @@ class IndividualGlobalSearchRepository extends LocalRepository { } else if (params.isProximityEnabled) { selectQuery = super.sql.individual.select().join([ joinIndividualAddress(sql), + leftOuterJoin(sql.household, + sql.household.householdType.equalsValue(params.householdType)), + leftOuterJoin( + sql.householdMember, + sql.householdMember.individualClientReferenceId + .equalsExp(sql.individual.clientReferenceId)), leftOuterJoin( sql.projectBeneficiary, sql.projectBeneficiary.beneficiaryClientReferenceId @@ -192,6 +198,8 @@ class IndividualGlobalSearchRepository extends LocalRepository { params.maxRadius != null) sql.address.longitude.isNotNull(), sql.address.latitude.isNotNull(), + sql.householdMember.householdClientReferenceId + .equalsExp(sql.household.clientReferenceId), ])) ..orderBy([ if (params.latitude != null && @@ -242,8 +250,11 @@ class IndividualGlobalSearchRepository extends LocalRepository { sql.householdMember.individualClientReferenceId .equalsExp(sql.individual.clientReferenceId)) ]) - ..where(sql.householdMember.householdClientReferenceId - .equals(params.householdClientReferenceId ?? '')); + ..where(buildAnd([ + sql.household.householdType.equalsValue(params.householdType), + sql.householdMember.householdClientReferenceId + .equals(params.householdClientReferenceId ?? '') + ])); } else { selectQuery = selectQuery.join([ leftOuterJoin( @@ -261,7 +272,7 @@ class IndividualGlobalSearchRepository extends LocalRepository { sql.projectBeneficiary, sql.projectBeneficiary.beneficiaryClientReferenceId .equalsExp(sql.household.clientReferenceId)) - ]); + ]).where(sql.household.householdType.equalsValue(params.householdType)); } } else if (params.nameSearch != null && params.nameSearch!.isNotEmpty && diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart index e27689640..0c55f4ba9 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart @@ -65,69 +65,122 @@ class HouseDetailsPageState extends LocalizedState { ], ), footer: DigitCard( - margin: const EdgeInsets.only(top: spacer2), - padding: - const EdgeInsets.all(spacer2), - children: [Button( - onPressed: () { - form.markAllAsTouched(); - if (form.control(_householdStructureKey).value == - null) { - setState(() { - form - .control(_householdStructureKey) - .setErrors({'': true}); - }); - } + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + Button( + onPressed: () { + form.markAllAsTouched(); + if (form.control(_householdStructureKey).value == + null) { + setState(() { + form + .control(_householdStructureKey) + .setErrors({'': true}); + }); + } - if (!form.valid) return; - selectedHouseStructureTypes = - form.control(_householdStructureKey).value; + if (!form.valid) return; + selectedHouseStructureTypes = + form.control(_householdStructureKey).value; - final noOfRooms = - form.control(_noOfRoomsKey).value as int; - registrationState.maybeWhen( - orElse: () { - return; - }, - create: ( - address, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - searchQuery, - loading, - isHeadOfHousehold, - ) { - var houseModel = HouseholdModel( - clientReferenceId: IdGen.i.identifier, - tenantId: - RegistrationDeliverySingleton().tenantId, - rowVersion: 1, - auditDetails: AuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: - context.millisecondsSinceEpoch(), - ), - memberCount: householdModel?.memberCount, - clientAuditDetails: ClientAuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: - context.millisecondsSinceEpoch(), - lastModifiedBy: - RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - additionalFields: HouseholdAdditionalFields( - version: 1, - fields: [ + final noOfRooms = + form.control(_noOfRoomsKey).value as int; + registrationState.maybeWhen( + orElse: () { + return; + }, + create: ( + address, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + searchQuery, + loading, + isHeadOfHousehold, + ) { + var houseModel = HouseholdModel( + householdType: + RegistrationDeliverySingleton() + .householdType, + clientReferenceId: IdGen.i.identifier, + tenantId: RegistrationDeliverySingleton() + .tenantId, + rowVersion: 1, + auditDetails: AuditDetails( + createdBy: + RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: + context.millisecondsSinceEpoch(), + ), + memberCount: householdModel?.memberCount, + clientAuditDetails: ClientAuditDetails( + createdBy: + RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: + context.millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: + context.millisecondsSinceEpoch(), + ), + additionalFields: + HouseholdAdditionalFields( + version: 1, + fields: [ + ...?householdModel + ?.additionalFields?.fields + .where((e) => + e.key != + AdditionalFieldsType + .houseStructureTypes + .toValue() && + e.key != + AdditionalFieldsType + .noOfRooms + .toValue()), + AdditionalField( + AdditionalFieldsType + .houseStructureTypes + .toValue(), + selectedHouseStructureTypes + ?.join("|") + .toString(), + ), + AdditionalField( + AdditionalFieldsType.noOfRooms + .toValue(), + noOfRooms, + ) + ])); + + bloc.add( + BeneficiaryRegistrationSaveHouseDetailsEvent( + model: houseModel, + ), + ); + router.push(HouseHoldDetailsRoute()); + }, + editHousehold: ( + address, + householdModel, + individuals, + registrationDate, + projectBeneficiaryModel, + loading, + headOfHousehold, + ) { + var houseModel = householdModel.copyWith( + additionalFields: + HouseholdAdditionalFields( + version: 1, + fields: [ ...?householdModel - ?.additionalFields?.fields + .additionalFields?.fields .where((e) => e.key != AdditionalFieldsType @@ -151,72 +204,29 @@ class HouseDetailsPageState extends LocalizedState { noOfRooms, ) ])); + // TODO [Linking of Voucher for Household based project need to be handled] - bloc.add( - BeneficiaryRegistrationSaveHouseDetailsEvent( - model: houseModel, - ), - ); - router.push(HouseHoldDetailsRoute()); - }, - editHousehold: ( - address, - householdModel, - individuals, - registrationDate, - projectBeneficiaryModel, - loading, - headOfHousehold, - ) { - var houseModel = householdModel.copyWith( - additionalFields: HouseholdAdditionalFields( - version: 1, - fields: [ - ...?householdModel.additionalFields?.fields - .where((e) => - e.key != - AdditionalFieldsType - .houseStructureTypes - .toValue() && - e.key != - AdditionalFieldsType.noOfRooms - .toValue()), - AdditionalField( - AdditionalFieldsType.houseStructureTypes - .toValue(), - selectedHouseStructureTypes - ?.join("|") - .toString(), + bloc.add( + BeneficiaryRegistrationSaveHouseDetailsEvent( + model: houseModel, ), - AdditionalField( - AdditionalFieldsType.noOfRooms.toValue(), - noOfRooms, - ) - ])); - // TODO [Linking of Voucher for Household based project need to be handled] - - bloc.add( - BeneficiaryRegistrationSaveHouseDetailsEvent( - model: houseModel, - ), + ); + router.push(HouseHoldDetailsRoute()); + }, ); - router.push(HouseHoldDetailsRoute()); }, - ); - }, - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - label: localizations.translate( - i18.householdLocation.actionLabel, - ), - ),] - ), + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + label: localizations.translate( + i18.householdLocation.actionLabel, + ), + ), + ]), slivers: [ SliverToBoxAdapter( - child: DigitCard( - children: [ - Padding( + child: DigitCard(children: [ + Padding( padding: const EdgeInsets.all(spacer2), child: Text( localizations.translate( @@ -235,15 +245,22 @@ class HouseDetailsPageState extends LocalizedState { options: RegistrationDeliverySingleton() .houseStructureTypes ?? [], - initialSelection: form.control(_householdStructureKey).value!= null ? [...form.control(_householdStructureKey).value ] : [], + initialSelection: + form.control(_householdStructureKey).value != + null + ? [ + ...form + .control(_householdStructureKey) + .value + ] + : [], onSelectionChanged: (values) { form .control(_householdStructureKey) .markAsTouched(); if (values.isEmpty) { - form - .control(_householdStructureKey) - .value = null; + form.control(_householdStructureKey).value = + null; setState(() { form .control(_householdStructureKey) @@ -251,9 +268,8 @@ class HouseDetailsPageState extends LocalizedState { }); } else { setState(() { - form - .control(_householdStructureKey) - .value = values; + form.control(_householdStructureKey).value = + values; }); } }, @@ -267,8 +283,7 @@ class HouseDetailsPageState extends LocalizedState { form .control(_householdStructureKey) .touched - ? localizations.translate(i18 - .householdDetails + ? localizations.translate(i18.householdDetails .selectStructureTypeError) : null, ), @@ -276,23 +291,27 @@ class HouseDetailsPageState extends LocalizedState { houseShowcaseData.noOfRooms.buildWith( child: ReactiveWrapperField( formControlName: _noOfRoomsKey, - builder:(field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdDetails.noOfRoomsLabel, ), child: DigitNumericFormInput( minValue: 1, maxValue: 20, - initialValue: form.control(_noOfRoomsKey).value.toString(), + initialValue: form + .control(_noOfRoomsKey) + .value + .toString(), step: 1, - onChange: (value){ - form.control(_noOfRoomsKey).value=int.parse(value); + onChange: (value) { + form.control(_noOfRoomsKey).value = + int.parse(value); }, ), ), ), - ),] - ), + ), + ]), ), ], ); diff --git a/packages/registration_delivery/lib/utils/global_search_parameters.dart b/packages/registration_delivery/lib/utils/global_search_parameters.dart index 69bfadbba..68aeea3f1 100644 --- a/packages/registration_delivery/lib/utils/global_search_parameters.dart +++ b/packages/registration_delivery/lib/utils/global_search_parameters.dart @@ -1,3 +1,5 @@ +import 'package:digit_data_model/models/entities/household_type.dart'; + class GlobalSearchParameters { final String? householdClientReferenceId; final bool isProximityEnabled; @@ -10,6 +12,7 @@ class GlobalSearchParameters { final int? limit; final List? filter; final int? totalCount; + final HouseholdType? householdType; GlobalSearchParameters( {required this.isProximityEnabled, @@ -22,5 +25,6 @@ class GlobalSearchParameters { required this.filter, this.totalCount, this.projectId, - this.householdClientReferenceId}); + this.householdClientReferenceId, + this.householdType}); } diff --git a/packages/registration_delivery/lib/utils/utils.dart b/packages/registration_delivery/lib/utils/utils.dart index b63156444..f57729570 100644 --- a/packages/registration_delivery/lib/utils/utils.dart +++ b/packages/registration_delivery/lib/utils/utils.dart @@ -3,6 +3,7 @@ import 'dart:math'; import 'package:collection/collection.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/utils/date_utils.dart'; import 'package:formula_parser/formula_parser.dart'; import 'package:reactive_forms/reactive_forms.dart'; @@ -132,9 +133,10 @@ bool checkEligibilityForAgeAndSideEffect( : false : false; } else { - if(projectType?.validMaxAge!=null && projectType?.validMinAge!=null){ + if (projectType?.validMaxAge != null && + projectType?.validMinAge != null) { return totalAgeMonths >= projectType!.validMinAge! && - totalAgeMonths <= projectType.validMaxAge! + totalAgeMonths <= projectType.validMaxAge! ? true : false; } @@ -328,6 +330,7 @@ class RegistrationDeliverySingleton { List? _referralReasons; List? _houseStructureTypes; List? _refusalReasons; + HouseholdType? _householdType; void setBoundary({required BoundaryModel boundary}) { _boundaryModel = boundary; @@ -381,6 +384,10 @@ class RegistrationDeliverySingleton { _tenantId = tenantId; } + void setHouseholdType(HouseholdType? householdType) { + _householdType = householdType; + } + String? get tenantId => _tenantId; String? get loggedInUserUuid => _loggedInUserUuid; double? get maxRadius => _maxRadius; @@ -404,6 +411,7 @@ class RegistrationDeliverySingleton { List? get houseStructureTypes => _houseStructureTypes; List? get refusalReasons => _refusalReasons; UserModel? get loggedInUser => _loggedInUser; + HouseholdType? get householdType => _householdType; } bool allDosesDelivered( From 78aab22aab5f023e032952150b2a030287ba933f Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Tue, 3 Dec 2024 12:14:32 +0530 Subject: [PATCH 09/19] fix issues with filter ui and query --- .../household_global_seach.dart | 1 + .../local/individual_global_search.dart | 17 ++- .../pages/beneficiary/household_overview.dart | 144 +++++++++--------- 3 files changed, 88 insertions(+), 74 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/search_households/household_global_seach.dart b/packages/registration_delivery/lib/blocs/search_households/household_global_seach.dart index 11e576113..97bb6ed40 100644 --- a/packages/registration_delivery/lib/blocs/search_households/household_global_seach.dart +++ b/packages/registration_delivery/lib/blocs/search_households/household_global_seach.dart @@ -51,6 +51,7 @@ class HouseHoldGlobalSearchBloc extends SearchHouseholdsBloc { final results = await houseHoldGlobalSearchRepository.houseHoldGlobalSearch( GlobalSearchParameters( + householdType: event.globalSearchParams.householdType, projectId: event.globalSearchParams.projectId, isProximityEnabled: event.globalSearchParams.isProximityEnabled, latitude: event.globalSearchParams.latitude, diff --git a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart index c1729bb28..9a8db602e 100644 --- a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart @@ -304,15 +304,26 @@ class IndividualGlobalSearchRepository extends LocalRepository { if (filter == Status.registered.name || filter == Status.notRegistered.name) { selectQuery = sql.individual.select().join([ + leftOuterJoin(sql.household, + sql.household.householdType.equalsValue(params.householdType)), + leftOuterJoin( + sql.householdMember, + sql.householdMember.individualClientReferenceId + .equalsExp(sql.individual.clientReferenceId)), if (params.nameSearch == null || !params.isProximityEnabled) leftOuterJoin( sql.projectBeneficiary, sql.projectBeneficiary.beneficiaryClientReferenceId .equalsExp(sql.individual.clientReferenceId)) ]) - ..where(filter == Status.registered.name - ? sql.projectBeneficiary.beneficiaryClientReferenceId.isNotNull() - : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull()); + ..where(buildAnd([ + sql.householdMember.householdClientReferenceId + .equalsExp(sql.household.clientReferenceId), + filter == Status.registered.name + ? sql.projectBeneficiary.beneficiaryClientReferenceId + .isNotNull() + : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull() + ])); if (params.householdClientReferenceId != null) { selectQuery = selectQuery.join([ diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 2f68a7998..1902ce521 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -398,63 +398,26 @@ class _HouseholdOverviewPageState // ), // ), // ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.all(spacer2), - child: Text( - RegistrationDeliverySingleton() - .householdType != - null && - RegistrationDeliverySingleton() - .householdType == - HouseholdType.community - ? localizations.translate(i18 - .householdOverView - .clfOverviewLabel) - : localizations.translate(i18 - .householdOverView - .householdOverViewLabel), - style: textTheme.headingXl, - ), - ), - ), - Column( - children: [ - RegistrationDeliverySingleton() - .searchHouseHoldFilter != - null && - RegistrationDeliverySingleton() - .searchHouseHoldFilter! - .isNotEmpty - ? Align( - alignment: Alignment.topLeft, - child: Padding( - padding: const EdgeInsets.all( - spacer2), - child: Button( - label: - getFilterIconNLabel()[ - 'label'], - size: ButtonSize.medium, - type: ButtonType.tertiary, - suffixIcon: - getFilterIconNLabel()[ - 'icon'], - onPressed: () => - showFilterDialog(), - ), - ), - ) - : const Offstage(), - ], + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(spacer2), + child: Text( + RegistrationDeliverySingleton() + .householdType != + null && + RegistrationDeliverySingleton() + .householdType == + HouseholdType.community + ? localizations.translate(i18 + .householdOverView + .clfOverviewLabel) + : localizations.translate(i18 + .householdOverView + .householdOverViewLabel), + style: textTheme.headingXl, ), - ], + ), ), Padding( @@ -558,21 +521,60 @@ class _HouseholdOverviewPageState Padding( padding: const EdgeInsets.only( top: spacer2, bottom: spacer2), - child: DigitSearchBar( - controller: searchController, - hintText: localizations.translate( - i18.common.searchByName, - ), - textCapitalization: - TextCapitalization.words, - onChanged: (value) { - if (value.length >= 3) { - callReloadEvent(offset: 0, limit: 10); - } else if (searchController - .value.text.isEmpty) { - callReloadEvent(offset: 0, limit: 10); - } - }, + child: Row( + children: [ + Expanded( + child: DigitSearchBar( + controller: searchController, + hintText: localizations.translate( + i18.common.searchByName, + ), + textCapitalization: + TextCapitalization.words, + onChanged: (value) { + if (value.length >= 3) { + callReloadEvent( + offset: 0, limit: 10); + } else if (searchController + .value.text.isEmpty) { + callReloadEvent( + offset: 0, limit: 10); + } + }, + ), + ), + Column( + children: [ + RegistrationDeliverySingleton() + .searchHouseHoldFilter != + null && + RegistrationDeliverySingleton() + .searchHouseHoldFilter! + .isNotEmpty + ? Align( + alignment: Alignment.topLeft, + child: Padding( + padding: + const EdgeInsets.all( + spacer2), + child: Button( + label: + getFilterIconNLabel()[ + 'label'], + size: ButtonSize.medium, + type: ButtonType.tertiary, + suffixIcon: + getFilterIconNLabel()[ + 'icon'], + onPressed: () => + showFilterDialog(), + ), + ), + ) + : const Offstage(), + ], + ), + ], ), ), selectedFilters.isNotEmpty From f5510130a6bfc8ad0b56af9776c3bb1598df1762 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 5 Dec 2024 07:46:59 +0530 Subject: [PATCH 10/19] added ui changes and mapping head of household search for clf --- .../household_overview.dart | 1 + .../search_households/search_households.dart | 6 + .../local/individual_global_search.dart | 14 +- .../pages/beneficiary/household_overview.dart | 12 +- .../house_details.dart | 22 +- .../household_details.dart | 613 +++++------ .../household_location.dart | 379 +++---- .../individual_details.dart | 990 +++++++++--------- .../lib/pages/search_beneficiary.dart | 193 ++-- .../lib/pages/summary_page.dart | 383 +++---- .../lib/utils/i18_key_constants.dart | 13 + .../beneficiary/view_beneficiary_card.dart | 76 +- 12 files changed, 1415 insertions(+), 1287 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart index 897f2ea7a..86209f1f3 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart @@ -278,6 +278,7 @@ class HouseholdOverviewBloc } else { final totalResult = await individualGlobalSearchRepository .individualGlobalSearch(GlobalSearchParameters( + householdType: RegistrationDeliverySingleton().householdType, householdClientReferenceId: state.householdMemberWrapper.household!.clientReferenceId, isProximityEnabled: false, diff --git a/packages/registration_delivery/lib/blocs/search_households/search_households.dart b/packages/registration_delivery/lib/blocs/search_households/search_households.dart index ed259aa84..0a14359fe 100644 --- a/packages/registration_delivery/lib/blocs/search_households/search_households.dart +++ b/packages/registration_delivery/lib/blocs/search_households/search_households.dart @@ -3,9 +3,11 @@ import 'dart:async'; import 'package:collection/collection.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_data_model/utils/typedefs.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:registration_delivery/registration_delivery.dart'; import 'package:stream_transform/stream_transform.dart'; import '../../data/repositories/local/household_global_search.dart'; @@ -184,6 +186,10 @@ class SearchHouseholdsBloc HouseholdMemberSearchModel( individualClientReferenceIds: individualClientReferenceIds, householdClientReferenceIds: householdClientReferenceIds, + isHeadOfHousehold: RegistrationDeliverySingleton().householdType == + HouseholdType.community + ? true + : null, ), ); } diff --git a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart index 9a8db602e..79161d756 100644 --- a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:math' as math; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:drift/drift.dart'; import 'package:flutter/material.dart'; @@ -181,6 +182,8 @@ class IndividualGlobalSearchRepository extends LocalRepository { .equalsExp(sql.individual.clientReferenceId)) ]) ..where(buildAnd([ + if (params.householdType == HouseholdType.community) + sql.householdMember.isHeadOfHousehold.equals(true), sql.address.relatedClientReferenceId.isNotNull(), sql.individual.clientReferenceId.isNotNull(), if (params.latitude != null && @@ -261,8 +264,7 @@ class IndividualGlobalSearchRepository extends LocalRepository { sql.householdMember, sql.householdMember.individualClientReferenceId .equalsExp(sql.individual.clientReferenceId)) - ]) - ..where(sql.householdMember.isHeadOfHousehold.equals(true)); + ]); selectQuery.join([ leftOuterJoin( sql.household, @@ -272,7 +274,11 @@ class IndividualGlobalSearchRepository extends LocalRepository { sql.projectBeneficiary, sql.projectBeneficiary.beneficiaryClientReferenceId .equalsExp(sql.household.clientReferenceId)) - ]).where(sql.household.householdType.equalsValue(params.householdType)); + ]).where(buildAnd([ + if (params.householdType == HouseholdType.community) + sql.householdMember.isHeadOfHousehold.equals(true), + sql.household.householdType.equalsValue(params.householdType) + ])); } } else if (params.nameSearch != null && params.nameSearch!.isNotEmpty && @@ -317,6 +323,8 @@ class IndividualGlobalSearchRepository extends LocalRepository { .equalsExp(sql.individual.clientReferenceId)) ]) ..where(buildAnd([ + if (params.householdType == HouseholdType.community) + sql.householdMember.isHeadOfHousehold.equals(true), sql.householdMember.householdClientReferenceId .equalsExp(sql.household.clientReferenceId), filter == Status.registered.name diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 1902ce521..a90de0ed6 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -432,11 +432,8 @@ class _HouseholdOverviewPageState BeneficiaryType.household; if (RegistrationDeliverySingleton() - .householdType != - null && - RegistrationDeliverySingleton() - .householdType == - HouseholdType.community) { + .householdType == + HouseholdType.community) { return Column( children: [ DigitTableCard(element: { @@ -449,11 +446,6 @@ class _HouseholdOverviewPageState ?.givenName ?? localizations.translate( i18.common.coreCommonNA), - localizations.translate(i18 - .householdOverView - .instituteTypeLabel): - RegistrationDeliverySingleton() - .householdType, localizations.translate( i18.deliverIntervention .memberCountText, diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart index 0c55f4ba9..076be78f4 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart @@ -1,5 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/digit_components.dart'; import 'package:digit_ui_components/theme/digit_extended_theme.dart'; import 'package:digit_ui_components/widgets/atoms/selection_card.dart'; @@ -163,7 +164,14 @@ class HouseDetailsPageState extends LocalizedState { model: houseModel, ), ); - router.push(HouseHoldDetailsRoute()); + if (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) { + router.push(IndividualDetailsRoute( + isHeadOfHousehold: true)); + } else { + router.push(HouseHoldDetailsRoute()); + } }, editHousehold: ( address, @@ -211,7 +219,17 @@ class HouseDetailsPageState extends LocalizedState { model: houseModel, ), ); - router.push(HouseHoldDetailsRoute()); + if (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) { + router.push(IndividualDetailsRoute( + isHeadOfHousehold: + headOfHousehold != null + ? true + : false)); + } else { + router.push(HouseHoldDetailsRoute()); + } }, ); }, diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart index c4946bafe..62245ad9b 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart @@ -58,28 +58,24 @@ class HouseHoldDetailsPageState extends LocalizedState { return BlocConsumer( listener: (context, state) { - if (state is BeneficiaryRegistrationPersistedState && state.isEdit) { - final overviewBloc = - context.read(); + if (state is BeneficiaryRegistrationPersistedState && + state.isEdit) { + final overviewBloc = context.read(); overviewBloc.add( HouseholdOverviewReloadEvent( - projectId: RegistrationDeliverySingleton() - .projectId - .toString(), + projectId: + RegistrationDeliverySingleton().projectId.toString(), projectBeneficiaryType: - RegistrationDeliverySingleton() - .beneficiaryType ?? - BeneficiaryType.household, + RegistrationDeliverySingleton().beneficiaryType ?? + BeneficiaryType.household, ), ); HouseholdMemberWrapper memberWrapper = overviewBloc.state.householdMemberWrapper; final route = router.parent() as StackRouter; - route.popUntilRouteWithName( - SearchBeneficiaryRoute.name); - route.push(BeneficiaryWrapperRoute( - wrapper: memberWrapper)); + route.popUntilRouteWithName(SearchBeneficiaryRoute.name); + route.push(BeneficiaryWrapperRoute(wrapper: memberWrapper)); } }, builder: (context, registrationState) { @@ -92,282 +88,294 @@ class HouseHoldDetailsPageState extends LocalizedState { ]), enableFixedButton: true, footer: DigitCard( - margin: const EdgeInsets.only(top: spacer2), - padding: const EdgeInsets.all(spacer2), - children: [Button( - label: registrationState.mapOrNull( - editHousehold: (value) => localizations - .translate(i18.common.coreCommonSave), - ) ?? - localizations - .translate(i18.householdDetails.actionLabel), - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () { - form.markAllAsTouched(); - if (!form.valid) return; + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + Button( + label: registrationState.mapOrNull( + editHousehold: (value) => localizations + .translate(i18.common.coreCommonSave), + ) ?? + localizations + .translate(i18.householdDetails.actionLabel), + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () { + form.markAllAsTouched(); + if (!form.valid) return; - final memberCount = - form.control(_memberCountKey).value as int; + final memberCount = + form.control(_memberCountKey).value as int; - final dateOfRegistration = form - .control(_dateOfRegistrationKey) - .value as DateTime; - //[TODO: Use pregnant women form value based on project config - final pregnantWomen = - form.control(_pregnantWomenCountKey).value as int; - final children = - form.control(_childrenCountKey).value as int; + final dateOfRegistration = form + .control(_dateOfRegistrationKey) + .value as DateTime; + //[TODO: Use pregnant women form value based on project config + final pregnantWomen = + form.control(_pregnantWomenCountKey).value as int; + final children = + form.control(_childrenCountKey).value as int; - if (memberCount < (pregnantWomen + children)) { - Toast.showToast( - context, - message: localizations.translate( + if (memberCount < (pregnantWomen + children)) { + Toast.showToast(context, + message: localizations.translate( i18.householdDetails.memberCountError), - type: ToastType.error - ); - } else { - registrationState.maybeWhen( - orElse: () { - return; - }, - create: ( - addressModel, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - searchQuery, - loading, - isHeadOfHousehold, - ) { - var household = householdModel; - household ??= HouseholdModel( - tenantId: - RegistrationDeliverySingleton().tenantId, - clientReferenceId: - householdModel?.clientReferenceId ?? - IdGen.i.identifier, - rowVersion: 1, - clientAuditDetails: ClientAuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: context.millisecondsSinceEpoch(), - lastModifiedBy: RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - auditDetails: AuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: context.millisecondsSinceEpoch(), - lastModifiedBy: RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - ); + type: ToastType.error); + } else { + registrationState.maybeWhen( + orElse: () { + return; + }, + create: ( + addressModel, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + searchQuery, + loading, + isHeadOfHousehold, + ) { + var household = householdModel; + household ??= HouseholdModel( + tenantId: + RegistrationDeliverySingleton().tenantId, + clientReferenceId: + householdModel?.clientReferenceId ?? + IdGen.i.identifier, + rowVersion: 1, + clientAuditDetails: ClientAuditDetails( + createdBy: RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: + context.millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: + context.millisecondsSinceEpoch(), + ), + auditDetails: AuditDetails( + createdBy: RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: + context.millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: + context.millisecondsSinceEpoch(), + ), + ); - household = household.copyWith( - rowVersion: 1, - tenantId: - RegistrationDeliverySingleton().tenantId, - clientReferenceId: - householdModel?.clientReferenceId ?? - IdGen.i.identifier, - memberCount: memberCount, - clientAuditDetails: ClientAuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid - .toString(), - createdTime: context.millisecondsSinceEpoch(), - lastModifiedBy: - RegistrationDeliverySingleton() + household = household.copyWith( + rowVersion: 1, + tenantId: RegistrationDeliverySingleton() + .tenantId, + clientReferenceId: + householdModel?.clientReferenceId ?? + IdGen.i.identifier, + memberCount: memberCount, + clientAuditDetails: ClientAuditDetails( + createdBy: RegistrationDeliverySingleton() .loggedInUserUuid .toString(), - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - auditDetails: AuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid - .toString(), - createdTime: context.millisecondsSinceEpoch(), - lastModifiedBy: - RegistrationDeliverySingleton() + createdTime: + context.millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid + .toString(), + lastModifiedTime: + context.millisecondsSinceEpoch(), + ), + auditDetails: AuditDetails( + createdBy: RegistrationDeliverySingleton() .loggedInUserUuid .toString(), - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - address: addressModel, - additionalFields: HouseholdAdditionalFields( - version: 1, - fields: [ - //[TODO: Use pregnant women form value based on project config - ...?householdModel - ?.additionalFields?.fields - .where((e) => - e.key != - AdditionalFieldsType - .pregnantWomen - .toValue() && - e.key != - AdditionalFieldsType.children - .toValue()), - AdditionalField( - AdditionalFieldsType.pregnantWomen - .toValue(), - pregnantWomen, - ), - AdditionalField( - AdditionalFieldsType.children.toValue(), - children, - ) - ])); + createdTime: + context.millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid + .toString(), + lastModifiedTime: + context.millisecondsSinceEpoch(), + ), + address: addressModel, + additionalFields: HouseholdAdditionalFields( + version: 1, + fields: [ + //[TODO: Use pregnant women form value based on project config + ...?householdModel + ?.additionalFields?.fields + .where((e) => + e.key != + AdditionalFieldsType + .pregnantWomen + .toValue() && + e.key != + AdditionalFieldsType + .children + .toValue()), + AdditionalField( + AdditionalFieldsType.pregnantWomen + .toValue(), + pregnantWomen, + ), + AdditionalField( + AdditionalFieldsType.children + .toValue(), + children, + ) + ])); - bloc.add( - BeneficiaryRegistrationSaveHouseholdDetailsEvent( - household: household, - registrationDate: dateOfRegistration, - ), - ); - context.router.push( - IndividualDetailsRoute(isHeadOfHousehold: true), - ); - }, - editHousehold: ( - addressModel, - householdModel, - individuals, - registrationDate, - projectBeneficiaryModel, - loading, - isHeadOfHousehold, - ) { - var household = householdModel.copyWith( - memberCount: memberCount, - address: addressModel, - clientAuditDetails: (householdModel - .clientAuditDetails - ?.createdBy != - null && - householdModel.clientAuditDetails - ?.createdTime != - null) - ? ClientAuditDetails( - createdBy: householdModel - .clientAuditDetails!.createdBy, - createdTime: householdModel - .clientAuditDetails!.createdTime, - lastModifiedBy: - RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: DateTime.now() - .millisecondsSinceEpoch, - ) - : null, - rowVersion: householdModel.rowVersion, - additionalFields: HouseholdAdditionalFields( - version: householdModel - .additionalFields?.version ?? - 1, - fields: [ - //[TODO: Use pregnant women form value based on project config - ...?householdModel - .additionalFields?.fields - .where((e) => - e.key != - AdditionalFieldsType - .pregnantWomen - .toValue() && - e.key != - AdditionalFieldsType.children - .toValue()), - AdditionalField( - AdditionalFieldsType.pregnantWomen - .toValue(), - pregnantWomen, - ), - AdditionalField( - AdditionalFieldsType.children.toValue(), - children, - ) - ])); + bloc.add( + BeneficiaryRegistrationSaveHouseholdDetailsEvent( + household: household, + registrationDate: dateOfRegistration, + ), + ); + context.router.push( + IndividualDetailsRoute( + isHeadOfHousehold: true), + ); + }, + editHousehold: ( + addressModel, + householdModel, + individuals, + registrationDate, + projectBeneficiaryModel, + loading, + isHeadOfHousehold, + ) { + var household = householdModel.copyWith( + memberCount: memberCount, + address: addressModel, + clientAuditDetails: (householdModel + .clientAuditDetails + ?.createdBy != + null && + householdModel.clientAuditDetails + ?.createdTime != + null) + ? ClientAuditDetails( + createdBy: householdModel + .clientAuditDetails!.createdBy, + createdTime: householdModel + .clientAuditDetails! + .createdTime, + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: DateTime.now() + .millisecondsSinceEpoch, + ) + : null, + rowVersion: householdModel.rowVersion, + additionalFields: HouseholdAdditionalFields( + version: householdModel + .additionalFields?.version ?? + 1, + fields: [ + //[TODO: Use pregnant women form value based on project config + ...?householdModel + .additionalFields?.fields + .where((e) => + e.key != + AdditionalFieldsType + .pregnantWomen + .toValue() && + e.key != + AdditionalFieldsType + .children + .toValue()), + AdditionalField( + AdditionalFieldsType.pregnantWomen + .toValue(), + pregnantWomen, + ), + AdditionalField( + AdditionalFieldsType.children + .toValue(), + children, + ) + ])); - bloc.add( - BeneficiaryRegistrationUpdateHouseholdDetailsEvent( - household: household.copyWith( - clientAuditDetails: (addressModel - .clientAuditDetails - ?.createdBy != - null && - addressModel.clientAuditDetails - ?.createdTime != - null) - ? ClientAuditDetails( - createdBy: addressModel - .clientAuditDetails!.createdBy, - createdTime: addressModel - .clientAuditDetails!.createdTime, - lastModifiedBy: - RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ) - : null, - ), - addressModel: addressModel.copyWith( - clientAuditDetails: (addressModel - .clientAuditDetails - ?.createdBy != - null && - addressModel.clientAuditDetails - ?.createdTime != - null) - ? ClientAuditDetails( - createdBy: addressModel - .clientAuditDetails!.createdBy, - createdTime: addressModel - .clientAuditDetails!.createdTime, - lastModifiedBy: - RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ) - : null, - ), - ), + bloc.add( + BeneficiaryRegistrationUpdateHouseholdDetailsEvent( + household: household.copyWith( + clientAuditDetails: (addressModel + .clientAuditDetails + ?.createdBy != + null && + addressModel.clientAuditDetails + ?.createdTime != + null) + ? ClientAuditDetails( + createdBy: addressModel + .clientAuditDetails! + .createdBy, + createdTime: addressModel + .clientAuditDetails! + .createdTime, + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ) + : null, + ), + addressModel: addressModel.copyWith( + clientAuditDetails: (addressModel + .clientAuditDetails + ?.createdBy != + null && + addressModel.clientAuditDetails + ?.createdTime != + null) + ? ClientAuditDetails( + createdBy: addressModel + .clientAuditDetails! + .createdBy, + createdTime: addressModel + .clientAuditDetails! + .createdTime, + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ) + : null, + ), + ), + ); + }, ); - - }, - ); - } - }, - ),] - ), + } + }, + ), + ]), slivers: [ SliverToBoxAdapter( - child: DigitCard( - children: [ - DigitTextBlock( - padding: const EdgeInsets.all(spacer2), - heading: localizations.translate( - i18.householdDetails.householdDetailsLabel, - ), - description: localizations.translate( - i18.householdDetails.householdDetailsDescription, + child: DigitCard(children: [ + DigitTextBlock( + padding: const EdgeInsets.all(spacer2), + heading: localizations.translate( + i18.householdDetails.householdDetailsLabel, + ), + description: localizations.translate( + i18.householdDetails.householdDetailsDescription, ), ), - householdDetailsShowcaseData.dateOfRegistration - .buildWith( + householdDetailsShowcaseData.dateOfRegistration.buildWith( child: ReactiveWrapperField( formControlName: _dateOfRegistrationKey, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdDetails.dateOfRegistrationLabel, ), @@ -379,8 +387,12 @@ class HouseHoldDetailsPageState extends LocalizedState { cancelText: localizations.translate( i18.common.coreCommonCancel, ), - initialValue: DateFormat(Constants().dateMonthYearFormat) - .format(form.control(_dateOfRegistrationKey).value).toString(), + initialValue: + DateFormat(Constants().dateMonthYearFormat) + .format(form + .control(_dateOfRegistrationKey) + .value) + .toString(), ), ), ), @@ -391,21 +403,23 @@ class HouseHoldDetailsPageState extends LocalizedState { .buildWith( child: ReactiveWrapperField( formControlName: _pregnantWomenCountKey, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( - i18.householdDetails - .noOfPregnantWomenCountLabel, + i18.householdDetails.noOfPregnantWomenCountLabel, ), child: DigitNumericFormInput( minValue: 0, maxValue: 10, step: 1, - initialValue: form.control(_pregnantWomenCountKey).value.toString(), + initialValue: form + .control(_pregnantWomenCountKey) + .value + .toString(), onChange: (value) { - form.control(_pregnantWomenCountKey).value=int.parse(value); - int pregnantWomen = form - .control(_pregnantWomenCountKey) - .value; + form.control(_pregnantWomenCountKey).value = + int.parse(value); + int pregnantWomen = + form.control(_pregnantWomenCountKey).value; int children = form.control(_childrenCountKey).value; int memberCount = @@ -424,21 +438,23 @@ class HouseHoldDetailsPageState extends LocalizedState { .buildWith( child: ReactiveWrapperField( formControlName: _childrenCountKey, - builder: (field)=>LabeledField( + builder: (field) => LabeledField( label: localizations.translate( - i18.householdDetails - .noOfChildrenBelow5YearsLabel, + i18.householdDetails.noOfChildrenBelow5YearsLabel, ), child: DigitNumericFormInput( minValue: 0, maxValue: 20, step: 1, - initialValue: form.control(_childrenCountKey).value.toString(), + initialValue: form + .control(_childrenCountKey) + .value + .toString(), onChange: (value) { - form.control(_childrenCountKey).value=int.parse(value); - int pregnantWomen = form - .control(_pregnantWomenCountKey) - .value; + form.control(_childrenCountKey).value = + int.parse(value); + int pregnantWomen = + form.control(_pregnantWomenCountKey).value; int children = form.control(_childrenCountKey).value; int memberCount = @@ -457,7 +473,7 @@ class HouseHoldDetailsPageState extends LocalizedState { .buildWith( child: ReactiveWrapperField( formControlName: _memberCountKey, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdDetails.noOfMembersCountLabel, ), @@ -467,12 +483,15 @@ class HouseHoldDetailsPageState extends LocalizedState { : 1, maxValue: 30, step: 1, - initialValue: form.control(_memberCountKey).value.toString(), + initialValue: form + .control(_memberCountKey) + .value + .toString(), onChange: (value) { - form.control(_memberCountKey).value=int.parse(value); - int pregnantWomen = form - .control(_pregnantWomenCountKey) - .value; + form.control(_memberCountKey).value = + int.parse(value); + int pregnantWomen = + form.control(_pregnantWomenCountKey).value; int children = form.control(_childrenCountKey).value; int memberCount = @@ -486,8 +505,8 @@ class HouseHoldDetailsPageState extends LocalizedState { ), ), ), - const SizedBox(height: 16),] - ), + const SizedBox(height: 16), + ]), ), ], ); diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index ab80f99dc..f17024fa8 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -1,6 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:digit_data_model/data_model.dart'; import 'package:digit_data_model/models/entities/address_type.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/blocs/fetch_location_bloc.dart'; import 'package:digit_ui_components/digit_components.dart'; import 'package:digit_ui_components/utils/component_utils.dart'; @@ -117,184 +118,197 @@ class HouseholdLocationPageState extends LocalizedState { ], ), footer: DigitCard( - margin: const EdgeInsets.only(top: spacer2), - padding: const EdgeInsets.all(spacer2), - children: [BlocBuilder( - builder: (context, locationState) { - return Button( - label: localizations.translate( - i18.householdLocation.actionLabel, - ), - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () { - form.markAllAsTouched(); - if (!form.valid) return; + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + BlocBuilder( + builder: (context, locationState) { + return Button( + label: localizations.translate( + i18.householdLocation.actionLabel, + ), + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () { + form.markAllAsTouched(); + if (!form.valid) return; - final addressLine1 = - form.control(_addressLine1Key).value as String?; - final addressLine2 = - form.control(_addressLine2Key).value as String?; - final landmark = - form.control(_landmarkKey).value as String?; - final postalCode = - form.control(_postalCodeKey).value as String?; - registrationState.maybeWhen( - orElse: () { - return; - }, - create: ( - address, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - searchQuery, - loading, - isHeadOfHousehold, - ) { - var addressModel = AddressModel( - addressLine1: addressLine1 != null && - addressLine1.trim().isNotEmpty - ? addressLine1 - : null, - addressLine2: addressLine2 != null && - addressLine2.trim().isNotEmpty - ? addressLine2 - : null, - landmark: - landmark != null && landmark.trim().isNotEmpty + final addressLine1 = + form.control(_addressLine1Key).value as String?; + final addressLine2 = + form.control(_addressLine2Key).value as String?; + final landmark = + form.control(_landmarkKey).value as String?; + final postalCode = + form.control(_postalCodeKey).value as String?; + registrationState.maybeWhen( + orElse: () { + return; + }, + create: ( + address, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + searchQuery, + loading, + isHeadOfHousehold, + ) { + var addressModel = AddressModel( + addressLine1: addressLine1 != null && + addressLine1.trim().isNotEmpty + ? addressLine1 + : null, + addressLine2: addressLine2 != null && + addressLine2.trim().isNotEmpty + ? addressLine2 + : null, + landmark: landmark != null && + landmark.trim().isNotEmpty ? landmark : null, - pincode: postalCode != null && - postalCode.trim().isNotEmpty - ? postalCode - : null, - type: AddressType.correspondence, - latitude: form.control(_latKey).value ?? - locationState.latitude, - longitude: form.control(_lngKey).value ?? - locationState.longitude, - locationAccuracy: - form.control(_accuracyKey).value ?? - locationState.accuracy, - locality: LocalityModel( - code: RegistrationDeliverySingleton() - .boundary! - .code!, - name: RegistrationDeliverySingleton() - .boundary! - .name, - ), - tenantId: - RegistrationDeliverySingleton().tenantId, - rowVersion: 1, - auditDetails: AuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: context.millisecondsSinceEpoch(), - ), - clientAuditDetails: ClientAuditDetails( - createdBy: RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: context.millisecondsSinceEpoch(), - lastModifiedBy: RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - ); + pincode: postalCode != null && + postalCode.trim().isNotEmpty + ? postalCode + : null, + type: AddressType.correspondence, + latitude: form.control(_latKey).value ?? + locationState.latitude, + longitude: form.control(_lngKey).value ?? + locationState.longitude, + locationAccuracy: + form.control(_accuracyKey).value ?? + locationState.accuracy, + locality: LocalityModel( + code: RegistrationDeliverySingleton() + .boundary! + .code!, + name: RegistrationDeliverySingleton() + .boundary! + .name, + ), + tenantId: + RegistrationDeliverySingleton().tenantId, + rowVersion: 1, + auditDetails: AuditDetails( + createdBy: RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: + context.millisecondsSinceEpoch(), + ), + clientAuditDetails: ClientAuditDetails( + createdBy: RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: + context.millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: + context.millisecondsSinceEpoch(), + ), + ); - bloc.add( - BeneficiaryRegistrationSaveAddressEvent( - addressModel, - ), - ); - router.push(HouseDetailsRoute()); - }, - editHousehold: ( - address, - householdModel, - individuals, - registrationDate, - projectBeneficiaryModel, - loading, - headOfHousehold, - ) { - var addressModel = address.copyWith( - addressLine1: addressLine1 != null && - addressLine1.trim().isNotEmpty - ? addressLine1 - : null, - addressLine2: addressLine2 != null && - addressLine2.trim().isNotEmpty - ? addressLine2 - : null, - landmark: - landmark != null && landmark.trim().isNotEmpty + bloc.add( + BeneficiaryRegistrationSaveAddressEvent( + addressModel, + ), + ); + router.push(HouseDetailsRoute()); + }, + editHousehold: ( + address, + householdModel, + individuals, + registrationDate, + projectBeneficiaryModel, + loading, + headOfHousehold, + ) { + var addressModel = address.copyWith( + addressLine1: addressLine1 != null && + addressLine1.trim().isNotEmpty + ? addressLine1 + : null, + addressLine2: addressLine2 != null && + addressLine2.trim().isNotEmpty + ? addressLine2 + : null, + landmark: landmark != null && + landmark.trim().isNotEmpty ? landmark : null, - locality: address.locality, - pincode: postalCode != null && - postalCode.trim().isNotEmpty - ? postalCode - : null, - type: AddressType.correspondence, - latitude: form.control(_latKey).value, - longitude: form.control(_lngKey).value, - locationAccuracy: - form.control(_accuracyKey).value, - ); - // TODO [Linking of Voucher for Household based project need to be handled] + locality: address.locality, + pincode: postalCode != null && + postalCode.trim().isNotEmpty + ? postalCode + : null, + type: AddressType.correspondence, + latitude: form.control(_latKey).value, + longitude: form.control(_lngKey).value, + locationAccuracy: + form.control(_accuracyKey).value, + ); + // TODO [Linking of Voucher for Household based project need to be handled] - bloc.add( - BeneficiaryRegistrationSaveAddressEvent( - addressModel, - ), + bloc.add( + BeneficiaryRegistrationSaveAddressEvent( + addressModel, + ), + ); + router.push(HouseDetailsRoute()); + }, ); - router.push(HouseDetailsRoute()); }, ); }, - ); - }, - ),] - ), + ), + ]), slivers: [ SliverToBoxAdapter( - child: DigitCard( - children: [ - DigitTextBlock( + child: DigitCard(children: [ + DigitTextBlock( padding: const EdgeInsets.only(top: spacer2), - heading: localizations.translate( - i18.householdLocation.householdLocationLabelText, - ), - description: localizations.translate( - i18.householdLocation - .householdLocationDescriptionText, - )), - householdLocationShowcaseData.administrativeArea - .buildWith( + heading: + (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? localizations.translate( + i18.householdLocation.clfLocationLabelText) + : localizations.translate( + i18.householdLocation + .householdLocationLabelText, + ), + description: + (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? null + : localizations.translate( + i18.householdLocation + .householdLocationDescriptionText, + )), + householdLocationShowcaseData.administrativeArea.buildWith( child: ReactiveWrapperField( formControlName: _administrationAreaKey, validationMessages: { 'required': (_) => localizations.translate( - i18.householdLocation - .administrationAreaRequiredValidation, - ), + i18.householdLocation + .administrationAreaRequiredValidation, + ), }, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( - i18.householdLocation - .administrationAreaFormLabel, + i18.householdLocation.administrationAreaFormLabel, ), child: DigitTextFormInput( readOnly: true, errorMessage: field.errorText, - initialValue: form.control(_administrationAreaKey).value, - onChange: (value){ - form.control(_administrationAreaKey).value=value; + initialValue: + form.control(_administrationAreaKey).value, + onChange: (value) { + form.control(_administrationAreaKey).value = + value; }, ), ), @@ -305,17 +319,18 @@ class HouseholdLocationPageState extends LocalizedState { formControlName: _accuracyKey, validationMessages: { 'required': (_) => localizations.translate( - i18.common.corecommonRequired, - ), + i18.common.corecommonRequired, + ), }, - builder: (field)=>LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdLocation.gpsAccuracyLabel, ), child: DigitTextFormInput( readOnly: true, errorMessage: field.errorText, - initialValue: form.control(_accuracyKey).value.toString(), + initialValue: + form.control(_accuracyKey).value.toString(), ), ), ), @@ -325,21 +340,21 @@ class HouseholdLocationPageState extends LocalizedState { formControlName: _addressLine1Key, validationMessages: { 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), + i18.common.min2CharsRequired, + ), 'maxLength': (object) => localizations .translate(i18.common.maxCharsRequired) .replaceAll('{}', maxLength.toString()), }, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdLocation .householdAddressLine1LabelText, ), child: DigitTextFormInput( errorMessage: field.errorText, - onChange: (value){ - form.control(_addressLine1Key).value=value; + onChange: (value) { + form.control(_addressLine1Key).value = value; }, initialValue: form.control(_addressLine1Key).value, ), @@ -351,21 +366,21 @@ class HouseholdLocationPageState extends LocalizedState { formControlName: _addressLine2Key, validationMessages: { 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), + i18.common.min2CharsRequired, + ), 'maxLength': (object) => localizations .translate(i18.common.maxCharsRequired) .replaceAll('{}', maxLength.toString()), }, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdLocation .householdAddressLine2LabelText, ), child: DigitTextFormInput( errorMessage: field.errorText, - onChange: (value){ - form.control(_addressLine2Key).value=value; + onChange: (value) { + form.control(_addressLine2Key).value = value; }, initialValue: form.control(_addressLine2Key).value, ), @@ -377,20 +392,20 @@ class HouseholdLocationPageState extends LocalizedState { formControlName: _landmarkKey, validationMessages: { 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), + i18.common.min2CharsRequired, + ), 'maxLength': (object) => localizations .translate(i18.common.maxCharsRequired) .replaceAll('{}', maxLength.toString()), }, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdLocation.landmarkFormLabel, ), child: DigitTextFormInput( errorMessage: field.errorText, - onChange: (value){ - form.control(_landmarkKey).value=value; + onChange: (value) { + form.control(_landmarkKey).value = value; }, initialValue: form.control(_landmarkKey).value, ), @@ -402,13 +417,13 @@ class HouseholdLocationPageState extends LocalizedState { formControlName: _postalCodeKey, validationMessages: { 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), + i18.common.min2CharsRequired, + ), 'maxLength': (object) => localizations .translate(i18.common.maxCharsRequired) .replaceAll('{}', '6'), }, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( i18.householdLocation.postalCodeFormLabel, ), @@ -418,16 +433,16 @@ class HouseholdLocationPageState extends LocalizedState { FilteringTextInputFormatter.digitsOnly, ], errorMessage: field.errorText, - onChange: (value){ - form.control(_postalCodeKey).value=value; + onChange: (value) { + form.control(_postalCodeKey).value = value; }, maxLength: 6, initialValue: form.control(_postalCodeKey).value, ), ), ), - ),] - ), + ), + ]), ), ], ), @@ -444,8 +459,8 @@ class HouseholdLocationPageState extends LocalizedState { return fb.group({ _administrationAreaKey: FormControl( - value: localizations.translate( - RegistrationDeliverySingleton().boundary!.code ?? ''), + value: localizations + .translate(RegistrationDeliverySingleton().boundary!.code ?? ''), validators: [Validators.required], ), _addressLine1Key: diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart index a77e1f777..4da08d07b 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart @@ -1,6 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:collection/collection.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_scanner/blocs/scanner.dart'; import 'package:digit_scanner/pages/qr_scanner.dart'; import 'package:digit_ui_components/digit_components.dart'; @@ -75,15 +76,15 @@ class IndividualDetailsPageState extends LocalizedState { overviewBloc.add( HouseholdOverviewReloadEvent( projectId: - RegistrationDeliverySingleton().projectId.toString(), + RegistrationDeliverySingleton().projectId.toString(), projectBeneficiaryType: - RegistrationDeliverySingleton().beneficiaryType ?? - BeneficiaryType.household, + RegistrationDeliverySingleton().beneficiaryType ?? + BeneficiaryType.household, ), ); await overviewBloc.stream.firstWhere((element) => - element.loading == false && + element.loading == false && element.householdMemberWrapper.household != null); HouseholdMemberWrapper memberWrapper = overviewBloc.state.householdMemberWrapper; @@ -106,44 +107,45 @@ class IndividualDetailsPageState extends LocalizedState { footer: DigitCard( margin: const EdgeInsets.only(top: spacer2), padding: const EdgeInsets.all(spacer2), - children: [ValueListenableBuilder( - valueListenable: clickedStatus, - builder: (context, bool isClicked, _) { - return Button( - label: state.mapOrNull( - editIndividual: (value) => localizations - .translate(i18.common.coreCommonSave), - ) ?? - localizations - .translate(i18.common.coreCommonSubmit), - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () async { - if(form.control(_dobKey).value==null){ - form.control(_dobKey).setErrors({'':true}); - } - if (form.control(_idTypeKey).value == null) { - form.control(_idTypeKey).setErrors({'': true}); - } - if (form.control(_genderKey).value == null) { - setState(() { - form.control(_genderKey).setErrors({'': true}); - }); - } - final userId = - RegistrationDeliverySingleton().loggedInUserUuid; - final projectId = - RegistrationDeliverySingleton().projectId; - form.markAllAsTouched(); - if (!form.valid) return; - FocusManager.instance.primaryFocus?.unfocus(); + children: [ + ValueListenableBuilder( + valueListenable: clickedStatus, + builder: (context, bool isClicked, _) { + return Button( + label: state.mapOrNull( + editIndividual: (value) => localizations + .translate(i18.common.coreCommonSave), + ) ?? + localizations + .translate(i18.common.coreCommonSubmit), + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () async { + if (form.control(_dobKey).value == null) { + form.control(_dobKey).setErrors({'': true}); + } + if (form.control(_idTypeKey).value == null) { + form.control(_idTypeKey).setErrors({'': true}); + } + if (form.control(_genderKey).value == null) { + setState(() { + form.control(_genderKey).setErrors({'': true}); + }); + } + final userId = RegistrationDeliverySingleton() + .loggedInUserUuid; + final projectId = + RegistrationDeliverySingleton().projectId; + form.markAllAsTouched(); + if (!form.valid) return; + FocusManager.instance.primaryFocus?.unfocus(); - state.maybeWhen( - orElse: () { - return; - }, - create: ( + state.maybeWhen( + orElse: () { + return; + }, + create: ( addressModel, householdModel, individualModel, @@ -152,498 +154,502 @@ class IndividualDetailsPageState extends LocalizedState { searchQuery, loading, isHeadOfHousehold, - ) async { - final individual = _getIndividualModel( - context, - form: form, - oldIndividual: null, - ); + ) async { + final individual = _getIndividualModel( + context, + form: form, + oldIndividual: null, + ); - final boundary = - RegistrationDeliverySingleton().boundary; + final boundary = + RegistrationDeliverySingleton().boundary; - bloc.add( - BeneficiaryRegistrationSaveIndividualDetailsEvent( - model: individual, - isHeadOfHousehold: widget.isHeadOfHousehold, - ), - ); - final scannerBloc = - context.read(); - - if (scannerBloc.state.duplicate) { - Toast.showToast( - context, - message: localizations.translate( - i18.deliverIntervention - .resourceAlreadyScanned, - ), - type: ToastType.error - ); - } else { - clickedStatus.value = true; - final scannerBloc = - context.read(); bloc.add( - BeneficiaryRegistrationSummaryEvent( - projectId: projectId!, - userUuid: userId!, - boundary: boundary!, - tag: scannerBloc.state.qrCodes.isNotEmpty - ? scannerBloc.state.qrCodes.first - : null, + BeneficiaryRegistrationSaveIndividualDetailsEvent( + model: individual, + isHeadOfHousehold: widget.isHeadOfHousehold, ), ); - router.push(SummaryRoute()); - } - }, - editIndividual: ( - householdModel, - individualModel, - addressModel, - projectBeneficiaryModel, - loading, - ) { - final scannerBloc = - context.read(); - final individual = _getIndividualModel( - context, - form: form, - oldIndividual: individualModel, - ); - final tag = scannerBloc.state.qrCodes.isNotEmpty - ? scannerBloc.state.qrCodes.first - : null; + final scannerBloc = + context.read(); - if (tag != null && - tag != projectBeneficiaryModel?.tag && - scannerBloc.state.duplicate) { - Toast.showToast( - context, - message: localizations.translate( - i18.deliverIntervention - .resourceAlreadyScanned, - ), - type: ToastType.error - ); - } else { - bloc.add( - BeneficiaryRegistrationUpdateIndividualDetailsEvent( - addressModel: addressModel, - householdModel: householdModel, - model: individual.copyWith( - clientAuditDetails: (individual - .clientAuditDetails - ?.createdBy != - null && - individual.clientAuditDetails - ?.createdTime != - null) - ? ClientAuditDetails( - createdBy: individual - .clientAuditDetails!.createdBy, - createdTime: individual - .clientAuditDetails! - .createdTime, - lastModifiedBy: - RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: context - .millisecondsSinceEpoch(), - ) + if (scannerBloc.state.duplicate) { + Toast.showToast(context, + message: localizations.translate( + i18.deliverIntervention + .resourceAlreadyScanned, + ), + type: ToastType.error); + } else { + clickedStatus.value = true; + final scannerBloc = + context.read(); + bloc.add( + BeneficiaryRegistrationSummaryEvent( + projectId: projectId!, + userUuid: userId!, + boundary: boundary!, + tag: scannerBloc.state.qrCodes.isNotEmpty + ? scannerBloc.state.qrCodes.first : null, ), - tag: scannerBloc.state.qrCodes.isNotEmpty - ? scannerBloc.state.qrCodes.first - : null, - ), - ); - } - }, - addMember: ( - addressModel, + ); + router.push(SummaryRoute()); + } + }, + editIndividual: ( householdModel, + individualModel, + addressModel, + projectBeneficiaryModel, loading, - ) { - final individual = _getIndividualModel( - context, - form: form, - ); - - if (context.mounted) { + ) { final scannerBloc = - context.read(); + context.read(); + final individual = _getIndividualModel( + context, + form: form, + oldIndividual: individualModel, + ); + final tag = scannerBloc.state.qrCodes.isNotEmpty + ? scannerBloc.state.qrCodes.first + : null; - if (scannerBloc.state.duplicate) { - Toast.showToast( - context, - message: localizations.translate( - i18.deliverIntervention - .resourceAlreadyScanned, - ), - type: ToastType.error, - ); + if (tag != null && + tag != projectBeneficiaryModel?.tag && + scannerBloc.state.duplicate) { + Toast.showToast(context, + message: localizations.translate( + i18.deliverIntervention + .resourceAlreadyScanned, + ), + type: ToastType.error); } else { bloc.add( - BeneficiaryRegistrationAddMemberEvent( - beneficiaryType: - RegistrationDeliverySingleton() - .beneficiaryType!, - householdModel: householdModel, - individualModel: individual, + BeneficiaryRegistrationUpdateIndividualDetailsEvent( addressModel: addressModel, - userUuid: RegistrationDeliverySingleton() - .loggedInUserUuid!, - projectId: RegistrationDeliverySingleton() - .projectId!, + householdModel: householdModel, + model: individual.copyWith( + clientAuditDetails: (individual + .clientAuditDetails + ?.createdBy != + null && + individual.clientAuditDetails + ?.createdTime != + null) + ? ClientAuditDetails( + createdBy: individual + .clientAuditDetails! + .createdBy, + createdTime: individual + .clientAuditDetails! + .createdTime, + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ) + : null, + ), tag: scannerBloc.state.qrCodes.isNotEmpty ? scannerBloc.state.qrCodes.first : null, ), ); } - } - }, - ); - }, - ); - }, - ),] - ), + }, + addMember: ( + addressModel, + householdModel, + loading, + ) { + final individual = _getIndividualModel( + context, + form: form, + ); + + if (context.mounted) { + final scannerBloc = + context.read(); + + if (scannerBloc.state.duplicate) { + Toast.showToast( + context, + message: localizations.translate( + i18.deliverIntervention + .resourceAlreadyScanned, + ), + type: ToastType.error, + ); + } else { + bloc.add( + BeneficiaryRegistrationAddMemberEvent( + beneficiaryType: + RegistrationDeliverySingleton() + .beneficiaryType!, + householdModel: householdModel, + individualModel: individual, + addressModel: addressModel, + userUuid: + RegistrationDeliverySingleton() + .loggedInUserUuid!, + projectId: + RegistrationDeliverySingleton() + .projectId!, + tag: scannerBloc + .state.qrCodes.isNotEmpty + ? scannerBloc.state.qrCodes.first + : null, + ), + ); + } + } + }, + ); + }, + ); + }, + ), + ]), slivers: [ SliverToBoxAdapter( - child: DigitCard( - children: [ - Padding( - padding: const EdgeInsets.only(bottom: spacer2), - child: Text( - localizations.translate( - i18.individualDetails.individualsDetailsLabelText, - ), - style: textTheme.headingXl, - ), - ), - individualDetailsShowcaseData.nameOfIndividual - .buildWith( - child: ReactiveWrapperField( - formControlName: _individualNameKey, - validationMessages: { - 'required': (object) => localizations.translate( - '${i18.individualDetails.nameLabelText}_IS_REQUIRED', - ), - 'maxLength': (object) => localizations - .translate(i18.common.maxCharsRequired) - .replaceAll('{}', maxLength.toString()), - }, - builder: (field)=> LabeledField( - label: localizations.translate( - i18.individualDetails.nameLabelText, - ), - isRequired: true, - child: DigitTextFormInput( - initialValue: form.control(_individualNameKey).value, - onChange: (value){ - form.control(_individualNameKey).value=value; - }, - errorMessage: field.errorText, - ), - ), + child: DigitCard(children: [ + Padding( + padding: const EdgeInsets.only(bottom: spacer2), + child: Text( + localizations.translate( + i18.individualDetails.individualsDetailsLabelText, ), + style: textTheme.headingXl, ), - Offstage( - offstage: !widget.isHeadOfHousehold, - child: DigitCheckbox( - label: localizations.translate( - i18.individualDetails.checkboxLabelText, - ), - value: widget.isHeadOfHousehold, - readOnly: widget.isHeadOfHousehold, - onChanged: (_){}, - ), - ), - ReactiveWrapperField( - formControlName: _idTypeKey, + ), + individualDetailsShowcaseData.nameOfIndividual.buildWith( + child: ReactiveWrapperField( + formControlName: _individualNameKey, validationMessages: { - 'required': (_)=> localizations.translate( - i18.common.corecommonRequired, - ), + 'required': (object) => localizations.translate( + '${i18.individualDetails.nameLabelText}_IS_REQUIRED', + ), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', maxLength.toString()), }, - builder: (field)=> LabeledField( + builder: (field) => LabeledField( label: localizations.translate( - i18.individualDetails.idTypeLabelText, + i18.individualDetails.nameLabelText, ), isRequired: true, - child: DigitDropdown( - selectedOption: (form.control(_idTypeKey).value!=null)? - DropdownItem( - name: localizations.translate(form.control(_idTypeKey).value), - code: form.control(_idTypeKey).value - ):const DropdownItem(name: '', code: ''), - items: RegistrationDeliverySingleton() - .idTypeOptions! - .map( - (e) => DropdownItem( - name: localizations.translate(e), - code: e - ), - ).toList(), - onSelect: (value) { - form.control(_idTypeKey).value=value.code; - setState(() { - if (value.code == 'DEFAULT') { - form.control(_idNumberKey).value = - IdGen.i.identifier.toString(); - } else { - form.control(_idNumberKey).value = null; - } - }); + child: DigitTextFormInput( + initialValue: + form.control(_individualNameKey).value, + onChange: (value) { + form.control(_individualNameKey).value = value; }, - emptyItemText: localizations - .translate(i18.common.noMatchFound), - errorMessage: form.control(_idTypeKey).hasErrors - ? localizations.translate( - i18.common.corecommonRequired, - ):null, + errorMessage: field.errorText, ), ), ), - if (form.control(_idTypeKey).value != 'DEFAULT') - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ReactiveFormConsumer( - builder: (context, formGroup, child) { - return ReactiveWrapperField( - formControlName: _idNumberKey, - validationMessages: { - 'required': (object) => - localizations.translate( - '${i18.individualDetails.idNumberLabelText}_IS_REQUIRED', - ), - }, - builder: (field)=> LabeledField( - label: localizations.translate( - i18.individualDetails.idNumberLabelText, - ), - isRequired: form.control(_idNumberKey).validators.isNotEmpty, - child: DigitTextFormInput( - readOnly: - form.control(_idTypeKey).value == - 'DEFAULT', - initialValue: form.control(_idNumberKey).value, - onChange: (value){ - form.control(_idNumberKey).value=value; - }, - errorMessage: field.errorText, - ), - ), - ); - }, + ), + Offstage( + offstage: !widget.isHeadOfHousehold, + child: DigitCheckbox( + label: (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? localizations.translate( + i18.individualDetails.clfCheckboxLabelText) + : localizations.translate( + i18.individualDetails.checkboxLabelText, + ), + value: widget.isHeadOfHousehold, + readOnly: widget.isHeadOfHousehold, + onChanged: (_) {}, + ), + ), + ReactiveWrapperField( + formControlName: _idTypeKey, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.corecommonRequired, ), - const SizedBox(height: 4), - ], - ), - if (form.control(_idTypeKey).value == 'DEFAULT') - const SizedBox( - height: spacer2, + }, + builder: (field) => LabeledField( + label: localizations.translate( + i18.individualDetails.idTypeLabelText, ), - individualDetailsShowcaseData.dateOfBirth.buildWith( - child: DigitDobPicker( - datePickerFormControl: _dobKey, - datePickerLabel: localizations.translate( - i18.individualDetails.dobLabelText, - ), - ageFieldLabel: localizations.translate( - i18.individualDetails.ageLabelText, - ), - yearsHintLabel: localizations.translate( - i18.individualDetails.yearsHintText, - ), - monthsHintLabel: localizations.translate( - i18.individualDetails.monthsHintText, - ), - separatorLabel: localizations.translate( - i18.individualDetails.separatorLabelText, - ), - yearsAndMonthsErrMsg: localizations.translate( - i18.individualDetails.yearsAndMonthsErrorText, - ), - errorMessage: form.control(_dobKey).hasErrors? - localizations.translate(i18.common.corecommonRequired):null, - initialDate: before150Years, - onChangeOfFormControl: (value) { - if(value!=null){ - setState(() { - form.control(_dobKey).setErrors({'' : false}); - }); - } - // Handle changes to the control's value here - form.control(_dobKey).value=value; + isRequired: true, + child: DigitDropdown( + selectedOption: + (form.control(_idTypeKey).value != null) + ? DropdownItem( + name: localizations.translate( + form.control(_idTypeKey).value), + code: form.control(_idTypeKey).value) + : const DropdownItem(name: '', code: ''), + items: RegistrationDeliverySingleton() + .idTypeOptions! + .map( + (e) => DropdownItem( + name: localizations.translate(e), code: e), + ) + .toList(), + onSelect: (value) { + form.control(_idTypeKey).value = value.code; + setState(() { + if (value.code == 'DEFAULT') { + form.control(_idNumberKey).value = + IdGen.i.identifier.toString(); + } else { + form.control(_idNumberKey).value = null; + } + }); }, - cancelText: localizations - .translate(i18.common.coreCommonCancel), - confirmText: localizations - .translate(i18.common.coreCommonOk), + emptyItemText: + localizations.translate(i18.common.noMatchFound), + errorMessage: form.control(_idTypeKey).hasErrors + ? localizations.translate( + i18.common.corecommonRequired, + ) + : null, ), ), - SelectionCard( - isRequired: true, - title: localizations.translate( - i18.individualDetails.genderLabelText, + ), + if (form.control(_idTypeKey).value != 'DEFAULT') + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ReactiveFormConsumer( + builder: (context, formGroup, child) { + return ReactiveWrapperField( + formControlName: _idNumberKey, + validationMessages: { + 'required': (object) => + localizations.translate( + '${i18.individualDetails.idNumberLabelText}_IS_REQUIRED', + ), + }, + builder: (field) => LabeledField( + label: localizations.translate( + i18.individualDetails.idNumberLabelText, + ), + isRequired: form + .control(_idNumberKey) + .validators + .isNotEmpty, + child: DigitTextFormInput( + readOnly: form.control(_idTypeKey).value == + 'DEFAULT', + initialValue: + form.control(_idNumberKey).value, + onChange: (value) { + form.control(_idNumberKey).value = value; + }, + errorMessage: field.errorText, + ), + ), + ); + }, + ), + const SizedBox(height: 4), + ], + ), + if (form.control(_idTypeKey).value == 'DEFAULT') + const SizedBox( + height: spacer2, + ), + individualDetailsShowcaseData.dateOfBirth.buildWith( + child: DigitDobPicker( + datePickerFormControl: _dobKey, + datePickerLabel: localizations.translate( + i18.individualDetails.dobLabelText, ), - allowMultipleSelection: false, - width: 126, - initialSelection: - form.control(_genderKey).value != null - ? [form.control(_genderKey).value] - : [], - options: RegistrationDeliverySingleton() - .genderOptions! - .map( - (e) => e, - ) - .toList(), - onSelectionChanged: (value) { - setState(() { - if (value.isNotEmpty) { - form.control(_genderKey).value = value.first; - } else { - form.control(_genderKey).value = null; - setState(() { - form - .control(_genderKey) - .setErrors({'': true}); - }); - } - }); - }, - valueMapper: (value) { - return localizations.translate(value); - }, - errorMessage: form.control(_genderKey).hasErrors + ageFieldLabel: localizations.translate( + i18.individualDetails.ageLabelText, + ), + yearsHintLabel: localizations.translate( + i18.individualDetails.yearsHintText, + ), + monthsHintLabel: localizations.translate( + i18.individualDetails.monthsHintText, + ), + separatorLabel: localizations.translate( + i18.individualDetails.separatorLabelText, + ), + yearsAndMonthsErrMsg: localizations.translate( + i18.individualDetails.yearsAndMonthsErrorText, + ), + errorMessage: form.control(_dobKey).hasErrors ? localizations - .translate(i18.common.corecommonRequired) + .translate(i18.common.corecommonRequired) : null, + initialDate: before150Years, + onChangeOfFormControl: (value) { + if (value != null) { + setState(() { + form.control(_dobKey).setErrors({'': false}); + }); + } + // Handle changes to the control's value here + form.control(_dobKey).value = value; + }, + cancelText: localizations + .translate(i18.common.coreCommonCancel), + confirmText: + localizations.translate(i18.common.coreCommonOk), ), - individualDetailsShowcaseData.mobile.buildWith( - child: ReactiveWrapperField( - formControlName: _mobileNumberKey, - validationMessages: { - 'maxLength': (object) => localizations.translate( - i18.individualDetails - .mobileNumberLengthValidationMessage), - 'minLength': (object) => localizations.translate( - i18.individualDetails - .mobileNumberLengthValidationMessage), - }, - builder: (field)=> LabeledField( - label: localizations.translate( - i18.individualDetails.mobileNumberLabelText, - ), - child: DigitTextFormInput( - keyboardType: TextInputType.number, - maxLength: 10, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - initialValue: form.control(_mobileNumberKey).value, - onChange: (value){ - form.control(_mobileNumberKey).value=value; - }, - ), + ), + SelectionCard( + isRequired: true, + title: localizations.translate( + i18.individualDetails.genderLabelText, + ), + allowMultipleSelection: false, + width: 126, + initialSelection: form.control(_genderKey).value != null + ? [form.control(_genderKey).value] + : [], + options: RegistrationDeliverySingleton() + .genderOptions! + .map( + (e) => e, + ) + .toList(), + onSelectionChanged: (value) { + setState(() { + if (value.isNotEmpty) { + form.control(_genderKey).value = value.first; + } else { + form.control(_genderKey).value = null; + setState(() { + form.control(_genderKey).setErrors({'': true}); + }); + } + }); + }, + valueMapper: (value) { + return localizations.translate(value); + }, + errorMessage: form.control(_genderKey).hasErrors + ? localizations + .translate(i18.common.corecommonRequired) + : null, + ), + individualDetailsShowcaseData.mobile.buildWith( + child: ReactiveWrapperField( + formControlName: _mobileNumberKey, + validationMessages: { + 'maxLength': (object) => localizations.translate(i18 + .individualDetails + .mobileNumberLengthValidationMessage), + 'minLength': (object) => localizations.translate(i18 + .individualDetails + .mobileNumberLengthValidationMessage), + }, + builder: (field) => LabeledField( + label: localizations.translate( + i18.individualDetails.mobileNumberLabelText, + ), + child: DigitTextFormInput( + keyboardType: TextInputType.number, + maxLength: 10, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + initialValue: form.control(_mobileNumberKey).value, + onChange: (value) { + form.control(_mobileNumberKey).value = value; + }, ), ), ), - const SizedBox(height: 16), - if ((RegistrationDeliverySingleton().beneficiaryType == - BeneficiaryType.household && - widget.isHeadOfHousehold) || - (RegistrationDeliverySingleton().beneficiaryType == - BeneficiaryType.individual)) - BlocBuilder( - buildWhen: (p, c) { - return true; - }, - builder: (context, state) => state - .qrCodes.isNotEmpty - ? Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - width: - MediaQuery.of(context).size.width / - 3, - child: Text( - localizations.translate( - i18.deliverIntervention.voucherCode, + ), + const SizedBox(height: 16), + if ((RegistrationDeliverySingleton().beneficiaryType == + BeneficiaryType.household && + widget.isHeadOfHousehold) || + (RegistrationDeliverySingleton().beneficiaryType == + BeneficiaryType.individual)) + BlocBuilder( + buildWhen: (p, c) { + return true; + }, + builder: (context, state) => state.qrCodes.isNotEmpty + ? Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + width: + MediaQuery.of(context).size.width / 3, + child: Text( + localizations.translate( + i18.deliverIntervention.voucherCode, + ), + style: theme.textTheme.headlineSmall, + ), ), - style: theme.textTheme.headlineSmall, - ), - ), - Flexible( - child: Text( - overflow: TextOverflow.ellipsis, - localizations - .translate(state.qrCodes.last), - ), - ), - Padding( - padding: const EdgeInsets.only( - bottom: spacer2 * 2, - ), - child: IconButton( - color: theme.colorScheme.secondary, - icon: const Icon(Icons.edit), - onPressed: () { - Navigator.of(context).push( - //[TODO: Add the route to auto_route] - MaterialPageRoute( - builder: (context) => - const DigitScannerPage( - quantity: 1, - isGS1code: false, - singleValue: true, - isEditEnabled: true, - ), - settings: const RouteSettings( - name: '/qr-scanner'), + Flexible( + child: Text( + overflow: TextOverflow.ellipsis, + localizations + .translate(state.qrCodes.last), + ), + ), + Padding( + padding: const EdgeInsets.only( + bottom: spacer2 * 2, + ), + child: IconButton( + color: theme.colorScheme.secondary, + icon: const Icon(Icons.edit), + onPressed: () { + Navigator.of(context).push( + //[TODO: Add the route to auto_route] + MaterialPageRoute( + builder: (context) => + const DigitScannerPage( + quantity: 1, + isGS1code: false, + singleValue: true, + isEditEnabled: true, + ), + settings: const RouteSettings( + name: '/qr-scanner'), + ), + ); + }, + ), + ), + ], + + // ignore: no-empty-block + ) + : Button( + type: ButtonType.secondary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () { + Navigator.of(context).push( + // [TODO: Add the route to auto_route] + MaterialPageRoute( + builder: (context) => + const DigitScannerPage( + quantity: 1, + isGS1code: false, + singleValue: true, ), - ); - }, + settings: const RouteSettings( + name: '/qr-scanner'), + ), + ); + }, + prefixIcon: Icons.qr_code, + label: localizations.translate( + i18.individualDetails.linkVoucherToIndividual, ), ), - ], - - // ignore: no-empty-block - ) - : Button( - type: ButtonType.secondary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () { - Navigator.of(context).push( - // [TODO: Add the route to auto_route] - MaterialPageRoute( - builder: (context) => - const DigitScannerPage( - quantity: 1, - isGS1code: false, - singleValue: true, - ), - settings: const RouteSettings( - name: '/qr-scanner'), - ), - ); - }, - prefixIcon: Icons.qr_code, - label: localizations.translate( - i18.individualDetails - .linkVoucherToIndividual, - ), - ), - ),] - ), + ), + ]), ), ], ); @@ -654,10 +660,10 @@ class IndividualDetailsPageState extends LocalizedState { } IndividualModel _getIndividualModel( - BuildContext context, { - required FormGroup form, - IndividualModel? oldIndividual, - }) { + BuildContext context, { + required FormGroup form, + IndividualModel? oldIndividual, + }) { final dob = form.control(_dobKey).value as DateTime?; String? dobString; if (dob != null) { @@ -732,7 +738,7 @@ class IndividualDetailsPageState extends LocalizedState { gender: form.control(_genderKey).value == null ? null : Gender.values - .byName(form.control(_genderKey).value.toString().toLowerCase()), + .byName(form.control(_genderKey).value.toString().toLowerCase()), mobileNumber: form.control(_mobileNumberKey).value, dateOfBirth: dobString, identifiers: [ @@ -789,13 +795,13 @@ class IndividualDetailsPageState extends LocalizedState { _dobKey: FormControl( value: individual?.dateOfBirth != null ? DateFormat(Constants().dateFormat).parse( - individual!.dateOfBirth!, - ) + individual!.dateOfBirth!, + ) : null, ), _genderKey: FormControl(value: getGenderOptions(individual)), _mobileNumberKey: - FormControl(value: individual?.mobileNumber, validators: [ + FormControl(value: individual?.mobileNumber, validators: [ CustomValidator.validMobileNumber, CustomValidator.minPhoneNumValidation, Validators.maxLength(10) @@ -808,6 +814,6 @@ class IndividualDetailsPageState extends LocalizedState { return options?.map((e) => e).firstWhereOrNull( (element) => element.toLowerCase() == individual?.gender?.name, - ); + ); } } diff --git a/packages/registration_delivery/lib/pages/search_beneficiary.dart b/packages/registration_delivery/lib/pages/search_beneficiary.dart index 47a246b2e..d526104a5 100644 --- a/packages/registration_delivery/lib/pages/search_beneficiary.dart +++ b/packages/registration_delivery/lib/pages/search_beneficiary.dart @@ -12,6 +12,7 @@ import 'package:digit_ui_components/widgets/atoms/pop_up_card.dart'; import 'package:digit_ui_components/widgets/atoms/switch.dart'; import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:registration_delivery/registration_delivery.dart'; @@ -139,9 +140,17 @@ class _SearchBeneficiaryPageState child: CustomSwitch( mainAxisAlignment: MainAxisAlignment.start, - label: localizations.translate( - i18.searchBeneficiary.proximityLabel, - ), + label: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? localizations.translate( + i18.searchBeneficiary + .communityProximityLabel, + ) + : localizations.translate( + i18.searchBeneficiary + .proximityLabel, + ), value: isProximityEnabled, onChanged: (value) { searchController.clear(); @@ -172,10 +181,15 @@ class _SearchBeneficiaryPageState padding: const EdgeInsets.all(spacer2), child: DigitSearchBar( controller: searchController, - hintText: localizations.translate( - i18.searchBeneficiary - .beneficiarySearchHintText, - ), + hintText: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? localizations.translate(i18 + .searchBeneficiary.clfSearchHintText) + : localizations.translate( + i18.searchBeneficiary + .beneficiarySearchHintText, + ), textCapitalization: TextCapitalization.words, onChanged: (value) { if (value.isEmpty || @@ -248,9 +262,15 @@ class _SearchBeneficiaryPageState !searchHouseholdsState.loading) InfoCard( type: InfoType.info, - description: localizations.translate( - i18.searchBeneficiary.beneficiaryInfoDescription, - ), + description: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? localizations + .translate(i18.searchBeneficiary.clfInfoTitle) + : localizations.translate( + i18.searchBeneficiary + .beneficiaryInfoDescription, + ), title: localizations.translate( i18.searchBeneficiary.beneficiaryInfoTitle, ), @@ -365,61 +385,72 @@ class _SearchBeneficiaryPageState ], ), ), - bottomNavigationBar: DigitCard( - margin: const EdgeInsets.only(top: spacer2), - padding: const EdgeInsets.all(spacer2), - children: [ - Button( - label: localizations.translate( - i18.searchBeneficiary.beneficiaryAddActionLabel, + bottomNavigationBar: Offstage( + offstage: RegistrationDeliverySingleton().householdType == + HouseholdType.community && + (searchHouseholdsState.searchQuery == null) || + (searchHouseholdsState.searchQuery != null && + searchHouseholdsState.householdMembers.isNotEmpty), + child: DigitCard( + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + Button( + label: (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? localizations + .translate(i18.searchBeneficiary.clfAddActionLabel) + : localizations.translate( + i18.searchBeneficiary.beneficiaryAddActionLabel, + ), + mainAxisSize: MainAxisSize.max, + type: ButtonType.primary, + size: ButtonSize.large, + isDisabled: searchHouseholdsState.searchQuery != null && + searchHouseholdsState.searchQuery!.isNotEmpty + ? false + : true, + onPressed: () { + FocusManager.instance.primaryFocus?.unfocus(); + context.read().add( + const DigitScannerEvent.handleScanner(), + ); + context.router.push(BeneficiaryRegistrationWrapperRoute( + initialState: BeneficiaryRegistrationCreateState( + searchQuery: searchHouseholdsState.searchQuery, + ), + )); + searchController.clear(); + selectedFilters = []; + blocWrapper.clearEvent(); + }, ), - mainAxisSize: MainAxisSize.max, - type: ButtonType.primary, - size: ButtonSize.large, - isDisabled: searchHouseholdsState.searchQuery != null && - searchHouseholdsState.searchQuery!.isNotEmpty - ? false - : true, - onPressed: () { - FocusManager.instance.primaryFocus?.unfocus(); - context.read().add( - const DigitScannerEvent.handleScanner(), - ); - context.router.push(BeneficiaryRegistrationWrapperRoute( - initialState: BeneficiaryRegistrationCreateState( - searchQuery: searchHouseholdsState.searchQuery, - ), - )); - searchController.clear(); - selectedFilters = []; - blocWrapper.clearEvent(); - }, - ), - Button( - type: ButtonType.secondary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - onPressed: () { - blocWrapper.clearEvent(); - selectedFilters = []; - searchController.clear(); - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const DigitScannerPage( - quantity: 1, - isGS1code: false, - singleValue: true, + Button( + type: ButtonType.secondary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + onPressed: () { + blocWrapper.clearEvent(); + selectedFilters = []; + searchController.clear(); + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const DigitScannerPage( + quantity: 1, + isGS1code: false, + singleValue: true, + ), + settings: const RouteSettings(name: '/qr-scanner'), ), - settings: const RouteSettings(name: '/qr-scanner'), - ), - ); - }, - prefixIcon: Icons.qr_code, - label: localizations.translate( - i18.deliverIntervention.scannerLabel, + ); + }, + prefixIcon: Icons.qr_code, + label: localizations.translate( + i18.deliverIntervention.scannerLabel, + ), ), - ), - ]), + ]), + ), ), ); } @@ -505,26 +536,26 @@ class _SearchBeneficiaryPageState if (isProximityEnabled || selectedFilters.isNotEmpty || searchController.text.isNotEmpty) { - blocWrapper.houseHoldGlobalSearchBloc.add( - SearchHouseholdsEvent.houseHoldGlobalSearch( + blocWrapper.houseHoldGlobalSearchBloc + .add(SearchHouseholdsEvent.houseHoldGlobalSearch( globalSearchParams: GlobalSearchParameters( - isProximityEnabled: isProximityEnabled, - latitude: lat, - longitude: long, - projectId: RegistrationDeliverySingleton().projectId!, - maxRadius: RegistrationDeliverySingleton().maxRadius, - nameSearch: searchController.text.trim().length > 2 - ? searchController.text.trim() - : blocWrapper.searchHouseholdsBloc.state.searchQuery, - filter: selectedFilters, - offset: isPagination - ? blocWrapper.houseHoldGlobalSearchBloc.state.offset - : offset, - limit: isPagination - ? blocWrapper.houseHoldGlobalSearchBloc.state.limit - : limit, - householdType: - RegistrationDeliverySingleton().householdType))); + isProximityEnabled: isProximityEnabled, + latitude: lat, + longitude: long, + projectId: RegistrationDeliverySingleton().projectId!, + maxRadius: RegistrationDeliverySingleton().maxRadius, + nameSearch: searchController.text.trim().length > 2 + ? searchController.text.trim() + : blocWrapper.searchHouseholdsBloc.state.searchQuery, + filter: selectedFilters, + offset: isPagination + ? blocWrapper.houseHoldGlobalSearchBloc.state.offset + : offset, + limit: isPagination + ? blocWrapper.houseHoldGlobalSearchBloc.state.limit + : limit, + householdType: RegistrationDeliverySingleton().householdType, + ))); } } } diff --git a/packages/registration_delivery/lib/pages/summary_page.dart b/packages/registration_delivery/lib/pages/summary_page.dart index 0b37f644f..54c449b1a 100644 --- a/packages/registration_delivery/lib/pages/summary_page.dart +++ b/packages/registration_delivery/lib/pages/summary_page.dart @@ -1,4 +1,5 @@ import 'package:auto_route/auto_route.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/digit_components.dart'; import 'package:digit_ui_components/utils/date_utils.dart'; import 'package:digit_ui_components/widgets/atoms/label_value_list.dart'; @@ -202,208 +203,214 @@ class SummaryPageState extends LocalizedState { child: Column( children: [ DigitCard( - margin: const EdgeInsets.all(spacer2), + margin: const EdgeInsets.all(spacer2), children: [ - LabelValueList( - heading: localizations.translate(i18 - .householdLocation.householdLocationLabelText), - - labelFlex: 6, - maxLines: 2, - items: [ - LabelValuePair( - label: localizations.translate( - i18.householdLocation.villageLabel), - value: householdState.householdModel?.address - ?.locality?.code ?? - localizations - .translate(i18.common.coreCommonNA), - isInline: true), - LabelValuePair( - label: localizations.translate( - i18.householdLocation.landmarkFormLabel), - value: householdState - .householdModel?.address?.landmark ?? - localizations - .translate(i18.common.coreCommonNA), - isInline: true), - ]), - ]), - DigitCard( - margin: const EdgeInsets.all(spacer2), - children: [ - LabelValueList( - heading: localizations.translate( - i18.householdDetails.householdDetailsLabel), - labelFlex: 6, - items: [ - LabelValuePair( - label: localizations.translate( - i18.beneficiaryDetails.totalMembers), - value: householdState - .householdModel?.memberCount - .toString() ?? - '0', - isInline: true), - LabelValuePair( - label: localizations.translate(i18 - .householdDetails - .noOfPregnantWomenCountLabel), - value: householdState.householdModel - ?.additionalFields?.fields - .where((h) => - h.key == - AdditionalFieldsType.pregnantWomen - .toValue()) - .firstOrNull - ?.value - .toString() ?? - '0', - isInline: true), - LabelValuePair( - label: localizations.translate(i18 - .householdDetails - .noOfChildrenBelow5YearsLabel), - value: householdState.householdModel - ?.additionalFields?.fields - .where((h) => - h.key == - AdditionalFieldsType.children - .toValue()) - .firstOrNull - ?.value - .toString() ?? - '0', - isInline: true), + LabelValueList( + heading: localizations.translate(i18 + .householdLocation + .householdLocationLabelText), + labelFlex: 6, + maxLines: 2, + items: [ + LabelValuePair( + label: localizations.translate( + i18.householdLocation.villageLabel), + value: householdState.householdModel + ?.address?.locality?.code ?? + localizations.translate( + i18.common.coreCommonNA), + isInline: true), + LabelValuePair( + label: localizations.translate(i18 + .householdLocation.landmarkFormLabel), + value: householdState.householdModel + ?.address?.landmark ?? + localizations.translate( + i18.common.coreCommonNA), + isInline: true), + ]), + ]), + if (RegistrationDeliverySingleton().householdType != + HouseholdType.community) + DigitCard( + margin: const EdgeInsets.all(spacer2), + children: [ + LabelValueList( + heading: localizations.translate(i18 + .householdDetails.householdDetailsLabel), + labelFlex: 6, + items: [ + LabelValuePair( + label: localizations.translate(i18 + .beneficiaryDetails.totalMembers), + value: householdState + .householdModel?.memberCount + .toString() ?? + '0', + isInline: true), + LabelValuePair( + label: localizations.translate(i18 + .householdDetails + .noOfPregnantWomenCountLabel), + value: householdState.householdModel + ?.additionalFields?.fields + .where((h) => + h.key == + AdditionalFieldsType + .pregnantWomen + .toValue()) + .firstOrNull + ?.value + .toString() ?? + '0', + isInline: true), + LabelValuePair( + label: localizations.translate(i18 + .householdDetails + .noOfChildrenBelow5YearsLabel), + value: householdState.householdModel + ?.additionalFields?.fields + .where((h) => + h.key == + AdditionalFieldsType + .children + .toValue()) + .firstOrNull + ?.value + .toString() ?? + '0', + isInline: true), + ]), ]), - ]), DigitCard( - margin: const EdgeInsets.all(spacer2), + margin: const EdgeInsets.all(spacer2), children: [ - LabelValueList( - heading: localizations.translate( - i18.householdDetails.houseDetailsLabel), - labelFlex: 6, - items: [ - LabelValuePair( - label: localizations.translate( - i18.householdDetails.noOfRoomsLabel), - value: householdState.householdModel - ?.additionalFields?.fields - .where((h) => - h.key == - AdditionalFieldsType.noOfRooms - .toValue()) - .firstOrNull - ?.value - .toString() ?? - '0', - isInline: true), - LabelValuePair( - label: localizations.translate( - i18.householdDetails.typeOfStructure), - value: (householdState.householdModel + LabelValueList( + heading: localizations.translate( + i18.householdDetails.houseDetailsLabel), + labelFlex: 6, + items: [ + LabelValuePair( + label: localizations.translate( + i18.householdDetails.noOfRoomsLabel), + value: householdState.householdModel ?.additionalFields?.fields .where((h) => h.key == - AdditionalFieldsType - .houseStructureTypes + AdditionalFieldsType.noOfRooms .toValue()) .firstOrNull - ?.value ?? - []) - .toString() - .split('|') - .map((item) => getLocalizedMessage(item)) - .toList() - .join(', '), - isInline: true), - ]), - ]), + ?.value + .toString() ?? + '0', + isInline: true), + LabelValuePair( + label: localizations.translate( + i18.householdDetails.typeOfStructure), + value: (householdState.householdModel + ?.additionalFields?.fields + .where((h) => + h.key == + AdditionalFieldsType + .houseStructureTypes + .toValue()) + .firstOrNull + ?.value ?? + []) + .toString() + .split('|') + .map((item) => + getLocalizedMessage(item)) + .toList() + .join(', '), + isInline: true), + ]), + ]), DigitCard( - margin: const EdgeInsets.all(spacer2), + margin: const EdgeInsets.all(spacer2), children: [ - LabelValueList( - heading: localizations.translate(i18 - .individualDetails.individualsDetailsLabelText), - labelFlex: 6, - items: [ - LabelValuePair( - label: localizations.translate( - i18.individualDetails.nameLabelText), - value: householdState.maybeWhen( - orElse: () => localizations - .translate(i18.common.coreCommonNA), - summary: ( - navigateToRoot, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - addressModel, - loading, - isHeadOfHousehold, - ) => - individualModel?.name?.givenName ?? - localizations.translate( - i18.common.coreCommonNA)), - ), - LabelValuePair( - label: localizations.translate( - i18.individualDetails.dobLabelText), - value: householdState.maybeWhen( - orElse: () => localizations - .translate(i18.common.coreCommonNA), - summary: ( - navigateToRoot, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - addressModel, - loading, - isHeadOfHousehold, - ) => - individualModel?.dateOfBirth != null - ? DigitDateUtils.getFilteredDate( - DigitDateUtils - .getFormattedDateToDateTime( + LabelValueList( + heading: localizations.translate(i18 + .individualDetails + .individualsDetailsLabelText), + labelFlex: 6, + items: [ + LabelValuePair( + label: localizations.translate( + i18.individualDetails.nameLabelText), + value: householdState.maybeWhen( + orElse: () => localizations + .translate(i18.common.coreCommonNA), + summary: ( + navigateToRoot, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + addressModel, + loading, + isHeadOfHousehold, + ) => + individualModel?.name?.givenName ?? + localizations.translate( + i18.common.coreCommonNA)), + ), + LabelValuePair( + label: localizations.translate( + i18.individualDetails.dobLabelText), + value: householdState.maybeWhen( + orElse: () => localizations + .translate(i18.common.coreCommonNA), + summary: ( + navigateToRoot, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + addressModel, + loading, + isHeadOfHousehold, + ) => + individualModel?.dateOfBirth != null + ? DigitDateUtils.getFilteredDate( + DigitDateUtils.getFormattedDateToDateTime( individualModel ?.dateOfBirth ?? '') - .toString(), - dateFormat: Constants() - .dateMonthYearFormat) - .toString() - : localizations.translate( - i18.common.coreCommonNA)), - ), - LabelValuePair( - label: localizations.translate( - i18.individualDetails.genderLabelText), - value: householdState.maybeWhen( - orElse: () => localizations - .translate(i18.common.coreCommonNA), - summary: ( - navigateToRoot, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - addressModel, - loading, - isHeadOfHousehold, - ) => - individualModel?.gender != null - ? localizations.translate( - individualModel?.gender?.name - .toUpperCase() ?? - '') - : localizations.translate( - i18.common.coreCommonNA)), - ), - ]), - ]), + .toString(), + dateFormat: Constants() + .dateMonthYearFormat) + .toString() + : localizations.translate( + i18.common.coreCommonNA)), + ), + LabelValuePair( + label: localizations.translate( + i18.individualDetails.genderLabelText), + value: householdState.maybeWhen( + orElse: () => localizations + .translate(i18.common.coreCommonNA), + summary: ( + navigateToRoot, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + addressModel, + loading, + isHeadOfHousehold, + ) => + individualModel?.gender != null + ? localizations.translate( + individualModel + ?.gender?.name + .toUpperCase() ?? + '') + : localizations.translate( + i18.common.coreCommonNA)), + ), + ]), + ]), ], ), ) diff --git a/packages/registration_delivery/lib/utils/i18_key_constants.dart b/packages/registration_delivery/lib/utils/i18_key_constants.dart index c8e4c62b0..3572c0142 100644 --- a/packages/registration_delivery/lib/utils/i18_key_constants.dart +++ b/packages/registration_delivery/lib/utils/i18_key_constants.dart @@ -125,6 +125,11 @@ class Common { class SearchBeneficiary { const SearchBeneficiary(); + String get communityProximityLabel => + 'BENEFICIARY_SEARCH_COMMUNITY_PROXIMITY_LABEL_TEXT'; + + String get clfSearchHintText => 'BENEFICIARY_CLF_SEARCH_HINT_TEXT'; + String get searchCLFLabel => 'BENEFICIARY_SEARCH_CLF_LABEL_TEXT'; String get statisticsLabelText => 'BENEFICIARY_STATISTICS_LABEL_TEXT'; @@ -145,8 +150,12 @@ class SearchBeneficiary { String get beneficiaryInfoTitle => 'BENEFICIARY_INFO_TITLE'; + String get clfInfoTitle => 'BENEFICIARY_CLF_INFO_TITLE'; + String get beneficiaryAddActionLabel => 'BENEFICIARY_ADD_ACTION_LABEL'; + String get clfAddActionLabel => 'BENEFICIARY_ADD_CLF_ACTION_LABEL'; + String get iconLabel => 'ICON_LABEL'; String get filterLabel => 'FILTER_LABEL'; @@ -248,6 +257,8 @@ class BeneficiaryDetails { class IndividualDetails { const IndividualDetails(); + String get clfCheckboxLabelText => 'INDIVIDUAL_CLF_CHECKBOX_LABEL_TEXT'; + String get individualsDetailsLabelText => 'INDIVIDUAL_LABEL_TEXT'; String get nameLabelText => 'INDIVIDUAL_NAME_LABEL_TEXT'; @@ -297,6 +308,8 @@ class IndividualDetails { class HouseholdLocation { const HouseholdLocation(); + String get clfLocationLabelText => 'CLF_LOCATION_LABEL_TEXT'; + String get householdLocationLabelText => 'HOUSEHOLD_LOCATION_LABEL_TEXT'; String get householdLocationDescriptionText => diff --git a/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart b/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart index ea60ce2d1..ef1fe44f8 100644 --- a/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart +++ b/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart @@ -1,5 +1,6 @@ import 'package:collection/collection.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/digit_components.dart'; import 'package:digit_ui_components/utils/date_utils.dart'; import 'package:digit_ui_components/widgets/atoms/table_cell.dart'; @@ -304,17 +305,25 @@ class ViewBeneficiaryCardState extends LocalizedState { householdMember.household?.address?.city, householdMember.household?.address?.pincode, ].whereNotNull().take(2).join(' '), - subtitle: widget.distance != null - ? '${householdMember.members?.length ?? 1} ${householdMember.members?.length == 1 ? localizations.translate(i18.beneficiaryDetails.householdMemberSingular) : localizations.translate(i18.beneficiaryDetails.householdMemberPlural)}\n${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts) ${localizations.translate(i18.beneficiaryDetails.fromCurrentLocation)}'}' - : '${householdMember.members?.length ?? 1} ${householdMember.members?.length == 1 ? localizations.translate(i18.beneficiaryDetails.householdMemberSingular) : localizations.translate(i18.beneficiaryDetails.householdMemberPlural)}', - status: getStatus( - tasks ?? [], - householdMember.projectBeneficiaries ?? [], - RegistrationDeliverySingleton().beneficiaryType == - BeneficiaryType.individual - ? isNotEligible - : false, - isBeneficiaryRefused), + subtitle: (RegistrationDeliverySingleton().householdType == + HouseholdType.family) + ? widget.distance != null + ? '${householdMember.members?.length ?? 1} ${householdMember.members?.length == 1 ? localizations.translate(i18.beneficiaryDetails.householdMemberSingular) : localizations.translate(i18.beneficiaryDetails.householdMemberPlural)}\n${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts) ${localizations.translate(i18.beneficiaryDetails.fromCurrentLocation)}'}' + : '${householdMember.members?.length ?? 1} ${householdMember.members?.length == 1 ? localizations.translate(i18.beneficiaryDetails.householdMemberSingular) : localizations.translate(i18.beneficiaryDetails.householdMemberPlural)}' + : (widget.distance != null) + ? '(${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts) ${localizations.translate(i18.beneficiaryDetails.fromCurrentLocation)}'}' + : null, + status: (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? null + : getStatus( + tasks ?? [], + householdMember.projectBeneficiaries ?? [], + RegistrationDeliverySingleton().beneficiaryType == + BeneficiaryType.individual + ? isNotEligible + : false, + isBeneficiaryRefused), title: [ householdMember.headOfHousehold?.name?.givenName ?? localizations.translate(i18.common.coreCommonNA), @@ -333,31 +342,34 @@ class ViewBeneficiaryCardState extends LocalizedState { ), ], ), - Offstage( - offstage: !isCardExpanded, - child: DigitTable( - enableBorder: true, - showPagination: false, - columns: filteredHeaderList, - rows: tableData ?? [], + if (RegistrationDeliverySingleton().householdType == + HouseholdType.family) ...[ + Offstage( + offstage: !isCardExpanded, + child: DigitTable( + enableBorder: true, + showPagination: false, + columns: filteredHeaderList, + rows: tableData ?? [], + ), ), - ), - Container( - height: 24, - margin: const EdgeInsets.all(4), - child: Center( - child: IconButton( - padding: EdgeInsets.zero, - icon: Icon( - isCardExpanded - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down, - size: 24, + Container( + height: 24, + margin: const EdgeInsets.all(4), + child: Center( + child: IconButton( + padding: EdgeInsets.zero, + icon: Icon( + isCardExpanded + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down, + size: 24, + ), + onPressed: () => isCardExpanded = !isCardExpanded, ), - onPressed: () => isCardExpanded = !isCardExpanded, ), ), - ), + ] ]); } From c36c17ca5b5afa3ba46728244001bf8250b835a7 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 5 Dec 2024 11:29:57 +0530 Subject: [PATCH 11/19] individual global search to show all total members --- .../individual_global_search.dart | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart b/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart index a474b4c65..1d65e01c9 100644 --- a/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart +++ b/packages/registration_delivery/lib/blocs/search_households/individual_global_search.dart @@ -95,11 +95,19 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { ), ); + var finalHouseholdMembersList = await fetchHouseholdMembersBulk( + null, householdList.map((e) => e.clientReferenceId).toList()); + + individualsList = await individual.search(IndividualSearchModel( + clientReferenceId: finalHouseholdMembersList + .map((e) => e.individualClientReferenceId!) + .toList())); + projectBeneficiariesList = await projectBeneficiary.search( ProjectBeneficiarySearchModel( projectId: [RegistrationDeliverySingleton().projectId.toString()], beneficiaryClientReferenceId: - individualClientReferenceIds.map((e) => e).toList())); + individualsList.map((e) => e.clientReferenceId).toList())); List tasksRelated = await _processTasksAndRelatedData( projectBeneficiariesList, taskList, sideEffectsList, referralsList); @@ -109,7 +117,7 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { referralsList = tasksRelated[2]; await _processHouseholdEntries( - householdMembers, + finalHouseholdMembersList, householdList, individualsList, projectBeneficiariesList, @@ -160,6 +168,20 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { clientReferenceId: houseHoldClientReferenceIds, )); + var finalHouseholdMembersList = await fetchHouseholdMembersBulk( + null, householdList.map((e) => e.clientReferenceId).toList()); + + individualsList = await individual.search(IndividualSearchModel( + clientReferenceId: finalHouseholdMembersList + .map((e) => e.individualClientReferenceId!) + .toList())); + + projectBeneficiariesList = await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + projectId: [RegistrationDeliverySingleton().projectId.toString()], + beneficiaryClientReferenceId: + individualsList.map((e) => e.clientReferenceId).toList())); + finalResults.forEach((element) { taskList.add(element); }); @@ -173,7 +195,7 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { // Process household entries and add to containers await _processHouseholdEntries( - householdMembersList, + finalHouseholdMembersList, householdList, individualsList, projectBeneficiariesList, @@ -206,11 +228,19 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { .toList(), )); + var finalHouseholdMembersList = await fetchHouseholdMembersBulk( + null, householdList.map((e) => e.clientReferenceId).toList()); + + individualsList = await individual.search(IndividualSearchModel( + clientReferenceId: finalHouseholdMembersList + .map((e) => e.individualClientReferenceId!) + .toList())); + projectBeneficiariesList = await projectBeneficiary.search( ProjectBeneficiarySearchModel( projectId: [RegistrationDeliverySingleton().projectId.toString()], beneficiaryClientReferenceId: - individualClientReferenceIds.map((e) => e).toList())); + individualsList.map((e) => e.clientReferenceId).toList())); List tasksRelated = await _processTasksAndRelatedData( projectBeneficiariesList, taskList, sideEffectsList, referralsList); @@ -220,7 +250,7 @@ class IndividualGlobalSearchBloc extends SearchHouseholdsBloc { referralsList = tasksRelated[2]; await _processHouseholdEntries( - householdMembers, + finalHouseholdMembersList, householdList, individualsList, projectBeneficiariesList, From c9a7b24537286fcb7e03bbf88010468c33902683 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 5 Dec 2024 16:49:00 +0530 Subject: [PATCH 12/19] added search by building name --- .../data/repositories/local/household.dart | 1 + .../local/household_global_search.dart | 30 ++++++++++++++--- .../local/individual_global_search.dart | 33 ++++++++++++++++--- .../pages/beneficiary/household_overview.dart | 6 ++-- .../lib/pages/search_beneficiary.dart | 5 ++- 5 files changed, 61 insertions(+), 14 deletions(-) diff --git a/packages/registration_delivery/lib/data/repositories/local/household.dart b/packages/registration_delivery/lib/data/repositories/local/household.dart index 31de2a1e8..8e1996987 100644 --- a/packages/registration_delivery/lib/data/repositories/local/household.dart +++ b/packages/registration_delivery/lib/data/repositories/local/household.dart @@ -102,6 +102,7 @@ class HouseholdLocalRepository ? null : AddressModel( id: address.id, + buildingName: address.buildingName, relatedClientReferenceId: household.clientReferenceId, tenantId: address.tenantId, doorNo: address.doorNo, diff --git a/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart index b3945bb11..3433e975a 100644 --- a/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:math' as math; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:drift/drift.dart'; import 'package:flutter/material.dart'; import 'package:registration_delivery/models/entities/task.dart'; @@ -229,7 +230,12 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { .individual .select() .join([joinName(sql), joinIndividualAddress(sql)]); - await searchByName(selectQuery, params, sql); + if (params.householdType == HouseholdType.community) { + await searchByBuildingName(selectQuery, params, sql); + } else { + await searchByName(selectQuery, params, sql); + } + selectQuery = selectQuery.join([ leftOuterJoin( sql.householdMember, @@ -250,10 +256,14 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { } else if (params.nameSearch != null && params.nameSearch!.isNotEmpty && selectQuery != null) { - selectQuery = selectQuery.join([ - joinName(sql), - ]); - selectQuery = searchByName(selectQuery, params, sql); + if (params.householdType == HouseholdType.community) { + selectQuery = searchByBuildingName(selectQuery, params, sql); + } else { + selectQuery = selectQuery.join([ + joinName(sql), + ]); + selectQuery = searchByName(selectQuery, params, sql); + } } return selectQuery; } @@ -383,6 +393,16 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { ); } + searchByBuildingName( + selectQuery, GlobalSearchParameters params, LocalSqlDataStore sql) { + return selectQuery.where(buildAnd([ + if (params.nameSearch != null) + buildOr([ + sql.address.buildingName.contains(params.nameSearch!), + ]), + ])); + } + joinHouseHoldAddress(LocalSqlDataStore sql) { return leftOuterJoin( sql.household, diff --git a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart index 79161d756..909bbfa74 100644 --- a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart @@ -235,8 +235,10 @@ class IndividualGlobalSearchRepository extends LocalRepository { .individual .select() .join([joinName(sql), joinIndividualAddress(sql)]); - await searchByName(selectQuery, params, sql); + if (params.householdClientReferenceId != null) { + await searchByName(selectQuery, params, sql); + selectQuery = selectQuery.join([ leftOuterJoin( sql.household, @@ -259,6 +261,12 @@ class IndividualGlobalSearchRepository extends LocalRepository { .equals(params.householdClientReferenceId ?? '') ])); } else { + if (params.householdType == HouseholdType.community) { + await searchByBuildingName(selectQuery, params, sql); + } else { + await searchByName(selectQuery, params, sql); + } + selectQuery = selectQuery.join([ leftOuterJoin( sql.householdMember, @@ -283,10 +291,15 @@ class IndividualGlobalSearchRepository extends LocalRepository { } else if (params.nameSearch != null && params.nameSearch!.isNotEmpty && selectQuery != null) { - selectQuery = selectQuery.join([ - joinName(sql), - ]); - selectQuery = searchByName(selectQuery, params, sql); + if (params.householdType == HouseholdType.community && + params.householdClientReferenceId == null) { + selectQuery = searchByBuildingName(selectQuery, params, sql); + } else { + selectQuery = selectQuery.join([ + joinName(sql), + ]); + selectQuery = searchByName(selectQuery, params, sql); + } } return selectQuery; } @@ -303,6 +316,16 @@ class IndividualGlobalSearchRepository extends LocalRepository { ])); } + searchByBuildingName( + selectQuery, GlobalSearchParameters params, LocalSqlDataStore sql) { + return selectQuery.where(buildAnd([ + if (params.nameSearch != null) + buildOr([ + sql.address.buildingName.contains(params.nameSearch!), + ]), + ])); + } + filterSearch(selectQuery, GlobalSearchParameters params, String filter, LocalSqlDataStore sql) async { var sql = super.sql; diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index a90de0ed6..057a4b00e 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -441,9 +441,9 @@ class _HouseholdOverviewPageState .householdOverView .instituteNameLabel): state .householdMemberWrapper - .headOfHousehold - ?.name - ?.givenName ?? + .household + ?.address + ?.buildingName ?? localizations.translate( i18.common.coreCommonNA), localizations.translate( diff --git a/packages/registration_delivery/lib/pages/search_beneficiary.dart b/packages/registration_delivery/lib/pages/search_beneficiary.dart index d526104a5..1d30e3999 100644 --- a/packages/registration_delivery/lib/pages/search_beneficiary.dart +++ b/packages/registration_delivery/lib/pages/search_beneficiary.dart @@ -204,7 +204,10 @@ class _SearchBeneficiaryPageState null && RegistrationDeliverySingleton() .searchHouseHoldFilter! - .isNotEmpty + .isNotEmpty && + RegistrationDeliverySingleton() + .householdType != + HouseholdType.community ? Align( alignment: Alignment.topLeft, child: Padding( From 77fbcbe51796646101ec0531cd857d95348788fe Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 5 Dec 2024 16:50:03 +0530 Subject: [PATCH 13/19] added test case for household overview bloc --- .../test/constants/test_constants.dart | 8 +- .../test/household_overview_test.dart | 76 +++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/packages/registration_delivery/test/constants/test_constants.dart b/packages/registration_delivery/test/constants/test_constants.dart index 3783e71f5..bf2592911 100644 --- a/packages/registration_delivery/test/constants/test_constants.dart +++ b/packages/registration_delivery/test/constants/test_constants.dart @@ -48,6 +48,7 @@ class RegistrationDeliveryTestConstants { static IndividualModel individualModel = IndividualModel( clientReferenceId: '1ce2-3f4g-5h6i-7j8k-9l0m', + name: NameModel(givenName: 'test'), address: [mockAddress], ); @@ -64,6 +65,9 @@ class RegistrationDeliveryTestConstants { static HouseholdMemberWrapper householdMemberWrapper = HouseholdMemberWrapper( household: mockHousehold, headOfHousehold: mockIndividual, - members: [], - projectBeneficiaries: []); + members: [individualModel], + projectBeneficiaries: [mockProjectBeneficiary], + tasks: [], + sideEffects: [], + referrals: []); } diff --git a/packages/registration_delivery/test/household_overview_test.dart b/packages/registration_delivery/test/household_overview_test.dart index aa5be5c24..dc9503113 100644 --- a/packages/registration_delivery/test/household_overview_test.dart +++ b/packages/registration_delivery/test/household_overview_test.dart @@ -1,4 +1,5 @@ import 'package:bloc_test/bloc_test.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_data_model/utils/typedefs.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; @@ -11,6 +12,7 @@ import 'package:registration_delivery/models/entities/project_beneficiary.dart'; import 'package:registration_delivery/models/entities/referral.dart'; import 'package:registration_delivery/models/entities/side_effect.dart'; import 'package:registration_delivery/models/entities/task.dart'; +import 'package:registration_delivery/utils/global_search_parameters.dart'; import 'package:registration_delivery/utils/typedefs.dart'; import 'constants/test_constants.dart'; @@ -52,6 +54,8 @@ void main() { mockIndividualGlobalSearchRepository; setUp(() { + mockIndividualGlobalSearchRepository = + MockIndividualGlobalSearchRepository(); mockHouseholdDataRepository = MockHouseholdDataRepository(); mockIndividualDataRepository = MockIndividualDataRepository(); mockHouseholdMemberDataRepository = MockHouseholdMemberDataRepository(); @@ -79,6 +83,18 @@ void main() { }); setUpAll(() { + registerFallbackValue(GlobalSearchParameters( + householdType: HouseholdType.community, + householdClientReferenceId: '1ce2-3f4g-5h6i-7j8k-9l0m', + isProximityEnabled: false, + latitude: null, + longitude: null, + maxRadius: null, + nameSearch: 'test', + offset: null, + limit: null, + filter: [], + )); registerFallbackValue(HouseholdSearchModel()); registerFallbackValue(HouseholdMemberSearchModel()); registerFallbackValue(IndividualSearchModel()); @@ -124,4 +140,64 @@ void main() { ) ], ); + + //Test case for when search is performed + blocTest( + 'emits [loading: true, search results] when search is performed', + build: () { + // Mock search behavior for individual and household members + when(() => + mockIndividualGlobalSearchRepository + .individualGlobalSearch(any())).thenAnswer((_) async => { + 'total_count': 0, + 'data': [RegistrationDeliveryTestConstants.individualModel] + }); + + when(() => mockHouseholdMemberDataRepository.search(any())) + .thenAnswer((_) async => [ + RegistrationDeliveryTestConstants.mockHouseholdMember, + ]); + when(() => mockHouseholdDataRepository.search(any())) + .thenAnswer((_) async => [ + RegistrationDeliveryTestConstants.mockHousehold, + ]); + when(() => mockIndividualDataRepository.search(any())) + .thenAnswer((_) async => [ + RegistrationDeliveryTestConstants.mockIndividual, + ]); + when(() => mockProjectBeneficiaryDataRepository.search(any())) + .thenAnswer((_) async => [ + RegistrationDeliveryTestConstants.mockProjectBeneficiary, + ]); + when(() => mockTaskDataRepository.search(any())) + .thenAnswer((_) async => []); + when(() => mockSideEffectDataRepository.search(any())) + .thenAnswer((_) async => []); + when(() => mockReferralDataRepository.search(any())) + .thenAnswer((_) async => []); + + return householdOverviewBloc; + }, + act: (bloc) { + // Perform a search query + bloc.add(const HouseholdOverviewReloadEvent( + projectId: RegistrationDeliveryTestConstants.testProjectId, + projectBeneficiaryType: BeneficiaryType.individual, + searchByName: 'test', + selectedFilter: [], + )); + }, + expect: () => [ + HouseholdOverviewState( + loading: true, + householdMemberWrapper: + RegistrationDeliveryTestConstants.householdMemberWrapper, + ), + HouseholdOverviewState( + loading: false, + householdMemberWrapper: + RegistrationDeliveryTestConstants.householdMemberWrapper, + offset: 10), + ], + ); } From 8bf341cc8c72863eceaef3a2f11875a48b867ae5 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Fri, 6 Dec 2024 10:26:27 +0530 Subject: [PATCH 14/19] removed clf hard-coded value --- apps/health_campaign_field_worker_app/lib/pages/home.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/pages/home.dart b/apps/health_campaign_field_worker_app/lib/pages/home.dart index 017cf43ca..798440eac 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/home.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/home.dart @@ -567,8 +567,7 @@ class _HomePageState extends LocalizedState { .map((e) => e.displayName) .toList() .contains(element) || - element == i18.home.db || - element == i18.home.clfLabel) + element == i18.home.db) .toList(); final showcaseKeys = filteredLabels From 779356017a541a9b90e23bf9367b12860bc326ab Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Mon, 16 Dec 2024 17:29:51 +0530 Subject: [PATCH 15/19] added placeholder for building name for clf --- .../pubspec.lock | 15 ++------ .../household_location.dart | 37 +++++++++++++++++++ .../lib/utils/i18_key_constants.dart | 6 +++ .../showcase/config/household_location.dart | 4 ++ 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/apps/health_campaign_field_worker_app/pubspec.lock b/apps/health_campaign_field_worker_app/pubspec.lock index e49f4e151..83b799cf2 100644 --- a/apps/health_campaign_field_worker_app/pubspec.lock +++ b/apps/health_campaign_field_worker_app/pubspec.lock @@ -1334,13 +1334,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.1+1" - institution_campaign: - dependency: "direct overridden" - description: - path: "../../packages/institution_campaign" - relative: true - source: path - version: "0.0.1" integration_test: dependency: "direct dev" description: flutter @@ -1350,10 +1343,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.19.0" inventory_management: dependency: "direct main" description: @@ -1557,10 +1550,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79" + sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017" url: "https://pub.dev" source: hosted - version: "5.0.1" + version: "4.2.0" package_info_plus_platform_interface: dependency: transitive description: diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index f17024fa8..078b2a46a 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -43,6 +43,7 @@ class HouseholdLocationPageState extends LocalizedState { static const _lngKey = 'lng'; static const _accuracyKey = 'accuracy'; static const maxLength = 64; + static const _buildingNameKey = 'buildingName'; @override void initState() { @@ -192,6 +193,11 @@ class HouseholdLocationPageState extends LocalizedState { tenantId: RegistrationDeliverySingleton().tenantId, rowVersion: 1, + buildingName: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? form.control(_buildingNameKey).value + : null, auditDetails: AuditDetails( createdBy: RegistrationDeliverySingleton() .loggedInUserUuid!, @@ -248,6 +254,11 @@ class HouseholdLocationPageState extends LocalizedState { type: AddressType.correspondence, latitude: form.control(_latKey).value, longitude: form.control(_lngKey).value, + buildingName: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? form.control(_buildingNameKey).value + : null, locationAccuracy: form.control(_accuracyKey).value, ); @@ -335,6 +346,27 @@ class HouseholdLocationPageState extends LocalizedState { ), ), ), + if (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + householdLocationShowcaseData.buildingName.buildWith( + child: ReactiveWrapperField( + formControlName: _buildingNameKey, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.min2CharsRequired, + ), + }, + builder: (field) => LabeledField( + label: localizations.translate( + i18.householdLocation.buildingNameLabel), + isRequired: true, + child: DigitTextFormInput( + errorMessage: field.errorText, + onChange: (value) { + form.control(_buildingNameKey).value = + value; + }, + )))), householdLocationShowcaseData.addressLine1.buildWith( child: ReactiveWrapperField( formControlName: _addressLine1Key, @@ -494,6 +526,11 @@ class HouseholdLocationPageState extends LocalizedState { _accuracyKey: FormControl( value: addressModel?.locationAccuracy, ), + if (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + _buildingNameKey: FormControl( + validators: [Validators.required], + ), }); } } diff --git a/packages/registration_delivery/lib/utils/i18_key_constants.dart b/packages/registration_delivery/lib/utils/i18_key_constants.dart index 3572c0142..7331f72ba 100644 --- a/packages/registration_delivery/lib/utils/i18_key_constants.dart +++ b/packages/registration_delivery/lib/utils/i18_key_constants.dart @@ -308,6 +308,8 @@ class IndividualDetails { class HouseholdLocation { const HouseholdLocation(); + String get buildingNameLabel => 'CLF_BUILDING_NAME_LABEL_TEXT'; + String get clfLocationLabelText => 'CLF_LOCATION_LABEL_TEXT'; String get householdLocationLabelText => 'HOUSEHOLD_LOCATION_LABEL_TEXT'; @@ -758,6 +760,10 @@ String get registerNewHousehold { class HouseholdLocationShowcase { const HouseholdLocationShowcase(); + String get buildingName { + return 'HOUSEHOLD_LOCATION_SHOWCASE_BUILDING_NAME'; + } + String get administrativeArea { return 'HOUSEHOLD_LOCATION_SHOWCASE_ADMINISTRATIVE_AREA'; } diff --git a/packages/registration_delivery/lib/widgets/showcase/config/household_location.dart b/packages/registration_delivery/lib/widgets/showcase/config/household_location.dart index 5a164ce5a..bd3f6e625 100644 --- a/packages/registration_delivery/lib/widgets/showcase/config/household_location.dart +++ b/packages/registration_delivery/lib/widgets/showcase/config/household_location.dart @@ -29,6 +29,10 @@ class _HouseholdLocationShowcaseData { messageLocalizationKey: i18.householdLocationShowcase.landmark, ); + final buildingName = ShowcaseItemBuilder( + messageLocalizationKey: i18.householdLocationShowcase.buildingName, + ); + final addressLine1 = ShowcaseItemBuilder( messageLocalizationKey: i18.householdLocationShowcase.address, ); From ce7745a223201b0132dc56e5f9e4ceb01c097bb1 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Thu, 19 Dec 2024 10:13:07 +0530 Subject: [PATCH 16/19] fix member count --- .../pages/beneficiary_registration/house_details.dart | 9 ++++++++- .../beneficiary_registration/household_location.dart | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart index 076be78f4..8f51457a7 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart @@ -116,7 +116,14 @@ class HouseDetailsPageState extends LocalizedState { createdTime: context.millisecondsSinceEpoch(), ), - memberCount: householdModel?.memberCount, + + ///[TODO]: NEED TO FIX THIS + memberCount: + (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? 0 + : householdModel?.memberCount, clientAuditDetails: ClientAuditDetails( createdBy: RegistrationDeliverySingleton() diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index 078b2a46a..a4cb28bfe 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -346,6 +346,8 @@ class HouseholdLocationPageState extends LocalizedState { ), ), ), + + ///[TODO]: NEED TO REMOVE THIS if (RegistrationDeliverySingleton().householdType == HouseholdType.community) householdLocationShowcaseData.buildingName.buildWith( From fafc934c049a795e0a44886c5803b38d3f8fed48 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Fri, 20 Dec 2024 10:25:21 +0530 Subject: [PATCH 17/19] fix issues with pagination and filter --- .../household_overview.dart | 7 +- .../local/individual_global_search.dart | 18 +- .../pages/beneficiary/household_overview.dart | 131 ++-- .../house_details.dart | 580 ++++++++++-------- .../household_location.dart | 17 +- .../lib/utils/i18_key_constants.dart | 8 + .../lib/utils/utils.dart | 6 + .../beneficiary/view_beneficiary_card.dart | 16 +- 8 files changed, 452 insertions(+), 331 deletions(-) diff --git a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart index 86209f1f3..cddee0f66 100644 --- a/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart +++ b/packages/registration_delivery/lib/blocs/household_overview/household_overview.dart @@ -363,7 +363,7 @@ class HouseholdOverviewBloc emit(state.copyWith( loading: false, - offset: individuals.isNotEmpty + offset: individuals.isNotEmpty && individuals.length == event.limit ? (event.offset ?? 0) + (event.limit ?? 10) : null, householdMemberWrapper: state.householdMemberWrapper.copyWith( @@ -496,7 +496,8 @@ class HouseholdOverviewBloc emit(state.copyWith( loading: false, - offset: individualsList.isNotEmpty + offset: individualsList.isNotEmpty && + individualsList.length == event.limit ? (event.offset ?? 0) + (event.limit ?? 10) : null, householdMemberWrapper: state.householdMemberWrapper.copyWith( @@ -601,7 +602,7 @@ class HouseholdOverviewBloc emit(state.copyWith( loading: false, - offset: individuals.isNotEmpty + offset: individuals.isNotEmpty && individuals.length == event.limit ? (event.offset ?? 0) + (event.limit ?? 10) : null, householdMemberWrapper: state.householdMemberWrapper.copyWith( diff --git a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart index 909bbfa74..681f90b6d 100644 --- a/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/individual_global_search.dart @@ -346,26 +346,16 @@ class IndividualGlobalSearchRepository extends LocalRepository { .equalsExp(sql.individual.clientReferenceId)) ]) ..where(buildAnd([ - if (params.householdType == HouseholdType.community) - sql.householdMember.isHeadOfHousehold.equals(true), sql.householdMember.householdClientReferenceId .equalsExp(sql.household.clientReferenceId), filter == Status.registered.name ? sql.projectBeneficiary.beneficiaryClientReferenceId .isNotNull() - : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull() + : sql.projectBeneficiary.beneficiaryClientReferenceId.isNull(), + if (params.householdClientReferenceId != null) + sql.householdMember.householdClientReferenceId + .equals(params.householdClientReferenceId ?? '') ])); - - if (params.householdClientReferenceId != null) { - selectQuery = selectQuery.join([ - leftOuterJoin( - sql.householdMember, - sql.householdMember.individualClientReferenceId - .equalsExp(sql.individual.clientReferenceId)) - ]) - ..where(sql.householdMember.householdClientReferenceId - .equals(params.householdClientReferenceId ?? '')); - } } else { var filterSearchQuery = await filterTasks(selectQuery, filter, sql, params); diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 057a4b00e..9231ed6ca 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -365,10 +365,16 @@ class _HouseholdOverviewPageState ), ); }, - label: localizations.translate( - i18.householdOverView - .householdOverViewEditIconText, - ), + label: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? localizations.translate(i18 + .householdOverView + .clfOverViewEditIconText) + : localizations.translate( + i18.householdOverView + .householdOverViewEditIconText, + ), type: ButtonType.tertiary, size: ButtonSize.medium, prefixIcon: Icons.edit, @@ -510,65 +516,71 @@ class _HouseholdOverviewPageState ); }), ), - Padding( - padding: const EdgeInsets.only( - top: spacer2, bottom: spacer2), - child: Row( - children: [ - Expanded( - child: DigitSearchBar( - controller: searchController, - hintText: localizations.translate( - i18.common.searchByName, + if (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) ...[ + Padding( + padding: const EdgeInsets.only( + top: spacer2, bottom: spacer2), + child: Row( + children: [ + Expanded( + child: DigitSearchBar( + controller: searchController, + hintText: localizations.translate( + i18.common.searchByName, + ), + textCapitalization: + TextCapitalization.words, + onChanged: (value) { + if (value.length >= 3) { + callReloadEvent( + offset: 0, limit: 10); + } else if (searchController + .value.text.isEmpty) { + callReloadEvent( + offset: 0, limit: 10); + } + }, ), - textCapitalization: - TextCapitalization.words, - onChanged: (value) { - if (value.length >= 3) { - callReloadEvent( - offset: 0, limit: 10); - } else if (searchController - .value.text.isEmpty) { - callReloadEvent( - offset: 0, limit: 10); - } - }, ), - ), - Column( - children: [ - RegistrationDeliverySingleton() - .searchHouseHoldFilter != - null && - RegistrationDeliverySingleton() - .searchHouseHoldFilter! - .isNotEmpty - ? Align( - alignment: Alignment.topLeft, - child: Padding( - padding: - const EdgeInsets.all( - spacer2), - child: Button( - label: - getFilterIconNLabel()[ - 'label'], - size: ButtonSize.medium, - type: ButtonType.tertiary, - suffixIcon: - getFilterIconNLabel()[ - 'icon'], - onPressed: () => - showFilterDialog(), + Column( + children: [ + RegistrationDeliverySingleton() + .searchHouseHoldFilter != + null && + RegistrationDeliverySingleton() + .searchHouseHoldFilter! + .isNotEmpty + ? Align( + alignment: + Alignment.topLeft, + child: Padding( + padding: + const EdgeInsets.all( + spacer2), + child: Button( + label: + getFilterIconNLabel()[ + 'label'], + size: ButtonSize.medium, + type: + ButtonType.tertiary, + suffixIcon: + getFilterIconNLabel()[ + 'icon'], + onPressed: () => + showFilterDialog(), + ), ), - ), - ) - : const Offstage(), - ], - ), - ], + ) + : const Offstage(), + ], + ), + ], + ), ), - ), + ], selectedFilters.isNotEmpty ? Align( alignment: Alignment.topLeft, @@ -1065,6 +1077,7 @@ class _HouseholdOverviewPageState ])); if (filters != null && filters.isNotEmpty) { + selectedFilters.clear(); selectedFilters.addAll(filters); callReloadEvent(offset: 0, limit: 10); } else { diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart index 8f51457a7..58a0d0c7f 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart @@ -49,99 +49,183 @@ class HouseDetailsPageState extends LocalizedState { final router = context.router; final textTheme = theme.digitTextTheme(context); - return Scaffold( - body: ReactiveFormBuilder( - form: () => buildForm(bloc.state), - builder: (_, form, __) => BlocBuilder( - builder: (context, registrationState) { - return ScrollableContent( - enableFixedButton: true, - header: const Column( - children: [ - BackNavigationHelpHeaderWidget( - showcaseButton: ShowcaseButton(), - showHelp: false, + return BlocConsumer( + listener: (context, state) { + if (state is BeneficiaryRegistrationPersistedState && state.isEdit) { + final overviewBloc = context.read(); + + overviewBloc.add( + HouseholdOverviewReloadEvent( + projectId: RegistrationDeliverySingleton().projectId.toString(), + projectBeneficiaryType: + RegistrationDeliverySingleton().beneficiaryType ?? + BeneficiaryType.household, + ), + ); + HouseholdMemberWrapper memberWrapper = + overviewBloc.state.householdMemberWrapper; + final route = router.parent() as StackRouter; + route.popUntilRouteWithName(SearchBeneficiaryRoute.name); + route.push(BeneficiaryWrapperRoute(wrapper: memberWrapper)); + } + }, + listenWhen: (previous, current) => + RegistrationDeliverySingleton().householdType == + HouseholdType.community, + builder: (context, registrationState) { + return Scaffold( + body: ReactiveFormBuilder( + form: () => buildForm(bloc.state), + builder: (_, form, __) => BlocBuilder( + builder: (context, registrationState) { + return ScrollableContent( + enableFixedButton: true, + header: const Column( + children: [ + BackNavigationHelpHeaderWidget( + showcaseButton: ShowcaseButton(), + showHelp: false, + ), + ], ), - ], - ), - footer: DigitCard( - margin: const EdgeInsets.only(top: spacer2), - padding: const EdgeInsets.all(spacer2), - children: [ - Button( - onPressed: () { - form.markAllAsTouched(); - if (form.control(_householdStructureKey).value == - null) { - setState(() { - form + footer: DigitCard( + margin: const EdgeInsets.only(top: spacer2), + padding: const EdgeInsets.all(spacer2), + children: [ + Button( + onPressed: () { + form.markAllAsTouched(); + if (form + .control(_householdStructureKey) + .value == + null) { + setState(() { + form + .control(_householdStructureKey) + .setErrors({'': true}); + }); + } + + if (!form.valid) return; + selectedHouseStructureTypes = form .control(_householdStructureKey) - .setErrors({'': true}); - }); - } + .value; - if (!form.valid) return; - selectedHouseStructureTypes = - form.control(_householdStructureKey).value; + final noOfRooms = + form.control(_noOfRoomsKey).value as int; + registrationState.maybeWhen( + orElse: () { + return; + }, + create: ( + address, + householdModel, + individualModel, + projectBeneficiaryModel, + registrationDate, + searchQuery, + loading, + isHeadOfHousehold, + ) { + var houseModel = HouseholdModel( + householdType: + RegistrationDeliverySingleton() + .householdType, + clientReferenceId: IdGen.i.identifier, + tenantId: + RegistrationDeliverySingleton() + .tenantId, + rowVersion: 1, + auditDetails: AuditDetails( + createdBy: + RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: context + .millisecondsSinceEpoch(), + ), - final noOfRooms = - form.control(_noOfRoomsKey).value as int; - registrationState.maybeWhen( - orElse: () { - return; - }, - create: ( - address, - householdModel, - individualModel, - projectBeneficiaryModel, - registrationDate, - searchQuery, - loading, - isHeadOfHousehold, - ) { - var houseModel = HouseholdModel( - householdType: - RegistrationDeliverySingleton() - .householdType, - clientReferenceId: IdGen.i.identifier, - tenantId: RegistrationDeliverySingleton() - .tenantId, - rowVersion: 1, - auditDetails: AuditDetails( - createdBy: - RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: - context.millisecondsSinceEpoch(), - ), + ///[TODO]: NEED TO FIX THIS + memberCount: + (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? 0 + : householdModel?.memberCount, + clientAuditDetails: + ClientAuditDetails( + createdBy: + RegistrationDeliverySingleton() + .loggedInUserUuid!, + createdTime: context + .millisecondsSinceEpoch(), + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ), + additionalFields: + HouseholdAdditionalFields( + version: 1, + fields: [ + ...?householdModel + ?.additionalFields?.fields + .where((e) => + e.key != + AdditionalFieldsType + .houseStructureTypes + .toValue() && + e.key != + AdditionalFieldsType + .noOfRooms + .toValue()), + AdditionalField( + AdditionalFieldsType + .houseStructureTypes + .toValue(), + selectedHouseStructureTypes + ?.join("|") + .toString(), + ), + AdditionalField( + AdditionalFieldsType.noOfRooms + .toValue(), + noOfRooms, + ) + ])); - ///[TODO]: NEED TO FIX THIS - memberCount: - (RegistrationDeliverySingleton() - .householdType == - HouseholdType.community) - ? 0 - : householdModel?.memberCount, - clientAuditDetails: ClientAuditDetails( - createdBy: - RegistrationDeliverySingleton() - .loggedInUserUuid!, - createdTime: - context.millisecondsSinceEpoch(), - lastModifiedBy: - RegistrationDeliverySingleton() - .loggedInUserUuid, - lastModifiedTime: - context.millisecondsSinceEpoch(), - ), - additionalFields: - HouseholdAdditionalFields( - version: 1, - fields: [ + bloc.add( + BeneficiaryRegistrationSaveHouseDetailsEvent( + model: houseModel, + ), + ); + if (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) { + router.push(IndividualDetailsRoute( + isHeadOfHousehold: true)); + } else { + router.push(HouseHoldDetailsRoute()); + } + }, + editHousehold: ( + address, + householdModel, + individuals, + registrationDate, + projectBeneficiaryModel, + loading, + headOfHousehold, + ) { + var houseModel = householdModel.copyWith( + additionalFields: + HouseholdAdditionalFields( + version: 1, + fields: [ ...?householdModel - ?.additionalFields?.fields + .additionalFields?.fields .where((e) => e.key != AdditionalFieldsType @@ -165,113 +249,114 @@ class HouseDetailsPageState extends LocalizedState { noOfRooms, ) ])); + // TODO [Linking of Voucher for Household based project need to be handled] - bloc.add( - BeneficiaryRegistrationSaveHouseDetailsEvent( - model: houseModel, - ), - ); - if (RegistrationDeliverySingleton() - .householdType == - HouseholdType.community) { - router.push(IndividualDetailsRoute( - isHeadOfHousehold: true)); - } else { - router.push(HouseHoldDetailsRoute()); - } - }, - editHousehold: ( - address, - householdModel, - individuals, - registrationDate, - projectBeneficiaryModel, - loading, - headOfHousehold, - ) { - var houseModel = householdModel.copyWith( - additionalFields: - HouseholdAdditionalFields( - version: 1, - fields: [ - ...?householdModel - .additionalFields?.fields - .where((e) => - e.key != - AdditionalFieldsType - .houseStructureTypes - .toValue() && - e.key != - AdditionalFieldsType - .noOfRooms - .toValue()), - AdditionalField( - AdditionalFieldsType - .houseStructureTypes - .toValue(), - selectedHouseStructureTypes - ?.join("|") - .toString(), - ), - AdditionalField( - AdditionalFieldsType.noOfRooms - .toValue(), - noOfRooms, - ) - ])); - // TODO [Linking of Voucher for Household based project need to be handled] - - bloc.add( - BeneficiaryRegistrationSaveHouseDetailsEvent( - model: houseModel, - ), + if (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) { + bloc.add( + BeneficiaryRegistrationUpdateHouseholdDetailsEvent( + household: houseModel.copyWith( + clientAuditDetails: (address + .clientAuditDetails + ?.createdBy != + null && + address.clientAuditDetails + ?.createdTime != + null) + ? ClientAuditDetails( + createdBy: address + .clientAuditDetails! + .createdBy, + createdTime: address + .clientAuditDetails! + .createdTime, + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ) + : null, + ), + addressModel: address.copyWith( + clientAuditDetails: (address + .clientAuditDetails + ?.createdBy != + null && + address.clientAuditDetails + ?.createdTime != + null) + ? ClientAuditDetails( + createdBy: address + .clientAuditDetails! + .createdBy, + createdTime: address + .clientAuditDetails! + .createdTime, + lastModifiedBy: + RegistrationDeliverySingleton() + .loggedInUserUuid, + lastModifiedTime: context + .millisecondsSinceEpoch(), + ) + : null, + ), + ), + ); + } else { + bloc.add( + BeneficiaryRegistrationSaveHouseDetailsEvent( + model: houseModel, + ), + ); + router.push(HouseHoldDetailsRoute()); + } + }, ); - if (RegistrationDeliverySingleton() - .householdType == - HouseholdType.community) { - router.push(IndividualDetailsRoute( - isHeadOfHousehold: - headOfHousehold != null - ? true - : false)); - } else { - router.push(HouseHoldDetailsRoute()); - } }, - ); - }, - type: ButtonType.primary, - size: ButtonSize.large, - mainAxisSize: MainAxisSize.max, - label: localizations.translate( - i18.householdLocation.actionLabel, - ), - ), - ]), - slivers: [ - SliverToBoxAdapter( - child: DigitCard(children: [ - Padding( - padding: const EdgeInsets.all(spacer2), - child: Text( - localizations.translate( - i18.householdDetails.houseDetailsLabel, + type: ButtonType.primary, + size: ButtonSize.large, + mainAxisSize: MainAxisSize.max, + label: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? registrationState.mapOrNull( + editHousehold: (value) => + localizations.translate( + i18.common.coreCommonSave), + ) ?? + localizations.translate( + i18.householdDetails.actionLabel) + : localizations.translate( + i18.householdDetails.actionLabel), ), - style: textTheme.headingXl, - ), - ), - houseShowcaseData.typeOfStructure.buildWith( - child: SelectionCard( - isRequired: true, - title: localizations.translate( - i18.householdDetails.typeOfStructure), - equalWidthOptions: true, - allowMultipleSelection: false, - options: RegistrationDeliverySingleton() - .houseStructureTypes ?? - [], - initialSelection: - form.control(_householdStructureKey).value != + ]), + slivers: [ + SliverToBoxAdapter( + child: DigitCard(children: [ + Padding( + padding: const EdgeInsets.all(spacer2), + child: Text( + localizations.translate( + i18.householdDetails.houseDetailsLabel, + ), + style: textTheme.headingXl, + ), + ), + houseShowcaseData.typeOfStructure.buildWith( + child: SelectionCard( + isRequired: true, + title: localizations.translate( + i18.householdDetails.typeOfStructure), + equalWidthOptions: true, + allowMultipleSelection: false, + options: RegistrationDeliverySingleton() + .houseStructureTypes ?? + [], + initialSelection: form + .control(_householdStructureKey) + .value != null ? [ ...form @@ -279,69 +364,74 @@ class HouseDetailsPageState extends LocalizedState { .value ] : [], - onSelectionChanged: (values) { - form - .control(_householdStructureKey) - .markAsTouched(); - if (values.isEmpty) { - form.control(_householdStructureKey).value = - null; - setState(() { + onSelectionChanged: (values) { form .control(_householdStructureKey) - .setErrors({'': true}); - }); - } else { - setState(() { - form.control(_householdStructureKey).value = - values; - }); - } - }, - valueMapper: (value) { - return localizations - .translate(value.toString()); - }, - errorMessage: form - .control(_householdStructureKey) - .hasErrors && + .markAsTouched(); + if (values.isEmpty) { form .control(_householdStructureKey) - .touched - ? localizations.translate(i18.householdDetails - .selectStructureTypeError) - : null, - ), - ), - houseShowcaseData.noOfRooms.buildWith( - child: ReactiveWrapperField( - formControlName: _noOfRoomsKey, - builder: (field) => LabeledField( - label: localizations.translate( - i18.householdDetails.noOfRoomsLabel, - ), - child: DigitNumericFormInput( - minValue: 1, - maxValue: 20, - initialValue: form - .control(_noOfRoomsKey) - .value - .toString(), - step: 1, - onChange: (value) { - form.control(_noOfRoomsKey).value = - int.parse(value); + .value = null; + setState(() { + form + .control(_householdStructureKey) + .setErrors({'': true}); + }); + } else { + setState(() { + form + .control(_householdStructureKey) + .value = values; + }); + } + }, + valueMapper: (value) { + return localizations + .translate(value.toString()); }, + errorMessage: form + .control(_householdStructureKey) + .hasErrors && + form + .control(_householdStructureKey) + .touched + ? localizations.translate(i18 + .householdDetails + .selectStructureTypeError) + : null, ), ), - ), + houseShowcaseData.noOfRooms.buildWith( + child: ReactiveWrapperField( + formControlName: _noOfRoomsKey, + builder: (field) => LabeledField( + label: localizations.translate( + i18.householdDetails.noOfRoomsLabel, + ), + child: DigitNumericFormInput( + minValue: 1, + maxValue: 20, + initialValue: form + .control(_noOfRoomsKey) + .value + .toString(), + step: 1, + onChange: (value) { + form.control(_noOfRoomsKey).value = + int.parse(value); + }, + ), + ), + ), + ), + ]), ), - ]), - ), - ], - ); - }, - )), + ], + ); + }, + )), + ); + }, ); } diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index a4cb28bfe..cf430b12a 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -355,8 +355,13 @@ class HouseholdLocationPageState extends LocalizedState { formControlName: _buildingNameKey, validationMessages: { 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, + i18.common.corecommonRequired, ), + 'sizeLessThan2': (_) => localizations + .translate(i18.common.min3CharsRequired), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', maxLength.toString()), }, builder: (field) => LabeledField( label: localizations.translate( @@ -368,6 +373,8 @@ class HouseholdLocationPageState extends LocalizedState { form.control(_buildingNameKey).value = value; }, + initialValue: + form.control(_buildingNameKey).value, )))), householdLocationShowcaseData.addressLine1.buildWith( child: ReactiveWrapperField( @@ -530,9 +537,11 @@ class HouseholdLocationPageState extends LocalizedState { ), if (RegistrationDeliverySingleton().householdType == HouseholdType.community) - _buildingNameKey: FormControl( - validators: [Validators.required], - ), + _buildingNameKey: FormControl(validators: [ + Validators.required, + CustomValidator.sizeLessThan2, + Validators.maxLength(64), + ], value: addressModel?.buildingName), }); } } diff --git a/packages/registration_delivery/lib/utils/i18_key_constants.dart b/packages/registration_delivery/lib/utils/i18_key_constants.dart index 7331f72ba..7cd59ab8d 100644 --- a/packages/registration_delivery/lib/utils/i18_key_constants.dart +++ b/packages/registration_delivery/lib/utils/i18_key_constants.dart @@ -91,6 +91,8 @@ class Common { String get min2CharsRequired => 'MIN_2_CHARS_REQUIRED'; + String get min3CharsRequired => 'MIN_3_CHARS_REQUIRED'; + String get maxCharsRequired => 'MAX_CHARS_ALLOWED'; String get maxValue => 'MAX_VALUE_ALLOWED'; @@ -431,12 +433,16 @@ class HouseholdOverView { String get householdOverViewEditLabel => 'HOUSEHOLD_OVER_VIEW_EDIT_ICON_LABEL'; + String get clfOverViewEditLabel => 'CLF_OVER_VIEW_EDIT_ICON_LABEL'; + String get householdOverViewDeleteLabel => 'HOUSEHOLD_OVER_VIEW_DELETE_ICON_LABEL'; String get householdOverViewEditIconText => 'HOUSEHOLD_OVER_VIEW_EDIT_ICON_LABEL_TEXT'; + String get clfOverViewEditIconText => 'CLF_OVER_VIEW_EDIT_ICON_LABEL_TEXT'; + String get householdOverViewActionCardTitle => 'HOUSEHOLD_OVER_VIEW_ACTION_CARD_TITLE'; @@ -485,6 +491,8 @@ class MemberCard { String get assignAsHouseholdhead => 'MEMBER_CARD_ASSIGN_AS_HEAD'; + String get assignAsClfhead => 'MEMBER_CARD_ASSIGN_AS_CLF'; + String get editIndividualDetails => 'MEMBER_CARD_EDIT_INDIVIDUAL_DETAILS'; String get deleteIndividualActionText => diff --git a/packages/registration_delivery/lib/utils/utils.dart b/packages/registration_delivery/lib/utils/utils.dart index f57729570..dc6d03269 100644 --- a/packages/registration_delivery/lib/utils/utils.dart +++ b/packages/registration_delivery/lib/utils/utils.dart @@ -28,6 +28,12 @@ class CustomValidator { : {'required': true}; } + static Map? sizeLessThan2(AbstractControl control) { + return control.value != null && control.value.toString().length <= 2 + ? {'sizeLessThan2': true} + : null; + } + static Map? validMobileNumber( AbstractControl control, ) { diff --git a/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart b/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart index ef1fe44f8..79258c5ff 100644 --- a/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart +++ b/packages/registration_delivery/lib/widgets/beneficiary/view_beneficiary_card.dart @@ -311,7 +311,7 @@ class ViewBeneficiaryCardState extends LocalizedState { ? '${householdMember.members?.length ?? 1} ${householdMember.members?.length == 1 ? localizations.translate(i18.beneficiaryDetails.householdMemberSingular) : localizations.translate(i18.beneficiaryDetails.householdMemberPlural)}\n${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts) ${localizations.translate(i18.beneficiaryDetails.fromCurrentLocation)}'}' : '${householdMember.members?.length ?? 1} ${householdMember.members?.length == 1 ? localizations.translate(i18.beneficiaryDetails.householdMemberSingular) : localizations.translate(i18.beneficiaryDetails.householdMemberPlural)}' : (widget.distance != null) - ? '(${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts) ${localizations.translate(i18.beneficiaryDetails.fromCurrentLocation)}'}' + ? '${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts) ${localizations.translate(i18.beneficiaryDetails.fromCurrentLocation)}'}' : null, status: (RegistrationDeliverySingleton().householdType == HouseholdType.community) @@ -324,11 +324,15 @@ class ViewBeneficiaryCardState extends LocalizedState { ? isNotEligible : false, isBeneficiaryRefused), - title: [ - householdMember.headOfHousehold?.name?.givenName ?? - localizations.translate(i18.common.coreCommonNA), - householdMember.headOfHousehold?.name?.familyName, - ].whereNotNull().join(''), + title: (RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? householdMember.household?.address?.buildingName ?? + localizations.translate(i18.common.coreCommonNA) + : [ + householdMember.headOfHousehold?.name?.givenName ?? + localizations.translate(i18.common.coreCommonNA), + householdMember.headOfHousehold?.name?.familyName, + ].whereNotNull().join(''), ), ), Flexible( From c90f7a4800097907f7c57a62c1a59825038f4cb2 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Fri, 20 Dec 2024 14:52:37 +0530 Subject: [PATCH 18/19] resolved review comments --- .../data/local_store/sql_store/sql_store.dart | 6 +- packages/digit_data_model/pubspec.lock | 433 +++++++++++++++++- packages/digit_data_model/pubspec.yaml | 2 +- .../local/household_global_search.dart | 4 +- .../pages/beneficiary/household_overview.dart | 43 +- .../household_location.dart | 19 +- .../individual_details.dart | 7 +- .../lib/pages/search_beneficiary.dart | 30 +- .../lib/utils/utils.dart | 28 ++ .../lib/widgets/member_card/member_card.dart | 15 +- 10 files changed, 507 insertions(+), 80 deletions(-) diff --git a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart index ad544fbdf..ce33c8ef4 100644 --- a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart +++ b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.dart @@ -1,8 +1,8 @@ // Importing necessary packages and files. import 'dart:io'; -import 'package:digit_components/utils/app_logger.dart'; import 'package:digit_data_model/data/local_store/sql_store/tables/localization.dart'; +import 'package:digit_ui_components/utils/app_logger.dart'; import 'package:drift/drift.dart'; import 'package:drift/native.dart'; import 'package:path/path.dart' as p; @@ -110,7 +110,7 @@ class LocalSqlDataStore extends _$LocalSqlDataStore { /// The `schemaVersion` getter returns the schema version of the database. @override - int get schemaVersion => 5; + int get schemaVersion => 6; /// The `_openConnection` method opens a connection to the database. /// It returns a `LazyDatabase` that opens the database when it is first accessed. @@ -132,7 +132,7 @@ class LocalSqlDataStore extends _$LocalSqlDataStore { await m.createAll(); }, onUpgrade: (Migrator m, int from, int to) async { //Add column for householdType for facility based campaign - if (from < 5) { + if (from < 6) { try { AppLogger.instance.info('Apply migration $from to $to'); await m.addColumn(household, household.householdType); diff --git a/packages/digit_data_model/pubspec.lock b/packages/digit_data_model/pubspec.lock index 638fab2f7..be17ed537 100644 --- a/packages/digit_data_model/pubspec.lock +++ b/packages/digit_data_model/pubspec.lock @@ -145,6 +145,46 @@ packages: url: "https://pub.dev" source: hosted version: "8.9.2" + camera: + dependency: transitive + description: + name: camera + sha256: "9499cbc2e51d8eb0beadc158b288380037618ce4e30c9acbc4fae1ac3ecb5797" + url: "https://pub.dev" + source: hosted + version: "0.10.5+9" + camera_android: + dependency: transitive + description: + name: camera_android + sha256: b350ac087f111467e705b2b76cc1322f7f5bdc122aa83b4b243b0872f390d229 + url: "https://pub.dev" + source: hosted + version: "0.10.9+2" + camera_avfoundation: + dependency: transitive + description: + name: camera_avfoundation + sha256: "608b56b0880722f703871329c4d7d4c2f379c8e2936940851df7fc041abc6f51" + url: "https://pub.dev" + source: hosted + version: "0.9.13+10" + camera_platform_interface: + dependency: transitive + description: + name: camera_platform_interface + sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061 + url: "https://pub.dev" + source: hosted + version: "2.8.0" + camera_web: + dependency: transitive + description: + name: camera_web + sha256: b9235ec0a2ce949daec546f1f3d86f05c3921ed31c7d9ab6b7c03214d152fc2d + url: "https://pub.dev" + source: hosted + version: "0.3.4" characters: dependency: transitive description: @@ -217,6 +257,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.0" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e + url: "https://pub.dev" + source: hosted + version: "0.3.3+8" crypto: dependency: transitive description: @@ -225,6 +273,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + csslib: + dependency: transitive + description: + name: csslib + sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" cupertino_icons: dependency: transitive description: @@ -283,12 +339,20 @@ packages: source: hosted version: "0.4.1" digit_components: - dependency: "direct main" + dependency: "direct overridden" description: path: "../digit_components" relative: true source: path version: "1.0.2+1" + digit_ui_components: + dependency: "direct main" + description: + name: digit_ui_components + sha256: e38f163515aa6a6c5283754e741b21f33fb3a6c0a1fc171a1e4e6620510d46ae + url: "https://pub.dev" + source: hosted + version: "0.0.1+7" dio: dependency: "direct main" description: @@ -297,6 +361,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.4.3+1" + dotted_border: + dependency: transitive + description: + name: dotted_border + sha256: "108837e11848ca776c53b30bc870086f84b62ed6e01c503ed976e8f8c7df9c04" + url: "https://pub.dev" + source: hosted + version: "2.1.0" drift: dependency: "direct main" description: @@ -353,6 +425,46 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.4" + file_picker: + dependency: transitive + description: + name: file_picker + sha256: d1d0ac3966b36dc3e66eeefb40280c17feb87fa2099c6e22e6a1fc959327bd03 + url: "https://pub.dev" + source: hosted + version: "8.0.0+1" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" + url: "https://pub.dev" + source: hosted + version: "0.9.2+1" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: f42eacb83b318e183b1ae24eead1373ab1334084404c8c16e0354f9a3e55d385 + url: "https://pub.dev" + source: hosted + version: "0.9.4" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b + url: "https://pub.dev" + source: hosted + version: "2.6.2" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "2ad726953f6e8affbc4df8dc78b77c3b4a060967a291e528ef72ae846c60fb69" + url: "https://pub.dev" + source: hosted + version: "0.9.3+2" fixnum: dependency: transitive description: @@ -374,6 +486,30 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.5" + flutter_dropzone: + dependency: transitive + description: + name: flutter_dropzone + sha256: b399c60411f9bf9c4c2f97933c6a3a185859e75aade8897831e76cee4346c8e1 + url: "https://pub.dev" + source: hosted + version: "3.0.7" + flutter_dropzone_platform_interface: + dependency: transitive + description: + name: flutter_dropzone_platform_interface + sha256: "96d2c51c86063ba150551c3b40fd26c5a18785bee071c0c751502d28a545df3b" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + flutter_dropzone_web: + dependency: transitive + description: + name: flutter_dropzone_web + sha256: c5a0fdb63b7216352a01761ec1b6eba1982e49541e60675735e2d3d95e207b19 + url: "https://pub.dev" + source: hosted + version: "3.0.13" flutter_focus_watcher: dependency: transitive description: @@ -438,6 +574,19 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" + url: "https://pub.dev" + source: hosted + version: "2.0.19" flutter_spinkit: dependency: transitive description: @@ -446,6 +595,22 @@ packages: url: "https://pub.dev" source: hosted version: "5.2.1" + flutter_styled_toast: + dependency: transitive + description: + name: flutter_styled_toast + sha256: e667f13a665820eb0fa8506547e47eacbcddf1948d6d3036cfd3b089bd4b0516 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" + url: "https://pub.dev" + source: hosted + version: "2.0.10+1" flutter_test: dependency: "direct dev" description: flutter @@ -496,6 +661,54 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.0" + geolocator: + dependency: transitive + description: + name: geolocator + sha256: f4efb8d3c4cdcad2e226af9661eb1a0dd38c71a9494b22526f9da80ab79520e5 + url: "https://pub.dev" + source: hosted + version: "10.1.1" + geolocator_android: + dependency: transitive + description: + name: geolocator_android + sha256: "93906636752ea4d4e778afa981fdfe7409f545b3147046300df194330044d349" + url: "https://pub.dev" + source: hosted + version: "4.3.1" + geolocator_apple: + dependency: transitive + description: + name: geolocator_apple + sha256: "6154ea2682563f69fc0125762ed7e91e7ed85d0b9776595653be33918e064807" + url: "https://pub.dev" + source: hosted + version: "2.3.8+1" + geolocator_platform_interface: + dependency: transitive + description: + name: geolocator_platform_interface + sha256: "386ce3d9cce47838355000070b1d0b13efb5bc430f8ecda7e9238c8409ace012" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + geolocator_web: + dependency: transitive + description: + name: geolocator_web + sha256: "102e7da05b48ca6bf0a5bda0010f886b171d1a08059f01bfe02addd0175ebece" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + geolocator_windows: + dependency: transitive + description: + name: geolocator_windows + sha256: "53da08937d07c24b0d9952eb57a3b474e29aae2abf9dd717f7e1230995f13f0e" + url: "https://pub.dev" + source: hosted + version: "0.2.3" glob: dependency: transitive description: @@ -528,6 +741,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.3.1" + html: + dependency: transitive + description: + name: html + sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec" + url: "https://pub.dev" + source: hosted + version: "0.15.5" http: dependency: transitive description: @@ -552,6 +773,70 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + image_picker: + dependency: transitive + description: + name: image_picker + sha256: "1f498d086203360cca099d20ffea2963f48c39ce91bdd8a3b6d4a045786b02c8" + url: "https://pub.dev" + source: hosted + version: "1.0.8" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "844c6da4e4f2829dffdab97816bca09d0e0977e8dcef7450864aba4e07967a58" + url: "https://pub.dev" + source: hosted + version: "0.8.9+6" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: e2423c53a68b579a7c37a1eda967b8ae536c3d98518e5db95ca1fe5719a730a3 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: fadafce49e8569257a0cad56d24438a6fa1f0cbd7ee0af9b631f7492818a4ca3 + url: "https://pub.dev" + source: hosted + version: "0.8.9+1" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: fa4e815e6fcada50e35718727d83ba1c92f1edf95c0b4436554cec301b56233b + url: "https://pub.dev" + source: hosted + version: "2.9.3" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" intl: dependency: transitive description: @@ -760,6 +1045,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + path_drawing: + dependency: transitive + description: + name: path_drawing + sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 + url: "https://pub.dev" + source: hosted + version: "1.0.1" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" path_provider: dependency: "direct main" description: @@ -808,6 +1109,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" platform: dependency: transitive description: @@ -1093,6 +1402,86 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_html: + dependency: transitive + description: + name: universal_html + sha256: "56536254004e24d9d8cfdb7dbbf09b74cf8df96729f38a2f5c238163e3d58971" + url: "https://pub.dev" + source: hosted + version: "2.2.4" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "17cd5e205ea615e2c6ea7a77323a11712dffa0720a8a90540db57a01347f9ad9" + url: "https://pub.dev" + source: hosted + version: "6.3.2" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "75bb6fe3f60070407704282a2d295630cab232991eb52542b18347a8a941df03" + url: "https://pub.dev" + source: hosted + version: "6.2.4" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 + url: "https://pub.dev" + source: hosted + version: "3.1.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b + url: "https://pub.dev" + source: hosted + version: "2.2.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185" + url: "https://pub.dev" + source: hosted + version: "3.1.2" uuid: dependency: "direct main" description: @@ -1101,6 +1490,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.7" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" + url: "https://pub.dev" + source: hosted + version: "1.1.11+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da + url: "https://pub.dev" + source: hosted + version: "1.1.11+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" + url: "https://pub.dev" + source: hosted + version: "1.1.11+1" vector_math: dependency: transitive description: @@ -1109,6 +1522,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 + url: "https://pub.dev" + source: hosted + version: "0.4.0+2" vm_service: dependency: transitive description: @@ -1165,6 +1586,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" xxh3: dependency: transitive description: @@ -1182,5 +1611,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0 <4.0.0" + dart: ">=3.2.0 <=3.9.0" flutter: ">=3.16.0" diff --git a/packages/digit_data_model/pubspec.yaml b/packages/digit_data_model/pubspec.yaml index 7f37b835f..f14497251 100644 --- a/packages/digit_data_model/pubspec.yaml +++ b/packages/digit_data_model/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: dio: ^5.1.2 mocktail: ^1.0.2 collection: ^1.16.0 - digit_components: ^1.0.2 + digit_ui_components: ^0.0.1+7 dev_dependencies: flutter_test: diff --git a/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart b/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart index 3433e975a..b595abe38 100644 --- a/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart +++ b/packages/registration_delivery/lib/data/repositories/local/household_global_search.dart @@ -397,9 +397,7 @@ class HouseHoldGlobalSearchRepository extends LocalRepository { selectQuery, GlobalSearchParameters params, LocalSqlDataStore sql) { return selectQuery.where(buildAnd([ if (params.nameSearch != null) - buildOr([ - sql.address.buildingName.contains(params.nameSearch!), - ]), + sql.address.buildingName.contains(params.nameSearch!), ])); } diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 9231ed6ca..47459c5ce 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -291,10 +291,16 @@ class _HouseholdOverviewPageState actions: [ Button( prefixIcon: Icons.edit, - label: localizations.translate( - i18.householdOverView - .householdOverViewEditLabel, - ), + label: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? localizations.translate(i18 + .householdOverView + .clfOverViewEditLabel) + : localizations.translate( + i18.householdOverView + .householdOverViewEditLabel, + ), type: ButtonType.secondary, size: ButtonSize.large, onPressed: () async { @@ -378,6 +384,7 @@ class _HouseholdOverviewPageState type: ButtonType.tertiary, size: ButtonSize.medium, prefixIcon: Icons.edit, + capitalizeLetters: false, ), ), // BlocBuilder element.value.name == selectedFilter) - .first - .key; - if (mappedStatus != null) { - return mappedStatus; - } else { - return selectedFilter; - } - } } diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index cf430b12a..54b68c09f 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -498,6 +498,12 @@ class HouseholdLocationPageState extends LocalizedState { editHousehold: (value) => value.addressModel, ); + final searchQuery = state.mapOrNull( + create: (value) { + return value.searchQuery; + }, + ); + return fb.group({ _administrationAreaKey: FormControl( value: localizations @@ -537,11 +543,14 @@ class HouseholdLocationPageState extends LocalizedState { ), if (RegistrationDeliverySingleton().householdType == HouseholdType.community) - _buildingNameKey: FormControl(validators: [ - Validators.required, - CustomValidator.sizeLessThan2, - Validators.maxLength(64), - ], value: addressModel?.buildingName), + _buildingNameKey: FormControl( + validators: [ + Validators.required, + CustomValidator.sizeLessThan2, + Validators.maxLength(64), + ], + value: addressModel?.buildingName ?? searchQuery?.trim(), + ), }); } } diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart index 4da08d07b..ee88ef53c 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart @@ -354,6 +354,7 @@ class IndividualDetailsPageState extends LocalizedState { Offstage( offstage: !widget.isHeadOfHousehold, child: DigitCheckbox( + capitalizeFirstLetter: false, label: (RegistrationDeliverySingleton().householdType == HouseholdType.community) ? localizations.translate( @@ -783,7 +784,11 @@ class IndividualDetailsPageState extends LocalizedState { CustomValidator.requiredMin, Validators.maxLength(200), ], - value: individual?.name?.givenName ?? searchQuery?.trim(), + value: individual?.name?.givenName ?? + ((RegistrationDeliverySingleton().householdType == + HouseholdType.community) + ? null + : searchQuery?.trim()), ), _idTypeKey: FormControl( value: individual?.identifiers?.firstOrNull?.identifierType, diff --git a/packages/registration_delivery/lib/pages/search_beneficiary.dart b/packages/registration_delivery/lib/pages/search_beneficiary.dart index 1d30e3999..c1ee1b24d 100644 --- a/packages/registration_delivery/lib/pages/search_beneficiary.dart +++ b/packages/registration_delivery/lib/pages/search_beneficiary.dart @@ -399,6 +399,7 @@ class _SearchBeneficiaryPageState padding: const EdgeInsets.all(spacer2), children: [ Button( + capitalizeLetters: false, label: (RegistrationDeliverySingleton().householdType == HouseholdType.community) ? localizations @@ -429,6 +430,7 @@ class _SearchBeneficiaryPageState }, ), Button( + capitalizeLetters: false, type: ButtonType.secondary, size: ButtonSize.large, mainAxisSize: MainAxisSize.max, @@ -562,32 +564,4 @@ class _SearchBeneficiaryPageState } } } - - String getStatus(String selectedFilter) { - final statusMap = { - Status.delivered.toValue(): Status.delivered, - Status.notAdministered.toValue(): Status.notAdministered, - Status.visited.toValue(): Status.visited, - Status.notVisited.toValue(): Status.notVisited, - Status.beneficiaryRefused.toValue(): Status.beneficiaryRefused, - Status.beneficiaryReferred.toValue(): Status.beneficiaryReferred, - Status.administeredSuccess.toValue(): Status.administeredSuccess, - Status.administeredFailed.toValue(): Status.administeredFailed, - Status.inComplete.toValue(): Status.inComplete, - Status.toAdminister.toValue(): Status.toAdminister, - Status.closeHousehold.toValue(): Status.closeHousehold, - Status.registered.toValue(): Status.registered, - Status.notRegistered.toValue(): Status.notRegistered, - }; - - var mappedStatus = statusMap.entries - .where((element) => element.value.name == selectedFilter) - .first - .key; - if (mappedStatus != null) { - return mappedStatus; - } else { - return selectedFilter; - } - } } diff --git a/packages/registration_delivery/lib/utils/utils.dart b/packages/registration_delivery/lib/utils/utils.dart index dc6d03269..faff9eb45 100644 --- a/packages/registration_delivery/lib/utils/utils.dart +++ b/packages/registration_delivery/lib/utils/utils.dart @@ -493,3 +493,31 @@ Status getTaskStatus(Iterable tasks) { return Status.registered.toValue(); } + +String getStatus(String selectedFilter) { + final statusMap = { + Status.delivered.toValue(): Status.delivered, + Status.notAdministered.toValue(): Status.notAdministered, + Status.visited.toValue(): Status.visited, + Status.notVisited.toValue(): Status.notVisited, + Status.beneficiaryRefused.toValue(): Status.beneficiaryRefused, + Status.beneficiaryReferred.toValue(): Status.beneficiaryReferred, + Status.administeredSuccess.toValue(): Status.administeredSuccess, + Status.administeredFailed.toValue(): Status.administeredFailed, + Status.inComplete.toValue(): Status.inComplete, + Status.toAdminister.toValue(): Status.toAdminister, + Status.closeHousehold.toValue(): Status.closeHousehold, + Status.registered.toValue(): Status.registered, + Status.notRegistered.toValue(): Status.notRegistered, + }; + + var mappedStatus = statusMap.entries + .where((element) => element.value.name == selectedFilter) + .first + .key; + if (mappedStatus != null) { + return mappedStatus; + } else { + return selectedFilter; + } +} diff --git a/packages/registration_delivery/lib/widgets/member_card/member_card.dart b/packages/registration_delivery/lib/widgets/member_card/member_card.dart index f3334c9e8..0b97c1a84 100644 --- a/packages/registration_delivery/lib/widgets/member_card/member_card.dart +++ b/packages/registration_delivery/lib/widgets/member_card/member_card.dart @@ -1,5 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_data_model/models/entities/household_type.dart'; import 'package:digit_ui_components/digit_components.dart'; import 'package:digit_ui_components/theme/digit_extended_theme.dart'; import 'package:digit_ui_components/widgets/atoms/digit_action_card.dart'; @@ -116,9 +117,14 @@ class MemberCard extends StatelessWidget { actions: [ Button( prefixIcon: Icons.person, - label: localizations.translate( - i18.memberCard.assignAsHouseholdhead, - ), + label: (RegistrationDeliverySingleton() + .householdType == + HouseholdType.community) + ? localizations.translate( + i18.memberCard.assignAsClfhead) + : localizations.translate( + i18.memberCard.assignAsHouseholdhead, + ), isDisabled: isHead ? true : false, onPressed: setAsHeadAction, type: ButtonType.secondary, @@ -181,8 +187,7 @@ class MemberCard extends StatelessWidget { ), ), Padding( - padding: - const EdgeInsets.only(left: spacer1, bottom: spacer2), + padding: const EdgeInsets.only(left: spacer1, bottom: spacer2), child: Offstage( offstage: beneficiaryType != BeneficiaryType.individual, child: !isDelivered || From 832fbbb347012f545bf139a9ddc52a61a43ff040 Mon Sep 17 00:00:00 2001 From: yashita-egov Date: Fri, 20 Dec 2024 16:03:00 +0530 Subject: [PATCH 19/19] fix address issues --- .../pages/beneficiary/household_overview.dart | 1 + .../household_location.dart | 1 + .../lib/pages/search_beneficiary.dart | 29 ++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart index 47459c5ce..ba3b22b75 100644 --- a/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart +++ b/packages/registration_delivery/lib/pages/beneficiary/household_overview.dart @@ -290,6 +290,7 @@ class _HouseholdOverviewPageState builder: (ctx) => ActionCard( actions: [ Button( + capitalizeLetters: false, prefixIcon: Icons.edit, label: (RegistrationDeliverySingleton() .householdType == diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index 54b68c09f..a20d0cf11 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -495,6 +495,7 @@ class HouseholdLocationPageState extends LocalizedState { FormGroup buildForm(BeneficiaryRegistrationState state) { final addressModel = state.mapOrNull( + create: (value) => value.addressModel, editHousehold: (value) => value.addressModel, ); diff --git a/packages/registration_delivery/lib/pages/search_beneficiary.dart b/packages/registration_delivery/lib/pages/search_beneficiary.dart index c1ee1b24d..30b3cfe99 100644 --- a/packages/registration_delivery/lib/pages/search_beneficiary.dart +++ b/packages/registration_delivery/lib/pages/search_beneficiary.dart @@ -511,7 +511,34 @@ class _SearchBeneficiaryPageState if (!isPagination) { blocWrapper.clearEvent(); } - if (RegistrationDeliverySingleton().beneficiaryType == + + if (RegistrationDeliverySingleton().householdType == + HouseholdType.community) { + if (isProximityEnabled || + selectedFilters.isNotEmpty || + searchController.text.isNotEmpty) { + blocWrapper.houseHoldGlobalSearchBloc + .add(SearchHouseholdsEvent.houseHoldGlobalSearch( + globalSearchParams: GlobalSearchParameters( + isProximityEnabled: isProximityEnabled, + latitude: lat, + longitude: long, + projectId: RegistrationDeliverySingleton().projectId!, + maxRadius: RegistrationDeliverySingleton().maxRadius, + nameSearch: searchController.text.trim().length > 2 + ? searchController.text.trim() + : blocWrapper.searchHouseholdsBloc.state.searchQuery, + filter: selectedFilters, + offset: isPagination + ? blocWrapper.houseHoldGlobalSearchBloc.state.offset + : offset, + limit: isPagination + ? blocWrapper.houseHoldGlobalSearchBloc.state.limit + : limit, + householdType: RegistrationDeliverySingleton().householdType, + ))); + } + } else if (RegistrationDeliverySingleton().beneficiaryType == BeneficiaryType.individual) { if (isProximityEnabled || selectedFilters.isNotEmpty ||