Skip to content

Commit 24455f9

Browse files
authored
feat: Introducing Ember Tables in Admin/Messages (#3340)
* Introducing Ember Tables in Admin/Messages * Final Changes * Making cell options correct * Removing one extraValue * Removing one extraValue
1 parent 028b405 commit 24455f9

File tree

5 files changed

+94
-44
lines changed

5 files changed

+94
-44
lines changed
Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,66 @@
11
import Controller from '@ember/controller';
2+
import { computed } from '@ember/object';
3+
import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-controller';
24

3-
export default Controller.extend({
4-
columns: [
5+
export default class extends Controller.extend(EmberTableControllerMixin) {
6+
per_page = 100;
7+
8+
sort_by = 'time';
9+
10+
sort_dir = 'ASC';
11+
12+
@computed()
13+
get columns() {
14+
return [
515
{
6-
propertyName : 'recipient',
7-
title : 'Recipients'
16+
name : 'Recipients',
17+
valuePath : 'recipient',
18+
headerComponent : 'tables/headers/sort',
19+
isSortable : true
820
},
921
{
10-
propertyName : 'action',
11-
title : 'Trigger'
22+
name : 'Trigger',
23+
valuePath : 'action'
1224
},
1325
{
14-
subject : 'emailSubject',
15-
message : 'emailMessage',
16-
title : 'Email Message',
17-
template : 'components/ui-table/cell/cell-title-message'
26+
name : 'Email Message',
27+
valuePath : 'emailMessage',
28+
29+
cellComponent : 'ui-table/cell/cell-title-message',
30+
extraValuePaths : ['emailSubject'],
31+
options : {
32+
subject : 'emailSubject',
33+
message : 'emailMessage'
34+
}
1835
},
1936
{
20-
subject : 'notificationTitle',
21-
message : 'notificationMessage',
22-
title : 'Notification Message',
23-
template : 'components/ui-table/cell/cell-title-message'
37+
name : 'Notification Message',
38+
valuePath : 'notificationMessage',
39+
cellComponent : 'ui-table/cell/cell-title-message',
40+
extraValuePaths : ['notificationTitle'],
41+
options : {
42+
subject : 'notificationTitle',
43+
message : 'notificationMessage'
44+
}
2445
},
2546
{
26-
title : 'Options',
27-
template : 'components/ui-table/cell/admin/messages/cell-options'
47+
name : 'Options',
48+
valuePath : 'option',
49+
extraValuePaths : ['mailStatus', 'notificationStatus', 'userControlStatus'],
50+
cellComponent : 'ui-table/cell/admin/messages/cell-options'
2851
},
2952
{
30-
propertyName : 'sentAt',
31-
title : 'Time/Date sent out',
32-
template : 'components/ui-table/cell/cell-simple-date',
33-
dateFormat : 'MMMM DD, YYYY - HH:mm A'
53+
name : 'Time/Date Sent Out',
54+
valuePath : 'sentAt',
55+
headerComponent : 'tables/headers/sort',
56+
isSortable : true,
57+
cellComponent : 'ui-table/cell/cell-simple-date',
58+
options : {
59+
dateFormat: 'MMMM DD, YYYY - HH:mm A'
60+
}
3461
}
35-
]
36-
});
62+
63+
];
64+
}
65+
}
66+

app/routes/admin/messages/list.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import Route from '@ember/routing/route';
2+
import EmberTableRouteMixin from 'open-event-frontend/mixins/ember-table-route';
23

3-
export default Route.extend({
4-
model() {
5-
return this.modelFor('admin.messages');
4+
export default class extends Route.extend(EmberTableRouteMixin) {
5+
6+
async model(params) {
7+
const searchField = 'recipient';
8+
let filterOptions = this.applySearchFilters([], params, searchField);
9+
let queryString = {
10+
filter : filterOptions,
11+
'page[size]' : params.per_page || 100,
12+
'page[number' : params.page || 1
13+
};
14+
queryString = this.applySortFilters(queryString, params);
15+
return this.asArray(this.modelFor('admin.messages', queryString));
616
}
7-
});
17+
18+
}

app/templates/admin/messages/list.hbs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
<div class="sixteen wide column">
2-
{{events/events-table columns=columns data=model
3-
useNumericPagination=true
4-
showGlobalFilter=true
5-
showPageSize=true
2+
{{tables/default columns=columns
3+
rows=model.data
4+
currentPage=page
5+
pageSize=per_page
6+
searchQuery=search
7+
sortBy=sort_by
8+
sortDir=sort_dir
9+
metaData=model.meta
10+
filterOptions=filterOptions
11+
widthConstraint="eq-container"
12+
resizeMode="fluid"
13+
fillMode="equal-column"
14+
615
}}
716
</div>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div class='ui checkbox'>
2-
{{input type='checkbox' name='mail_status' checked=record.mailStatus}}
2+
{{input type='checkbox' name='mail_status' checked=extraRecords.mailStatus}}
33
<label>Mail</label>
44
</div>
55
<div class='ui checkbox'>
6-
{{input type='checkbox' name='notification_status' checked=record.notificationStatus}}
6+
{{input type='checkbox' name='notification_status' checked=extraRecords.notificationStatus}}
77
<label>Notification</label>
88
</div>
99
<div class='ui checkbox'>
10-
{{input type='checkbox' name='user_control_status' checked=record.userControlStatus}}
10+
{{input type='checkbox' name='user_control_status' checked=extraRecords.userControlStatus}}
1111
<label>User Control</label>
1212
</div>

app/templates/components/ui-table/cell/cell-title-message.hbs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<div class="content">
2-
{{#if (eq column.subject 'emailSubject')}}
3-
<a class="header">{{sanitize record.emailSubject}}</a>
4-
{{else}}
5-
{{#if record.notificationTitle}}
6-
<a class="header">{{sanitize record.notificationTitle}}</a>
7-
{{/if}}
2+
{{#if (eq props.options.subject 'emailSubject')}}
3+
<a class="header">{{sanitize extraRecords.emailSubject}}</a>
4+
{{else if (eq props.options.subject 'notificationTitle')}}
5+
{{#if extraRecords.notificationTitle}}
6+
<a class="header">{{sanitize extraRecords.notificationTitle}}</a>
7+
{{/if}}
88
{{/if}}
99
<div class="description">
10-
{{#if (eq column.message 'emailMessage')}}
11-
<p>{{sanitize record.emailMessage}}</p>
12-
{{else if (eq column.message 'notificationMessage')}}
13-
{{#if record.notificationMessage}}
14-
<p>{{sanitize record.notificationMessage}}</p>
10+
{{#if (eq props.options.message 'emailMessage')}}
11+
<p>{{sanitize record}}</p>
12+
{{else if (eq props.options.message 'notificationMessage')}}
13+
{{#if record}}
14+
<p>{{sanitize record}}</p>
1515
{{/if}}
1616
{{/if}}
1717
</div>

0 commit comments

Comments
 (0)