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

View File

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

View File

@ -178,6 +178,9 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'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<PrefState> {
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<EntityType, PrefStateSortField> 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<PrefState, PrefStateBuilder> {
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<PrefState, PrefStateBuilder> {
_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<PrefState, PrefStateBuilder> {
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<PrefState, PrefStateBuilder> {
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());

View File

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

View File

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

View File

@ -56,6 +56,7 @@ class DeviceSettingsVM {
@required this.onShowPdfChanged,
@required this.onTapSelectedChanged,
@required this.onTextScaleFactorChanged,
@required this.onEditAfterSavingChanged,
});
static DeviceSettingsVM fromStore(Store<AppState> 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;

View File

@ -16,6 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _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) {