diff --git a/lib/redux/reports/reports_actions.dart b/lib/redux/reports/reports_actions.dart index 2f264ce0e..068b9e9c6 100644 --- a/lib/redux/reports/reports_actions.dart +++ b/lib/redux/reports/reports_actions.dart @@ -17,6 +17,7 @@ class UpdateReportSettings implements PersistUI { UpdateReportSettings({ @required this.report, this.filters, + this.groupBy, this.sortIndex, this.customStartDate, this.customEndDate, @@ -24,6 +25,7 @@ class UpdateReportSettings implements PersistUI { final String report; final BuiltMap filters; + final String groupBy; final int sortIndex; final String customStartDate; final String customEndDate; diff --git a/lib/redux/reports/reports_reducer.dart b/lib/redux/reports/reports_reducer.dart index c032b93d6..2ae52c4dd 100644 --- a/lib/redux/reports/reports_reducer.dart +++ b/lib/redux/reports/reports_reducer.dart @@ -6,6 +6,7 @@ ReportsUIState reportsUIReducer(ReportsUIState state, dynamic action) { if (action is UpdateReportSettings) { return state.rebuild((b) => b ..report = action.report ?? state.report + ..groupBy = action.groupBy ?? state.groupBy ..customStartDate = action.customStartDate ?? state.customStartDate ..customEndDate = action.customEndDate ?? state.customEndDate ..filters.replace(action.filters ?? state.filters)); diff --git a/lib/redux/reports/reports_state.dart b/lib/redux/reports/reports_state.dart index bd30622a0..a1baf5595 100644 --- a/lib/redux/reports/reports_state.dart +++ b/lib/redux/reports/reports_state.dart @@ -12,6 +12,7 @@ abstract class ReportsUIState report: kReportClient, customStartDate: '', customEndDate: '', + groupBy: '', filters: BuiltMap(), ); } @@ -20,6 +21,8 @@ abstract class ReportsUIState String get report; + String get groupBy; + String get customStartDate; String get customEndDate; diff --git a/lib/redux/reports/reports_state.g.dart b/lib/redux/reports/reports_state.g.dart index 102e02d49..eb587567b 100644 --- a/lib/redux/reports/reports_state.g.dart +++ b/lib/redux/reports/reports_state.g.dart @@ -23,6 +23,9 @@ class _$ReportsUIStateSerializer 'report', serializers.serialize(object.report, specifiedType: const FullType(String)), + 'groupBy', + serializers.serialize(object.groupBy, + specifiedType: const FullType(String)), 'customStartDate', serializers.serialize(object.customStartDate, specifiedType: const FullType(String)), @@ -54,6 +57,10 @@ class _$ReportsUIStateSerializer result.report = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; + case 'groupBy': + result.groupBy = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; case 'customStartDate': result.customStartDate = serializers.deserialize(value, specifiedType: const FullType(String)) as String; @@ -80,6 +87,8 @@ class _$ReportsUIState extends ReportsUIState { @override final String report; @override + final String groupBy; + @override final String customStartDate; @override final String customEndDate; @@ -90,11 +99,18 @@ class _$ReportsUIState extends ReportsUIState { (new ReportsUIStateBuilder()..update(updates)).build(); _$ReportsUIState._( - {this.report, this.customStartDate, this.customEndDate, this.filters}) + {this.report, + this.groupBy, + this.customStartDate, + this.customEndDate, + this.filters}) : super._() { if (report == null) { throw new BuiltValueNullFieldError('ReportsUIState', 'report'); } + if (groupBy == null) { + throw new BuiltValueNullFieldError('ReportsUIState', 'groupBy'); + } if (customStartDate == null) { throw new BuiltValueNullFieldError('ReportsUIState', 'customStartDate'); } @@ -119,6 +135,7 @@ class _$ReportsUIState extends ReportsUIState { if (identical(other, this)) return true; return other is ReportsUIState && report == other.report && + groupBy == other.groupBy && customStartDate == other.customStartDate && customEndDate == other.customEndDate && filters == other.filters; @@ -127,7 +144,9 @@ class _$ReportsUIState extends ReportsUIState { @override int get hashCode { return $jf($jc( - $jc($jc($jc(0, report.hashCode), customStartDate.hashCode), + $jc( + $jc($jc($jc(0, report.hashCode), groupBy.hashCode), + customStartDate.hashCode), customEndDate.hashCode), filters.hashCode)); } @@ -136,6 +155,7 @@ class _$ReportsUIState extends ReportsUIState { String toString() { return (newBuiltValueToStringHelper('ReportsUIState') ..add('report', report) + ..add('groupBy', groupBy) ..add('customStartDate', customStartDate) ..add('customEndDate', customEndDate) ..add('filters', filters)) @@ -151,6 +171,10 @@ class ReportsUIStateBuilder String get report => _$this._report; set report(String report) => _$this._report = report; + String _groupBy; + String get groupBy => _$this._groupBy; + set groupBy(String groupBy) => _$this._groupBy = groupBy; + String _customStartDate; String get customStartDate => _$this._customStartDate; set customStartDate(String customStartDate) => @@ -171,6 +195,7 @@ class ReportsUIStateBuilder ReportsUIStateBuilder get _$this { if (_$v != null) { _report = _$v.report; + _groupBy = _$v.groupBy; _customStartDate = _$v.customStartDate; _customEndDate = _$v.customEndDate; _filters = _$v.filters?.toBuilder(); @@ -199,6 +224,7 @@ class ReportsUIStateBuilder _$result = _$v ?? new _$ReportsUIState._( report: report, + groupBy: groupBy, customStartDate: customStartDate, customEndDate: customEndDate, filters: filters.build()); diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index c592f30b7..fdfab263c 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -112,11 +112,12 @@ class ReportsScreen extends StatelessWidget { ), AppDropdownButton( labelText: localization.groupBy, - value: null, - blankValue: null, + value: reportsUIState.groupBy, + blankValue: '', showBlank: true, onChanged: (dynamic value) { print('Group: onChanged - $value'); + viewModel.onSettingsChanged(groupBy: value); }, items: reportResult.columns .where((column) => @@ -412,6 +413,7 @@ class ReportResult { for (String column in columns) if (getReportColumnType(column) == ReportColumnType.number) DataCell(DecoratedFormField( + label: '', controller: textEditingControllers[column], keyboardType: TextInputType.numberWithOptions(decimal: true), )) diff --git a/lib/ui/reports/reports_screen_vm.dart b/lib/ui/reports/reports_screen_vm.dart index 82b77ab0a..0b3753491 100644 --- a/lib/ui/reports/reports_screen_vm.dart +++ b/lib/ui/reports/reports_screen_vm.dart @@ -51,6 +51,7 @@ class ReportsScreenVM { String report, String customStartDate, String customEndDate, + String groupBy, }) onSettingsChanged; static ReportsScreenVM fromStore(Store store) { @@ -123,11 +124,13 @@ class ReportsScreenVM { }, onSettingsChanged: ({ String report, + String groupBy, String customStartDate, String customEndDate, }) { store.dispatch(UpdateReportSettings( report: report ?? state.uiState.reportsUIState.report, + groupBy: groupBy, customStartDate: customStartDate, customEndDate: customEndDate, ));