From 4ec9c7f65ee741da10579c22e1905654eada1dbf Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 31 Mar 2022 13:42:28 +0300 Subject: [PATCH] Edition forms of invoices, tasks etc. are not closing after saving - intended change or bug? #350 --- lib/redux/app/app_actions.dart | 2 + lib/redux/ui/pref_state.dart | 4 ++ lib/redux/ui/pref_state.g.dart | 59 +++++++++++++++------- lib/ui/app/forms/bool_dropdown_button.dart | 2 +- lib/ui/settings/device_settings.dart | 15 ++++-- lib/ui/settings/device_settings_vm.dart | 5 ++ lib/utils/i18n.dart | 11 ++++ 7 files changed, 75 insertions(+), 23 deletions(-) diff --git a/lib/redux/app/app_actions.dart b/lib/redux/app/app_actions.dart index 2e9dac0f2..1ce0aab2a 100644 --- a/lib/redux/app/app_actions.dart +++ b/lib/redux/app/app_actions.dart @@ -147,6 +147,7 @@ class UpdateUserPreferences implements PersistPrefs { this.persistUi, this.tapSelectedToEdit, this.showPdfPreview, + this.editAfterSaving, }); final AppLayout appLayout; @@ -169,6 +170,7 @@ class UpdateUserPreferences implements PersistPrefs { final double textScaleFactor; final bool showPdfPreview; final BuiltMap customColors; + final bool editAfterSaving; } class LoadAccountSuccess implements StopLoading { diff --git a/lib/redux/ui/pref_state.dart b/lib/redux/ui/pref_state.dart index 04a6b1713..91d1b408a 100644 --- a/lib/redux/ui/pref_state.dart +++ b/lib/redux/ui/pref_state.dart @@ -26,6 +26,7 @@ abstract class PrefState implements Built { isMenuVisible: true, isHistoryVisible: false, enableDarkMode: false, + editAfterSaving: true, requireAuthentication: false, colorTheme: kColorThemeLight, isFilterVisible: false, @@ -129,6 +130,8 @@ abstract class PrefState implements Built { bool get hideDesktopWarning; + bool get editAfterSaving; + double get textScaleFactor; BuiltMap get sortFields; @@ -197,6 +200,7 @@ abstract class PrefState implements Built { ..tapSelectedToEdit = false ..persistData = false ..persistUI = true + ..editAfterSaving = true ..showPdfPreview = true ..textScaleFactor = 1 ..colorTheme = diff --git a/lib/redux/ui/pref_state.g.dart b/lib/redux/ui/pref_state.g.dart index ba5c269a6..0c575c321 100644 --- a/lib/redux/ui/pref_state.g.dart +++ b/lib/redux/ui/pref_state.g.dart @@ -178,6 +178,9 @@ class _$PrefStateSerializer implements StructuredSerializer { 'hideDesktopWarning', serializers.serialize(object.hideDesktopWarning, specifiedType: const FullType(bool)), + 'editAfterSaving', + serializers.serialize(object.editAfterSaving, + specifiedType: const FullType(bool)), 'textScaleFactor', serializers.serialize(object.textScaleFactor, specifiedType: const FullType(double)), @@ -295,6 +298,10 @@ class _$PrefStateSerializer implements StructuredSerializer { result.hideDesktopWarning = serializers.deserialize(value, specifiedType: const FullType(bool)) as bool; break; + case 'editAfterSaving': + result.editAfterSaving = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; case 'textScaleFactor': result.textScaleFactor = serializers.deserialize(value, specifiedType: const FullType(double)) as double; @@ -586,6 +593,8 @@ class _$PrefState extends PrefState { @override final bool hideDesktopWarning; @override + final bool editAfterSaving; + @override final double textScaleFactor; @override final BuiltMap sortFields; @@ -617,6 +626,7 @@ class _$PrefState extends PrefState { this.rowsPerPage, this.colorTheme, this.hideDesktopWarning, + this.editAfterSaving, this.textScaleFactor, this.sortFields, this.companyPrefs}) @@ -661,6 +671,8 @@ class _$PrefState extends PrefState { colorTheme, 'PrefState', 'colorTheme'); BuiltValueNullFieldError.checkNotNull( hideDesktopWarning, 'PrefState', 'hideDesktopWarning'); + BuiltValueNullFieldError.checkNotNull( + editAfterSaving, 'PrefState', 'editAfterSaving'); BuiltValueNullFieldError.checkNotNull( textScaleFactor, 'PrefState', 'textScaleFactor'); BuiltValueNullFieldError.checkNotNull( @@ -701,6 +713,7 @@ class _$PrefState extends PrefState { rowsPerPage == other.rowsPerPage && colorTheme == other.colorTheme && hideDesktopWarning == other.hideDesktopWarning && + editAfterSaving == other.editAfterSaving && textScaleFactor == other.textScaleFactor && sortFields == other.sortFields && companyPrefs == other.companyPrefs; @@ -727,23 +740,23 @@ class _$PrefState extends PrefState { $jc( $jc( $jc( - $jc($jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode), useSidebarEditor.hashCode), - customColors.hashCode), - isPreviewVisible.hashCode), - isMenuVisible.hashCode), - showKanban.hashCode), - showPdfPreview.hashCode), - isHistoryVisible.hashCode), - enableDarkMode.hashCode), - isFilterVisible.hashCode), - persistData.hashCode), - persistUI.hashCode), - longPressSelectionIsDefault.hashCode), - requireAuthentication.hashCode), - tapSelectedToEdit.hashCode), - rowsPerPage.hashCode), - colorTheme.hashCode), - hideDesktopWarning.hashCode), + $jc($jc($jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode), useSidebarEditor.hashCode), customColors.hashCode), + isPreviewVisible.hashCode), + isMenuVisible.hashCode), + showKanban.hashCode), + showPdfPreview.hashCode), + isHistoryVisible.hashCode), + enableDarkMode.hashCode), + isFilterVisible.hashCode), + persistData.hashCode), + persistUI.hashCode), + longPressSelectionIsDefault.hashCode), + requireAuthentication.hashCode), + tapSelectedToEdit.hashCode), + rowsPerPage.hashCode), + colorTheme.hashCode), + hideDesktopWarning.hashCode), + editAfterSaving.hashCode), textScaleFactor.hashCode), sortFields.hashCode), companyPrefs.hashCode)); @@ -773,6 +786,7 @@ class _$PrefState extends PrefState { ..add('rowsPerPage', rowsPerPage) ..add('colorTheme', colorTheme) ..add('hideDesktopWarning', hideDesktopWarning) + ..add('editAfterSaving', editAfterSaving) ..add('textScaleFactor', textScaleFactor) ..add('sortFields', sortFields) ..add('companyPrefs', companyPrefs)) @@ -884,6 +898,11 @@ class PrefStateBuilder implements Builder { set hideDesktopWarning(bool hideDesktopWarning) => _$this._hideDesktopWarning = hideDesktopWarning; + bool _editAfterSaving; + bool get editAfterSaving => _$this._editAfterSaving; + set editAfterSaving(bool editAfterSaving) => + _$this._editAfterSaving = editAfterSaving; + double _textScaleFactor; double get textScaleFactor => _$this._textScaleFactor; set textScaleFactor(double textScaleFactor) => @@ -929,6 +948,7 @@ class PrefStateBuilder implements Builder { _rowsPerPage = $v.rowsPerPage; _colorTheme = $v.colorTheme; _hideDesktopWarning = $v.hideDesktopWarning; + _editAfterSaving = $v.editAfterSaving; _textScaleFactor = $v.textScaleFactor; _sortFields = $v.sortFields.toBuilder(); _companyPrefs = $v.companyPrefs.toBuilder(); @@ -970,8 +990,8 @@ class PrefStateBuilder implements Builder { isMenuVisible, 'PrefState', 'isMenuVisible'), showKanban: BuiltValueNullFieldError.checkNotNull( showKanban, 'PrefState', 'showKanban'), - showPdfPreview: BuiltValueNullFieldError.checkNotNull( - showPdfPreview, 'PrefState', 'showPdfPreview'), + showPdfPreview: + BuiltValueNullFieldError.checkNotNull(showPdfPreview, 'PrefState', 'showPdfPreview'), isHistoryVisible: BuiltValueNullFieldError.checkNotNull(isHistoryVisible, 'PrefState', 'isHistoryVisible'), enableDarkMode: BuiltValueNullFieldError.checkNotNull(enableDarkMode, 'PrefState', 'enableDarkMode'), isFilterVisible: BuiltValueNullFieldError.checkNotNull(isFilterVisible, 'PrefState', 'isFilterVisible'), @@ -983,6 +1003,7 @@ class PrefStateBuilder implements Builder { rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'), colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'), hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, 'PrefState', 'hideDesktopWarning'), + editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, 'PrefState', 'editAfterSaving'), textScaleFactor: BuiltValueNullFieldError.checkNotNull(textScaleFactor, 'PrefState', 'textScaleFactor'), sortFields: sortFields.build(), companyPrefs: companyPrefs.build()); diff --git a/lib/ui/app/forms/bool_dropdown_button.dart b/lib/ui/app/forms/bool_dropdown_button.dart index 5c03369d3..6ddc8cfd0 100644 --- a/lib/ui/app/forms/bool_dropdown_button.dart +++ b/lib/ui/app/forms/bool_dropdown_button.dart @@ -96,7 +96,7 @@ class BoolDropdownButton extends StatelessWidget { onTap: () => onChanged(false), child: ConstrainedBox( constraints: BoxConstraints( - minWidth: minWidth ?? 120, minHeight: 36), + minWidth: minWidth ?? 130, minHeight: 36), child: Row( children: [ IgnorePointer( diff --git a/lib/ui/settings/device_settings.dart b/lib/ui/settings/device_settings.dart index d31a84fba..264f8147d 100644 --- a/lib/ui/settings/device_settings.dart +++ b/lib/ui/settings/device_settings.dart @@ -150,7 +150,7 @@ class _DeviceSettingsState extends State disabledLabel: localization.showOrHide, ), ], - if (isDesktop(context)) + if (isDesktop(context)) ...[ BoolDropdownButton( label: localization.clickSelected, value: prefState.tapSelectedToEdit, @@ -159,8 +159,17 @@ class _DeviceSettingsState extends State }, enabledLabel: localization.editRecord, disabledLabel: localization.hidePreview, - ) - else + ), + BoolDropdownButton( + label: localization.afterSaving, + value: prefState.editAfterSaving, + onChanged: (value) { + viewModel.onEditAfterSavingChanged(context, value); + }, + enabledLabel: localization.editRecord, + disabledLabel: localization.viewRecord, + ), + ] else BoolDropdownButton( label: localization.listLongPress, value: !prefState.longPressSelectionIsDefault, diff --git a/lib/ui/settings/device_settings_vm.dart b/lib/ui/settings/device_settings_vm.dart index dd4cd3ec3..69356319e 100644 --- a/lib/ui/settings/device_settings_vm.dart +++ b/lib/ui/settings/device_settings_vm.dart @@ -56,6 +56,7 @@ class DeviceSettingsVM { @required this.onShowPdfChanged, @required this.onTapSelectedChanged, @required this.onTextScaleFactorChanged, + @required this.onEditAfterSavingChanged, }); static DeviceSettingsVM fromStore(Store store) { @@ -110,6 +111,9 @@ class DeviceSettingsVM { store.dispatch(UpdateUserPreferences(colorTheme: value)); } }, + onEditAfterSavingChanged: (context, value) async { + store.dispatch(UpdateUserPreferences(editAfterSaving: value)); + }, onLayoutChanged: (BuildContext context, AppLayout value) async { if (store.state.prefState.appLayout == value) { return; @@ -186,6 +190,7 @@ class DeviceSettingsVM { final Function(BuildContext, String) onColorThemeChanged; final Function(BuildContext, bool) onLongPressSelectionIsDefault; final Function(BuildContext, bool) onTapSelectedChanged; + final Function(BuildContext, bool) onEditAfterSavingChanged; final Function(BuildContext, bool) onRequireAuthenticationChanged; final Function(BuildContext, bool) onPersistDataChanged; final Function(BuildContext, bool) onPersistUiChanged; diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 0e848a672..a2c224eb2 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -16,6 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'after_saving': 'After Saving', + 'view_record': 'View Record', 'enable_email_markdown': 'Enable Email Markdown', 'enable_email_markdown_help': 'Use visual markdown editor for emails', 'enable_pdf_markdown': 'Enable PDF Markdown', @@ -74190,6 +74192,15 @@ mixin LocalizationsProvider on LocaleCodeAware { _localizedValues[localeCode]['enable_pdf_markdown'] ?? _localizedValues['en']['enable_pdf_markdown']; + String get afterSaving => + _localizedValues[localeCode]['after_saving'] ?? + _localizedValues['en']['after_saving']; + + String get viewRecord => + _localizedValues[localeCode]['view_record'] ?? + _localizedValues['en']['view_record']; + + // STARTER: lang field - do not remove comment String lookup(String key) {