-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: adding table for admin-sales-by-event #5243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,83 @@ | ||
import classic from 'ember-classic-decorator'; | ||
import Controller from '@ember/controller'; | ||
import AdminSalesMixin from 'open-event-frontend/mixins/admin-sales'; | ||
import { or } from '@ember/object/computed'; | ||
import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-controller'; | ||
|
||
@classic | ||
export default class IndexController extends Controller.extend(AdminSalesMixin) {} | ||
export default class IndexController extends Controller.extend(AdminSalesMixin, EmberTableControllerMixin) { | ||
|
||
@or('authManager.currentUser.isSuperAdmin', 'authManager.currentUser.isAdmin') hasRestorePrivileges; | ||
|
||
get columns() { | ||
return [ | ||
{ | ||
name : 'Events', | ||
valuePath : 'name', | ||
isSortable : true, | ||
headerComponent : 'tables/headers/sort' | ||
}, | ||
{ | ||
name : 'Event Date', | ||
valuePath : 'startsAt', | ||
isSortable : true, | ||
headerComponent : 'tables/headers/sort', | ||
extraValuePaths : ['timezone'], | ||
cellComponent : 'ui-table/cell/cell-simple-date' | ||
}, | ||
{ | ||
name : 'Completed Orders', | ||
headerComponent : 'tables/headers/sort', | ||
color : 'green', | ||
subcolumns : [ | ||
{ | ||
name : 'Tickets', | ||
valuePath : 'sales.completed.ticket_count', | ||
width : 30 | ||
}, | ||
{ | ||
name : 'Sales', | ||
valuePath : 'sales.completed.sales_total', | ||
extraValuePaths : ['paymentCurrency'], | ||
cellComponent : 'ui-table/cell/admin/sales/cell-amount' | ||
} | ||
] | ||
}, | ||
{ | ||
name : 'Placed Orders', | ||
color : 'blue', | ||
headerComponent : 'tables/headers/sort', | ||
subcolumns : [ | ||
{ | ||
name : 'Tickets', | ||
valuePath : 'sales.placed.ticket_count', | ||
width : 30 | ||
}, | ||
{ | ||
name : 'Sales', | ||
valuePath : 'sales.placed.sales_total', | ||
extraValuePaths : ['paymentCurrency'], | ||
cellComponent : 'ui-table/cell/admin/sales/cell-amount' | ||
} | ||
] | ||
}, | ||
{ | ||
name : 'Pending Orders', | ||
color : 'yellow', | ||
headerComponent : 'tables/headers/sort', | ||
subcolumns : [ | ||
{ | ||
name : 'Tickets', | ||
valuePath : 'sales.pending.ticket_count', | ||
width : 30 | ||
}, | ||
{ | ||
name : 'Sales', | ||
valuePath : 'sales.pending.sales_total', | ||
extraValuePaths : ['paymentCurrency'], | ||
cellComponent : 'ui-table/cell/admin/sales/cell-amount' | ||
} | ||
] | ||
} | ||
]; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import classic from 'ember-classic-decorator'; | ||
import Route from '@ember/routing/route'; | ||
import { action } from '@ember/object'; | ||
import EmberTableRouteMixin from 'open-event-frontend/mixins/ember-table-route'; | ||
|
||
@classic | ||
export default class IndexRoute extends Route { | ||
export default class IndexRoute extends Route.extend(EmberTableRouteMixin) { | ||
|
||
titleToken() { | ||
return this.l10n.t('Overview'); | ||
} | ||
|
||
model() { | ||
return this.store.findAll('admin-sales-by-event'); | ||
|
||
async model(params) { | ||
this.set('params', params); | ||
let filterOptions = []; | ||
const searchField = 'name'; | ||
filterOptions = this.applySearchFilters(filterOptions, params, searchField); | ||
let queryString = { | ||
filter : filterOptions, | ||
'page[size]' : params.per_page || 10, | ||
'page[number]' : params.page || 1 | ||
}; | ||
queryString = this.applySortFilters(queryString, params); | ||
return this.asArray(this.store.query('admin-sales-by-event', queryString)); | ||
} | ||
|
||
@action | ||
refreshRoute() { | ||
this.refresh(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,17 @@ | ||
<div class="ui stackable grid"> | ||
<div class="row"> | ||
<h2 class="ui header column">{{t 'Tickets Summary'}}</h2> | ||
</div> | ||
<div class="row"> | ||
<div class="sixteen wide column"> | ||
<table class="ui stackable structured celled compact table"> | ||
<thead> | ||
<tr> | ||
<th rowspan="2">{{t 'Events'}}</th> | ||
<th rowspan="2">{{t 'Event Date'}}</th> | ||
<th colspan="2" class="ui green inverted segment center aligned">{{t 'Completed Orders '}}</th> | ||
<th colspan="2" class="ui blue inverted segment center aligned">{{t 'Placed Orders'}}</th> | ||
<th colspan="2" class="ui yellow inverted segment center aligned">{{t 'Pending Orders '}}</th> | ||
</tr> | ||
<tr> | ||
<th class="right aligned">{{t 'Tickets'}}</th> | ||
<th class="right aligned">{{t 'Sales'}}</th> | ||
<th class="right aligned">{{t 'Tickets'}}</th> | ||
<th class="right aligned">{{t 'Sales'}}</th> | ||
<th class="right aligned">{{t 'Tickets'}}</th> | ||
<th class="right aligned">{{t 'Sales'}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each this.model as |entry|}} | ||
<tr> | ||
<td>{{entry.name}}</td> | ||
<td>{{moment-format entry.startsAt 'ddd, MMM DD \at h:mm A'}}</td> | ||
<td class="right aligned">{{entry.sales.completed.ticket_count}}</td> | ||
<td class="right aligned">{{currency-symbol entry.paymentCurrency}} {{format-money entry.sales.completed.sales_total}}</td> | ||
<td class="right aligned">{{entry.sales.placed.ticket_count}}</td> | ||
<td class="right aligned">{{currency-symbol entry.paymentCurrency}} {{format-money entry.sales.placed.sales_total}}</td> | ||
<td class="right aligned">{{entry.sales.pending.ticket_count}}</td> | ||
<td class="right aligned">{{currency-symbol entry.paymentCurrency}} {{format-money entry.sales.pending.sales_total}}</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
{{!-- <tfoot> | ||
<tr> | ||
<th colspan="2"> | ||
<span class="weight-600">{{t 'Total'}}</span> | ||
</th> | ||
<th class="right aligned"> | ||
{{totalCompletedTickets}} | ||
</th> | ||
<th class="right aligned"> | ||
US$ {{format-money totalCompletedSales}} | ||
</th> | ||
<th class="right aligned"> | ||
{{totalPlacedTickets}} | ||
</th> | ||
<th class="right aligned"> | ||
US$ {{format-money totalPlacedSales}} | ||
</th> | ||
<th class="right aligned"> | ||
{{totalPendingTickets}} | ||
</th> | ||
<th class="right aligned"> | ||
US$ {{format-money totalPendingSales}} | ||
</th> | ||
</tr> | ||
</tfoot> --}} | ||
</table> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<h2 class="ui header column">{{t 'Tickets Summary'}}</h2> | ||
</div> | ||
<br> | ||
<Tables::Default | ||
@columns={{this.columns}} | ||
@rows={{this.model.data}} | ||
@currentPage={{this.page}} | ||
@pageSize={{this.per_page}} | ||
@searchQuery={{this.search}} | ||
@sortBy={{this.sort_by}} | ||
@sortDir={{this.sort_dir}} | ||
@metaData={{this.model.meta}} | ||
@filterOptions={{this.filterOptions}} | ||
@widthConstraint="eq-container" | ||
@resizeMode="fluid" | ||
@fillMode="equal-column" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{{yield}} | ||
{{#if this.column.isSortable}} | ||
<i class="{{this.sortIcon}} icon"></i> | ||
{{/if}} | ||
<div class="{{if this.column.color (concat 'ui inverted segment ' this.column.color)}}"> | ||
{{yield}} | ||
{{#if this.column.isSortable}} | ||
<i class="{{this.sortIcon}} icon"></i> | ||
{{/if}} | ||
</div> |
1 change: 1 addition & 0 deletions
1
app/templates/components/ui-table/cell/admin/sales/cell-amount.hbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{currency-symbol @extraRecords.paymentCurrency}} {{format-money @record}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.