Settings
This commit is contained in:
parent
cd8393c70d
commit
eca14593f8
|
|
@ -208,7 +208,7 @@ class _$ClientEntitySerializer implements StructuredSerializer<ClientEntity> {
|
|||
];
|
||||
if (object.groupId != null) {
|
||||
result
|
||||
..add('group_id')
|
||||
..add('group_setting_id')
|
||||
..add(serializers.serialize(object.groupId,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ class _$ClientEntitySerializer implements StructuredSerializer<ClientEntity> {
|
|||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case 'group_id':
|
||||
case 'group_setting_id':
|
||||
result.groupId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,9 @@ abstract class SettingsUIState extends Object
|
|||
{UserCompanyEntity userCompany,
|
||||
ClientEntity client,
|
||||
GroupEntity group,
|
||||
UserCompanyEntity origUserCompany,
|
||||
ClientEntity origClient,
|
||||
GroupEntity origGroup,
|
||||
String section}) {
|
||||
return _$SettingsUIState._(
|
||||
userCompany: userCompany ?? UserCompanyEntity(),
|
||||
|
|
@ -103,6 +106,9 @@ abstract class SettingsUIState extends Object
|
|||
entityType: client != null
|
||||
? EntityType.client
|
||||
: group != null ? EntityType.group : EntityType.company,
|
||||
origClient: origClient ?? ClientEntity(),
|
||||
origGroup: origGroup ?? GroupEntity(),
|
||||
origUserCompany: origUserCompany ?? UserCompanyEntity(),
|
||||
isChanged: false,
|
||||
updatedAt: 0,
|
||||
section: section ?? kSettingsCompanyDetails,
|
||||
|
|
@ -113,10 +119,16 @@ abstract class SettingsUIState extends Object
|
|||
|
||||
UserCompanyEntity get userCompany;
|
||||
|
||||
UserCompanyEntity get origUserCompany;
|
||||
|
||||
ClientEntity get client;
|
||||
|
||||
ClientEntity get origClient;
|
||||
|
||||
GroupEntity get group;
|
||||
|
||||
GroupEntity get origGroup;
|
||||
|
||||
EntityType get entityType;
|
||||
|
||||
bool get isChanged;
|
||||
|
|
|
|||
|
|
@ -154,12 +154,21 @@ class _$SettingsUIStateSerializer
|
|||
'userCompany',
|
||||
serializers.serialize(object.userCompany,
|
||||
specifiedType: const FullType(UserCompanyEntity)),
|
||||
'origUserCompany',
|
||||
serializers.serialize(object.origUserCompany,
|
||||
specifiedType: const FullType(UserCompanyEntity)),
|
||||
'client',
|
||||
serializers.serialize(object.client,
|
||||
specifiedType: const FullType(ClientEntity)),
|
||||
'origClient',
|
||||
serializers.serialize(object.origClient,
|
||||
specifiedType: const FullType(ClientEntity)),
|
||||
'group',
|
||||
serializers.serialize(object.group,
|
||||
specifiedType: const FullType(GroupEntity)),
|
||||
'origGroup',
|
||||
serializers.serialize(object.origGroup,
|
||||
specifiedType: const FullType(GroupEntity)),
|
||||
'entityType',
|
||||
serializers.serialize(object.entityType,
|
||||
specifiedType: const FullType(EntityType)),
|
||||
|
|
@ -194,14 +203,27 @@ class _$SettingsUIStateSerializer
|
|||
specifiedType: const FullType(UserCompanyEntity))
|
||||
as UserCompanyEntity);
|
||||
break;
|
||||
case 'origUserCompany':
|
||||
result.origUserCompany.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(UserCompanyEntity))
|
||||
as UserCompanyEntity);
|
||||
break;
|
||||
case 'client':
|
||||
result.client.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(ClientEntity)) as ClientEntity);
|
||||
break;
|
||||
case 'origClient':
|
||||
result.origClient.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(ClientEntity)) as ClientEntity);
|
||||
break;
|
||||
case 'group':
|
||||
result.group.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(GroupEntity)) as GroupEntity);
|
||||
break;
|
||||
case 'origGroup':
|
||||
result.origGroup.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(GroupEntity)) as GroupEntity);
|
||||
break;
|
||||
case 'entityType':
|
||||
result.entityType = serializers.deserialize(value,
|
||||
specifiedType: const FullType(EntityType)) as EntityType;
|
||||
|
|
@ -566,10 +588,16 @@ class _$SettingsUIState extends SettingsUIState {
|
|||
@override
|
||||
final UserCompanyEntity userCompany;
|
||||
@override
|
||||
final UserCompanyEntity origUserCompany;
|
||||
@override
|
||||
final ClientEntity client;
|
||||
@override
|
||||
final ClientEntity origClient;
|
||||
@override
|
||||
final GroupEntity group;
|
||||
@override
|
||||
final GroupEntity origGroup;
|
||||
@override
|
||||
final EntityType entityType;
|
||||
@override
|
||||
final bool isChanged;
|
||||
|
|
@ -583,8 +611,11 @@ class _$SettingsUIState extends SettingsUIState {
|
|||
|
||||
_$SettingsUIState._(
|
||||
{this.userCompany,
|
||||
this.origUserCompany,
|
||||
this.client,
|
||||
this.origClient,
|
||||
this.group,
|
||||
this.origGroup,
|
||||
this.entityType,
|
||||
this.isChanged,
|
||||
this.updatedAt,
|
||||
|
|
@ -593,12 +624,21 @@ class _$SettingsUIState extends SettingsUIState {
|
|||
if (userCompany == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'userCompany');
|
||||
}
|
||||
if (origUserCompany == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'origUserCompany');
|
||||
}
|
||||
if (client == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'client');
|
||||
}
|
||||
if (origClient == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'origClient');
|
||||
}
|
||||
if (group == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'group');
|
||||
}
|
||||
if (origGroup == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'origGroup');
|
||||
}
|
||||
if (entityType == null) {
|
||||
throw new BuiltValueNullFieldError('SettingsUIState', 'entityType');
|
||||
}
|
||||
|
|
@ -626,8 +666,11 @@ class _$SettingsUIState extends SettingsUIState {
|
|||
if (identical(other, this)) return true;
|
||||
return other is SettingsUIState &&
|
||||
userCompany == other.userCompany &&
|
||||
origUserCompany == other.origUserCompany &&
|
||||
client == other.client &&
|
||||
origClient == other.origClient &&
|
||||
group == other.group &&
|
||||
origGroup == other.origGroup &&
|
||||
entityType == other.entityType &&
|
||||
isChanged == other.isChanged &&
|
||||
updatedAt == other.updatedAt &&
|
||||
|
|
@ -640,8 +683,16 @@ class _$SettingsUIState extends SettingsUIState {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc($jc(0, userCompany.hashCode), client.hashCode),
|
||||
group.hashCode),
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc(0, userCompany.hashCode),
|
||||
origUserCompany.hashCode),
|
||||
client.hashCode),
|
||||
origClient.hashCode),
|
||||
group.hashCode),
|
||||
origGroup.hashCode),
|
||||
entityType.hashCode),
|
||||
isChanged.hashCode),
|
||||
updatedAt.hashCode),
|
||||
|
|
@ -652,8 +703,11 @@ class _$SettingsUIState extends SettingsUIState {
|
|||
String toString() {
|
||||
return (newBuiltValueToStringHelper('SettingsUIState')
|
||||
..add('userCompany', userCompany)
|
||||
..add('origUserCompany', origUserCompany)
|
||||
..add('client', client)
|
||||
..add('origClient', origClient)
|
||||
..add('group', group)
|
||||
..add('origGroup', origGroup)
|
||||
..add('entityType', entityType)
|
||||
..add('isChanged', isChanged)
|
||||
..add('updatedAt', updatedAt)
|
||||
|
|
@ -672,15 +726,32 @@ class SettingsUIStateBuilder
|
|||
set userCompany(UserCompanyEntityBuilder userCompany) =>
|
||||
_$this._userCompany = userCompany;
|
||||
|
||||
UserCompanyEntityBuilder _origUserCompany;
|
||||
UserCompanyEntityBuilder get origUserCompany =>
|
||||
_$this._origUserCompany ??= new UserCompanyEntityBuilder();
|
||||
set origUserCompany(UserCompanyEntityBuilder origUserCompany) =>
|
||||
_$this._origUserCompany = origUserCompany;
|
||||
|
||||
ClientEntityBuilder _client;
|
||||
ClientEntityBuilder get client =>
|
||||
_$this._client ??= new ClientEntityBuilder();
|
||||
set client(ClientEntityBuilder client) => _$this._client = client;
|
||||
|
||||
ClientEntityBuilder _origClient;
|
||||
ClientEntityBuilder get origClient =>
|
||||
_$this._origClient ??= new ClientEntityBuilder();
|
||||
set origClient(ClientEntityBuilder origClient) =>
|
||||
_$this._origClient = origClient;
|
||||
|
||||
GroupEntityBuilder _group;
|
||||
GroupEntityBuilder get group => _$this._group ??= new GroupEntityBuilder();
|
||||
set group(GroupEntityBuilder group) => _$this._group = group;
|
||||
|
||||
GroupEntityBuilder _origGroup;
|
||||
GroupEntityBuilder get origGroup =>
|
||||
_$this._origGroup ??= new GroupEntityBuilder();
|
||||
set origGroup(GroupEntityBuilder origGroup) => _$this._origGroup = origGroup;
|
||||
|
||||
EntityType _entityType;
|
||||
EntityType get entityType => _$this._entityType;
|
||||
set entityType(EntityType entityType) => _$this._entityType = entityType;
|
||||
|
|
@ -702,8 +773,11 @@ class SettingsUIStateBuilder
|
|||
SettingsUIStateBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_userCompany = _$v.userCompany?.toBuilder();
|
||||
_origUserCompany = _$v.origUserCompany?.toBuilder();
|
||||
_client = _$v.client?.toBuilder();
|
||||
_origClient = _$v.origClient?.toBuilder();
|
||||
_group = _$v.group?.toBuilder();
|
||||
_origGroup = _$v.origGroup?.toBuilder();
|
||||
_entityType = _$v.entityType;
|
||||
_isChanged = _$v.isChanged;
|
||||
_updatedAt = _$v.updatedAt;
|
||||
|
|
@ -733,8 +807,11 @@ class SettingsUIStateBuilder
|
|||
_$result = _$v ??
|
||||
new _$SettingsUIState._(
|
||||
userCompany: userCompany.build(),
|
||||
origUserCompany: origUserCompany.build(),
|
||||
client: client.build(),
|
||||
origClient: origClient.build(),
|
||||
group: group.build(),
|
||||
origGroup: origGroup.build(),
|
||||
entityType: entityType,
|
||||
isChanged: isChanged,
|
||||
updatedAt: updatedAt,
|
||||
|
|
@ -744,10 +821,16 @@ class SettingsUIStateBuilder
|
|||
try {
|
||||
_$failedField = 'userCompany';
|
||||
userCompany.build();
|
||||
_$failedField = 'origUserCompany';
|
||||
origUserCompany.build();
|
||||
_$failedField = 'client';
|
||||
client.build();
|
||||
_$failedField = 'origClient';
|
||||
origClient.build();
|
||||
_$failedField = 'group';
|
||||
group.build();
|
||||
_$failedField = 'origGroup';
|
||||
origGroup.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
'SettingsUIState', _$failedField, e.toString());
|
||||
|
|
|
|||
|
|
@ -24,20 +24,9 @@ class ViewSettings implements PersistUI {
|
|||
final String section;
|
||||
}
|
||||
|
||||
class ClearSettingsFilter {
|
||||
ClearSettingsFilter({@required this.userCompany});
|
||||
final UserCompanyEntity userCompany;
|
||||
}
|
||||
class ClearSettingsFilter {}
|
||||
|
||||
class ResetCompany {
|
||||
ResetCompany({@required this.company});
|
||||
final CompanyEntity company;
|
||||
}
|
||||
|
||||
class ResetUser {
|
||||
ResetUser({@required this.user});
|
||||
final UserEntity user;
|
||||
}
|
||||
class ResetSettings {}
|
||||
|
||||
class UpdateCompany {
|
||||
UpdateCompany({@required this.company});
|
||||
|
|
|
|||
|
|
@ -172,14 +172,17 @@ int selectCompanyReducer(int selectedCompanyIndex, SelectCompany action) {
|
|||
Reducer<SettingsUIState> settingsUIReducer = combineReducers([
|
||||
TypedReducer<SettingsUIState, ClearSettingsFilter>((state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..userCompany.replace(action.userCompany ?? state.userCompany)
|
||||
..userCompany.replace(state.origUserCompany)
|
||||
..entityType = EntityType.company);
|
||||
}),
|
||||
TypedReducer<SettingsUIState, ViewSettings>((state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..userCompany.replace(action.userCompany ?? state.userCompany)
|
||||
..origUserCompany.replace(action.userCompany ?? state.origUserCompany)
|
||||
..group.replace(action.group ?? state.group)
|
||||
..origGroup.replace(action.group ?? state.origGroup)
|
||||
..client.replace(action.client ?? state.client)
|
||||
..origClient.replace(action.client ?? state.origClient)
|
||||
..entityType = action.client != null
|
||||
? EntityType.client
|
||||
: action.group != null ? EntityType.group : state.entityType);
|
||||
|
|
@ -210,15 +213,11 @@ Reducer<SettingsUIState> settingsUIReducer = combineReducers([
|
|||
..userCompany.user.replace(action.user)
|
||||
..isChanged = true);
|
||||
}),
|
||||
TypedReducer<SettingsUIState, ResetCompany>((state, action) {
|
||||
TypedReducer<SettingsUIState, ResetSettings>((state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..userCompany.company.replace(action.company)
|
||||
..isChanged = false
|
||||
..updatedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
}),
|
||||
TypedReducer<SettingsUIState, ResetUser>((state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..userCompany.user.replace(action.user)
|
||||
..userCompany.replace(state.origUserCompany)
|
||||
..group.replace(state.origGroup)
|
||||
..client.replace(state.origClient)
|
||||
..isChanged = false
|
||||
..updatedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ class CompanyDetailsVM {
|
|||
store.dispatch(UpdateSettings(settings: settings)),
|
||||
onCompanyChanged: (company) =>
|
||||
store.dispatch(UpdateCompany(company: company)),
|
||||
onCancelPressed: (context) =>
|
||||
store.dispatch(ResetCompany(company: state.selectedCompany)),
|
||||
onCancelPressed: (context) => store.dispatch(ResetSettings()),
|
||||
onSavePressed: (context) {
|
||||
final completer = snackBarCompleter(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ class LocalizationSettingsVM {
|
|||
onChanged: (settings) {
|
||||
store.dispatch(UpdateSettings(settings: settings));
|
||||
},
|
||||
onCancelPressed: (context) =>
|
||||
store.dispatch(ResetCompany(company: state.selectedCompany)),
|
||||
onCancelPressed: (context) => store.dispatch(ResetSettings()),
|
||||
onSavePressed: (context) {
|
||||
final completer = snackBarCompleter(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class SettingsListVM {
|
|||
userCompany: state.userCompany));
|
||||
},
|
||||
onClearSettingsFilterPressed: () =>
|
||||
store.dispatch(ClearSettingsFilter(userCompany: state.userCompany)),
|
||||
store.dispatch(ClearSettingsFilter()),
|
||||
onViewClientPressed: (context) => store.dispatch(
|
||||
ViewClient(context: context, clientId: settingsUIState.client.id)),
|
||||
onViewGroupPressed: (context) => store.dispatch(
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ class UserDetailsVM {
|
|||
state: state,
|
||||
user: state.uiState.settingsUIState.userCompany.user,
|
||||
onChanged: (user) => store.dispatch(UpdateUser(user: user)),
|
||||
onCancelPressed: (context) =>
|
||||
store.dispatch(ResetUser(user: state.user)),
|
||||
onCancelPressed: (context) => store.dispatch(ResetSettings()),
|
||||
onSavePressed: (context) {
|
||||
final completer = snackBarCompleter(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
|
|
|
|||
Loading…
Reference in New Issue