Vendors
This commit is contained in:
parent
49c6cb6764
commit
f9c23176cc
|
|
@ -19,9 +19,14 @@ class ViewVendor implements PersistUI {
|
|||
|
||||
class EditVendor implements PersistUI {
|
||||
EditVendor(
|
||||
{this.vendor, this.context, this.completer, this.trackRoute = true});
|
||||
{this.vendor,
|
||||
this.contact,
|
||||
this.context,
|
||||
this.completer,
|
||||
this.trackRoute = true});
|
||||
|
||||
final VendorEntity vendor;
|
||||
final VendorContactEntity contact;
|
||||
final BuildContext context;
|
||||
final Completer completer;
|
||||
final bool trackRoute;
|
||||
|
|
@ -185,7 +190,6 @@ class RestoreVendorFailure implements StopSaving {
|
|||
final VendorEntity vendor;
|
||||
}
|
||||
|
||||
|
||||
class EditVendorContact implements PersistUI {
|
||||
EditVendorContact([this.contact]);
|
||||
|
||||
|
|
@ -211,7 +215,6 @@ class DeleteVendorContact implements PersistUI {
|
|||
final int index;
|
||||
}
|
||||
|
||||
|
||||
class FilterVendors {
|
||||
FilterVendors(this.filter);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,20 @@ EntityUIState vendorUIReducer(VendorUIState state, dynamic action) {
|
|||
return state.rebuild((b) => b
|
||||
..listUIState.replace(vendorListReducer(state.listUIState, action))
|
||||
..editing.replace(editingReducer(state.editing, action))
|
||||
..editingContact
|
||||
.replace(editingVendorContactReducer(state.editingContact, action))
|
||||
..selectedId = selectedIdReducer(state.selectedId, action));
|
||||
}
|
||||
|
||||
final editingVendorContactReducer = combineReducers<VendorContactEntity>([
|
||||
TypedReducer<VendorContactEntity, EditVendor>(editVendorContact),
|
||||
TypedReducer<VendorContactEntity, EditVendorContact>(editVendorContact),
|
||||
]);
|
||||
|
||||
VendorContactEntity editVendorContact(VendorContactEntity contact, dynamic action) {
|
||||
return action.contact ?? VendorContactEntity();
|
||||
}
|
||||
|
||||
Reducer<int> selectedIdReducer = combineReducers([
|
||||
TypedReducer<int, ViewVendor>(
|
||||
(int selectedId, dynamic action) => action.vendorId),
|
||||
|
|
@ -28,6 +39,9 @@ final editingReducer = combineReducers<VendorEntity>([
|
|||
TypedReducer<VendorEntity, DeleteVendorSuccess>(_updateEditing),
|
||||
TypedReducer<VendorEntity, EditVendor>(_updateEditing),
|
||||
TypedReducer<VendorEntity, UpdateVendor>(_updateEditing),
|
||||
TypedReducer<VendorEntity, AddVendorContact>(_addContact),
|
||||
TypedReducer<VendorEntity, DeleteVendorContact>(_removeContact),
|
||||
TypedReducer<VendorEntity, UpdateVendorContact>(_updateContact),
|
||||
TypedReducer<VendorEntity, SelectCompany>(_clearEditing),
|
||||
]);
|
||||
|
||||
|
|
@ -39,6 +53,19 @@ VendorEntity _updateEditing(VendorEntity vendor, dynamic action) {
|
|||
return action.vendor;
|
||||
}
|
||||
|
||||
VendorEntity _addContact(VendorEntity vendor, AddVendorContact action) {
|
||||
return vendor
|
||||
.rebuild((b) => b..contacts.add(action.contact ?? VendorContactEntity()));
|
||||
}
|
||||
|
||||
VendorEntity _removeContact(VendorEntity vendor, DeleteVendorContact action) {
|
||||
return vendor.rebuild((b) => b..contacts.removeAt(action.index));
|
||||
}
|
||||
|
||||
VendorEntity _updateContact(VendorEntity vendor, UpdateVendorContact action) {
|
||||
return vendor.rebuild((b) => b..contacts[action.index] = action.contact);
|
||||
}
|
||||
|
||||
final vendorListReducer = combineReducers<ListUIState>([
|
||||
TypedReducer<ListUIState, SortVendors>(_sortVendors),
|
||||
TypedReducer<ListUIState, FilterVendorsByState>(_filterVendorsByState),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: invoiceninja_flutter
|
||||
description: Mobile app for Invoice Ninja
|
||||
version: 0.1.41
|
||||
version: 0.1.42
|
||||
author: Hillel Coren
|
||||
homepage: https://www.invoiceninja.com
|
||||
documentation: http://docs.invoiceninja.com
|
||||
|
|
|
|||
Loading…
Reference in New Issue