Refactor
This commit is contained in:
parent
569f9a1487
commit
3ff71c3a87
|
|
@ -656,8 +656,6 @@ class _$InvitationEntitySerializer
|
||||||
Iterable serialize(Serializers serializers, InvitationEntity object,
|
Iterable serialize(Serializers serializers, InvitationEntity object,
|
||||||
{FullType specifiedType: FullType.unspecified}) {
|
{FullType specifiedType: FullType.unspecified}) {
|
||||||
final result = <Object>[
|
final result = <Object>[
|
||||||
'key',
|
|
||||||
serializers.serialize(object.key, specifiedType: const FullType(String)),
|
|
||||||
'link',
|
'link',
|
||||||
serializers.serialize(object.link, specifiedType: const FullType(String)),
|
serializers.serialize(object.link, specifiedType: const FullType(String)),
|
||||||
'sent_date',
|
'sent_date',
|
||||||
|
|
@ -706,10 +704,6 @@ class _$InvitationEntitySerializer
|
||||||
iterator.moveNext();
|
iterator.moveNext();
|
||||||
final dynamic value = iterator.current;
|
final dynamic value = iterator.current;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'key':
|
|
||||||
result.key = serializers.deserialize(value,
|
|
||||||
specifiedType: const FullType(String)) as String;
|
|
||||||
break;
|
|
||||||
case 'link':
|
case 'link':
|
||||||
result.link = serializers.deserialize(value,
|
result.link = serializers.deserialize(value,
|
||||||
specifiedType: const FullType(String)) as String;
|
specifiedType: const FullType(String)) as String;
|
||||||
|
|
@ -1952,8 +1946,6 @@ class InvoiceItemEntityBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
class _$InvitationEntity extends InvitationEntity {
|
class _$InvitationEntity extends InvitationEntity {
|
||||||
@override
|
|
||||||
final String key;
|
|
||||||
@override
|
@override
|
||||||
final String link;
|
final String link;
|
||||||
@override
|
@override
|
||||||
|
|
@ -1973,8 +1965,7 @@ class _$InvitationEntity extends InvitationEntity {
|
||||||
(new InvitationEntityBuilder()..update(updates)).build();
|
(new InvitationEntityBuilder()..update(updates)).build();
|
||||||
|
|
||||||
_$InvitationEntity._(
|
_$InvitationEntity._(
|
||||||
{this.key,
|
{this.link,
|
||||||
this.link,
|
|
||||||
this.sentDate,
|
this.sentDate,
|
||||||
this.viewedDate,
|
this.viewedDate,
|
||||||
this.id,
|
this.id,
|
||||||
|
|
@ -1982,8 +1973,6 @@ class _$InvitationEntity extends InvitationEntity {
|
||||||
this.archivedAt,
|
this.archivedAt,
|
||||||
this.isDeleted})
|
this.isDeleted})
|
||||||
: super._() {
|
: super._() {
|
||||||
if (key == null)
|
|
||||||
throw new BuiltValueNullFieldError('InvitationEntity', 'key');
|
|
||||||
if (link == null)
|
if (link == null)
|
||||||
throw new BuiltValueNullFieldError('InvitationEntity', 'link');
|
throw new BuiltValueNullFieldError('InvitationEntity', 'link');
|
||||||
if (sentDate == null)
|
if (sentDate == null)
|
||||||
|
|
@ -2004,8 +1993,7 @@ class _$InvitationEntity extends InvitationEntity {
|
||||||
bool operator ==(dynamic other) {
|
bool operator ==(dynamic other) {
|
||||||
if (identical(other, this)) return true;
|
if (identical(other, this)) return true;
|
||||||
if (other is! InvitationEntity) return false;
|
if (other is! InvitationEntity) return false;
|
||||||
return key == other.key &&
|
return link == other.link &&
|
||||||
link == other.link &&
|
|
||||||
sentDate == other.sentDate &&
|
sentDate == other.sentDate &&
|
||||||
viewedDate == other.viewedDate &&
|
viewedDate == other.viewedDate &&
|
||||||
id == other.id &&
|
id == other.id &&
|
||||||
|
|
@ -2020,9 +2008,7 @@ class _$InvitationEntity extends InvitationEntity {
|
||||||
$jc(
|
$jc(
|
||||||
$jc(
|
$jc(
|
||||||
$jc(
|
$jc(
|
||||||
$jc(
|
$jc($jc($jc(0, link.hashCode), sentDate.hashCode),
|
||||||
$jc($jc($jc(0, key.hashCode), link.hashCode),
|
|
||||||
sentDate.hashCode),
|
|
||||||
viewedDate.hashCode),
|
viewedDate.hashCode),
|
||||||
id.hashCode),
|
id.hashCode),
|
||||||
updatedAt.hashCode),
|
updatedAt.hashCode),
|
||||||
|
|
@ -2033,7 +2019,6 @@ class _$InvitationEntity extends InvitationEntity {
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (newBuiltValueToStringHelper('InvitationEntity')
|
return (newBuiltValueToStringHelper('InvitationEntity')
|
||||||
..add('key', key)
|
|
||||||
..add('link', link)
|
..add('link', link)
|
||||||
..add('sentDate', sentDate)
|
..add('sentDate', sentDate)
|
||||||
..add('viewedDate', viewedDate)
|
..add('viewedDate', viewedDate)
|
||||||
|
|
@ -2049,10 +2034,6 @@ class InvitationEntityBuilder
|
||||||
implements Builder<InvitationEntity, InvitationEntityBuilder> {
|
implements Builder<InvitationEntity, InvitationEntityBuilder> {
|
||||||
_$InvitationEntity _$v;
|
_$InvitationEntity _$v;
|
||||||
|
|
||||||
String _key;
|
|
||||||
String get key => _$this._key;
|
|
||||||
set key(String key) => _$this._key = key;
|
|
||||||
|
|
||||||
String _link;
|
String _link;
|
||||||
String get link => _$this._link;
|
String get link => _$this._link;
|
||||||
set link(String link) => _$this._link = link;
|
set link(String link) => _$this._link = link;
|
||||||
|
|
@ -2085,7 +2066,6 @@ class InvitationEntityBuilder
|
||||||
|
|
||||||
InvitationEntityBuilder get _$this {
|
InvitationEntityBuilder get _$this {
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_key = _$v.key;
|
|
||||||
_link = _$v.link;
|
_link = _$v.link;
|
||||||
_sentDate = _$v.sentDate;
|
_sentDate = _$v.sentDate;
|
||||||
_viewedDate = _$v.viewedDate;
|
_viewedDate = _$v.viewedDate;
|
||||||
|
|
@ -2113,7 +2093,6 @@ class InvitationEntityBuilder
|
||||||
_$InvitationEntity build() {
|
_$InvitationEntity build() {
|
||||||
final _$result = _$v ??
|
final _$result = _$v ??
|
||||||
new _$InvitationEntity._(
|
new _$InvitationEntity._(
|
||||||
key: key,
|
|
||||||
link: link,
|
link: link,
|
||||||
sentDate: sentDate,
|
sentDate: sentDate,
|
||||||
viewedDate: viewedDate,
|
viewedDate: viewedDate,
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ List<String> _getRoutes(AppState state) {
|
||||||
.forEach((part) {
|
.forEach((part) {
|
||||||
if (part == 'edit') {
|
if (part == 'edit') {
|
||||||
// Only restore new unsaved entities to prevent conflicts
|
// Only restore new unsaved entities to prevent conflicts
|
||||||
bool isNew = state.getUIState(entityType).isSelectedNew;
|
final bool isNew = state.getUIState(entityType).isCreatingNew;
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
route += '/edit';
|
route += '/edit';
|
||||||
} else if (entityType == EntityType.client) {
|
} else if (entityType == EntityType.client) {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||||
class ViewClientList implements PersistUI {}
|
class ViewClientList implements PersistUI {}
|
||||||
|
|
||||||
class ViewClient implements PersistUI {
|
class ViewClient implements PersistUI {
|
||||||
final ClientEntity client;
|
final int clientId;
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
ViewClient({this.client, this.context});
|
ViewClient({this.clientId, this.context});
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditClient implements PersistUI {
|
class EditClient implements PersistUI {
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@ import 'package:redux/redux.dart';
|
||||||
import 'package:invoiceninja/redux/client/client_actions.dart';
|
import 'package:invoiceninja/redux/client/client_actions.dart';
|
||||||
import 'package:invoiceninja/redux/client/client_state.dart';
|
import 'package:invoiceninja/redux/client/client_state.dart';
|
||||||
|
|
||||||
EntityUIState clientUIReducer(ClientUIState state, action) {
|
EntityUIState clientUIReducer(ClientUIState state, dynamic action) {
|
||||||
return state.rebuild((b) => b
|
return state.rebuild((b) => b
|
||||||
..listUIState.replace(clientListReducer(state.listUIState, action))
|
..listUIState.replace(clientListReducer(state.listUIState, action))
|
||||||
..selected.replace(editingReducer(state.selected, action))
|
..editing.replace(editingReducer(state.editing, action))
|
||||||
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
|
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
|
||||||
|
..selectedId = selectedIdReducer(state.selectedId, action)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,13 +23,20 @@ String filterClientDropdownReducer(String dropdownFilter, FilterClientDropdown a
|
||||||
return action.filter;
|
return action.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reducer<int> selectedIdReducer = combineReducers([
|
||||||
|
TypedReducer<int, ViewClient>(updateSelectedId),
|
||||||
|
]);
|
||||||
|
|
||||||
|
int updateSelectedId(int selectedId, ViewClient action) {
|
||||||
|
return action.clientId;
|
||||||
|
}
|
||||||
|
|
||||||
final editingReducer = combineReducers<ClientEntity>([
|
final editingReducer = combineReducers<ClientEntity>([
|
||||||
TypedReducer<ClientEntity, SaveClientSuccess>(_updateEditing),
|
TypedReducer<ClientEntity, SaveClientSuccess>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, AddClientSuccess>(_updateEditing),
|
TypedReducer<ClientEntity, AddClientSuccess>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, RestoreClientSuccess>(_updateEditing),
|
TypedReducer<ClientEntity, RestoreClientSuccess>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, ArchiveClientSuccess>(_updateEditing),
|
TypedReducer<ClientEntity, ArchiveClientSuccess>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, DeleteClientSuccess>(_updateEditing),
|
TypedReducer<ClientEntity, DeleteClientSuccess>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, ViewClient>(_updateEditing),
|
|
||||||
TypedReducer<ClientEntity, EditClient>(_updateEditing),
|
TypedReducer<ClientEntity, EditClient>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, UpdateClient>(_updateEditing),
|
TypedReducer<ClientEntity, UpdateClient>(_updateEditing),
|
||||||
TypedReducer<ClientEntity, AddContact>(_addContact),
|
TypedReducer<ClientEntity, AddContact>(_addContact),
|
||||||
|
|
@ -45,6 +53,10 @@ ClientEntity _updateEditing(ClientEntity client, action) {
|
||||||
return action.client;
|
return action.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClientEntity _updateViewing(ClientEntity client, ViewClient action) {
|
||||||
|
return action.clientId;
|
||||||
|
}
|
||||||
|
|
||||||
ClientEntity _addContact(ClientEntity client, AddContact action) {
|
ClientEntity _addContact(ClientEntity client, AddContact action) {
|
||||||
return client.rebuild((b) => b
|
return client.rebuild((b) => b
|
||||||
..contacts.add(ContactEntity())
|
..contacts.add(ContactEntity())
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,15 @@ abstract class ClientState implements Built<ClientState, ClientStateBuilder> {
|
||||||
abstract class ClientUIState extends Object with EntityUIState implements Built<ClientUIState, ClientUIStateBuilder> {
|
abstract class ClientUIState extends Object with EntityUIState implements Built<ClientUIState, ClientUIStateBuilder> {
|
||||||
|
|
||||||
@nullable
|
@nullable
|
||||||
ClientEntity get selected;
|
ClientEntity get editing;
|
||||||
|
|
||||||
bool get isSelectedNew => selected.isNew();
|
@override
|
||||||
|
bool get isCreatingNew => editing.isNew();
|
||||||
|
|
||||||
factory ClientUIState() {
|
factory ClientUIState() {
|
||||||
return _$ClientUIState._(
|
return _$ClientUIState._(
|
||||||
listUIState: ListUIState(ClientFields.name),
|
listUIState: ListUIState(ClientFields.name),
|
||||||
selected: ClientEntity(),
|
editing: ClientEntity(),
|
||||||
dropdownFilter: '',
|
dropdownFilter: '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,9 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
|
||||||
Iterable serialize(Serializers serializers, ClientUIState object,
|
Iterable serialize(Serializers serializers, ClientUIState object,
|
||||||
{FullType specifiedType: FullType.unspecified}) {
|
{FullType specifiedType: FullType.unspecified}) {
|
||||||
final result = <Object>[
|
final result = <Object>[
|
||||||
|
'selectedId',
|
||||||
|
serializers.serialize(object.selectedId,
|
||||||
|
specifiedType: const FullType(int)),
|
||||||
'listUIState',
|
'listUIState',
|
||||||
serializers.serialize(object.listUIState,
|
serializers.serialize(object.listUIState,
|
||||||
specifiedType: const FullType(ListUIState)),
|
specifiedType: const FullType(ListUIState)),
|
||||||
|
|
@ -99,10 +102,10 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
|
||||||
serializers.serialize(object.dropdownFilter,
|
serializers.serialize(object.dropdownFilter,
|
||||||
specifiedType: const FullType(String)),
|
specifiedType: const FullType(String)),
|
||||||
];
|
];
|
||||||
if (object.selected != null) {
|
if (object.editing != null) {
|
||||||
result
|
result
|
||||||
..add('selected')
|
..add('editing')
|
||||||
..add(serializers.serialize(object.selected,
|
..add(serializers.serialize(object.editing,
|
||||||
specifiedType: const FullType(ClientEntity)));
|
specifiedType: const FullType(ClientEntity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,10 +123,14 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
|
||||||
iterator.moveNext();
|
iterator.moveNext();
|
||||||
final dynamic value = iterator.current;
|
final dynamic value = iterator.current;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'selected':
|
case 'editing':
|
||||||
result.selected.replace(serializers.deserialize(value,
|
result.editing.replace(serializers.deserialize(value,
|
||||||
specifiedType: const FullType(ClientEntity)) as ClientEntity);
|
specifiedType: const FullType(ClientEntity)) as ClientEntity);
|
||||||
break;
|
break;
|
||||||
|
case 'selectedId':
|
||||||
|
result.selectedId = serializers.deserialize(value,
|
||||||
|
specifiedType: const FullType(int)) as int;
|
||||||
|
break;
|
||||||
case 'listUIState':
|
case 'listUIState':
|
||||||
result.listUIState.replace(serializers.deserialize(value,
|
result.listUIState.replace(serializers.deserialize(value,
|
||||||
specifiedType: const FullType(ListUIState)) as ListUIState);
|
specifiedType: const FullType(ListUIState)) as ListUIState);
|
||||||
|
|
@ -253,7 +260,9 @@ class ClientStateBuilder implements Builder<ClientState, ClientStateBuilder> {
|
||||||
|
|
||||||
class _$ClientUIState extends ClientUIState {
|
class _$ClientUIState extends ClientUIState {
|
||||||
@override
|
@override
|
||||||
final ClientEntity selected;
|
final ClientEntity editing;
|
||||||
|
@override
|
||||||
|
final int selectedId;
|
||||||
@override
|
@override
|
||||||
final ListUIState listUIState;
|
final ListUIState listUIState;
|
||||||
@override
|
@override
|
||||||
|
|
@ -262,8 +271,11 @@ class _$ClientUIState extends ClientUIState {
|
||||||
factory _$ClientUIState([void updates(ClientUIStateBuilder b)]) =>
|
factory _$ClientUIState([void updates(ClientUIStateBuilder b)]) =>
|
||||||
(new ClientUIStateBuilder()..update(updates)).build();
|
(new ClientUIStateBuilder()..update(updates)).build();
|
||||||
|
|
||||||
_$ClientUIState._({this.selected, this.listUIState, this.dropdownFilter})
|
_$ClientUIState._(
|
||||||
|
{this.editing, this.selectedId, this.listUIState, this.dropdownFilter})
|
||||||
: super._() {
|
: super._() {
|
||||||
|
if (selectedId == null)
|
||||||
|
throw new BuiltValueNullFieldError('ClientUIState', 'selectedId');
|
||||||
if (listUIState == null)
|
if (listUIState == null)
|
||||||
throw new BuiltValueNullFieldError('ClientUIState', 'listUIState');
|
throw new BuiltValueNullFieldError('ClientUIState', 'listUIState');
|
||||||
if (dropdownFilter == null)
|
if (dropdownFilter == null)
|
||||||
|
|
@ -281,21 +293,25 @@ class _$ClientUIState extends ClientUIState {
|
||||||
bool operator ==(dynamic other) {
|
bool operator ==(dynamic other) {
|
||||||
if (identical(other, this)) return true;
|
if (identical(other, this)) return true;
|
||||||
if (other is! ClientUIState) return false;
|
if (other is! ClientUIState) return false;
|
||||||
return selected == other.selected &&
|
return editing == other.editing &&
|
||||||
|
selectedId == other.selectedId &&
|
||||||
listUIState == other.listUIState &&
|
listUIState == other.listUIState &&
|
||||||
dropdownFilter == other.dropdownFilter;
|
dropdownFilter == other.dropdownFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
return $jf($jc($jc($jc(0, selected.hashCode), listUIState.hashCode),
|
return $jf($jc(
|
||||||
|
$jc($jc($jc(0, editing.hashCode), selectedId.hashCode),
|
||||||
|
listUIState.hashCode),
|
||||||
dropdownFilter.hashCode));
|
dropdownFilter.hashCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (newBuiltValueToStringHelper('ClientUIState')
|
return (newBuiltValueToStringHelper('ClientUIState')
|
||||||
..add('selected', selected)
|
..add('editing', editing)
|
||||||
|
..add('selectedId', selectedId)
|
||||||
..add('listUIState', listUIState)
|
..add('listUIState', listUIState)
|
||||||
..add('dropdownFilter', dropdownFilter))
|
..add('dropdownFilter', dropdownFilter))
|
||||||
.toString();
|
.toString();
|
||||||
|
|
@ -306,10 +322,14 @@ class ClientUIStateBuilder
|
||||||
implements Builder<ClientUIState, ClientUIStateBuilder> {
|
implements Builder<ClientUIState, ClientUIStateBuilder> {
|
||||||
_$ClientUIState _$v;
|
_$ClientUIState _$v;
|
||||||
|
|
||||||
ClientEntityBuilder _selected;
|
ClientEntityBuilder _editing;
|
||||||
ClientEntityBuilder get selected =>
|
ClientEntityBuilder get editing =>
|
||||||
_$this._selected ??= new ClientEntityBuilder();
|
_$this._editing ??= new ClientEntityBuilder();
|
||||||
set selected(ClientEntityBuilder selected) => _$this._selected = selected;
|
set editing(ClientEntityBuilder editing) => _$this._editing = editing;
|
||||||
|
|
||||||
|
int _selectedId;
|
||||||
|
int get selectedId => _$this._selectedId;
|
||||||
|
set selectedId(int selectedId) => _$this._selectedId = selectedId;
|
||||||
|
|
||||||
ListUIStateBuilder _listUIState;
|
ListUIStateBuilder _listUIState;
|
||||||
ListUIStateBuilder get listUIState =>
|
ListUIStateBuilder get listUIState =>
|
||||||
|
|
@ -326,7 +346,8 @@ class ClientUIStateBuilder
|
||||||
|
|
||||||
ClientUIStateBuilder get _$this {
|
ClientUIStateBuilder get _$this {
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_selected = _$v.selected?.toBuilder();
|
_editing = _$v.editing?.toBuilder();
|
||||||
|
_selectedId = _$v.selectedId;
|
||||||
_listUIState = _$v.listUIState?.toBuilder();
|
_listUIState = _$v.listUIState?.toBuilder();
|
||||||
_dropdownFilter = _$v.dropdownFilter;
|
_dropdownFilter = _$v.dropdownFilter;
|
||||||
_$v = null;
|
_$v = null;
|
||||||
|
|
@ -351,14 +372,16 @@ class ClientUIStateBuilder
|
||||||
try {
|
try {
|
||||||
_$result = _$v ??
|
_$result = _$v ??
|
||||||
new _$ClientUIState._(
|
new _$ClientUIState._(
|
||||||
selected: _selected?.build(),
|
editing: _editing?.build(),
|
||||||
|
selectedId: selectedId,
|
||||||
listUIState: listUIState.build(),
|
listUIState: listUIState.build(),
|
||||||
dropdownFilter: dropdownFilter);
|
dropdownFilter: dropdownFilter);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
String _$failedField;
|
String _$failedField;
|
||||||
try {
|
try {
|
||||||
_$failedField = 'selected';
|
_$failedField = 'editing';
|
||||||
_selected?.build();
|
_editing?.build();
|
||||||
|
|
||||||
_$failedField = 'listUIState';
|
_$failedField = 'listUIState';
|
||||||
listUIState.build();
|
listUIState.build();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||||
class ViewInvoiceList implements PersistUI {}
|
class ViewInvoiceList implements PersistUI {}
|
||||||
|
|
||||||
class ViewInvoice implements PersistUI {
|
class ViewInvoice implements PersistUI {
|
||||||
final InvoiceEntity invoice;
|
final int invoiceId;
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
ViewInvoice({this.invoice, this.context});
|
ViewInvoice({this.invoiceId, this.context});
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditInvoice implements PersistUI {
|
class EditInvoice implements PersistUI {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ import 'package:invoiceninja/redux/invoice/invoice_state.dart';
|
||||||
EntityUIState invoiceUIReducer(InvoiceUIState state, action) {
|
EntityUIState invoiceUIReducer(InvoiceUIState state, action) {
|
||||||
return state.rebuild((b) => b
|
return state.rebuild((b) => b
|
||||||
..listUIState.replace(invoiceListReducer(state.listUIState, action))
|
..listUIState.replace(invoiceListReducer(state.listUIState, action))
|
||||||
..selected.replace(editingReducer(state.selected, action))
|
..editing.replace(editingReducer(state.editing, action))
|
||||||
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
|
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
|
||||||
|
..selectedId = selectedIdReducer(state.selectedId, action)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -23,10 +24,17 @@ String filterClientDropdownReducer(String dropdownFilter, FilterInvoiceDropdown
|
||||||
return action.filter;
|
return action.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reducer<int> selectedIdReducer = combineReducers([
|
||||||
|
TypedReducer<int, ViewInvoice>(updateSelectedId),
|
||||||
|
]);
|
||||||
|
|
||||||
|
int updateSelectedId(int selectedId, ViewInvoice action) {
|
||||||
|
return action.invoiceId;
|
||||||
|
}
|
||||||
|
|
||||||
final editingReducer = combineReducers<InvoiceEntity>([
|
final editingReducer = combineReducers<InvoiceEntity>([
|
||||||
TypedReducer<InvoiceEntity, SaveInvoiceSuccess>(_updateEditing),
|
TypedReducer<InvoiceEntity, SaveInvoiceSuccess>(_updateEditing),
|
||||||
TypedReducer<InvoiceEntity, AddInvoiceSuccess>(_updateEditing),
|
TypedReducer<InvoiceEntity, AddInvoiceSuccess>(_updateEditing),
|
||||||
TypedReducer<InvoiceEntity, ViewInvoice>(_updateEditing),
|
|
||||||
TypedReducer<InvoiceEntity, EditInvoice>(_updateEditing),
|
TypedReducer<InvoiceEntity, EditInvoice>(_updateEditing),
|
||||||
TypedReducer<InvoiceEntity, UpdateInvoice>(_updateEditing),
|
TypedReducer<InvoiceEntity, UpdateInvoice>(_updateEditing),
|
||||||
TypedReducer<InvoiceEntity, RestoreInvoiceSuccess>(_updateEditing),
|
TypedReducer<InvoiceEntity, RestoreInvoiceSuccess>(_updateEditing),
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,15 @@ abstract class InvoiceState implements Built<InvoiceState, InvoiceStateBuilder>
|
||||||
abstract class InvoiceUIState extends Object with EntityUIState implements Built<InvoiceUIState, InvoiceUIStateBuilder> {
|
abstract class InvoiceUIState extends Object with EntityUIState implements Built<InvoiceUIState, InvoiceUIStateBuilder> {
|
||||||
|
|
||||||
@nullable
|
@nullable
|
||||||
InvoiceEntity get selected;
|
InvoiceEntity get editing;
|
||||||
|
|
||||||
bool get isSelectedNew => selected.isNew();
|
@override
|
||||||
|
bool get isCreatingNew => editing.isNew();
|
||||||
|
|
||||||
factory InvoiceUIState() {
|
factory InvoiceUIState() {
|
||||||
return _$InvoiceUIState._(
|
return _$InvoiceUIState._(
|
||||||
listUIState: ListUIState(InvoiceFields.invoiceNumber),
|
listUIState: ListUIState(InvoiceFields.invoiceNumber),
|
||||||
selected: InvoiceEntity(),
|
editing: InvoiceEntity(),
|
||||||
dropdownFilter: '',
|
dropdownFilter: '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,9 @@ class _$InvoiceUIStateSerializer
|
||||||
Iterable serialize(Serializers serializers, InvoiceUIState object,
|
Iterable serialize(Serializers serializers, InvoiceUIState object,
|
||||||
{FullType specifiedType: FullType.unspecified}) {
|
{FullType specifiedType: FullType.unspecified}) {
|
||||||
final result = <Object>[
|
final result = <Object>[
|
||||||
|
'selectedId',
|
||||||
|
serializers.serialize(object.selectedId,
|
||||||
|
specifiedType: const FullType(int)),
|
||||||
'listUIState',
|
'listUIState',
|
||||||
serializers.serialize(object.listUIState,
|
serializers.serialize(object.listUIState,
|
||||||
specifiedType: const FullType(ListUIState)),
|
specifiedType: const FullType(ListUIState)),
|
||||||
|
|
@ -101,10 +104,10 @@ class _$InvoiceUIStateSerializer
|
||||||
serializers.serialize(object.dropdownFilter,
|
serializers.serialize(object.dropdownFilter,
|
||||||
specifiedType: const FullType(String)),
|
specifiedType: const FullType(String)),
|
||||||
];
|
];
|
||||||
if (object.selected != null) {
|
if (object.editing != null) {
|
||||||
result
|
result
|
||||||
..add('selected')
|
..add('editing')
|
||||||
..add(serializers.serialize(object.selected,
|
..add(serializers.serialize(object.editing,
|
||||||
specifiedType: const FullType(InvoiceEntity)));
|
specifiedType: const FullType(InvoiceEntity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,10 +125,14 @@ class _$InvoiceUIStateSerializer
|
||||||
iterator.moveNext();
|
iterator.moveNext();
|
||||||
final dynamic value = iterator.current;
|
final dynamic value = iterator.current;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'selected':
|
case 'editing':
|
||||||
result.selected.replace(serializers.deserialize(value,
|
result.editing.replace(serializers.deserialize(value,
|
||||||
specifiedType: const FullType(InvoiceEntity)) as InvoiceEntity);
|
specifiedType: const FullType(InvoiceEntity)) as InvoiceEntity);
|
||||||
break;
|
break;
|
||||||
|
case 'selectedId':
|
||||||
|
result.selectedId = serializers.deserialize(value,
|
||||||
|
specifiedType: const FullType(int)) as int;
|
||||||
|
break;
|
||||||
case 'listUIState':
|
case 'listUIState':
|
||||||
result.listUIState.replace(serializers.deserialize(value,
|
result.listUIState.replace(serializers.deserialize(value,
|
||||||
specifiedType: const FullType(ListUIState)) as ListUIState);
|
specifiedType: const FullType(ListUIState)) as ListUIState);
|
||||||
|
|
@ -257,7 +264,9 @@ class InvoiceStateBuilder
|
||||||
|
|
||||||
class _$InvoiceUIState extends InvoiceUIState {
|
class _$InvoiceUIState extends InvoiceUIState {
|
||||||
@override
|
@override
|
||||||
final InvoiceEntity selected;
|
final InvoiceEntity editing;
|
||||||
|
@override
|
||||||
|
final int selectedId;
|
||||||
@override
|
@override
|
||||||
final ListUIState listUIState;
|
final ListUIState listUIState;
|
||||||
@override
|
@override
|
||||||
|
|
@ -266,8 +275,11 @@ class _$InvoiceUIState extends InvoiceUIState {
|
||||||
factory _$InvoiceUIState([void updates(InvoiceUIStateBuilder b)]) =>
|
factory _$InvoiceUIState([void updates(InvoiceUIStateBuilder b)]) =>
|
||||||
(new InvoiceUIStateBuilder()..update(updates)).build();
|
(new InvoiceUIStateBuilder()..update(updates)).build();
|
||||||
|
|
||||||
_$InvoiceUIState._({this.selected, this.listUIState, this.dropdownFilter})
|
_$InvoiceUIState._(
|
||||||
|
{this.editing, this.selectedId, this.listUIState, this.dropdownFilter})
|
||||||
: super._() {
|
: super._() {
|
||||||
|
if (selectedId == null)
|
||||||
|
throw new BuiltValueNullFieldError('InvoiceUIState', 'selectedId');
|
||||||
if (listUIState == null)
|
if (listUIState == null)
|
||||||
throw new BuiltValueNullFieldError('InvoiceUIState', 'listUIState');
|
throw new BuiltValueNullFieldError('InvoiceUIState', 'listUIState');
|
||||||
if (dropdownFilter == null)
|
if (dropdownFilter == null)
|
||||||
|
|
@ -286,21 +298,25 @@ class _$InvoiceUIState extends InvoiceUIState {
|
||||||
bool operator ==(dynamic other) {
|
bool operator ==(dynamic other) {
|
||||||
if (identical(other, this)) return true;
|
if (identical(other, this)) return true;
|
||||||
if (other is! InvoiceUIState) return false;
|
if (other is! InvoiceUIState) return false;
|
||||||
return selected == other.selected &&
|
return editing == other.editing &&
|
||||||
|
selectedId == other.selectedId &&
|
||||||
listUIState == other.listUIState &&
|
listUIState == other.listUIState &&
|
||||||
dropdownFilter == other.dropdownFilter;
|
dropdownFilter == other.dropdownFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
return $jf($jc($jc($jc(0, selected.hashCode), listUIState.hashCode),
|
return $jf($jc(
|
||||||
|
$jc($jc($jc(0, editing.hashCode), selectedId.hashCode),
|
||||||
|
listUIState.hashCode),
|
||||||
dropdownFilter.hashCode));
|
dropdownFilter.hashCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (newBuiltValueToStringHelper('InvoiceUIState')
|
return (newBuiltValueToStringHelper('InvoiceUIState')
|
||||||
..add('selected', selected)
|
..add('editing', editing)
|
||||||
|
..add('selectedId', selectedId)
|
||||||
..add('listUIState', listUIState)
|
..add('listUIState', listUIState)
|
||||||
..add('dropdownFilter', dropdownFilter))
|
..add('dropdownFilter', dropdownFilter))
|
||||||
.toString();
|
.toString();
|
||||||
|
|
@ -311,10 +327,14 @@ class InvoiceUIStateBuilder
|
||||||
implements Builder<InvoiceUIState, InvoiceUIStateBuilder> {
|
implements Builder<InvoiceUIState, InvoiceUIStateBuilder> {
|
||||||
_$InvoiceUIState _$v;
|
_$InvoiceUIState _$v;
|
||||||
|
|
||||||
InvoiceEntityBuilder _selected;
|
InvoiceEntityBuilder _editing;
|
||||||
InvoiceEntityBuilder get selected =>
|
InvoiceEntityBuilder get editing =>
|
||||||
_$this._selected ??= new InvoiceEntityBuilder();
|
_$this._editing ??= new InvoiceEntityBuilder();
|
||||||
set selected(InvoiceEntityBuilder selected) => _$this._selected = selected;
|
set editing(InvoiceEntityBuilder editing) => _$this._editing = editing;
|
||||||
|
|
||||||
|
int _selectedId;
|
||||||
|
int get selectedId => _$this._selectedId;
|
||||||
|
set selectedId(int selectedId) => _$this._selectedId = selectedId;
|
||||||
|
|
||||||
ListUIStateBuilder _listUIState;
|
ListUIStateBuilder _listUIState;
|
||||||
ListUIStateBuilder get listUIState =>
|
ListUIStateBuilder get listUIState =>
|
||||||
|
|
@ -331,7 +351,8 @@ class InvoiceUIStateBuilder
|
||||||
|
|
||||||
InvoiceUIStateBuilder get _$this {
|
InvoiceUIStateBuilder get _$this {
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_selected = _$v.selected?.toBuilder();
|
_editing = _$v.editing?.toBuilder();
|
||||||
|
_selectedId = _$v.selectedId;
|
||||||
_listUIState = _$v.listUIState?.toBuilder();
|
_listUIState = _$v.listUIState?.toBuilder();
|
||||||
_dropdownFilter = _$v.dropdownFilter;
|
_dropdownFilter = _$v.dropdownFilter;
|
||||||
_$v = null;
|
_$v = null;
|
||||||
|
|
@ -356,14 +377,16 @@ class InvoiceUIStateBuilder
|
||||||
try {
|
try {
|
||||||
_$result = _$v ??
|
_$result = _$v ??
|
||||||
new _$InvoiceUIState._(
|
new _$InvoiceUIState._(
|
||||||
selected: _selected?.build(),
|
editing: _editing?.build(),
|
||||||
|
selectedId: selectedId,
|
||||||
listUIState: listUIState.build(),
|
listUIState: listUIState.build(),
|
||||||
dropdownFilter: dropdownFilter);
|
dropdownFilter: dropdownFilter);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
String _$failedField;
|
String _$failedField;
|
||||||
try {
|
try {
|
||||||
_$failedField = 'selected';
|
_$failedField = 'editing';
|
||||||
_selected?.build();
|
_editing?.build();
|
||||||
|
|
||||||
_$failedField = 'listUIState';
|
_$failedField = 'listUIState';
|
||||||
listUIState.build();
|
listUIState.build();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import 'package:invoiceninja/redux/product/product_state.dart';
|
||||||
EntityUIState productUIReducer(ProductUIState state, action) {
|
EntityUIState productUIReducer(ProductUIState state, action) {
|
||||||
return state.rebuild((b) => b
|
return state.rebuild((b) => b
|
||||||
..listUIState.replace(productListReducer(state.listUIState, action))
|
..listUIState.replace(productListReducer(state.listUIState, action))
|
||||||
..selected.replace(editingReducer(state.selected, action))
|
..editing.replace(editingReducer(state.editing, action))
|
||||||
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
|
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,15 @@ abstract class ProductState implements Built<ProductState, ProductStateBuilder>
|
||||||
abstract class ProductUIState extends Object with EntityUIState implements Built<ProductUIState, ProductUIStateBuilder> {
|
abstract class ProductUIState extends Object with EntityUIState implements Built<ProductUIState, ProductUIStateBuilder> {
|
||||||
|
|
||||||
@nullable
|
@nullable
|
||||||
ProductEntity get selected;
|
ProductEntity get editing;
|
||||||
|
|
||||||
bool get isSelectedNew => selected.isNew();
|
@override
|
||||||
|
bool get isCreatingNew => editing.isNew();
|
||||||
|
|
||||||
factory ProductUIState() {
|
factory ProductUIState() {
|
||||||
return _$ProductUIState._(
|
return _$ProductUIState._(
|
||||||
listUIState: ListUIState(ProductFields.productKey),
|
listUIState: ListUIState(ProductFields.productKey),
|
||||||
selected: ProductEntity(),
|
editing: ProductEntity(),
|
||||||
dropdownFilter: '',
|
dropdownFilter: '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,9 @@ class _$ProductUIStateSerializer
|
||||||
Iterable serialize(Serializers serializers, ProductUIState object,
|
Iterable serialize(Serializers serializers, ProductUIState object,
|
||||||
{FullType specifiedType: FullType.unspecified}) {
|
{FullType specifiedType: FullType.unspecified}) {
|
||||||
final result = <Object>[
|
final result = <Object>[
|
||||||
|
'selectedId',
|
||||||
|
serializers.serialize(object.selectedId,
|
||||||
|
specifiedType: const FullType(int)),
|
||||||
'listUIState',
|
'listUIState',
|
||||||
serializers.serialize(object.listUIState,
|
serializers.serialize(object.listUIState,
|
||||||
specifiedType: const FullType(ListUIState)),
|
specifiedType: const FullType(ListUIState)),
|
||||||
|
|
@ -101,10 +104,10 @@ class _$ProductUIStateSerializer
|
||||||
serializers.serialize(object.dropdownFilter,
|
serializers.serialize(object.dropdownFilter,
|
||||||
specifiedType: const FullType(String)),
|
specifiedType: const FullType(String)),
|
||||||
];
|
];
|
||||||
if (object.selected != null) {
|
if (object.editing != null) {
|
||||||
result
|
result
|
||||||
..add('selected')
|
..add('editing')
|
||||||
..add(serializers.serialize(object.selected,
|
..add(serializers.serialize(object.editing,
|
||||||
specifiedType: const FullType(ProductEntity)));
|
specifiedType: const FullType(ProductEntity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,10 +125,14 @@ class _$ProductUIStateSerializer
|
||||||
iterator.moveNext();
|
iterator.moveNext();
|
||||||
final dynamic value = iterator.current;
|
final dynamic value = iterator.current;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'selected':
|
case 'editing':
|
||||||
result.selected.replace(serializers.deserialize(value,
|
result.editing.replace(serializers.deserialize(value,
|
||||||
specifiedType: const FullType(ProductEntity)) as ProductEntity);
|
specifiedType: const FullType(ProductEntity)) as ProductEntity);
|
||||||
break;
|
break;
|
||||||
|
case 'selectedId':
|
||||||
|
result.selectedId = serializers.deserialize(value,
|
||||||
|
specifiedType: const FullType(int)) as int;
|
||||||
|
break;
|
||||||
case 'listUIState':
|
case 'listUIState':
|
||||||
result.listUIState.replace(serializers.deserialize(value,
|
result.listUIState.replace(serializers.deserialize(value,
|
||||||
specifiedType: const FullType(ListUIState)) as ListUIState);
|
specifiedType: const FullType(ListUIState)) as ListUIState);
|
||||||
|
|
@ -257,7 +264,9 @@ class ProductStateBuilder
|
||||||
|
|
||||||
class _$ProductUIState extends ProductUIState {
|
class _$ProductUIState extends ProductUIState {
|
||||||
@override
|
@override
|
||||||
final ProductEntity selected;
|
final ProductEntity editing;
|
||||||
|
@override
|
||||||
|
final int selectedId;
|
||||||
@override
|
@override
|
||||||
final ListUIState listUIState;
|
final ListUIState listUIState;
|
||||||
@override
|
@override
|
||||||
|
|
@ -266,8 +275,11 @@ class _$ProductUIState extends ProductUIState {
|
||||||
factory _$ProductUIState([void updates(ProductUIStateBuilder b)]) =>
|
factory _$ProductUIState([void updates(ProductUIStateBuilder b)]) =>
|
||||||
(new ProductUIStateBuilder()..update(updates)).build();
|
(new ProductUIStateBuilder()..update(updates)).build();
|
||||||
|
|
||||||
_$ProductUIState._({this.selected, this.listUIState, this.dropdownFilter})
|
_$ProductUIState._(
|
||||||
|
{this.editing, this.selectedId, this.listUIState, this.dropdownFilter})
|
||||||
: super._() {
|
: super._() {
|
||||||
|
if (selectedId == null)
|
||||||
|
throw new BuiltValueNullFieldError('ProductUIState', 'selectedId');
|
||||||
if (listUIState == null)
|
if (listUIState == null)
|
||||||
throw new BuiltValueNullFieldError('ProductUIState', 'listUIState');
|
throw new BuiltValueNullFieldError('ProductUIState', 'listUIState');
|
||||||
if (dropdownFilter == null)
|
if (dropdownFilter == null)
|
||||||
|
|
@ -286,21 +298,25 @@ class _$ProductUIState extends ProductUIState {
|
||||||
bool operator ==(dynamic other) {
|
bool operator ==(dynamic other) {
|
||||||
if (identical(other, this)) return true;
|
if (identical(other, this)) return true;
|
||||||
if (other is! ProductUIState) return false;
|
if (other is! ProductUIState) return false;
|
||||||
return selected == other.selected &&
|
return editing == other.editing &&
|
||||||
|
selectedId == other.selectedId &&
|
||||||
listUIState == other.listUIState &&
|
listUIState == other.listUIState &&
|
||||||
dropdownFilter == other.dropdownFilter;
|
dropdownFilter == other.dropdownFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
return $jf($jc($jc($jc(0, selected.hashCode), listUIState.hashCode),
|
return $jf($jc(
|
||||||
|
$jc($jc($jc(0, editing.hashCode), selectedId.hashCode),
|
||||||
|
listUIState.hashCode),
|
||||||
dropdownFilter.hashCode));
|
dropdownFilter.hashCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (newBuiltValueToStringHelper('ProductUIState')
|
return (newBuiltValueToStringHelper('ProductUIState')
|
||||||
..add('selected', selected)
|
..add('editing', editing)
|
||||||
|
..add('selectedId', selectedId)
|
||||||
..add('listUIState', listUIState)
|
..add('listUIState', listUIState)
|
||||||
..add('dropdownFilter', dropdownFilter))
|
..add('dropdownFilter', dropdownFilter))
|
||||||
.toString();
|
.toString();
|
||||||
|
|
@ -311,10 +327,14 @@ class ProductUIStateBuilder
|
||||||
implements Builder<ProductUIState, ProductUIStateBuilder> {
|
implements Builder<ProductUIState, ProductUIStateBuilder> {
|
||||||
_$ProductUIState _$v;
|
_$ProductUIState _$v;
|
||||||
|
|
||||||
ProductEntityBuilder _selected;
|
ProductEntityBuilder _editing;
|
||||||
ProductEntityBuilder get selected =>
|
ProductEntityBuilder get editing =>
|
||||||
_$this._selected ??= new ProductEntityBuilder();
|
_$this._editing ??= new ProductEntityBuilder();
|
||||||
set selected(ProductEntityBuilder selected) => _$this._selected = selected;
|
set editing(ProductEntityBuilder editing) => _$this._editing = editing;
|
||||||
|
|
||||||
|
int _selectedId;
|
||||||
|
int get selectedId => _$this._selectedId;
|
||||||
|
set selectedId(int selectedId) => _$this._selectedId = selectedId;
|
||||||
|
|
||||||
ListUIStateBuilder _listUIState;
|
ListUIStateBuilder _listUIState;
|
||||||
ListUIStateBuilder get listUIState =>
|
ListUIStateBuilder get listUIState =>
|
||||||
|
|
@ -331,7 +351,8 @@ class ProductUIStateBuilder
|
||||||
|
|
||||||
ProductUIStateBuilder get _$this {
|
ProductUIStateBuilder get _$this {
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_selected = _$v.selected?.toBuilder();
|
_editing = _$v.editing?.toBuilder();
|
||||||
|
_selectedId = _$v.selectedId;
|
||||||
_listUIState = _$v.listUIState?.toBuilder();
|
_listUIState = _$v.listUIState?.toBuilder();
|
||||||
_dropdownFilter = _$v.dropdownFilter;
|
_dropdownFilter = _$v.dropdownFilter;
|
||||||
_$v = null;
|
_$v = null;
|
||||||
|
|
@ -356,14 +377,16 @@ class ProductUIStateBuilder
|
||||||
try {
|
try {
|
||||||
_$result = _$v ??
|
_$result = _$v ??
|
||||||
new _$ProductUIState._(
|
new _$ProductUIState._(
|
||||||
selected: _selected?.build(),
|
editing: _editing?.build(),
|
||||||
|
selectedId: selectedId,
|
||||||
listUIState: listUIState.build(),
|
listUIState: listUIState.build(),
|
||||||
dropdownFilter: dropdownFilter);
|
dropdownFilter: dropdownFilter);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
String _$failedField;
|
String _$failedField;
|
||||||
try {
|
try {
|
||||||
_$failedField = 'selected';
|
_$failedField = 'editing';
|
||||||
_selected?.build();
|
_editing?.build();
|
||||||
|
|
||||||
_$failedField = 'listUIState';
|
_$failedField = 'listUIState';
|
||||||
listUIState.build();
|
listUIState.build();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'package:invoiceninja/redux/ui/list_ui_state.dart';
|
||||||
|
|
||||||
abstract class EntityUIState {
|
abstract class EntityUIState {
|
||||||
|
|
||||||
bool get isSelectedNew;
|
bool get isCreatingNew;
|
||||||
|
int get selectedId;
|
||||||
ListUIState get listUIState;
|
ListUIState get listUIState;
|
||||||
String get dropdownFilter;
|
String get dropdownFilter;
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,7 @@ class ClientListVM {
|
||||||
isLoading: store.state.isLoading,
|
isLoading: store.state.isLoading,
|
||||||
isLoaded: store.state.clientState.isLoaded,
|
isLoaded: store.state.clientState.isLoaded,
|
||||||
onClientTap: (context, client) {
|
onClientTap: (context, client) {
|
||||||
store.dispatch(ViewClient(client: client, context: context));
|
store.dispatch(ViewClient(clientId: client.id, context: context));
|
||||||
},
|
},
|
||||||
onRefreshed: (context) => _handleRefresh(context),
|
onRefreshed: (context) => _handleRefresh(context),
|
||||||
onDismissed: (BuildContext context, ClientEntity client,
|
onDismissed: (BuildContext context, ClientEntity client,
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class ClientEditVM {
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ClientEditVM.fromStore(Store<AppState> store) {
|
factory ClientEditVM.fromStore(Store<AppState> store) {
|
||||||
final client = store.state.clientUIState.selected;
|
final client = store.state.clientUIState.editing;
|
||||||
|
|
||||||
return ClientEditVM(
|
return ClientEditVM(
|
||||||
client: client,
|
client: client,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ class ClientViewVM {
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ClientViewVM.fromStore(Store<AppState> store) {
|
factory ClientViewVM.fromStore(Store<AppState> store) {
|
||||||
final client = store.state.clientUIState.selected;
|
final state = store.state;
|
||||||
|
final client = state.clientState.map[state.clientUIState.selectedId];
|
||||||
|
|
||||||
return ClientViewVM(
|
return ClientViewVM(
|
||||||
state: store.state,
|
state: store.state,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class InvoiceEditDetailsVM {
|
||||||
|
|
||||||
factory InvoiceEditDetailsVM.fromStore(Store<AppState> store) {
|
factory InvoiceEditDetailsVM.fromStore(Store<AppState> store) {
|
||||||
AppState state = store.state;
|
AppState state = store.state;
|
||||||
final invoice = state.invoiceUIState.selected;
|
final invoice = state.invoiceUIState.editing;
|
||||||
|
|
||||||
return InvoiceEditDetailsVM(
|
return InvoiceEditDetailsVM(
|
||||||
state: state,
|
state: state,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class InvoiceEditItemsVM {
|
||||||
|
|
||||||
factory InvoiceEditItemsVM.fromStore(Store<AppState> store) {
|
factory InvoiceEditItemsVM.fromStore(Store<AppState> store) {
|
||||||
AppState state = store.state;
|
AppState state = store.state;
|
||||||
final invoice = state.invoiceUIState.selected;
|
final invoice = state.invoiceUIState.editing;
|
||||||
|
|
||||||
return InvoiceEditItemsVM(
|
return InvoiceEditItemsVM(
|
||||||
state: state,
|
state: state,
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class InvoiceEditVM {
|
||||||
|
|
||||||
factory InvoiceEditVM.fromStore(Store<AppState> store) {
|
factory InvoiceEditVM.fromStore(Store<AppState> store) {
|
||||||
AppState state = store.state;
|
AppState state = store.state;
|
||||||
final invoice = state.invoiceUIState.selected;
|
final invoice = state.invoiceUIState.editing;
|
||||||
|
|
||||||
return InvoiceEditVM(
|
return InvoiceEditVM(
|
||||||
state: state,
|
state: state,
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class InvoiceListVM {
|
||||||
isLoaded: state.invoiceState.isLoaded &&
|
isLoaded: state.invoiceState.isLoaded &&
|
||||||
state.clientState.isLoaded,
|
state.clientState.isLoaded,
|
||||||
onInvoiceTap: (context, invoice) {
|
onInvoiceTap: (context, invoice) {
|
||||||
store.dispatch(ViewInvoice(invoice: invoice, context: context));
|
store.dispatch(ViewInvoice(invoiceId: invoice.id, context: context));
|
||||||
},
|
},
|
||||||
onRefreshed: (context) => _handleRefresh(context),
|
onRefreshed: (context) => _handleRefresh(context),
|
||||||
onDismissed: (BuildContext context, InvoiceEntity invoice,
|
onDismissed: (BuildContext context, InvoiceEntity invoice,
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ class InvoiceViewVM {
|
||||||
});
|
});
|
||||||
|
|
||||||
factory InvoiceViewVM.fromStore(Store<AppState> store) {
|
factory InvoiceViewVM.fromStore(Store<AppState> store) {
|
||||||
final invoice = store.state.invoiceUIState.selected;
|
final state = store.state;
|
||||||
|
final invoice = state.invoiceState.map[state.invoiceUIState.selectedId];
|
||||||
final client = store.state.clientState.map[invoice.clientId];
|
final client = store.state.clientState.map[invoice.clientId];
|
||||||
|
|
||||||
Future<Null> _viewPdf(BuildContext context) async {
|
Future<Null> _viewPdf(BuildContext context) async {
|
||||||
|
|
@ -91,7 +92,7 @@ class InvoiceViewVM {
|
||||||
},
|
},
|
||||||
onBackPressed: () => store.dispatch(UpdateCurrentRoute(InvoiceScreen.route)),
|
onBackPressed: () => store.dispatch(UpdateCurrentRoute(InvoiceScreen.route)),
|
||||||
onClientPressed: (BuildContext context) {
|
onClientPressed: (BuildContext context) {
|
||||||
store.dispatch(ViewClient(client: client, context: context));
|
store.dispatch(ViewClient(clientId: client.id, context: context));
|
||||||
},
|
},
|
||||||
onActionSelected: (BuildContext context, EntityAction action) {
|
onActionSelected: (BuildContext context, EntityAction action) {
|
||||||
final Completer<Null> completer = new Completer<Null>();
|
final Completer<Null> completer = new Completer<Null>();
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class ProductEditVM {
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ProductEditVM.fromStore(Store<AppState> store) {
|
factory ProductEditVM.fromStore(Store<AppState> store) {
|
||||||
final product = store.state.productUIState.selected;
|
final product = store.state.productUIState.editing;
|
||||||
|
|
||||||
return ProductEditVM(
|
return ProductEditVM(
|
||||||
state: store.state,
|
state: store.state,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue