Skip to content

Commit 7fdb688

Browse files
committed
clean up, DRY and tests
1 parent f89774b commit 7fdb688

File tree

23 files changed

+187
-173
lines changed

23 files changed

+187
-173
lines changed

app/components/tables/base.js

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

app/components/tables/default.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Component from '@ember/component';
2-
import { action } from '@ember/object';
32

43
export default class extends Component {
54

app/components/tables/events/list.js

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

app/components/tables/headers/sort.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ export default class extends Component {
1818

1919

2020
didInsertElement() {
21+
super.didInsertElement(...arguments);
2122
if (this.sorts && this.sorts[0] && this.sorts[0].valuePath === this.column.valuePath) {
22-
this.set('sortBy', this.sorts[0].valuePath);
23-
this.set('sortDir', this.sorts[0].isAscending ? 'ASC' : 'DSC');
23+
this.setProperties({
24+
sortBy : this.sorts[0].valuePath,
25+
sortDir : this.sorts[0].isAscending ? 'ASC' : 'DSC'
26+
});
27+
2428
} else {
25-
this.set('sortBy', null);
26-
this.set('sortDir', null);
29+
this.setProperties({
30+
sortBy : null,
31+
sortDir : null
32+
});
2733
}
2834
}
2935
}

app/components/tables/utilities/pagination.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { computed, action, get } from '@ember/object';
33

44
export default class extends Component {
55

6-
totalCount = 100;
76

8-
metaPagesCountProperty = 'page[size]';
97
metaItemsCountProperty = 'count';
108

119
@computed('currentPage', 'pageSize', 'totalContentLength')
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Component from '@ember/component';
22

3-
export default Component.extend({
4-
});
3+
export default class extends Component {
4+
5+
}

app/components/ui-table/cell/cell-actions-test.js

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

app/controllers/events/list.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { computed, action } from '@ember/object';
44
export default class extends Controller {
55
queryParams = ['page', 'per_page'];
66
page = 1;
7-
per_page = 2;
7+
per_page = 10;
88
search = null;
99
sort_dir = null;
1010
sort_by = null;
@@ -31,37 +31,40 @@ export default class extends Controller {
3131
{
3232
name : 'Date',
3333
valuePath : 'startsAt',
34-
isSortable: false,
3534
cellComponent : 'ui-table/cell/cell-event-date'
3635

3736
},
3837
{
3938
name : 'Roles',
4039
valuePath : 'roles',
41-
cellComponent : 'ui-table/cell/cell-roles'
40+
cellComponent : 'ui-table/cell/cell-roles',
41+
isSortable : false
4242
},
4343
{
4444
name : 'Sessions',
4545
valuePath : 'sessions',
46-
isSortable: false,
46+
isSortable : false,
4747
cellComponent : 'ui-table/cell/cell-sessions-dashboard'
4848
},
4949
{
5050
name : 'Speakers',
5151
valuePath : 'speakers',
52-
cellComponent : 'ui-table/cell/cell-speakers-dashboard'
52+
cellComponent : 'ui-table/cell/cell-speakers-dashboard',
53+
isSortable : false
5354

5455
},
5556
{
5657
name : 'Tickets',
5758
valuePath : 'tickets',
58-
cellComponent : 'ui-table/cell/cell-tickets'
59+
cellComponent : 'ui-table/cell/cell-tickets',
60+
isSortable : false
5961

6062
},
6163
{
6264
name : 'Public URL',
6365
valuePath : 'url',
64-
cellComponent : 'ui-table/cell/cell-link'
66+
cellComponent : 'ui-table/cell/cell-link',
67+
isSortable : false
6568
}
6669
];
6770
}
@@ -72,7 +75,7 @@ export default class extends Controller {
7275
this.model.data.forEach(row => {
7376
rows.pushObject({
7477
name : row,
75-
startsAt : row.startsAt,
78+
startsAt : row,
7679
roles : row,
7780
sessions : row,
7881
speakers : row,
@@ -100,19 +103,21 @@ export default class extends Controller {
100103

101104
@action
102105
openDeleteEventModal(id, name) {
103-
this.set('isEventDeleteModalOpen', true);
104-
this.set('confirmName', '');
105-
this.set('eventName', name);
106-
this.set('eventId', id);
106+
this.setProperties({
107+
isEventDeleteModalOpen : true,
108+
confirmName : '',
109+
eventName : name,
110+
eventId : id
111+
});
107112
}
108113

109114
@action
110115
async deleteEvent() {
111116
this.set('isLoading', true);
112117

113118
try {
114-
const event = await this.store.findRecord('event', this.eventId, { backgroundReload: false });
115-
event.destroyRecord();
119+
const event = this.store.peekRecord('event', this.eventId, { backgroundReload: false });
120+
await event.destroyRecord();
116121
this.notify.success(this.l10n.t('Event has been deleted successfully.'));
117122
this.send('refreshRoute');
118123
} catch (e) {
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<table class="ui table">
2-
{{yield (hash
3-
api=api
4-
head=(component "ember-thead" api=api)
5-
body=(component "ember-tbody" api=api)
6-
foot=(component "ember-tfoot" api=api)
7-
)}}
8-
</table>
1+
<div class="resize-container">
2+
<table class="ui unstackable table">
3+
{{yield (hash
4+
api=api
5+
head=(component "ember-thead" api=api)
6+
body=(component "ember-tbody" api=api)
7+
foot=(component "ember-tfoot" api=api)
8+
)}}
9+
</table>
10+
</div>

app/initializers/blanket.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export function initialize(application) {
2222
inject('routing', 'service:-routing');
2323
inject('cookies', 'service:cookies');
2424
inject('infinity', 'service:infinity');
25-
inject('headData', 'service:headData');
2625
application.inject('component', 'router', 'service:router');
2726
}
2827

0 commit comments

Comments
 (0)