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