author | ymh <ymh.work@gmail.com> |
Tue, 08 Nov 2016 01:22:56 +0100 | |
changeset 394 | 48458e099b05 |
parent 392 | 4fbe94af93e8 |
child 401 | 9ff56cc0c656 |
permissions | -rw-r--r-- |
51
70dff07a76ff
add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
2 |
import _ from 'lodash/lodash'; |
51
70dff07a76ff
add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
3 |
|
70dff07a76ff
add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
4 |
export default Ember.Controller.extend({ |
94
62984937a062
- add params when modal appear so we can come back right on this document modal
nowmad@23.1.168.192.in-addr.arpa
parents:
91
diff
changeset
|
5 |
|
254 | 6 |
player: Ember.inject.service(), |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
7 |
filter: Ember.inject.service(), |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
8 |
constants: Ember.inject.service(), |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
9 |
|
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
10 |
page: 1, |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
11 |
limit: Ember.computed(function() { |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
12 |
return this.get('constants').DOCUMENTS_PAGINATION_PERPAGE; |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
13 |
}), |
254 | 14 |
|
15 |
playerVideoscreenObserver: Ember.observer('player.videoscreen', function() { |
|
16 |
Ember.$('body').toggleClass('videoscreen', this.get('player').get('videoscreen')); |
|
17 |
}), |
|
18 |
||
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
19 |
queryParams : Ember.computed('filter.queryParams', function() { |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
20 |
var res = _.clone(this.get('filter').get('queryParams')); |
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
21 |
res.push('notice'); |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
22 |
res.push('page'); |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
23 |
return res; |
196 | 24 |
}), |
25 |
||
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
26 |
// this has to be done because queryParameters can not be computed properties... |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
27 |
// Of course, we rather had computed properties. |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
28 |
// c.f. : https://github.com/emberjs/ember.js/issues/11592 |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
29 |
date: null, |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
30 |
discourse: null, |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
31 |
language: null, |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
32 |
location: null, |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
33 |
theme: null, |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
34 |
|
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
35 |
languageObserver: Ember.observer('language', 'date', 'date.[]', 'discourse', 'discourse.[]', 'location', 'theme', 'theme.[]', function() { |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
36 |
this.get('filter').setProperties(this.getProperties('language', 'date', 'discourse', 'theme', 'location')); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
37 |
}), |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
38 |
filterObserver: Ember.observer('filter', 'filter.language', 'filter.date', 'filter.date.[]', 'filter.discourse', 'filter.discourse.[]', 'filter.location', 'filter.theme', 'filter.theme.[]', function() { |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
39 |
this.set('language', this.get('filter').get('language')); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
40 |
this.setProperties(this.get('filter').getProperties('language', 'date', 'discourse', 'theme', 'location')); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
41 |
}), |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
42 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
43 |
itemObserver: Ember.observer('player.item', function() { |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
44 |
var self = this; |
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
45 |
this.store.findRecord('document', this.get('player').get('item'), { reload: true }).then(function(model){ |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
46 |
self.get('player').set('model', model); |
253
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
245
diff
changeset
|
47 |
if (self.get('player').get('model').get('transcript')) { |
321
aefaad270b9b
reimplement ThemeController using ES requests to be able to sort by label
ymh <ymh.work@gmail.com>
parents:
254
diff
changeset
|
48 |
self.store.findRecord('transcript', self.get('player').get('item')).then(function(model) { |
253
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
245
diff
changeset
|
49 |
self.get('player').set('transcript', model); |
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
245
diff
changeset
|
50 |
}); |
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
245
diff
changeset
|
51 |
} else { |
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
245
diff
changeset
|
52 |
self.get('player').set('transcript', null); |
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
245
diff
changeset
|
53 |
} |
245
c9dd78a43b07
Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents:
233
diff
changeset
|
54 |
}); |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
55 |
}), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
56 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
57 |
notice: null, |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
58 |
noticeModel: null, |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
59 |
|
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
60 |
noticeObserver: Ember.observer('notice', function() { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
61 |
var self = this; |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
62 |
if (this.get('notice')) { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
63 |
this.store.findRecord('document', this.get('notice'), { reload: true }).then(function(model){ |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
64 |
self.set('noticeModel', model); |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
65 |
}); |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
66 |
} |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
67 |
}), |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
68 |
noticeModelObserver: Ember.observer('noticeModel', function() { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
69 |
if (!this.get('noticeModel')) { |
321
aefaad270b9b
reimplement ThemeController using ES requests to be able to sort by label
ymh <ymh.work@gmail.com>
parents:
254
diff
changeset
|
70 |
this.set('notice', null); |
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
71 |
} |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
72 |
}), |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
73 |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
74 |
init: function() { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
75 |
this._super(...arguments); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
76 |
this.get('player'); |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
77 |
this.get('filter'); |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
78 |
}, |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
79 |
|
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
80 |
actions: { |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
81 |
|
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
82 |
setPageQueryparams: function(type) { |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
83 |
var page = this.get('page'); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
84 |
if(type === 'previous') { |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
85 |
page = page - 1; |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
86 |
} else if(type === 'next') { |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
87 |
page = page + 1; |
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
88 |
} |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
89 |
this.propertyWillChange('page'); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
90 |
this.set('page', page); |
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
91 |
this.propertyDidChange('page'); |
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
92 |
}, |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
93 |
|
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
94 |
play: function(item){ |
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
95 |
this.set("currentId", item.id); |
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
96 |
} |
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
97 |
|
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
98 |
} |
51
70dff07a76ff
add click event on visu-carto and visu-langue and update the url with the selected element as filter parameter
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
99 |
}); |