diff --git a/app/components/ui-table/cell/admin/sales/cell-status-action.hbs b/app/components/ui-table/cell/admin/sales/cell-status-action.hbs new file mode 100644 index 00000000000..47af9ff204b --- /dev/null +++ b/app/components/ui-table/cell/admin/sales/cell-status-action.hbs @@ -0,0 +1,12 @@ + +
+ {{t-var (capitalize @record)}} + +
diff --git a/app/controllers/admin/sales/invoices.js b/app/controllers/admin/sales/invoices.js index 25dab067140..f6d3c6b2796 100644 --- a/app/controllers/admin/sales/invoices.js +++ b/app/controllers/admin/sales/invoices.js @@ -1,8 +1,12 @@ import Controller from '@ember/controller'; import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-controller'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; export default class extends Controller.extend(EmberTableControllerMixin) { + @service errorHandler; + get columns() { return [ { @@ -55,8 +59,16 @@ export default class extends Controller.extend(EmberTableControllerMixin) { { name : this.l10n.t('Status'), valuePath : 'status', + extraValuePaths : ['id'], isSortable : true, - headerComponent : 'tables/headers/sort' + headerComponent : 'tables/headers/sort', + cellComponent : 'ui-table/cell/admin/sales/cell-status-action', + options : { + paymentStateMap: [{ 'name': 'paid', 'color': 'green' }, { 'name': 'due', 'color': 'red' }, { 'name': 'refunding', 'color': 'orange' }, { 'name': 'refunded', 'color': 'violet' }, { 'name': 'failed', 'color': 'black' }, { 'name': 'resolved', 'color': 'green' }] + }, + actions: { + changeState: this.changeState.bind(this) + } }, { name : this.l10n.t('Action'), @@ -66,4 +78,28 @@ export default class extends Controller.extend(EmberTableControllerMixin) { } ]; } + + @action + async changeState(invoice_id, status) { + const invoice = this.store.peekRecord('eventInvoice', invoice_id, { backgroundReload: false }); + const oldState = invoice.status; + invoice.set('status', status); + this.set('isLoading', true); + + try { + await invoice.save(); + this.notify.success(this.l10n.t('Invoice state has been changed to {{action}} successfully.', { + action: status + }), { + id: 'invoice_state' + }); + } catch (e) { + invoice.set('status', oldState); + this.errorHandler.handle(e); + } finally { + this.set('isLoading', false); + } + } + + } diff --git a/app/routes/account/billing/invoices/list.js b/app/routes/account/billing/invoices/list.js index 64233a41774..07aca55db47 100644 --- a/app/routes/account/billing/invoices/list.js +++ b/app/routes/account/billing/invoices/list.js @@ -23,7 +23,7 @@ export default class extends Route.extend(EmberTableRouteMixin) { this.set('params', params); const searchField = 'status'; let filterOptions = []; - if (['paid', 'due', 'refunding', 'refunded'].includes(params.invoice_status)) { + if (['paid', 'due', 'refunding', 'refunded', 'failed', 'resolved'].includes(params.invoice_status)) { filterOptions = [ { name : 'status', diff --git a/app/templates/account/billing/invoices.hbs b/app/templates/account/billing/invoices.hbs index 0c6400dfd07..30c95191cbd 100644 --- a/app/templates/account/billing/invoices.hbs +++ b/app/templates/account/billing/invoices.hbs @@ -17,6 +17,12 @@ {{t 'Refunded'}} + + {{t 'Failed'}} + + + {{t 'Resolved'}} + diff --git a/app/templates/components/event-invoice/invoice-summary.hbs b/app/templates/components/event-invoice/invoice-summary.hbs index ba514ae0757..8b68497b1dd 100644 --- a/app/templates/components/event-invoice/invoice-summary.hbs +++ b/app/templates/components/event-invoice/invoice-summary.hbs @@ -1,8 +1,8 @@
-
+
- {{t 'Paid'}} + {{@data.status}}
{{t 'Your invoice payment completed successfully.'}}