Skip to content

Commit 3bf8558

Browse files
committed
Added table support for due invoices
1 parent 6fa5635 commit 3bf8558

File tree

5 files changed

+121
-119
lines changed

5 files changed

+121
-119
lines changed
Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,4 @@
11
import Controller from '@ember/controller';
2-
import { filterBy } from '@ember/object/computed';
3-
import { computed } from '@ember/object';
4-
import EmberTableMixin from 'open-event-frontend/mixins/ember-table';
5-
6-
export default class extends Controller.extend(EmberTableMixin) {
7-
// queryParams = ['page', 'per_page'];
8-
// page = 1;
9-
// per_page = 10;
10-
// search = null;
11-
// sort_dir = null;
12-
// sort_by = null;
13-
@filterBy('model.eventInvoices', 'status', 'due')
14-
dueInvoices;
152

16-
@filterBy('model.eventInvoices', 'status', 'paid')
17-
paidInvoices;
18-
19-
@computed()
20-
get dueInvoiceColumns() {
21-
return [
22-
{
23-
name: 'Invoice ID',
24-
valuePath: 'invoiceId'
25-
},
26-
{
27-
name: 'Event Name',
28-
valuePath: 'eventName'
29-
},
30-
{
31-
name: 'Date Issued',
32-
valuePath: 'dateIssued'
33-
},
34-
{
35-
name: 'Amount',
36-
valuePath: 'amount'
37-
},
38-
{
39-
name: 'View Invoice',
40-
valuePath: 'invoiceLink'
41-
}
42-
43-
];
44-
}
45-
46-
@computed('dueInvoices')
47-
get dueInvoiceRows() {
48-
const rows = [];
49-
this.dueInvoices.forEach(row => {
50-
rows.pushObject({
51-
invoiceId : row.identifier,
52-
eventName : row.event.name,
53-
dateIssued : row.createdAt,
54-
amount : row.amount,
55-
invoiceLink : row.invoicePdfUrl
56-
});
57-
});
58-
return rows;
59-
}
60-
61-
@computed('paidInvoices')
62-
get paidInvoiceRows() {
63-
const rows = [];
64-
this.paidInvoices.forEach(row => {
65-
rows.pushObject({
66-
invoiceId : row.identifier,
67-
eventName : row.event.name,
68-
dateIssued : row.createdAt,
69-
amount : row.amount,
70-
datePaid : row.completedAt,
71-
invoiceLink : row.invoicePdfUrl
72-
});
73-
});
74-
return rows;
75-
}
76-
77-
@computed('upcomingInvoices')
78-
get upcomingInvoiceRows() {
79-
const rows = [];
80-
this.upcomingInvoices.forEach(row => {
81-
rows.pushObject({
82-
invoiceId : row.identifier,
83-
eventName : row.event.name,
84-
dateIssued : row.createdAt,
85-
amount : row.amount,
86-
invoiceLink : row.invoicePdfUrl
87-
});
88-
});
89-
return rows;
90-
}
3+
export default class extends Controller {
914
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import Controller from '@ember/controller';
2+
import { filterBy } from '@ember/object/computed';
3+
import { computed } from '@ember/object';
4+
import EmberTableMixin from 'open-event-frontend/mixins/ember-table';
5+
6+
export default class extends Controller.extend(EmberTableMixin) {
7+
8+
@filterBy('model.eventInvoices', 'status', 'due')
9+
dueInvoices;
10+
11+
@filterBy('model.eventInvoices', 'status', 'paid')
12+
paidInvoices;
13+
14+
@computed()
15+
get dueInvoiceColumns() {
16+
return [
17+
{
18+
name : 'Invoice ID',
19+
valuePath : 'invoiceId'
20+
},
21+
{
22+
name : 'Event Name',
23+
valuePath : 'eventName'
24+
},
25+
{
26+
name : 'Date Issued',
27+
valuePath : 'dateIssued'
28+
},
29+
{
30+
name : 'Amount',
31+
valuePath : 'amount'
32+
},
33+
{
34+
name : 'View Invoice',
35+
valuePath : 'invoiceLink'
36+
}
37+
38+
];
39+
}
40+
41+
@computed()
42+
get dueInvoiceRows() {
43+
const rows = [];
44+
this.dueInvoices.forEach(row => {
45+
rows.pushObject({
46+
invoiceId : row.identifier,
47+
eventName : row.event.name,
48+
dateIssued : row.createdAt,
49+
amount : row.amount,
50+
invoiceLink : row.invoicePdfUrl
51+
});
52+
});
53+
return rows;
54+
}
55+
56+
@computed()
57+
get paidInvoiceRows() {
58+
const rows = [];
59+
this.paidInvoices.forEach(row => {
60+
rows.pushObject({
61+
invoiceId : row.identifier,
62+
eventName : row.event.name,
63+
dateIssued : row.createdAt,
64+
amount : row.amount,
65+
datePaid : row.completedAt,
66+
invoiceLink : row.invoicePdfUrl
67+
});
68+
});
69+
return rows;
70+
}
71+
72+
@computed()
73+
get upcomingInvoiceRows() {
74+
const rows = [];
75+
this.upcomingInvoices.forEach(row => {
76+
rows.pushObject({
77+
invoiceId : row.identifier,
78+
eventName : row.event.name,
79+
dateIssued : row.createdAt,
80+
amount : row.amount,
81+
invoiceLink : row.invoicePdfUrl
82+
});
83+
});
84+
return rows;
85+
}
86+
}

app/routes/app/templates/account/billing-info/invoices/list.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import EmberTableMixin from 'open-event-frontend/mixins/ember-table';
66
export default class extends Route.extend(EmberTableMixin) {
77
titleToken() {
88
switch (this.params.orders_status) {
9-
case 'placed':
10-
return this.l10n.t('Placed');
11-
case 'pending':
12-
return this.l10n.t('Pending');
13-
case 'expired':
14-
return this.l10n.t('Expired');
15-
case 'cancelled':
16-
return this.l10n.t('Cancelled');
9+
case 'paid':
10+
return this.l10n.t('Paid');
11+
case 'due':
12+
return this.l10n.t('Due');
13+
case 'upcoming':
14+
return this.l10n.t('Upcoming');
1715
case 'all':
1816
return this.l10n.t('All');
1917
}
@@ -48,22 +46,28 @@ export default class extends Route.extend(EmberTableMixin) {
4846
];
4947
}
5048

49+
filterOptions = this.applySearchFilters(filterOptions, params, searchField);
50+
5151
let queryObject = {
52-
include : 'event',
53-
filter : filterOptions,
54-
'page[size]' : 10
52+
include : 'event',
53+
filter : filterOptions,
54+
'page[size]' : params.per_page || 10,
55+
'page[number]' : params.page || 4
5556
};
5657

58+
queryObject = this.applySortFilters(queryObject, params);
59+
5760
let store = this.modelFor('billing-info.invoices');
5861

5962
let data = await store.query('event-invoice', queryObject);
6063

6164
return {
62-
store,
63-
data,
64-
query : queryObject,
65-
objectType : 'event-invoice'
65+
data
6666
};
6767

6868
}
69+
@action
70+
refreshRoute() {
71+
this.refresh();
72+
}
6973
}

app/templates/account/billing-info/invoices.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<div class="row">
33
<div class="eight wide column">
44
{{#tabbed-navigation isNonPointing=true}}
5-
{{#link-to 'account.billing-info.invoices.list' 'Due' class='item'}}
5+
{{#link-to 'account.billing-info.invoices.list' 'due' class='item'}}
66
{{t 'Due'}}
77
{{/link-to}}
8-
{{#link-to 'account.billing-info.invoices.list' 'Paid' class='item'}}
8+
{{#link-to 'account.billing-info.invoices.list' 'paid' class='item'}}
99
{{t 'Paid'}}
1010
{{/link-to}}
11-
{{#link-to 'account.billing-info.invoices.list' 'Upcoming' class='item'}}
11+
{{#link-to 'account.billing-info.invoices.list' 'upcoming' class='item'}}
1212
{{t 'Upcoming'}}
1313
{{/link-to}}
1414
{{/tabbed-navigation}}
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<div class="sixteen wide column">
2-
{{!-- <h2 class="ui header column">{{t 'Due Invoices'}}</h2> --}}
32
{{tables/default columns=dueInvoiceColumns
4-
rows=dueInvoiceRows
5-
currentPage=page
6-
pageSize=per_page
7-
searchQuery=search
8-
sortBy=sort_by
9-
sortDir=sort_dir
10-
metaData=model.data.meta
11-
filterOptions=filterOptions
12-
widthConstraint="eq-container"
13-
resizeMode="fluid"
14-
fillMode="equal-column"
3+
rows=dueInvoiceRows
4+
currentPage=page
5+
pageSize=per_page
6+
searchQuery=search
7+
sortBy=sort_by
8+
sortDir=sort_dir
9+
metaData=model.data.meta
10+
filterOptions=filterOptions
11+
widthConstraint="eq-container"
12+
resizeMode="fluid"
13+
fillMode="equal-column"
1514
}}
16-
</div>
15+
</div>

0 commit comments

Comments
 (0)