Skip to content

Commit 17d201c

Browse files
authored
feat: implement a method for reloading model for tables (#3403)
1 parent 3cb1485 commit 17d201c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/initializers/blanket.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function initialize(application) {
2020
inject('settings', 'service:settings');
2121
inject('fastboot', 'service:fastboot');
2222
inject('routing', 'service:-routing');
23+
inject('router', 'service:router');
2324
inject('cookies', 'service:cookies');
2425
inject('infinity', 'service:infinity');
2526
application.inject('component', 'router', 'service:router');

app/mixins/ember-table-controller.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Mixin from '@ember/object/mixin';
2+
import { getOwner } from '@ember/application';
23

34
export default Mixin.create({
45
queryParams : ['page', 'per_page', 'search', 'sort_dir', 'sort_by'],
@@ -7,5 +8,17 @@ export default Mixin.create({
78
search : null,
89
sort_dir : null,
910
sort_by : null,
10-
sorts : []
11+
sorts : [],
12+
13+
/*
14+
Refreshes the current model, with latest data from API server without reloading
15+
the entire page.
16+
Requires correct context.
17+
Usage example inside a controller:
18+
this.refreshModel.bind(this)()
19+
*/
20+
21+
refreshModel() {
22+
getOwner(this).lookup(`route:${this.router.currentRoute.name}`).refresh();
23+
}
1124
});

0 commit comments

Comments
 (0)