Edition forms of invoices, tasks etc. are not closing after saving - intended change or bug? #350

This commit is contained in:
Hillel Coren 2022-03-31 13:42:28 +03:00
parent f34e560c6f
commit 4ec9c7f65e
7 changed files with 75 additions and 23 deletions

View File

@ -147,6 +147,7 @@ class UpdateUserPreferences implements PersistPrefs {
this.persistUi, this.persistUi,
this.tapSelectedToEdit, this.tapSelectedToEdit,
this.showPdfPreview, this.showPdfPreview,
this.editAfterSaving,
}); });
final AppLayout appLayout; final AppLayout appLayout;
@ -169,6 +170,7 @@ class UpdateUserPreferences implements PersistPrefs {
final double textScaleFactor; final double textScaleFactor;
final bool showPdfPreview; final bool showPdfPreview;
final BuiltMap<String, String> customColors; final BuiltMap<String, String> customColors;
final bool editAfterSaving;
} }
class LoadAccountSuccess implements StopLoading { class LoadAccountSuccess implements StopLoading {

View File

@ -26,6 +26,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
isMenuVisible: true, isMenuVisible: true,
isHistoryVisible: false, isHistoryVisible: false,
enableDarkMode: false, enableDarkMode: false,
editAfterSaving: true,
requireAuthentication: false, requireAuthentication: false,
colorTheme: kColorThemeLight, colorTheme: kColorThemeLight,
isFilterVisible: false, isFilterVisible: false,
@ -129,6 +130,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
bool get hideDesktopWarning; bool get hideDesktopWarning;
bool get editAfterSaving;
double get textScaleFactor; double get textScaleFactor;
BuiltMap<EntityType, PrefStateSortField> get sortFields; BuiltMap<EntityType, PrefStateSortField> get sortFields;
@ -197,6 +200,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
..tapSelectedToEdit = false ..tapSelectedToEdit = false
..persistData = false ..persistData = false
..persistUI = true ..persistUI = true
..editAfterSaving = true
..showPdfPreview = true ..showPdfPreview = true
..textScaleFactor = 1 ..textScaleFactor = 1
..colorTheme = ..colorTheme =

View File

@ -178,6 +178,9 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'hideDesktopWarning', 'hideDesktopWarning',
serializers.serialize(object.hideDesktopWarning, serializers.serialize(object.hideDesktopWarning,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'editAfterSaving',
serializers.serialize(object.editAfterSaving,
specifiedType: const FullType(bool)),
'textScaleFactor', 'textScaleFactor',
serializers.serialize(object.textScaleFactor, serializers.serialize(object.textScaleFactor,
specifiedType: const FullType(double)), specifiedType: const FullType(double)),
@ -295,6 +298,10 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
result.hideDesktopWarning = serializers.deserialize(value, result.hideDesktopWarning = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'editAfterSaving':
result.editAfterSaving = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'textScaleFactor': case 'textScaleFactor':
result.textScaleFactor = serializers.deserialize(value, result.textScaleFactor = serializers.deserialize(value,
specifiedType: const FullType(double)) as double; specifiedType: const FullType(double)) as double;
@ -586,6 +593,8 @@ class _$PrefState extends PrefState {
@override @override
final bool hideDesktopWarning; final bool hideDesktopWarning;
@override @override
final bool editAfterSaving;
@override
final double textScaleFactor; final double textScaleFactor;
@override @override
final BuiltMap<EntityType, PrefStateSortField> sortFields; final BuiltMap<EntityType, PrefStateSortField> sortFields;
@ -617,6 +626,7 @@ class _$PrefState extends PrefState {
this.rowsPerPage, this.rowsPerPage,
this.colorTheme, this.colorTheme,
this.hideDesktopWarning, this.hideDesktopWarning,
this.editAfterSaving,
this.textScaleFactor, this.textScaleFactor,
this.sortFields, this.sortFields,
this.companyPrefs}) this.companyPrefs})
@ -661,6 +671,8 @@ class _$PrefState extends PrefState {
colorTheme, 'PrefState', 'colorTheme'); colorTheme, 'PrefState', 'colorTheme');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
hideDesktopWarning, 'PrefState', 'hideDesktopWarning'); hideDesktopWarning, 'PrefState', 'hideDesktopWarning');
BuiltValueNullFieldError.checkNotNull(
editAfterSaving, 'PrefState', 'editAfterSaving');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
textScaleFactor, 'PrefState', 'textScaleFactor'); textScaleFactor, 'PrefState', 'textScaleFactor');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -701,6 +713,7 @@ class _$PrefState extends PrefState {
rowsPerPage == other.rowsPerPage && rowsPerPage == other.rowsPerPage &&
colorTheme == other.colorTheme && colorTheme == other.colorTheme &&
hideDesktopWarning == other.hideDesktopWarning && hideDesktopWarning == other.hideDesktopWarning &&
editAfterSaving == other.editAfterSaving &&
textScaleFactor == other.textScaleFactor && textScaleFactor == other.textScaleFactor &&
sortFields == other.sortFields && sortFields == other.sortFields &&
companyPrefs == other.companyPrefs; companyPrefs == other.companyPrefs;
@ -727,8 +740,7 @@ class _$PrefState extends PrefState {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode), useSidebarEditor.hashCode), $jc($jc($jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode), useSidebarEditor.hashCode), customColors.hashCode),
customColors.hashCode),
isPreviewVisible.hashCode), isPreviewVisible.hashCode),
isMenuVisible.hashCode), isMenuVisible.hashCode),
showKanban.hashCode), showKanban.hashCode),
@ -744,6 +756,7 @@ class _$PrefState extends PrefState {
rowsPerPage.hashCode), rowsPerPage.hashCode),
colorTheme.hashCode), colorTheme.hashCode),
hideDesktopWarning.hashCode), hideDesktopWarning.hashCode),
editAfterSaving.hashCode),
textScaleFactor.hashCode), textScaleFactor.hashCode),
sortFields.hashCode), sortFields.hashCode),
companyPrefs.hashCode)); companyPrefs.hashCode));
@ -773,6 +786,7 @@ class _$PrefState extends PrefState {
..add('rowsPerPage', rowsPerPage) ..add('rowsPerPage', rowsPerPage)
..add('colorTheme', colorTheme) ..add('colorTheme', colorTheme)
..add('hideDesktopWarning', hideDesktopWarning) ..add('hideDesktopWarning', hideDesktopWarning)
..add('editAfterSaving', editAfterSaving)
..add('textScaleFactor', textScaleFactor) ..add('textScaleFactor', textScaleFactor)
..add('sortFields', sortFields) ..add('sortFields', sortFields)
..add('companyPrefs', companyPrefs)) ..add('companyPrefs', companyPrefs))
@ -884,6 +898,11 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
set hideDesktopWarning(bool hideDesktopWarning) => set hideDesktopWarning(bool hideDesktopWarning) =>
_$this._hideDesktopWarning = hideDesktopWarning; _$this._hideDesktopWarning = hideDesktopWarning;
bool _editAfterSaving;
bool get editAfterSaving => _$this._editAfterSaving;
set editAfterSaving(bool editAfterSaving) =>
_$this._editAfterSaving = editAfterSaving;
double _textScaleFactor; double _textScaleFactor;
double get textScaleFactor => _$this._textScaleFactor; double get textScaleFactor => _$this._textScaleFactor;
set textScaleFactor(double textScaleFactor) => set textScaleFactor(double textScaleFactor) =>
@ -929,6 +948,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
_rowsPerPage = $v.rowsPerPage; _rowsPerPage = $v.rowsPerPage;
_colorTheme = $v.colorTheme; _colorTheme = $v.colorTheme;
_hideDesktopWarning = $v.hideDesktopWarning; _hideDesktopWarning = $v.hideDesktopWarning;
_editAfterSaving = $v.editAfterSaving;
_textScaleFactor = $v.textScaleFactor; _textScaleFactor = $v.textScaleFactor;
_sortFields = $v.sortFields.toBuilder(); _sortFields = $v.sortFields.toBuilder();
_companyPrefs = $v.companyPrefs.toBuilder(); _companyPrefs = $v.companyPrefs.toBuilder();
@ -970,8 +990,8 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
isMenuVisible, 'PrefState', 'isMenuVisible'), isMenuVisible, 'PrefState', 'isMenuVisible'),
showKanban: BuiltValueNullFieldError.checkNotNull( showKanban: BuiltValueNullFieldError.checkNotNull(
showKanban, 'PrefState', 'showKanban'), showKanban, 'PrefState', 'showKanban'),
showPdfPreview: BuiltValueNullFieldError.checkNotNull( showPdfPreview:
showPdfPreview, 'PrefState', 'showPdfPreview'), BuiltValueNullFieldError.checkNotNull(showPdfPreview, 'PrefState', 'showPdfPreview'),
isHistoryVisible: BuiltValueNullFieldError.checkNotNull(isHistoryVisible, 'PrefState', 'isHistoryVisible'), isHistoryVisible: BuiltValueNullFieldError.checkNotNull(isHistoryVisible, 'PrefState', 'isHistoryVisible'),
enableDarkMode: BuiltValueNullFieldError.checkNotNull(enableDarkMode, 'PrefState', 'enableDarkMode'), enableDarkMode: BuiltValueNullFieldError.checkNotNull(enableDarkMode, 'PrefState', 'enableDarkMode'),
isFilterVisible: BuiltValueNullFieldError.checkNotNull(isFilterVisible, 'PrefState', 'isFilterVisible'), isFilterVisible: BuiltValueNullFieldError.checkNotNull(isFilterVisible, 'PrefState', 'isFilterVisible'),
@ -983,6 +1003,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'), rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'),
colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'), colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'),
hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, 'PrefState', 'hideDesktopWarning'), hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, 'PrefState', 'hideDesktopWarning'),
editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, 'PrefState', 'editAfterSaving'),
textScaleFactor: BuiltValueNullFieldError.checkNotNull(textScaleFactor, 'PrefState', 'textScaleFactor'), textScaleFactor: BuiltValueNullFieldError.checkNotNull(textScaleFactor, 'PrefState', 'textScaleFactor'),
sortFields: sortFields.build(), sortFields: sortFields.build(),
companyPrefs: companyPrefs.build()); companyPrefs: companyPrefs.build());

