This commit is contained in:
Hillel Coren 2020-02-13 20:32:50 +02:00
parent 93b4b2a3c3
commit 2c3345dc8c
6 changed files with 41 additions and 4 deletions

View File

@ -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<String, String> filters;
final String groupBy;
final int sortIndex;
final String customStartDate;
final String customEndDate;

View File

@ -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));

View File

@ -12,6 +12,7 @@ abstract class ReportsUIState
report: kReportClient,
customStartDate: '',
customEndDate: '',
groupBy: '',
filters: BuiltMap<String, String>(),
);
}
@ -20,6 +21,8 @@ abstract class ReportsUIState
String get report;
String get groupBy;
String get customStartDate;
String get customEndDate;

View File

@ -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());

View File

@ -112,11 +112,12 @@ class ReportsScreen extends StatelessWidget {
),
AppDropdownButton<String>(
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),
))

View File

@ -51,6 +51,7 @@ class ReportsScreenVM {
String report,
String customStartDate,
String customEndDate,
String groupBy,
}) onSettingsChanged;
static ReportsScreenVM fromStore(Store<AppState> 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,
));