[UX] Clicking row in index view automatically opens corresponding edit view #247

This commit is contained in:
Hillel Coren 2021-11-10 09:34:45 +02:00
parent eafca5c0ab
commit 7212d73524
7 changed files with 93 additions and 36 deletions

View File

@ -140,6 +140,7 @@ class UpdateUserPreferences implements PersistPrefs {
this.customColors, this.customColors,
this.persistData, this.persistData,
this.persistUi, this.persistUi,
this.tapSelectedToEdit,
}); });
final AppLayout appLayout; final AppLayout appLayout;
@ -158,6 +159,7 @@ class UpdateUserPreferences implements PersistPrefs {
final String colorTheme; final String colorTheme;
final bool persistData; final bool persistData;
final bool persistUi; final bool persistUi;
final bool tapSelectedToEdit;
final BuiltMap<String, String> customColors; final BuiltMap<String, String> customColors;
} }
@ -1429,7 +1431,7 @@ void selectEntity({
entityUIState.selectedId == entity.id) { entityUIState.selectedId == entity.id) {
if (entityUIState.tabIndex > 0) { if (entityUIState.tabIndex > 0) {
store.dispatch(PreviewEntity()); store.dispatch(PreviewEntity());
} else { } else if (state.prefState.tapSelectedToEdit) {
editEntity(context: context, entity: entity); editEntity(context: context, entity: entity);
} }
} else { } else {

View File

@ -61,6 +61,8 @@ PrefState prefReducer(
..isFilterVisible = isFilterVisibleReducer(state.isFilterVisible, action) ..isFilterVisible = isFilterVisibleReducer(state.isFilterVisible, action)
..longPressSelectionIsDefault = ..longPressSelectionIsDefault =
longPressReducer(state.longPressSelectionIsDefault, action) longPressReducer(state.longPressSelectionIsDefault, action)
..tapSelectedToEdit =
tapSelectedToEditReducer(state.tapSelectedToEdit, action)
..requireAuthentication = ..requireAuthentication =
requireAuthenticationReducer(state.requireAuthentication, action) requireAuthenticationReducer(state.requireAuthentication, action)
..colorTheme = colorThemeReducer(state.colorTheme, action) ..colorTheme = colorThemeReducer(state.colorTheme, action)
@ -275,6 +277,12 @@ Reducer<bool> longPressReducer = combineReducers([
}), }),
]); ]);
Reducer<bool> tapSelectedToEditReducer = combineReducers([
TypedReducer<bool, UpdateUserPreferences>((tapSelectedToEdit, action) {
return action.tapSelectedToEdit ?? tapSelectedToEdit;
}),
]);
Reducer<bool> isPreviewVisibleReducer = combineReducers([ Reducer<bool> isPreviewVisibleReducer = combineReducers([
TypedReducer<bool, TogglePreviewSidebar>((value, action) { TypedReducer<bool, TogglePreviewSidebar>((value, action) {
return !value; return !value;

View File

@ -25,6 +25,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
colorTheme: kColorThemeLight, colorTheme: kColorThemeLight,
isFilterVisible: false, isFilterVisible: false,
longPressSelectionIsDefault: true, longPressSelectionIsDefault: true,
tapSelectedToEdit: false,
showKanban: false, showKanban: false,
persistData: false, persistData: false,
persistUI: true, persistUI: true,
@ -105,6 +106,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
bool get requireAuthentication; bool get requireAuthentication;
bool get tapSelectedToEdit;
int get rowsPerPage; int get rowsPerPage;
String get colorTheme; String get colorTheme;
@ -177,6 +180,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
..showKanban = false ..showKanban = false
..isPreviewVisible = false ..isPreviewVisible = false
..isFilterVisible = false ..isFilterVisible = false
..tapSelectedToEdit = false
..persistData = false ..persistData = false
..persistUI = true ..persistUI = true
..colorTheme = ..colorTheme =

View File

@ -163,6 +163,9 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'requireAuthentication', 'requireAuthentication',
serializers.serialize(object.requireAuthentication, serializers.serialize(object.requireAuthentication,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'tapSelectedToEdit',
serializers.serialize(object.tapSelectedToEdit,
specifiedType: const FullType(bool)),
'rowsPerPage', 'rowsPerPage',
serializers.serialize(object.rowsPerPage, serializers.serialize(object.rowsPerPage,
specifiedType: const FullType(int)), specifiedType: const FullType(int)),
@ -263,6 +266,10 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
result.requireAuthentication = serializers.deserialize(value, result.requireAuthentication = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'tapSelectedToEdit':
result.tapSelectedToEdit = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'rowsPerPage': case 'rowsPerPage':
result.rowsPerPage = serializers.deserialize(value, result.rowsPerPage = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
@ -548,6 +555,8 @@ class _$PrefState extends PrefState {
@override @override
final bool requireAuthentication; final bool requireAuthentication;
@override @override
final bool tapSelectedToEdit;
@override
final int rowsPerPage; final int rowsPerPage;
@override @override
final String colorTheme; final String colorTheme;
@ -576,6 +585,7 @@ class _$PrefState extends PrefState {
this.persistUI, this.persistUI,
this.longPressSelectionIsDefault, this.longPressSelectionIsDefault,
this.requireAuthentication, this.requireAuthentication,
this.tapSelectedToEdit,
this.rowsPerPage, this.rowsPerPage,
this.colorTheme, this.colorTheme,
this.sortFields, this.sortFields,
@ -611,6 +621,8 @@ class _$PrefState extends PrefState {
'PrefState', 'longPressSelectionIsDefault'); 'PrefState', 'longPressSelectionIsDefault');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
requireAuthentication, 'PrefState', 'requireAuthentication'); requireAuthentication, 'PrefState', 'requireAuthentication');
BuiltValueNullFieldError.checkNotNull(
tapSelectedToEdit, 'PrefState', 'tapSelectedToEdit');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
rowsPerPage, 'PrefState', 'rowsPerPage'); rowsPerPage, 'PrefState', 'rowsPerPage');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -648,6 +660,7 @@ class _$PrefState extends PrefState {
persistUI == other.persistUI && persistUI == other.persistUI &&
longPressSelectionIsDefault == other.longPressSelectionIsDefault && longPressSelectionIsDefault == other.longPressSelectionIsDefault &&
requireAuthentication == other.requireAuthentication && requireAuthentication == other.requireAuthentication &&
tapSelectedToEdit == other.tapSelectedToEdit &&
rowsPerPage == other.rowsPerPage && rowsPerPage == other.rowsPerPage &&
colorTheme == other.colorTheme && colorTheme == other.colorTheme &&
sortFields == other.sortFields && sortFields == other.sortFields &&
@ -675,32 +688,22 @@ class _$PrefState extends PrefState {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc( $jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode),
$jc( menuSidebarMode.hashCode),
0, historySidebarMode.hashCode),
appLayout useSidebarEditor.hashCode),
.hashCode), customColors.hashCode),
moduleLayout isPreviewVisible.hashCode),
.hashCode), isMenuVisible.hashCode),
menuSidebarMode showKanban.hashCode),
.hashCode), isHistoryVisible.hashCode),
historySidebarMode enableDarkMode.hashCode),
.hashCode), isFilterVisible.hashCode),
useSidebarEditor persistData.hashCode),
.hashCode), persistUI.hashCode),
customColors longPressSelectionIsDefault.hashCode),
.hashCode), requireAuthentication.hashCode),
isPreviewVisible tapSelectedToEdit.hashCode),
.hashCode),
isMenuVisible.hashCode),
showKanban.hashCode),
isHistoryVisible.hashCode),
enableDarkMode.hashCode),
isFilterVisible.hashCode),
persistData.hashCode),
persistUI.hashCode),
longPressSelectionIsDefault.hashCode),
requireAuthentication.hashCode),
rowsPerPage.hashCode), rowsPerPage.hashCode),
colorTheme.hashCode), colorTheme.hashCode),
sortFields.hashCode), sortFields.hashCode),
@ -726,6 +729,7 @@ class _$PrefState extends PrefState {
..add('persistUI', persistUI) ..add('persistUI', persistUI)
..add('longPressSelectionIsDefault', longPressSelectionIsDefault) ..add('longPressSelectionIsDefault', longPressSelectionIsDefault)
..add('requireAuthentication', requireAuthentication) ..add('requireAuthentication', requireAuthentication)
..add('tapSelectedToEdit', tapSelectedToEdit)
..add('rowsPerPage', rowsPerPage) ..add('rowsPerPage', rowsPerPage)
..add('colorTheme', colorTheme) ..add('colorTheme', colorTheme)
..add('sortFields', sortFields) ..add('sortFields', sortFields)
@ -815,6 +819,11 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
set requireAuthentication(bool requireAuthentication) => set requireAuthentication(bool requireAuthentication) =>
_$this._requireAuthentication = requireAuthentication; _$this._requireAuthentication = requireAuthentication;
bool _tapSelectedToEdit;
bool get tapSelectedToEdit => _$this._tapSelectedToEdit;
set tapSelectedToEdit(bool tapSelectedToEdit) =>
_$this._tapSelectedToEdit = tapSelectedToEdit;
int _rowsPerPage; int _rowsPerPage;
int get rowsPerPage => _$this._rowsPerPage; int get rowsPerPage => _$this._rowsPerPage;
set rowsPerPage(int rowsPerPage) => _$this._rowsPerPage = rowsPerPage; set rowsPerPage(int rowsPerPage) => _$this._rowsPerPage = rowsPerPage;
@ -858,6 +867,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
_persistUI = $v.persistUI; _persistUI = $v.persistUI;
_longPressSelectionIsDefault = $v.longPressSelectionIsDefault; _longPressSelectionIsDefault = $v.longPressSelectionIsDefault;
_requireAuthentication = $v.requireAuthentication; _requireAuthentication = $v.requireAuthentication;
_tapSelectedToEdit = $v.tapSelectedToEdit;
_rowsPerPage = $v.rowsPerPage; _rowsPerPage = $v.rowsPerPage;
_colorTheme = $v.colorTheme; _colorTheme = $v.colorTheme;
_sortFields = $v.sortFields.toBuilder(); _sortFields = $v.sortFields.toBuilder();
@ -908,6 +918,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
persistUI: BuiltValueNullFieldError.checkNotNull(persistUI, 'PrefState', 'persistUI'), persistUI: BuiltValueNullFieldError.checkNotNull(persistUI, 'PrefState', 'persistUI'),
longPressSelectionIsDefault: BuiltValueNullFieldError.checkNotNull(longPressSelectionIsDefault, 'PrefState', 'longPressSelectionIsDefault'), longPressSelectionIsDefault: BuiltValueNullFieldError.checkNotNull(longPressSelectionIsDefault, 'PrefState', 'longPressSelectionIsDefault'),
requireAuthentication: BuiltValueNullFieldError.checkNotNull(requireAuthentication, 'PrefState', 'requireAuthentication'), requireAuthentication: BuiltValueNullFieldError.checkNotNull(requireAuthentication, 'PrefState', 'requireAuthentication'),
tapSelectedToEdit: BuiltValueNullFieldError.checkNotNull(tapSelectedToEdit, 'PrefState', 'tapSelectedToEdit'),
rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'), rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'),
colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'), colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'),
sortFields: sortFields.build(), sortFields: sortFields.build(),

