Add approve quote bulk action
This commit is contained in:
parent
f18c9c1ea3
commit
04e97e5ba4
|
|
@ -901,6 +901,9 @@ abstract class InvoiceEntity extends Object
|
|||
|
||||
if (isQuote) {
|
||||
if ((invoiceId ?? '').isEmpty) {
|
||||
if (!isApproved) {
|
||||
actions.add(EntityAction.approve);
|
||||
}
|
||||
actions.add(EntityAction.convertToInvoice);
|
||||
} else {
|
||||
actions.add(EntityAction.viewInvoice);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ class EntityAction extends EnumClass {
|
|||
return 'email';
|
||||
}
|
||||
|
||||
// else if (value == 'approve') {
|
||||
// return 'approved';
|
||||
// }
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -428,6 +428,25 @@ class ConvertQuoteFailure implements StopSaving {
|
|||
final dynamic error;
|
||||
}
|
||||
|
||||
class ApproveQuotes implements StartSaving {
|
||||
ApproveQuotes(this.completer, this.quoteIds);
|
||||
|
||||
final List<String> quoteIds;
|
||||
final Completer completer;
|
||||
}
|
||||
|
||||
class ApproveQuoteSuccess implements StopSaving {
|
||||
ApproveQuoteSuccess({this.quotes});
|
||||
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class ApproveQuoteFailure implements StopSaving {
|
||||
ApproveQuoteFailure(this.error);
|
||||
|
||||
final dynamic error;
|
||||
}
|
||||
|
||||
class SaveQuoteDocumentRequest implements StartSaving {
|
||||
SaveQuoteDocumentRequest({
|
||||
@required this.completer,
|
||||
|
|
@ -478,6 +497,15 @@ Future handleQuoteAction(
|
|||
snackBarCompleter<Null>(context, localization.convertedQuote),
|
||||
quoteIds));
|
||||
break;
|
||||
case EntityAction.approve:
|
||||
store.dispatch(ApproveQuotes(
|
||||
snackBarCompleter<Null>(
|
||||
context,
|
||||
quotes.length == 1
|
||||
? localization.approvedQuote
|
||||
: localization.approvedQuotes),
|
||||
quoteIds));
|
||||
break;
|
||||
case EntityAction.viewInvoice:
|
||||
viewEntityById(entityId: quote.invoiceId, entityType: EntityType.invoice);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ List<Middleware<AppState>> createStoreQuotesMiddleware([
|
|||
final showEmailQuote = _showEmailQuote();
|
||||
final showPdfQuote = _showPdfQuote();
|
||||
final convertQuote = _convertQuote(repository);
|
||||
final approveQuote = _approveQuote(repository);
|
||||
final loadQuotes = _loadQuotes(repository);
|
||||
final loadQuote = _loadQuote(repository);
|
||||
final saveQuote = _saveQuote(repository);
|
||||
|
|
@ -45,6 +46,7 @@ List<Middleware<AppState>> createStoreQuotesMiddleware([
|
|||
TypedMiddleware<AppState, ViewQuote>(viewQuote),
|
||||
TypedMiddleware<AppState, EditQuote>(editQuote),
|
||||
TypedMiddleware<AppState, ConvertQuotes>(convertQuote),
|
||||
TypedMiddleware<AppState, ApproveQuotes>(approveQuote),
|
||||
TypedMiddleware<AppState, ShowEmailQuote>(showEmailQuote),
|
||||
TypedMiddleware<AppState, ShowPdfQuote>(showPdfQuote),
|
||||
TypedMiddleware<AppState, LoadQuotes>(loadQuotes),
|
||||
|
|
@ -241,6 +243,26 @@ Middleware<AppState> _convertQuote(QuoteRepository repository) {
|
|||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _approveQuote(QuoteRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as ApproveQuotes;
|
||||
repository
|
||||
.bulkAction(
|
||||
store.state.credentials, action.quoteIds, EntityAction.approve)
|
||||
.then((quotes) {
|
||||
store.dispatch(ApproveQuoteSuccess(quotes: quotes));
|
||||
store.dispatch(RefreshData());
|
||||
action.completer.complete(null);
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(ApproveQuoteFailure(error));
|
||||
action.completer.completeError(error);
|
||||
});
|
||||
|
||||
next(action);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _markSentQuote(QuoteRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as MarkSentQuotesRequest;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'approved_quote': 'Successfully apporved quote',
|
||||
'approved_quotes': 'Successfully approved quotes',
|
||||
'approve': 'Approve',
|
||||
'client_website': 'Client Website',
|
||||
'invalid_time': 'Invalid Time',
|
||||
'client_shipping_state': 'Client Shipping State',
|
||||
|
|
@ -74135,6 +74138,18 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]['client_website'] ??
|
||||
_localizedValues['en']['client_website'];
|
||||
|
||||
String get approve =>
|
||||
_localizedValues[localeCode]['approve'] ??
|
||||
_localizedValues['en']['approve'];
|
||||
|
||||
String get approvedQuote =>
|
||||
_localizedValues[localeCode]['approved_quote'] ??
|
||||
_localizedValues['en']['approved_quote'];
|
||||
|
||||
String get approvedQuotes =>
|
||||
_localizedValues[localeCode]['approved_quotes'] ??
|
||||
_localizedValues['en']['approved_quotes'];
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue