This commit is contained in:
unknown 2018-07-01 11:47:14 -07:00
parent 569f9a1487
commit 3ff71c3a87
23 changed files with 183 additions and 109 deletions

View File

@ -656,8 +656,6 @@ class _$InvitationEntitySerializer
Iterable serialize(Serializers serializers, InvitationEntity object,
{FullType specifiedType: FullType.unspecified}) {
final result = <Object>[
'key',
serializers.serialize(object.key, specifiedType: const FullType(String)),
'link',
serializers.serialize(object.link, specifiedType: const FullType(String)),
'sent_date',
@ -706,10 +704,6 @@ class _$InvitationEntitySerializer
iterator.moveNext();
final dynamic value = iterator.current;
switch (key) {
case 'key':
result.key = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'link':
result.link = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
@ -1952,8 +1946,6 @@ class InvoiceItemEntityBuilder
}
class _$InvitationEntity extends InvitationEntity {
@override
final String key;
@override
final String link;
@override
@ -1973,8 +1965,7 @@ class _$InvitationEntity extends InvitationEntity {
(new InvitationEntityBuilder()..update(updates)).build();
_$InvitationEntity._(
{this.key,
this.link,
{this.link,
this.sentDate,
this.viewedDate,
this.id,
@ -1982,8 +1973,6 @@ class _$InvitationEntity extends InvitationEntity {
this.archivedAt,
this.isDeleted})
: super._() {
if (key == null)
throw new BuiltValueNullFieldError('InvitationEntity', 'key');
if (link == null)
throw new BuiltValueNullFieldError('InvitationEntity', 'link');
if (sentDate == null)
@ -2004,8 +1993,7 @@ class _$InvitationEntity extends InvitationEntity {
bool operator ==(dynamic other) {
if (identical(other, this)) return true;
if (other is! InvitationEntity) return false;
return key == other.key &&
link == other.link &&
return link == other.link &&
sentDate == other.sentDate &&
viewedDate == other.viewedDate &&
id == other.id &&
@ -2020,9 +2008,7 @@ class _$InvitationEntity extends InvitationEntity {
$jc(
$jc(
$jc(
$jc(
$jc($jc($jc(0, key.hashCode), link.hashCode),
sentDate.hashCode),
$jc($jc($jc(0, link.hashCode), sentDate.hashCode),
viewedDate.hashCode),
id.hashCode),
updatedAt.hashCode),
@ -2033,7 +2019,6 @@ class _$InvitationEntity extends InvitationEntity {
@override
String toString() {
return (newBuiltValueToStringHelper('InvitationEntity')
..add('key', key)
..add('link', link)
..add('sentDate', sentDate)
..add('viewedDate', viewedDate)
@ -2049,10 +2034,6 @@ class InvitationEntityBuilder
implements Builder<InvitationEntity, InvitationEntityBuilder> {
_$InvitationEntity _$v;
String _key;
String get key => _$this._key;
set key(String key) => _$this._key = key;
String _link;
String get link => _$this._link;
set link(String link) => _$this._link = link;
@ -2085,7 +2066,6 @@ class InvitationEntityBuilder
InvitationEntityBuilder get _$this {
if (_$v != null) {
_key = _$v.key;
_link = _$v.link;
_sentDate = _$v.sentDate;
_viewedDate = _$v.viewedDate;
@ -2113,7 +2093,6 @@ class InvitationEntityBuilder
_$InvitationEntity build() {
final _$result = _$v ??
new _$InvitationEntity._(
key: key,
link: link,
sentDate: sentDate,
viewedDate: viewedDate,

View File

@ -197,7 +197,7 @@ List<String> _getRoutes(AppState state) {
.forEach((part) {
if (part == 'edit') {
// Only restore new unsaved entities to prevent conflicts
bool isNew = state.getUIState(entityType).isSelectedNew;
final bool isNew = state.getUIState(entityType).isCreatingNew;
if (isNew) {
route += '/edit';
} else if (entityType == EntityType.client) {

View File

@ -8,9 +8,9 @@ import 'package:invoiceninja/redux/app/app_actions.dart';
class ViewClientList implements PersistUI {}
class ViewClient implements PersistUI {
final ClientEntity client;
final int clientId;
final BuildContext context;
ViewClient({this.client, this.context});
ViewClient({this.clientId, this.context});
}
class EditClient implements PersistUI {

View File

@ -6,11 +6,12 @@ import 'package:redux/redux.dart';
import 'package:invoiceninja/redux/client/client_actions.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
..listUIState.replace(clientListReducer(state.listUIState, action))
..selected.replace(editingReducer(state.selected, action))
..editing.replace(editingReducer(state.editing, action))
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
..selectedId = selectedIdReducer(state.selectedId, action)
);
}
@ -22,13 +23,20 @@ String filterClientDropdownReducer(String dropdownFilter, FilterClientDropdown a
return action.filter;
}
Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewClient>(updateSelectedId),
]);
int updateSelectedId(int selectedId, ViewClient action) {
return action.clientId;
}
final editingReducer = combineReducers<ClientEntity>([
TypedReducer<ClientEntity, SaveClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, AddClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, RestoreClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, ArchiveClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, DeleteClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, ViewClient>(_updateEditing),
TypedReducer<ClientEntity, EditClient>(_updateEditing),
TypedReducer<ClientEntity, UpdateClient>(_updateEditing),
TypedReducer<ClientEntity, AddContact>(_addContact),
@ -45,6 +53,10 @@ ClientEntity _updateEditing(ClientEntity client, action) {
return action.client;
}
ClientEntity _updateViewing(ClientEntity client, ViewClient action) {
return action.clientId;
}
ClientEntity _addContact(ClientEntity client, AddContact action) {
return client.rebuild((b) => b
..contacts.add(ContactEntity())

View File

@ -42,14 +42,15 @@ abstract class ClientState implements Built<ClientState, ClientStateBuilder> {
abstract class ClientUIState extends Object with EntityUIState implements Built<ClientUIState, ClientUIStateBuilder> {
@nullable
ClientEntity get selected;
ClientEntity get editing;
bool get isSelectedNew => selected.isNew();
@override
bool get isCreatingNew => editing.isNew();
factory ClientUIState() {
return _$ClientUIState._(
listUIState: ListUIState(ClientFields.name),
selected: ClientEntity(),
editing: ClientEntity(),
dropdownFilter: '',
);
}

View File

@ -92,6 +92,9 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
Iterable serialize(Serializers serializers, ClientUIState object,
{FullType specifiedType: FullType.unspecified}) {
final result = <Object>[
'selectedId',
serializers.serialize(object.selectedId,
specifiedType: const FullType(int)),
'listUIState',
serializers.serialize(object.listUIState,
specifiedType: const FullType(ListUIState)),
@ -99,10 +102,10 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
serializers.serialize(object.dropdownFilter,
specifiedType: const FullType(String)),
];
if (object.selected != null) {
if (object.editing != null) {
result
..add('selected')
..add(serializers.serialize(object.selected,
..add('editing')
..add(serializers.serialize(object.editing,
specifiedType: const FullType(ClientEntity)));
}
@ -120,10 +123,14 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
iterator.moveNext();
final dynamic value = iterator.current;
switch (key) {
case 'selected':
result.selected.replace(serializers.deserialize(value,
case 'editing':
result.editing.replace(serializers.deserialize(value,
specifiedType: const FullType(ClientEntity)) as ClientEntity);
break;
case 'selectedId':
result.selectedId = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'listUIState':
result.listUIState.replace(serializers.deserialize(value,
specifiedType: const FullType(ListUIState)) as ListUIState);
@ -253,7 +260,9 @@ class ClientStateBuilder implements Builder<ClientState, ClientStateBuilder> {
class _$ClientUIState extends ClientUIState {
@override
final ClientEntity selected;
final ClientEntity editing;
@override
final int selectedId;
@override
final ListUIState listUIState;
@override
@ -262,8 +271,11 @@ class _$ClientUIState extends ClientUIState {
factory _$ClientUIState([void updates(ClientUIStateBuilder b)]) =>
(new ClientUIStateBuilder()..update(updates)).build();
_$ClientUIState._({this.selected, this.listUIState, this.dropdownFilter})
_$ClientUIState._(
{this.editing, this.selectedId, this.listUIState, this.dropdownFilter})
: super._() {
if (selectedId == null)
throw new BuiltValueNullFieldError('ClientUIState', 'selectedId');
if (listUIState == null)
throw new BuiltValueNullFieldError('ClientUIState', 'listUIState');
if (dropdownFilter == null)
@ -281,21 +293,25 @@ class _$ClientUIState extends ClientUIState {
bool operator ==(dynamic other) {
if (identical(other, this)) return true;
if (other is! ClientUIState) return false;
return selected == other.selected &&
return editing == other.editing &&
selectedId == other.selectedId &&
listUIState == other.listUIState &&
dropdownFilter == other.dropdownFilter;
}
@override
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));
}
@override
String toString() {
return (newBuiltValueToStringHelper('ClientUIState')
..add('selected', selected)
..add('editing', editing)
..add('selectedId', selectedId)
..add('listUIState', listUIState)
..add('dropdownFilter', dropdownFilter))
.toString();
@ -306,10 +322,14 @@ class ClientUIStateBuilder
implements Builder<ClientUIState, ClientUIStateBuilder> {
_$ClientUIState _$v;
ClientEntityBuilder _selected;
ClientEntityBuilder get selected =>
_$this._selected ??= new ClientEntityBuilder();
set selected(ClientEntityBuilder selected) => _$this._selected = selected;
ClientEntityBuilder _editing;
ClientEntityBuilder get editing =>
_$this._editing ??= new ClientEntityBuilder();
set editing(ClientEntityBuilder editing) => _$this._editing = editing;
int _selectedId;
int get selectedId => _$this._selectedId;
set selectedId(int selectedId) => _$this._selectedId = selectedId;
ListUIStateBuilder _listUIState;
ListUIStateBuilder get listUIState =>
@ -326,7 +346,8 @@ class ClientUIStateBuilder
ClientUIStateBuilder get _$this {
if (_$v != null) {
_selected = _$v.selected?.toBuilder();
_editing = _$v.editing?.toBuilder();
_selectedId = _$v.selectedId;
_listUIState = _$v.listUIState?.toBuilder();
_dropdownFilter = _$v.dropdownFilter;
_$v = null;
@ -351,14 +372,16 @@ class ClientUIStateBuilder
try {
_$result = _$v ??
new _$ClientUIState._(
selected: _selected?.build(),
editing: _editing?.build(),
selectedId: selectedId,
listUIState: listUIState.build(),
dropdownFilter: dropdownFilter);
} catch (_) {
String _$failedField;
try {
_$failedField = 'selected';
_selected?.build();
_$failedField = 'editing';
_editing?.build();
_$failedField = 'listUIState';
listUIState.build();
} catch (e) {

View File

@ -8,9 +8,9 @@ import 'package:invoiceninja/redux/app/app_actions.dart';
class ViewInvoiceList implements PersistUI {}
class ViewInvoice implements PersistUI {
final InvoiceEntity invoice;
final int invoiceId;
final BuildContext context;
ViewInvoice({this.invoice, this.context});
ViewInvoice({this.invoiceId, this.context});
}
class EditInvoice implements PersistUI {

View File

@ -10,8 +10,9 @@ import 'package:invoiceninja/redux/invoice/invoice_state.dart';
EntityUIState invoiceUIReducer(InvoiceUIState state, action) {
return state.rebuild((b) => b
..listUIState.replace(invoiceListReducer(state.listUIState, action))
..selected.replace(editingReducer(state.selected, action))
..editing.replace(editingReducer(state.editing, action))
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
..selectedId = selectedIdReducer(state.selectedId, action)
);
}
@ -23,10 +24,17 @@ String filterClientDropdownReducer(String dropdownFilter, FilterInvoiceDropdown
return action.filter;
}
Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewInvoice>(updateSelectedId),
]);
int updateSelectedId(int selectedId, ViewInvoice action) {
return action.invoiceId;
}
final editingReducer = combineReducers<InvoiceEntity>([
TypedReducer<InvoiceEntity, SaveInvoiceSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, AddInvoiceSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, ViewInvoice>(_updateEditing),
TypedReducer<InvoiceEntity, EditInvoice>(_updateEditing),
TypedReducer<InvoiceEntity, UpdateInvoice>(_updateEditing),
TypedReducer<InvoiceEntity, RestoreInvoiceSuccess>(_updateEditing),

View File

@ -42,14 +42,15 @@ abstract class InvoiceState implements Built<InvoiceState, InvoiceStateBuilder>
abstract class InvoiceUIState extends Object with EntityUIState implements Built<InvoiceUIState, InvoiceUIStateBuilder> {
@nullable
InvoiceEntity get selected;
InvoiceEntity get editing;
bool get isSelectedNew => selected.isNew();
@override
bool get isCreatingNew => editing.isNew();
factory InvoiceUIState() {
return _$InvoiceUIState._(
listUIState: ListUIState(InvoiceFields.invoiceNumber),
selected: InvoiceEntity(),
editing: InvoiceEntity(),
dropdownFilter: '',
);
}

View File

@ -94,6 +94,9 @@ class _$InvoiceUIStateSerializer
Iterable serialize(Serializers serializers, InvoiceUIState object,
{FullType specifiedType: FullType.unspecified}) {
final result = <Object>[
'selectedId',
serializers.serialize(object.selectedId,
specifiedType: const FullType(int)),
'listUIState',
serializers.serialize(object.listUIState,
specifiedType: const FullType(ListUIState)),
@ -101,10 +104,10 @@ class _$InvoiceUIStateSerializer
serializers.serialize(object.dropdownFilter,
specifiedType: const FullType(String)),
];
if (object.selected != null) {
if (object.editing != null) {
result
..add('selected')
..add(serializers.serialize(object.selected,
..add('editing')
..add(serializers.serialize(object.editing,
specifiedType: const FullType(InvoiceEntity)));
}
@ -122,10 +125,14 @@ class _$InvoiceUIStateSerializer
iterator.moveNext();
final dynamic value = iterator.current;
switch (key) {
case 'selected':
result.selected.replace(serializers.deserialize(value,
case 'editing':
result.editing.replace(serializers.deserialize(value,
specifiedType: const FullType(InvoiceEntity)) as InvoiceEntity);
break;
case 'selectedId':
result.selectedId = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'listUIState':
result.listUIState.replace(serializers.deserialize(value,
specifiedType: const FullType(ListUIState)) as ListUIState);
@ -257,7 +264,9 @@ class InvoiceStateBuilder
class _$InvoiceUIState extends InvoiceUIState {
@override
final InvoiceEntity selected;
final InvoiceEntity editing;
@override
final int selectedId;
@override
final ListUIState listUIState;
@override
@ -266,8 +275,11 @@ class _$InvoiceUIState extends InvoiceUIState {
factory _$InvoiceUIState([void updates(InvoiceUIStateBuilder b)]) =>
(new InvoiceUIStateBuilder()..update(updates)).build();
_$InvoiceUIState._({this.selected, this.listUIState, this.dropdownFilter})
_$InvoiceUIState._(
{this.editing, this.selectedId, this.listUIState, this.dropdownFilter})
: super._() {
if (selectedId == null)
throw new BuiltValueNullFieldError('InvoiceUIState', 'selectedId');
if (listUIState == null)
throw new BuiltValueNullFieldError('InvoiceUIState', 'listUIState');
if (dropdownFilter == null)
@ -286,21 +298,25 @@ class _$InvoiceUIState extends InvoiceUIState {
bool operator ==(dynamic other) {
if (identical(other, this)) return true;
if (other is! InvoiceUIState) return false;
return selected == other.selected &&
return editing == other.editing &&
selectedId == other.selectedId &&
listUIState == other.listUIState &&
dropdownFilter == other.dropdownFilter;
}
@override
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));
}
@override
String toString() {
return (newBuiltValueToStringHelper('InvoiceUIState')
..add('selected', selected)
..add('editing', editing)
..add('selectedId', selectedId)
..add('listUIState', listUIState)
..add('dropdownFilter', dropdownFilter))
.toString();
@ -311,10 +327,14 @@ class InvoiceUIStateBuilder
implements Builder<InvoiceUIState, InvoiceUIStateBuilder> {
_$InvoiceUIState _$v;
InvoiceEntityBuilder _selected;
InvoiceEntityBuilder get selected =>
_$this._selected ??= new InvoiceEntityBuilder();
set selected(InvoiceEntityBuilder selected) => _$this._selected = selected;
InvoiceEntityBuilder _editing;
InvoiceEntityBuilder get editing =>
_$this._editing ??= new InvoiceEntityBuilder();
set editing(InvoiceEntityBuilder editing) => _$this._editing = editing;
int _selectedId;
int get selectedId => _$this._selectedId;
set selectedId(int selectedId) => _$this._selectedId = selectedId;
ListUIStateBuilder _listUIState;
ListUIStateBuilder get listUIState =>
@ -331,7 +351,8 @@ class InvoiceUIStateBuilder
InvoiceUIStateBuilder get _$this {
if (_$v != null) {
_selected = _$v.selected?.toBuilder();
_editing = _$v.editing?.toBuilder();
_selectedId = _$v.selectedId;
_listUIState = _$v.listUIState?.toBuilder();
_dropdownFilter = _$v.dropdownFilter;
_$v = null;
@ -356,14 +377,16 @@ class InvoiceUIStateBuilder
try {
_$result = _$v ??
new _$InvoiceUIState._(
selected: _selected?.build(),
editing: _editing?.build(),
selectedId: selectedId,
listUIState: listUIState.build(),
dropdownFilter: dropdownFilter);
} catch (_) {
String _$failedField;
try {
_$failedField = 'selected';
_selected?.build();
_$failedField = 'editing';
_editing?.build();
_$failedField = 'listUIState';
listUIState.build();
} catch (e) {

View File

@ -9,7 +9,7 @@ import 'package:invoiceninja/redux/product/product_state.dart';
EntityUIState productUIReducer(ProductUIState state, action) {
return state.rebuild((b) => b
..listUIState.replace(productListReducer(state.listUIState, action))
..selected.replace(editingReducer(state.selected, action))
..editing.replace(editingReducer(state.editing, action))
..dropdownFilter = dropdownFilterReducer(state.dropdownFilter, action)
);
}

View File

@ -42,14 +42,15 @@ abstract class ProductState implements Built<ProductState, ProductStateBuilder>
abstract class ProductUIState extends Object with EntityUIState implements Built<ProductUIState, ProductUIStateBuilder> {
@nullable
ProductEntity get selected;
ProductEntity get editing;
bool get isSelectedNew => selected.isNew();
@override
bool get isCreatingNew => editing.isNew();
factory ProductUIState() {
return _$ProductUIState._(
listUIState: ListUIState(ProductFields.productKey),
selected: ProductEntity(),
editing: ProductEntity(),
dropdownFilter: '',
);
}

View File

@ -94,6 +94,9 @@ class _$ProductUIStateSerializer
Iterable serialize(Serializers serializers, ProductUIState object,
{FullType specifiedType: FullType.unspecified}) {
final result = <Object>[
'selectedId',
serializers.serialize(object.selectedId,
specifiedType: const FullType(int)),
'listUIState',
serializers.serialize(object.listUIState,
specifiedType: const FullType(ListUIState)),
@ -101,10 +104,10 @@ class _$ProductUIStateSerializer
serializers.serialize(object.dropdownFilter,
specifiedType: const FullType(String)),
];
if (object.selected != null) {
if (object.editing != null) {
result
..add('selected')
..add(serializers.serialize(object.selected,
..add('editing')
..add(serializers.serialize(object.editing,
specifiedType: const FullType(ProductEntity)));
}
@ -122,10 +125,14 @@ class _$ProductUIStateSerializer
iterator.moveNext();
final dynamic value = iterator.current;
switch (key) {
case 'selected':
result.selected.replace(serializers.deserialize(value,
case 'editing':
result.editing.replace(serializers.deserialize(value,
specifiedType: const FullType(ProductEntity)) as ProductEntity);
break;
case 'selectedId':
result.selectedId = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'listUIState':
result.listUIState.replace(serializers.deserialize(value,
specifiedType: const FullType(ListUIState)) as ListUIState);
@ -257,7 +264,9 @@ class ProductStateBuilder
class _$ProductUIState extends ProductUIState {
@override
final ProductEntity selected;
final ProductEntity editing;
@override
final int selectedId;
@override
final ListUIState listUIState;
@override
@ -266,8 +275,11 @@ class _$ProductUIState extends ProductUIState {
factory _$ProductUIState([void updates(ProductUIStateBuilder b)]) =>
(new ProductUIStateBuilder()..update(updates)).build();
_$ProductUIState._({this.selected, this.listUIState, this.dropdownFilter})
_$ProductUIState._(
{this.editing, this.selectedId, this.listUIState, this.dropdownFilter})
: super._() {
if (selectedId == null)
throw new BuiltValueNullFieldError('ProductUIState', 'selectedId');
if (listUIState == null)
throw new BuiltValueNullFieldError('ProductUIState', 'listUIState');
if (dropdownFilter == null)
@ -286,21 +298,25 @@ class _$ProductUIState extends ProductUIState {
bool operator ==(dynamic other) {
if (identical(other, this)) return true;
if (other is! ProductUIState) return false;
return selected == other.selected &&
return editing == other.editing &&
selectedId == other.selectedId &&
listUIState == other.listUIState &&
dropdownFilter == other.dropdownFilter;
}
@override
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));
}
@override
String toString() {
return (newBuiltValueToStringHelper('ProductUIState')
..add('selected', selected)
..add('editing', editing)
..add('selectedId', selectedId)
..add('listUIState', listUIState)
..add('dropdownFilter', dropdownFilter))
.toString();
@ -311,10 +327,14 @@ class ProductUIStateBuilder
implements Builder<ProductUIState, ProductUIStateBuilder> {
_$ProductUIState _$v;
ProductEntityBuilder _selected;
ProductEntityBuilder get selected =>
_$this._selected ??= new ProductEntityBuilder();
set selected(ProductEntityBuilder selected) => _$this._selected = selected;
ProductEntityBuilder _editing;
ProductEntityBuilder get editing =>
_$this._editing ??= new ProductEntityBuilder();
set editing(ProductEntityBuilder editing) => _$this._editing = editing;
int _selectedId;
int get selectedId => _$this._selectedId;
set selectedId(int selectedId) => _$this._selectedId = selectedId;
ListUIStateBuilder _listUIState;
ListUIStateBuilder get listUIState =>
@ -331,7 +351,8 @@ class ProductUIStateBuilder
ProductUIStateBuilder get _$this {
if (_$v != null) {
_selected = _$v.selected?.toBuilder();
_editing = _$v.editing?.toBuilder();
_selectedId = _$v.selectedId;
_listUIState = _$v.listUIState?.toBuilder();
_dropdownFilter = _$v.dropdownFilter;
_$v = null;
@ -356,14 +377,16 @@ class ProductUIStateBuilder
try {
_$result = _$v ??
new _$ProductUIState._(
selected: _selected?.build(),
editing: _editing?.build(),
selectedId: selectedId,
listUIState: listUIState.build(),
dropdownFilter: dropdownFilter);
} catch (_) {
String _$failedField;
try {
_$failedField = 'selected';
_selected?.build();
_$failedField = 'editing';
_editing?.build();
_$failedField = 'listUIState';
listUIState.build();
} catch (e) {

View File

@ -2,7 +2,8 @@ import 'package:invoiceninja/redux/ui/list_ui_state.dart';
abstract class EntityUIState {
bool get isSelectedNew;
bool get isCreatingNew;
int get selectedId;
ListUIState get listUIState;
String get dropdownFilter;
}

View File

@ -72,7 +72,7 @@ class ClientListVM {
isLoading: store.state.isLoading,
isLoaded: store.state.clientState.isLoaded,
onClientTap: (context, client) {
store.dispatch(ViewClient(client: client, context: context));
store.dispatch(ViewClient(clientId: client.id, context: context));
},
onRefreshed: (context) => _handleRefresh(context),
onDismissed: (BuildContext context, ClientEntity client,

View File

@ -54,7 +54,7 @@ class ClientEditVM {
});
factory ClientEditVM.fromStore(Store<AppState> store) {
final client = store.state.clientUIState.selected;
final client = store.state.clientUIState.editing;
return ClientEditVM(
client: client,

View File

@ -51,7 +51,8 @@ class ClientViewVM {
});
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(
state: store.state,

View File

@ -47,7 +47,7 @@ class InvoiceEditDetailsVM {
factory InvoiceEditDetailsVM.fromStore(Store<AppState> store) {
AppState state = store.state;
final invoice = state.invoiceUIState.selected;
final invoice = state.invoiceUIState.editing;
return InvoiceEditDetailsVM(
state: state,

View File

@ -40,7 +40,7 @@ class InvoiceEditItemsVM {
factory InvoiceEditItemsVM.fromStore(Store<AppState> store) {
AppState state = store.state;
final invoice = state.invoiceUIState.selected;
final invoice = state.invoiceUIState.editing;
return InvoiceEditItemsVM(
state: state,

View File

@ -55,7 +55,7 @@ class InvoiceEditVM {
factory InvoiceEditVM.fromStore(Store<AppState> store) {
AppState state = store.state;
final invoice = state.invoiceUIState.selected;
final invoice = state.invoiceUIState.editing;
return InvoiceEditVM(
state: state,

View File

@ -82,7 +82,7 @@ class InvoiceListVM {
isLoaded: state.invoiceState.isLoaded &&
state.clientState.isLoaded,
onInvoiceTap: (context, invoice) {
store.dispatch(ViewInvoice(invoice: invoice, context: context));
store.dispatch(ViewInvoice(invoiceId: invoice.id, context: context));
},
onRefreshed: (context) => _handleRefresh(context),
onDismissed: (BuildContext context, InvoiceEntity invoice,

View File

@ -57,7 +57,8 @@ class InvoiceViewVM {
});
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];
Future<Null> _viewPdf(BuildContext context) async {
@ -91,7 +92,7 @@ class InvoiceViewVM {
},
onBackPressed: () => store.dispatch(UpdateCurrentRoute(InvoiceScreen.route)),
onClientPressed: (BuildContext context) {
store.dispatch(ViewClient(client: client, context: context));
store.dispatch(ViewClient(clientId: client.id, context: context));
},
onActionSelected: (BuildContext context, EntityAction action) {
final Completer<Null> completer = new Completer<Null>();

View File

@ -55,7 +55,7 @@ class ProductEditVM {
});
factory ProductEditVM.fromStore(Store<AppState> store) {
final product = store.state.productUIState.selected;
final product = store.state.productUIState.editing;
return ProductEditVM(
state: store.state,