author | ymh <ymh.work@gmail.com> |
Sat, 03 Dec 2016 01:32:43 +0100 | |
changeset 462 | ebd8269781fa |
parent 415 | 0046797e0411 |
child 465 | 9df336529b2f |
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 |
|
404
0a5eef6ad2fe
correction, change colors for discourse categories, add loding spinner
ymh <ymh.work@gmail.com>
parents:
401
diff
changeset
|
10 |
isLoading: false, |
415 | 11 |
currentUrl: '', |
404
0a5eef6ad2fe
correction, change colors for discourse categories, add loding spinner
ymh <ymh.work@gmail.com>
parents:
401
diff
changeset
|
12 |
|
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
13 |
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
|
14 |
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
|
15 |
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
|
16 |
}), |
254 | 17 |
|
18 |
playerVideoscreenObserver: Ember.observer('player.videoscreen', function() { |
|
19 |
Ember.$('body').toggleClass('videoscreen', this.get('player').get('videoscreen')); |
|
20 |
}), |
|
21 |
||
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
22 |
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
|
23 |
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
|
24 |
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
|
25 |
res.push('page'); |
392
4fbe94af93e8
Improve filter service. Centralize filter management in a single point
ymh <ymh.work@gmail.com>
parents:
339
diff
changeset
|
26 |
return res; |
196 | 27 |
}), |
28 |
||
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
29 |
// 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
|
30 |
// 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
|
31 |
// 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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
|
401
9ff56cc0c656
reset pagination when filter change, translate player button
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
38 |
localObserver: Ember.observer('language', 'date', 'date.[]', 'discourse', 'discourse.[]', 'location', 'theme', 'theme.[]', function() { |
394
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.get('filter').setProperties(this.getProperties('language', 'date', 'discourse', 'theme', 'location')); |
401
9ff56cc0c656
reset pagination when filter change, translate player button
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
40 |
// need to reset pagination |
9ff56cc0c656
reset pagination when filter change, translate player button
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
41 |
this.set("page", 1); |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
42 |
}), |
414
5c6c526a7fc1
Display for single notice, preparation for share link
ymh <ymh.work@gmail.com>
parents:
404
diff
changeset
|
43 |
filterObserver: Ember.observer('filter', 'filter.language', 'filter.date', 'filter.date.[]', 'filter.discourse', 'filter.discourse.[]', 'filter.location', 'filter.theme', 'filter.theme.[]',function() { |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
44 |
this.setProperties(this.get('filter').getProperties('language', 'date', 'discourse', 'theme', 'location')); |
401
9ff56cc0c656
reset pagination when filter change, translate player button
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
45 |
// need to reset pagination |
9ff56cc0c656
reset pagination when filter change, translate player button
ymh <ymh.work@gmail.com>
parents:
394
diff
changeset
|
46 |
this.set("page", 1); |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
47 |
}), |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
48 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
49 |
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
|
50 |
var self = this; |
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
51 |
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
|
52 |
self.get('player').set('model', model); |
462 | 53 |
let transcript = self.get('player').get('model').get('transcript'); |
54 |
console.log("transcript", transcript); |
|
55 |
if (transcript && transcript.format === "application/pdf") { |
|
56 |
self.get('player').set('transcript', transcript.url); |
|
57 |
self.get('player').set('transcriptIframe', true); |
|
58 |
} |
|
59 |
else if (transcript) { |
|
60 |
self.get('player').set('transcriptIframe', false); |
|
321
aefaad270b9b
reimplement ThemeController using ES requests to be able to sort by label
ymh <ymh.work@gmail.com>
parents:
254
diff
changeset
|
61 |
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
|
62 |
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
|
63 |
}); |
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
|
64 |
} else { |
462 | 65 |
self.get('player').set('transcriptIframe', false); |
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
|
66 |
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
|
67 |
} |
245
c9dd78a43b07
Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents:
233
diff
changeset
|
68 |
}); |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
69 |
}), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
70 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
71 |
notice: null, |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
72 |
noticeModel: null, |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
73 |
|
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
74 |
noticeObserver: Ember.observer('notice', function() { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
75 |
var self = this; |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
76 |
if (this.get('notice')) { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
77 |
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
|
78 |
self.set('noticeModel', model); |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
79 |
}); |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
80 |
} |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
81 |
}), |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
82 |
noticeModelObserver: Ember.observer('noticeModel', function() { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
83 |
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
|
84 |
this.set('notice', null); |
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
85 |
} |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
86 |
}), |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
227
diff
changeset
|
87 |
|
415 | 88 |
targetUrlChanged: Ember.observer('target.url', function() { |
89 |
Ember.run.next(this, function() { |
|
90 |
this.set('currentUrl', window.location.href); |
|
91 |
}); |
|
92 |
}), |
|
93 |
||
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
94 |
init: function() { |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
95 |
this._super(...arguments); |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
}, |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
204
diff
changeset
|
99 |
|
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
100 |
actions: { |
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
101 |
|
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
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
|
106 |
} 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
|
107 |
page = page + 1; |
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
108 |
} |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
this.propertyDidChange('page'); |
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
112 |
}, |
394
48458e099b05
make dynamic filters for all route and do some code pruning and cleaning
ymh <ymh.work@gmail.com>
parents:
392
diff
changeset
|
113 |
|
190
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
114 |
play: function(item){ |
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
115 |
this.set("currentId", item.id); |
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
116 |
} |
226ae8f2e8e9
JSLinting on /langues endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents:
189
diff
changeset
|
117 |
|
58
6c03fafb6b62
Add missing filters to the application controller
nowmad@nowmads-macbook-pro.local
parents:
51
diff
changeset
|
118 |
} |
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
|
119 |
}); |