View File

@ -96,7 +96,7 @@ class BoolDropdownButton extends StatelessWidget {
onTap: () => onChanged(false), onTap: () => onChanged(false),
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints( constraints: BoxConstraints(
minWidth: minWidth ?? 120, minHeight: 36), minWidth: minWidth ?? 130, minHeight: 36),
child: Row( child: Row(
children: [ children: [
IgnorePointer( IgnorePointer(

View File

@ -150,7 +150,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
disabledLabel: localization.showOrHide, disabledLabel: localization.showOrHide,
), ),
], ],
if (isDesktop(context)) if (isDesktop(context)) ...[
BoolDropdownButton( BoolDropdownButton(
label: localization.clickSelected, label: localization.clickSelected,
value: prefState.tapSelectedToEdit, value: prefState.tapSelectedToEdit,
@ -159,8 +159,17 @@ class _DeviceSettingsState extends State<DeviceSettings>
}, },
enabledLabel: localization.editRecord, enabledLabel: localization.editRecord,
disabledLabel: localization.hidePreview, 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( BoolDropdownButton(
label: localization.listLongPress, label: localization.listLongPress,
value: !prefState.longPressSelectionIsDefault, value: !prefState.longPressSelectionIsDefault,

View File

@ -56,6 +56,7 @@ class DeviceSettingsVM {
@required this.onShowPdfChanged, @required this.onShowPdfChanged,
@required this.onTapSelectedChanged, @required this.onTapSelectedChanged,
@required this.onTextScaleFactorChanged, @required this.onTextScaleFactorChanged,
@required this.onEditAfterSavingChanged,
}); });
static DeviceSettingsVM fromStore(Store<AppState> store) { static DeviceSettingsVM fromStore(Store<AppState> store) {
@ -110,6 +111,9 @@ class DeviceSettingsVM {
store.dispatch(UpdateUserPreferences(colorTheme: value)); store.dispatch(UpdateUserPreferences(colorTheme: value));
} }
}, },
onEditAfterSavingChanged: (context, value) async {
store.dispatch(UpdateUserPreferences(editAfterSaving: value));
},
onLayoutChanged: (BuildContext context, AppLayout value) async { onLayoutChanged: (BuildContext context, AppLayout value) async {
if (store.state.prefState.appLayout == value) { if (store.state.prefState.appLayout == value) {
return; return;
@ -186,6 +190,7 @@ class DeviceSettingsVM {
final Function(BuildContext, String) onColorThemeChanged; final Function(BuildContext, String) onColorThemeChanged;
final Function(BuildContext, bool) onLongPressSelectionIsDefault; final Function(BuildContext, bool) onLongPressSelectionIsDefault;
final Function(BuildContext, bool) onTapSelectedChanged; final Function(BuildContext, bool) onTapSelectedChanged;
final Function(BuildContext, bool) onEditAfterSavingChanged;
final Function(BuildContext, bool) onRequireAuthenticationChanged; final Function(BuildContext, bool) onRequireAuthenticationChanged;
final Function(BuildContext, bool) onPersistDataChanged; final Function(BuildContext, bool) onPersistDataChanged;
final Function(BuildContext, bool) onPersistUiChanged; final Function(BuildContext, bool) onPersistUiChanged;

View File

@ -16,6 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
// STARTER: lang key - do not remove comment // STARTER: lang key - do not remove comment
'after_saving': 'After Saving',
'view_record': 'View Record',
'enable_email_markdown': 'Enable Email Markdown', 'enable_email_markdown': 'Enable Email Markdown',
'enable_email_markdown_help': 'Use visual markdown editor for emails', 'enable_email_markdown_help': 'Use visual markdown editor for emails',
'enable_pdf_markdown': 'Enable PDF Markdown', 'enable_pdf_markdown': 'Enable PDF Markdown',
@ -74190,6 +74192,15 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['enable_pdf_markdown'] ?? _localizedValues[localeCode]['enable_pdf_markdown'] ??
_localizedValues['en']['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 // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {