Skip to content

Commit 2e32e93

Browse files
authored
fix: pagination page size in message list (#6254)
1 parent 8da8455 commit 2e32e93

File tree

7 files changed

+100
-120
lines changed

7 files changed

+100
-120
lines changed

app/controllers/admin/messages.js

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,77 @@
11
import Controller from '@ember/controller';
22
import { action } from '@ember/object';
3+
import EmberTableControllerMixin from 'open-event-frontend/mixins/ember-table-controller';
34

4-
export default class extends Controller {
5-
@action
6-
save() {
7-
try {
8-
const systemMessages = this.model;
9-
systemMessages.forEach(systemMessage => {
10-
systemMessage.save();
11-
});
12-
this.notify.success(this.l10n.t('Changes have been saved successfully'),
13-
{
14-
id: 'message_success'
15-
});
16-
} catch (e) {
17-
console.error('Error while saving system messages', e);
18-
this.notify.error(e.errors[0].detail,
19-
{
20-
id: 'change_error_message'
21-
});
5+
export default class extends Controller.extend(EmberTableControllerMixin) {
6+
per_page = 100;
7+
8+
sort_dir = 'ASC';
9+
10+
get columns() {
11+
return [
12+
{
13+
name : this.l10n.t('Recipients'),
14+
valuePath : 'recipient'
15+
},
16+
{
17+
name : this.l10n.t('Trigger'),
18+
valuePath : 'action'
19+
},
20+
{
21+
name : this.l10n.t('Email Message'),
22+
valuePath : 'emailMessage',
23+
24+
cellComponent : 'ui-table/cell/cell-title-message',
25+
extraValuePaths : ['emailSubject'],
26+
options : {
27+
subject : 'emailSubject',
28+
message : 'emailMessage'
29+
}
30+
},
31+
{
32+
name : this.l10n.t('Notification Message'),
33+
valuePath : 'notificationMessage',
34+
cellComponent : 'ui-table/cell/cell-title-message',
35+
extraValuePaths : ['notificationTitle'],
36+
options : {
37+
subject : 'notificationTitle',
38+
message : 'notificationMessage'
39+
}
40+
},
41+
{
42+
name : this.l10n.t('Options'),
43+
valuePath : 'option',
44+
extraValuePaths : ['mailStatus', 'notificationStatus', 'userControlStatus'],
45+
cellComponent : 'ui-table/cell/admin/messages/cell-options'
46+
},
47+
{
48+
name : this.l10n.t('Time/Date Sent Out'),
49+
valuePath : 'sentAt',
50+
headerComponent : 'tables/headers/sort',
51+
isSortable : true,
52+
cellComponent : 'ui-table/cell/cell-simple-date'
2253
}
54+
55+
];
56+
}
57+
58+
@action
59+
save() {
60+
try {
61+
const systemMessages = this.model;
62+
Array.from(systemMessages).forEach(systemMessage => {
63+
systemMessage.save();
64+
});
65+
this.notify.success(this.l10n.t('Changes have been saved successfully'),
66+
{
67+
id: 'message_success'
68+
});
69+
} catch (e) {
70+
console.error('Error while saving system messages', e);
71+
this.notify.error(e.errors[0].detail,
72+
{
73+
id: 'change_error_message'
74+
});
2375
}
2476
}
77+
}

app/controllers/admin/messages/list.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

app/router.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ Router.map(function() {
153153
this.route('all', { path: '/:notification_state' });
154154
});
155155
this.route('admin', function() {
156-
this.route('messages', function() {
157-
this.route('list');
158-
});
159156
this.route('events', function() {
160157
this.route('list', { path: '/:events_status' });
161158
this.route('import');

app/routes/admin/messages.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import classic from 'ember-classic-decorator';
21
import Route from '@ember/routing/route';
2+
import EmberTableRouteMixin from 'open-event-frontend/mixins/ember-table-route';
33

4-
@classic
5-
export default class MessagesRoute extends Route {
4+
export default class extends Route.extend(EmberTableRouteMixin) {
65
titleToken() {
76
return this.l10n.t('Messages');
87
}
98

10-
model() {
11-
return this.store.query('message-setting', {});
9+
async model(params) {
10+
let queryString = {
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.store.query('message-setting', queryString));
1216
}
1317
}

app/routes/admin/messages/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/routes/admin/messages/list.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/templates/admin/messages.hbs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
<div class="ui grid stackable">
22
<div class="row">
3-
{{outlet}}
4-
<div class="sixteen wide {{if this.device.isMobile 'center aligned'}} column">
5-
<button class="ui blue button left floated {{if this.isLoading 'loading'}}" {{action 'save'}}>{{t 'Save'}}</button>
3+
<div class="sixteen wide column">
4+
<Tables::Default
5+
@columns={{this.columns}}
6+
@rows={{this.model.data}}
7+
@currentPage={{this.page}}
8+
@pageSize={{this.per_page}}
9+
@searchQuery={{this.search}}
10+
@sortBy={{this.sort_by}}
11+
@sortDir={{this.sort_dir}}
12+
@metaData={{this.model.meta}}
13+
@filterOptions={{this.filterOptions}}
14+
@hideSearchBox={{true}}
15+
@widthConstraint="eq-container"
16+
@resizeMode="fluid"
17+
@fillMode="equal-column" />
618
</div>
719
</div>
20+
<div class="row">
21+
<div class="sixteen wide {{if this.device.isMobile 'center aligned'}} column">
22+
<button class="ui blue button left floated {{if this.isLoading 'loading'}}" {{action 'save'}}>{{t 'Save'}}</button>
23+
</div>
24+
</div>
825
</div>

0 commit comments

Comments
 (0)