Skip to content

Commit 16e5145

Browse files
fix: adding table for admin-sales-by-event (#5243)
Co-authored-by: iamareebjamal <[email protected]>
1 parent 8dd7cc8 commit 16e5145

File tree

5 files changed

+125
-76
lines changed

5 files changed

+125
-76
lines changed

app/controllers/admin/sales/index.js

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,83 @@
1-
import classic from 'ember-classic-decorator';
21
import Controller from '@ember/controller';
32
import AdminSalesMixin from 'open-event-frontend/mixins/admin-sales';
3+
import { or } from '@ember/object/computed';
4+
import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-controller';
45

5-
@classic
6-
export default class IndexController extends Controller.extend(AdminSalesMixin) {}
6+
export default class IndexController extends Controller.extend(AdminSalesMixin, EmberTableControllerMixin) {
7+
8+
@or('authManager.currentUser.isSuperAdmin', 'authManager.currentUser.isAdmin') hasRestorePrivileges;
9+
10+
get columns() {
11+
return [
12+
{
13+
name : 'Events',
14+
valuePath : 'name',
15+
isSortable : true,
16+
headerComponent : 'tables/headers/sort'
17+
},
18+
{
19+
name : 'Event Date',
20+
valuePath : 'startsAt',
21+
isSortable : true,
22+
headerComponent : 'tables/headers/sort',
23+
extraValuePaths : ['timezone'],
24+
cellComponent : 'ui-table/cell/cell-simple-date'
25+
},
26+
{
27+
name : 'Completed Orders',
28+
headerComponent : 'tables/headers/sort',
29+
color : 'green',
30+
subcolumns : [
31+
{
32+
name : 'Tickets',
33+
valuePath : 'sales.completed.ticket_count',
34+
width : 30
35+
},
36+
{
37+
name : 'Sales',
38+
valuePath : 'sales.completed.sales_total',
39+
extraValuePaths : ['paymentCurrency'],
40+
cellComponent : 'ui-table/cell/admin/sales/cell-amount'
41+
}
42+
]
43+
},
44+
{
45+
name : 'Placed Orders',
46+
color : 'blue',
47+
headerComponent : 'tables/headers/sort',
48+
subcolumns : [
49+
{
50+
name : 'Tickets',
51+
valuePath : 'sales.placed.ticket_count',
52+
width : 30
53+
},
54+
{
55+
name : 'Sales',
56+
valuePath : 'sales.placed.sales_total',
57+
extraValuePaths : ['paymentCurrency'],
58+
cellComponent : 'ui-table/cell/admin/sales/cell-amount'
59+
}
60+
]
61+
},
62+
{
63+
name : 'Pending Orders',
64+
color : 'yellow',
65+
headerComponent : 'tables/headers/sort',
66+
subcolumns : [
67+
{
68+
name : 'Tickets',
69+
valuePath : 'sales.pending.ticket_count',
70+
width : 30
71+
},
72+
{
73+
name : 'Sales',
74+
valuePath : 'sales.pending.sales_total',
75+
extraValuePaths : ['paymentCurrency'],
76+
cellComponent : 'ui-table/cell/admin/sales/cell-amount'
77+
}
78+
]
79+
}
80+
];
81+
}
82+
83+
}

app/routes/admin/sales/index.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
import classic from 'ember-classic-decorator';
22
import Route from '@ember/routing/route';
3+
import { action } from '@ember/object';
4+
import EmberTableRouteMixin from 'open-event-frontend/mixins/ember-table-route';
35

46
@classic
5-
export default class IndexRoute extends Route {
7+
export default class IndexRoute extends Route.extend(EmberTableRouteMixin) {
8+
69
titleToken() {
710
return this.l10n.t('Overview');
811
}
912

10-
model() {
11-
return this.store.findAll('admin-sales-by-event');
13+
14+
async model(params) {
15+
this.set('params', params);
16+
let filterOptions = [];
17+
const searchField = 'name';
18+
filterOptions = this.applySearchFilters(filterOptions, params, searchField);
19+
let queryString = {
20+
filter : filterOptions,
21+
'page[size]' : params.per_page || 10,
22+
'page[number]' : params.page || 1
23+
};
24+
queryString = this.applySortFilters(queryString, params);
25+
return this.asArray(this.store.query('admin-sales-by-event', queryString));
26+
}
27+
28+
@action
29+
refreshRoute() {
30+
this.refresh();
1231
}
1332
}

app/templates/admin/sales/index.hbs

Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,17 @@
1-
<div class="ui stackable grid">
2-
<div class="row">
3-
<h2 class="ui header column">{{t 'Tickets Summary'}}</h2>
4-
</div>
5-
<div class="row">
6-
<div class="sixteen wide column">
7-
<table class="ui stackable structured celled compact table">
8-
<thead>
9-
<tr>
10-
<th rowspan="2">{{t 'Events'}}</th>
11-
<th rowspan="2">{{t 'Event Date'}}</th>
12-
<th colspan="2" class="ui green inverted segment center aligned">{{t 'Completed Orders '}}</th>
13-
<th colspan="2" class="ui blue inverted segment center aligned">{{t 'Placed Orders'}}</th>
14-
<th colspan="2" class="ui yellow inverted segment center aligned">{{t 'Pending Orders '}}</th>
15-
</tr>
16-
<tr>
17-
<th class="right aligned">{{t 'Tickets'}}</th>
18-
<th class="right aligned">{{t 'Sales'}}</th>
19-
<th class="right aligned">{{t 'Tickets'}}</th>
20-
<th class="right aligned">{{t 'Sales'}}</th>
21-
<th class="right aligned">{{t 'Tickets'}}</th>
22-
<th class="right aligned">{{t 'Sales'}}</th>
23-
</tr>
24-
</thead>
25-
<tbody>
26-
{{#each this.model as |entry|}}
27-
<tr>
28-
<td>{{entry.name}}</td>
29-
<td>{{moment-format entry.startsAt 'ddd, MMM DD \at h:mm A'}}</td>
30-
<td class="right aligned">{{entry.sales.completed.ticket_count}}</td>
31-
<td class="right aligned">{{currency-symbol entry.paymentCurrency}} {{format-money entry.sales.completed.sales_total}}</td>
32-
<td class="right aligned">{{entry.sales.placed.ticket_count}}</td>
33-
<td class="right aligned">{{currency-symbol entry.paymentCurrency}} {{format-money entry.sales.placed.sales_total}}</td>
34-
<td class="right aligned">{{entry.sales.pending.ticket_count}}</td>
35-
<td class="right aligned">{{currency-symbol entry.paymentCurrency}} {{format-money entry.sales.pending.sales_total}}</td>
36-
</tr>
37-
{{/each}}
38-
</tbody>
39-
{{!-- <tfoot>
40-
<tr>
41-
<th colspan="2">
42-
<span class="weight-600">{{t 'Total'}}</span>
43-
</th>
44-
<th class="right aligned">
45-
{{totalCompletedTickets}}
46-
</th>
47-
<th class="right aligned">
48-
US$ {{format-money totalCompletedSales}}
49-
</th>
50-
<th class="right aligned">
51-
{{totalPlacedTickets}}
52-
</th>
53-
<th class="right aligned">
54-
US$ {{format-money totalPlacedSales}}
55-
</th>
56-
<th class="right aligned">
57-
{{totalPendingTickets}}
58-
</th>
59-
<th class="right aligned">
60-
US$ {{format-money totalPendingSales}}
61-
</th>
62-
</tr>
63-
</tfoot> --}}
64-
</table>
65-
</div>
66-
</div>
1+
<div class="row">
2+
<h2 class="ui header column">{{t 'Tickets Summary'}}</h2>
673
</div>
4+
<br>
5+
<Tables::Default
6+
@columns={{this.columns}}
7+
@rows={{this.model.data}}
8+
@currentPage={{this.page}}
9+
@pageSize={{this.per_page}}
10+
@searchQuery={{this.search}}
11+
@sortBy={{this.sort_by}}
12+
@sortDir={{this.sort_dir}}
13+
@metaData={{this.model.meta}}
14+
@filterOptions={{this.filterOptions}}
15+
@widthConstraint="eq-container"
16+
@resizeMode="fluid"
17+
@fillMode="equal-column" />
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{{yield}}
2-
{{#if this.column.isSortable}}
3-
<i class="{{this.sortIcon}} icon"></i>
4-
{{/if}}
1+
<div class="{{if this.column.color (concat 'ui inverted segment ' this.column.color)}}">
2+
{{yield}}
3+
{{#if this.column.isSortable}}
4+
<i class="{{this.sortIcon}} icon"></i>
5+
{{/if}}
6+
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{currency-symbol @extraRecords.paymentCurrency}} {{format-money @record}}

0 commit comments

Comments
 (0)