View File

@ -144,15 +144,27 @@ class _DeviceSettingsState extends State<DeviceSettings>
disabledLabel: localization.showOrHide, disabledLabel: localization.showOrHide,
), ),
], ],
BoolDropdownButton( if (isDesktop(context))
label: localization.listLongPress, BoolDropdownButton(
value: !prefState.longPressSelectionIsDefault, label: localization.clickSelected,
onChanged: (value) { value: prefState.tapSelectedToEdit,
viewModel.onLongPressSelectionIsDefault(context, !value); onChanged: (value) {
}, viewModel.onTapSelectedChanged(context, value);
enabledLabel: localization.showActions, },
disabledLabel: localization.startMultiselect, enabledLabel: localization.editRecord,
), disabledLabel: localization.noAction,
)
else
BoolDropdownButton(
label: localization.listLongPress,
value: !prefState.longPressSelectionIsDefault,
onChanged: (value) {
viewModel.onLongPressSelectionIsDefault(
context, !value);
},
enabledLabel: localization.showActions,
disabledLabel: localization.startMultiselect,
),
AppDropdownButton<int>( AppDropdownButton<int>(
blankValue: null, blankValue: null,
labelText: localization.rowsPerPage, labelText: localization.rowsPerPage,

View File

@ -50,6 +50,7 @@ class DeviceSettingsVM {
@required this.onCustomColorsChanged, @required this.onCustomColorsChanged,
@required this.onPersistDataChanged, @required this.onPersistDataChanged,
@required this.onPersistUiChanged, @required this.onPersistUiChanged,
@required this.onTapSelectedChanged,
}); });
static DeviceSettingsVM fromStore(Store<AppState> store) { static DeviceSettingsVM fromStore(Store<AppState> store) {
@ -90,6 +91,9 @@ class DeviceSettingsVM {
store.dispatch(UpdateUserPreferences(historyMode: value)); store.dispatch(UpdateUserPreferences(historyMode: value));
}, },
onTapSelectedChanged: (context, value) async {
store.dispatch(UpdateUserPreferences(tapSelectedToEdit: value));
},
onColorThemeChanged: (context, value) async { onColorThemeChanged: (context, value) async {
if (store.state.prefState.colorTheme != value) { if (store.state.prefState.colorTheme != value) {
store.dispatch(UpdateUserPreferences(colorTheme: value)); store.dispatch(UpdateUserPreferences(colorTheme: value));
@ -173,6 +177,7 @@ class DeviceSettingsVM {
final Function(BuildContext, AppSidebarMode) onHistoryModeChanged; final Function(BuildContext, AppSidebarMode) onHistoryModeChanged;
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) 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

@ -15,6 +15,9 @@ 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
'click_selected': 'Click Selected',
'no_action': 'No Action',
'edit_record': 'Edit Record',
'credit_is_more_than_invoice': 'credit_is_more_than_invoice':
'The credit amount can not be more than the invoice amount', 'The credit amount can not be more than the invoice amount',
'giropay': 'Giropay', 'giropay': 'Giropay',
@ -62813,6 +62816,18 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['credit_is_more_than_invoice'] ?? _localizedValues[localeCode]['credit_is_more_than_invoice'] ??
_localizedValues['en']['credit_is_more_than_invoice']; _localizedValues['en']['credit_is_more_than_invoice'];
String get clickSelected =>
_localizedValues[localeCode]['click_selected'] ??
_localizedValues['en']['click_selected'];
String get noAction =>
_localizedValues[localeCode]['no_action'] ??
_localizedValues['en']['no_action'];
String get editRecord =>
_localizedValues[localeCode]['edit_record'] ??
_localizedValues['en']['edit_record'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {