Settings
This commit is contained in:
parent
bf2b3303df
commit
e659f07f20
|
|
@ -292,9 +292,8 @@ void handleClientAction(
|
|||
break;
|
||||
case EntityAction.newInvoice:
|
||||
store.dispatch(EditInvoice(
|
||||
invoice: InvoiceEntity(company: company)
|
||||
.rebuild((b) => b.clientId = client.id),
|
||||
context: context));
|
||||
invoice: InvoiceEntity(company: company), context: context));
|
||||
store.dispatch(UpdateInvoiceClient(client: client));
|
||||
break;
|
||||
case EntityAction.newExpense:
|
||||
store.dispatch(EditExpense(
|
||||
|
|
|
|||
|
|
@ -63,6 +63,12 @@ class UpdateInvoice implements PersistUI {
|
|||
final InvoiceEntity invoice;
|
||||
}
|
||||
|
||||
class UpdateInvoiceClient implements PersistUI {
|
||||
UpdateInvoiceClient({this.client});
|
||||
|
||||
final ClientEntity client;
|
||||
}
|
||||
|
||||
class LoadInvoice {
|
||||
LoadInvoice({this.completer, this.invoiceId});
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,14 @@ final editingReducer = combineReducers<InvoiceEntity>([
|
|||
TypedReducer<InvoiceEntity, UpdateInvoice>((invoice, action) {
|
||||
return action.invoice.rebuild((b) => b..isChanged = true);
|
||||
}),
|
||||
TypedReducer<InvoiceEntity, UpdateInvoiceClient>((invoice, action) {
|
||||
final client = action.client;
|
||||
return invoice.rebuild((b) => b
|
||||
..isChanged = true
|
||||
..clientId = client.id
|
||||
..invitations.addAll(client.contacts
|
||||
.map((contact) => InvitationEntity(contactId: contact.id))));
|
||||
}),
|
||||
TypedReducer<InvoiceEntity, RestoreInvoiceSuccess>(_updateEditing),
|
||||
TypedReducer<InvoiceEntity, ArchiveInvoiceSuccess>(_updateEditing),
|
||||
TypedReducer<InvoiceEntity, DeleteInvoiceSuccess>(_updateEditing),
|
||||
|
|
|
|||
|
|
@ -63,6 +63,13 @@ class UpdateQuote implements PersistUI {
|
|||
final InvoiceEntity quote;
|
||||
}
|
||||
|
||||
class UpdateQuoteClient implements PersistUI {
|
||||
UpdateQuoteClient({this.client});
|
||||
|
||||
final ClientEntity client;
|
||||
}
|
||||
|
||||
|
||||
class LoadQuote {
|
||||
LoadQuote({this.completer, this.quoteId});
|
||||
|
||||
|
|
@ -125,6 +132,20 @@ class LoadQuotesSuccess implements StopLoading, PersistData {
|
|||
}
|
||||
}
|
||||
|
||||
class AddQuoteContact implements PersistUI {
|
||||
AddQuoteContact({this.contact, this.invitation});
|
||||
|
||||
final ContactEntity contact;
|
||||
final InvitationEntity invitation;
|
||||
}
|
||||
|
||||
class RemoveQuoteContact implements PersistUI {
|
||||
RemoveQuoteContact({this.invitation});
|
||||
|
||||
final InvitationEntity invitation;
|
||||
}
|
||||
|
||||
|
||||
class AddQuoteItem implements PersistUI {
|
||||
AddQuoteItem({this.quoteItem});
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,14 @@ final editingReducer = combineReducers<InvoiceEntity>([
|
|||
TypedReducer<InvoiceEntity, UpdateQuote>((quote, action) {
|
||||
return action.quote.rebuild((b) => b..isChanged = true);
|
||||
}),
|
||||
TypedReducer<InvoiceEntity, UpdateQuoteClient>((quote, action) {
|
||||
final client = action.client;
|
||||
return quote.rebuild((b) => b
|
||||
..isChanged = true
|
||||
..clientId = client.id
|
||||
..invitations.addAll(client.contacts
|
||||
.map((contact) => InvitationEntity(contactId: contact.id))));
|
||||
}),
|
||||
TypedReducer<InvoiceEntity, RestoreQuoteSuccess>(_updateEditing),
|
||||
TypedReducer<InvoiceEntity, ArchiveQuoteSuccess>(_updateEditing),
|
||||
TypedReducer<InvoiceEntity, DeleteQuoteSuccess>(_updateEditing),
|
||||
|
|
@ -60,6 +68,14 @@ final editingReducer = combineReducers<InvoiceEntity>([
|
|||
TypedReducer<InvoiceEntity, UpdateQuoteItem>(_updateQuoteItem),
|
||||
TypedReducer<InvoiceEntity, SelectCompany>(_clearEditing),
|
||||
TypedReducer<InvoiceEntity, DiscardChanges>(_clearEditing),
|
||||
TypedReducer<InvoiceEntity, AddQuoteContact>((invoice, action) {
|
||||
return invoice.rebuild((b) => b
|
||||
..invitations.add(
|
||||
action.invitation ?? InvitationEntity(contactId: action.contact.id)));
|
||||
}),
|
||||
TypedReducer<InvoiceEntity, RemoveQuoteContact>((invoice, action) {
|
||||
return invoice.rebuild((b) => b..invitations.remove(action.invitation));
|
||||
}),
|
||||
]);
|
||||
|
||||
InvoiceEntity _clearEditing(InvoiceEntity quote, dynamic action) {
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ class _ClientViewState extends State<ClientView>
|
|||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
store.dispatch(EditInvoice(
|
||||
invoice: InvoiceEntity(company: company)
|
||||
.rebuild((b) => b.clientId = client.id),
|
||||
invoice: InvoiceEntity(company: company),
|
||||
context: context));
|
||||
store.dispatch(UpdateInvoiceClient(client: client));
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
|
|
@ -115,9 +115,9 @@ class _ClientViewState extends State<ClientView>
|
|||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
store.dispatch(EditQuote(
|
||||
quote: InvoiceEntity(isQuote: true)
|
||||
.rebuild((b) => b.clientId = client.id),
|
||||
quote: InvoiceEntity(isQuote: true),
|
||||
context: context));
|
||||
store.dispatch(UpdateQuoteClient(client: client));
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ class ClientViewVM {
|
|||
|
||||
Future<Null> _handleRefresh(BuildContext context, bool loadActivities) {
|
||||
final completer = snackBarCompleter(
|
||||
context, AppLocalization.of(context).refreshComplete);
|
||||
context, AppLocalization
|
||||
.of(context)
|
||||
.refreshComplete);
|
||||
store.dispatch(LoadClient(
|
||||
completer: completer,
|
||||
clientId: client.id,
|
||||
|
|
@ -85,8 +87,10 @@ class ClientViewVM {
|
|||
completer.future.then((client) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: AppLocalization.of(context).updatedClient,
|
||||
)));
|
||||
message: AppLocalization
|
||||
.of(context)
|
||||
.updatedClient,
|
||||
)));
|
||||
});
|
||||
},
|
||||
onEntityPressed: (BuildContext context, EntityType entityType,
|
||||
|
|
@ -96,8 +100,8 @@ class ClientViewVM {
|
|||
if (longPress && client.isActive) {
|
||||
store.dispatch(EditInvoice(
|
||||
context: context,
|
||||
invoice: InvoiceEntity(company: state.selectedCompany)
|
||||
.rebuild((b) => b..clientId = client.id)));
|
||||
invoice: InvoiceEntity(company: state.selectedCompany)));
|
||||
store.dispatch(UpdateInvoiceClient(client: client));
|
||||
} else {
|
||||
store.dispatch(FilterInvoicesByEntity(
|
||||
entityId: client.id, entityType: EntityType.client));
|
||||
|
|
@ -109,8 +113,8 @@ class ClientViewVM {
|
|||
store.dispatch(EditQuote(
|
||||
context: context,
|
||||
quote: InvoiceEntity(
|
||||
company: state.selectedCompany, isQuote: true)
|
||||
.rebuild((b) => b..clientId = client.id)));
|
||||
company: state.selectedCompany, isQuote: true)));
|
||||
store.dispatch(UpdateQuoteClient(client: client));
|
||||
} else {
|
||||
store.dispatch(FilterQuotesByEntity(
|
||||
entityId: client.id, entityType: EntityType.client));
|
||||
|
|
@ -134,7 +138,7 @@ class ClientViewVM {
|
|||
store.dispatch(EditProject(
|
||||
context: context,
|
||||
project:
|
||||
ProjectEntity().rebuild((b) => b..clientId = client.id)));
|
||||
ProjectEntity().rebuild((b) => b..clientId = client.id)));
|
||||
} else {
|
||||
store.dispatch(FilterProjectsByEntity(
|
||||
entityId: client.id, entityType: EntityType.client));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ class InvoiceEditContacts extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
//final viewModel = widget.viewModel;
|
||||
final invoice = viewModel.invoice;
|
||||
final client = viewModel.client;
|
||||
|
||||
|
|
|
|||
|
|
@ -151,8 +151,7 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
|
|||
? AppLocalization.of(context).pleaseSelectAClient
|
||||
: null,
|
||||
onSelected: (client) {
|
||||
viewModel.onChanged(
|
||||
invoice.rebuild((b) => b..clientId = client.id));
|
||||
viewModel.onClientChanged(invoice, client);
|
||||
},
|
||||
onAddPressed: (completer) {
|
||||
viewModel.onAddClientPressed(context, completer);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class EntityEditDetailsVM {
|
|||
@required this.company,
|
||||
@required this.invoice,
|
||||
@required this.onChanged,
|
||||
@required this.onClientChanged,
|
||||
@required this.clientMap,
|
||||
@required this.clientList,
|
||||
@required this.onAddClientPressed,
|
||||
|
|
@ -47,6 +48,7 @@ class EntityEditDetailsVM {
|
|||
final CompanyEntity company;
|
||||
final InvoiceEntity invoice;
|
||||
final Function(InvoiceEntity) onChanged;
|
||||
final Function(InvoiceEntity, ClientEntity) onClientChanged;
|
||||
final BuiltMap<String, ClientEntity> clientMap;
|
||||
final BuiltList<String> clientList;
|
||||
final Function(BuildContext context, Completer<SelectableEntity> completer)
|
||||
|
|
@ -58,6 +60,7 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM {
|
|||
CompanyEntity company,
|
||||
InvoiceEntity invoice,
|
||||
Function(InvoiceEntity) onChanged,
|
||||
Function(InvoiceEntity, ClientEntity) onClientChanged,
|
||||
BuiltMap<String, ClientEntity> clientMap,
|
||||
BuiltList<String> clientList,
|
||||
Function(BuildContext context, Completer<SelectableEntity> completer)
|
||||
|
|
@ -66,6 +69,7 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM {
|
|||
company: company,
|
||||
invoice: invoice,
|
||||
onChanged: onChanged,
|
||||
onClientChanged: onClientChanged,
|
||||
clientMap: clientMap,
|
||||
clientList: clientList,
|
||||
onAddClientPressed: onAddClientPressed,
|
||||
|
|
@ -82,6 +86,9 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM {
|
|||
store.dispatch(UpdateInvoice(invoice)),
|
||||
clientMap: state.clientState.map,
|
||||
clientList: state.clientState.list,
|
||||
onClientChanged: (invoice, client) {
|
||||
store.dispatch(UpdateInvoiceClient(client: client));
|
||||
},
|
||||
onAddClientPressed: (context, completer) {
|
||||
store.dispatch(EditClient(
|
||||
client: ClientEntity(),
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM {
|
|||
CompanyEntity company,
|
||||
InvoiceEntity invoice,
|
||||
Function(InvoiceEntity) onChanged,
|
||||
Function(InvoiceEntity, ClientEntity) onClientChanged,
|
||||
BuiltMap<String, ClientEntity> clientMap,
|
||||
BuiltList<String> clientList,
|
||||
Function(BuildContext context, Completer<SelectableEntity> completer)
|
||||
|
|
@ -48,6 +49,7 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM {
|
|||
company: company,
|
||||
invoice: invoice,
|
||||
onChanged: onChanged,
|
||||
onClientChanged: onClientChanged,
|
||||
clientMap: clientMap,
|
||||
clientList: clientList,
|
||||
onAddClientPressed: onAddClientPressed,
|
||||
|
|
@ -63,6 +65,9 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM {
|
|||
onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)),
|
||||
clientMap: state.clientState.map,
|
||||
clientList: state.clientState.list,
|
||||
onClientChanged: (invoice, client) {
|
||||
store.dispatch(UpdateQuoteClient(client: client));
|
||||
},
|
||||
onAddClientPressed: (context, completer) {
|
||||
store.dispatch(EditClient(
|
||||
client: ClientEntity(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue