author | ymh <ymh.work@gmail.com> |
Tue, 08 Nov 2016 01:22:56 +0100 | |
changeset 394 | 48458e099b05 |
parent 338 | 4a3899b6a7ed |
child 474 | 245b4df137d3 |
permissions | -rw-r--r-- |
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
2 |
import _ from 'lodash/lodash'; |
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
3 |
|
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
4 |
export default Ember.Route.extend({ |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
5 |
|
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
337
diff
changeset
|
6 |
player: Ember.inject.service(), |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
7 |
filter: Ember.inject.service(), |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
337
diff
changeset
|
8 |
|
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
9 |
index: 0, |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
10 |
limit: 40, |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
11 |
sort: 'alphabetical', |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
12 |
|
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
13 |
themes: [], |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
14 |
|
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
15 |
model: Ember.observer('index', function() { |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
16 |
var self = this; |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
17 |
var filterQueryParams = _.clone(this.get('filter').get('queryParamsValues')); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
18 |
var promise = this.store.query('theme', _.merge(filterQueryParams, { |
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
19 |
'limit': this.get('limit'), |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
20 |
'index': this.get('index'), |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
21 |
'sort': this.get('sort') |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
22 |
})); |
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
23 |
promise.then(function(value) { |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
24 |
if (self.get('themes').length) { |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
25 |
value = self.get('themes').pushObjects(value.get('content')); |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
26 |
} |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
27 |
self.set('themes', value); |
243 | 28 |
}); |
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
29 |
return promise; |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
30 |
}), |
236
ac6928e86d14
Adapt theme query limit and offset and sorting order in fixtures
Chloe Laisne <chloe.laisne@gmail.com>
parents:
176
diff
changeset
|
31 |
|
243 | 32 |
setupController: function(controller) { |
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
33 |
this._super(...arguments); |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
34 |
controller.set('themes', this.get('themes')); |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
35 |
}, |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
36 |
|
337
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
37 |
deactivate: function () { |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
38 |
this.set('themes', []); |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
39 |
}, |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
40 |
|
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
337
diff
changeset
|
41 |
activate: function() { |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
337
diff
changeset
|
42 |
this.get('player').set('window', false); |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
337
diff
changeset
|
43 |
}, |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
337
diff
changeset
|
44 |
|
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
45 |
actions: { |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
46 |
|
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
47 |
setIndexQueryparams: function() { |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
48 |
this.set('index', this.get('index') + 1); |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
49 |
}, |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
50 |
|
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
51 |
setSortQueryparams: function(sort) { |
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
52 |
this.set('sort', sort); |
337
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
53 |
this.get('themes').get('content').clear(); |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
54 |
if(this.get('index') === 0) { |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
55 |
// Force property reset to trigger request |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
56 |
this.propertyWillChange('index'); |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
57 |
this.set('index', 0); |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
58 |
this.propertyDidChange('index'); |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
59 |
} else { |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
60 |
this.set('index', 0); |
2ea18460d5e3
Fix loading alphabetical/popularity sorting in themes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
299
diff
changeset
|
61 |
} |
237
69a9f3687902
Scrolling system in thematiques: more button and append data on scroll
Chloe Laisne <chloe.laisne@gmail.com>
parents:
236
diff
changeset
|
62 |
} |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
63 |
|
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
64 |
} |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
65 |
|
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
66 |
}); |