# HG changeset patch # User nowmad@23.1.168.192.in-addr.arpa # Date 1453406822 -3600 # Node ID 62984937a062a6d3b7c6b41cbf8230746fc35473 # Parent f7223e2f302377394ded6c07bd5ad0071c825ac4 - add params when modal appear so we can come back right on this document modal - load the complete document info when modal is called or when played diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/adapters/application.js --- a/cms/app-client/app/adapters/application.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/adapters/application.js Thu Jan 21 21:07:02 2016 +0100 @@ -1,8 +1,8 @@ import DS from 'ember-data'; -export { default } from 'ember-data-fixture-adapter'; +// export { default } from 'ember-data-fixture-adapter'; -// export default DS.RESTAdapter.extend({ -// host: 'http://int.corpusdelaparole.huma-num.fr/corpus', -// namespace: 'api/v1', -// }); +export default DS.RESTAdapter.extend({ + host: 'http://127.0.0.1:8000', + namespace: 'api', +}); diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/components/player-component.js --- a/cms/app-client/app/components/player-component.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/components/player-component.js Thu Jan 21 21:07:02 2016 +0100 @@ -4,20 +4,25 @@ classNames: ['player-component'], currentTime: "00:00", duration: "00:00", + documentLoaded: Ember.observer('document.mediaArray', function() { + var mediaList = this.get('document').get("mediaList"); + if ((typeof(mediaList) !== 'undefined') && (mediaList.length > 0)){ + if (this.audio.src){ + this.pause(); + this.updateProgress(0); + } + var mp3 = mediaList.findBy('format', 'audio/mpeg'); + this.audio.src = mp3.url; + this.audio.load(); + this.set("currentTime", "00:00"); + } - _documentChanged: Ember.observer('document', function() { - this.pause(); - this.changeTime(0); - this.updateProgress(0); - this.audio.src = this.get("document").get("master"); - this.audio.load(); - this.set("currentTime", "00:00"); }), didInsertElement: function(){ var _this = this; - this.audio = new Audio("http://stop.com.pk/file/music_folder/700.mp3"); + this.audio = new Audio(); this.button = { play: this.$('#action_play'), diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/components/visu-carto.js --- a/cms/app-client/app/components/visu-carto.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/components/visu-carto.js Thu Jan 21 21:07:02 2016 +0100 @@ -92,11 +92,6 @@ } function handleMapObjectClick (event) { console.log("bbox: ", event.mapObject.displayObject.node.getBBox()); - // console.log("event", event); - // console.log("originalTarget", event.event.originalTarget); - // console.log("getTotalLength", event.event.originalTarget.getTotalLength()); - // console.log("getBBox", event.event.originalTarget.getBBox()); - // console.log("event", event.event.originalTarget.attributes[1].d); if (event.mapObject.id === "backButton") { handleGoHome(); } diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/controllers/application.js --- a/cms/app-client/app/controllers/application.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/controllers/application.js Thu Jan 21 21:07:02 2016 +0100 @@ -1,15 +1,26 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - queryParams: ['location', 'langue', 'discours', 'date', 'thematique'], + queryParams: ['location', 'langue', 'discours', 'date', 'thematique', 'detailId'], location: null, langue: null, discours: null, date: [], thematique: null, - isShowingModal: false, - currentDetails: null, - currentItem: {title: "example", master: 'http://www.noiseaddicts.com/samples_1w72b820/3921.mp3'}, + detailId: null, + + currentId: null, + currentItem: Ember.computed('currentId', function() { + Ember.$(".result-item").toggleClass("playing", false); + Ember.$("#"+this.get('currentId')).toggleClass("playing", true); + if (this.get('currentId') === null){ + return null; + } + return this.store.findRecord('document', this.get('currentId')); + }), + modalItem: Ember.computed('detailId', function() { + return this.store.findRecord('document', this.get('detailId')); + }), filteredDocuments: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() { var location = this.get('location'); var langue = this.get('langue'); @@ -42,10 +53,6 @@ } return documents; }), - currentItemChanged: Ember.observer('currentItem', function() { - Ember.$(".result-item").toggleClass("playing", false); - Ember.$("#"+this.get('currentItem').id).toggleClass("playing", true); - }), actions: { deleteTag: function(query, item){ var newParams = null; @@ -63,16 +70,17 @@ }, changeDocument: function(docDirection){ var direction = (docDirection === "next") ? 1 : -1; - var index = this.get("filteredDocuments").indexOf(this.get("currentItem")); - if ( index !== -1){ - if (typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){ - return this.set('currentItem', this.get("filteredDocuments").objectAt(index+direction)); + var currentObject = this.get("filteredDocuments").findBy('id', this.get("currentItem").get('id')); + if ( currentObject !== 'undefined'){ + var index = this.get("filteredDocuments").indexOf(currentObject); + if ( typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){ + return this.set('currentId', this.get("filteredDocuments").objectAt(index+direction).id); } } - return this.set('currentItem', this.get('filteredDocuments').get('firstObject')); + return this.set('currentId', this.get('filteredDocuments').get('firstObject').id); }, play: function(item){ - this.set("currentItem", item); + this.set("currentId", item.id); }, details: function(item){ if (Ember.$("#"+item.id).hasClass("details")){ @@ -83,8 +91,10 @@ } }, toggleModal: function(item){ - this.set("isShowingModal", !this.isShowingModal); - this.set("currentDetails", item); + if (typeof(item) !== 'undefined'){ + this.set("detailId", item.id); + } + this.set("detailId", null); } } }); diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/models/document.js --- a/cms/app-client/app/models/document.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/models/document.js Thu Jan 21 21:07:02 2016 +0100 @@ -1,5 +1,6 @@ import DS from 'ember-data'; import Ember from 'ember'; +import _ from 'lodash/lodash'; var Document = DS.Model.extend({ // id: DS.attr('string'), @@ -12,7 +13,7 @@ mediaList: Ember.computed('mediaArray', function() { var res = []; var mp3 = null; - Ember.$.forEach(this.get('mediaArray'), function(m) { + _.forEach(this.get('mediaArray'), function(m) { if(m.format === 'audio/mpeg') { mp3 = m; } else if (m.format.startsWith('audio/')) { diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/router.js --- a/cms/app-client/app/router.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/router.js Thu Jan 21 21:07:02 2016 +0100 @@ -6,7 +6,6 @@ }); Router.map(function() { - // this.route('application', { path: '/detail/:document_id' }); this.route('tabs/langues', { path: '/langues' }); this.route('tabs/carto', { path: '/cartographie' }); this.route('tabs/thematiques', { path: '/thematiques' }); diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/routes/tabs/chrono.js --- a/cms/app-client/app/routes/tabs/chrono.js Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/routes/tabs/chrono.js Thu Jan 21 21:07:02 2016 +0100 @@ -4,7 +4,6 @@ actions: { queryParamsDidChange: function() { console.log("chrono params"); - // console.log("visu-chrono ?", this.controller.get('visu-chrono')); }, } }); diff -r f7223e2f3023 -r 62984937a062 cms/app-client/app/templates/application.hbs --- a/cms/app-client/app/templates/application.hbs Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/app/templates/application.hbs Thu Jan 21 21:07:02 2016 +0100 @@ -11,17 +11,20 @@ {{partial "results"}} -{{#if isShowingModal}} +{{#if detail}} {{#ember-wormhole to='info-modal'}}
-

{{currentDetails.title}}

-

Description: {{currentDetails.description}}

-

Interviewer: {{currentDetails.interviewer}}

-

Type de Discours: {{currentDetails.type}}

-

Localisation: {{currentDetails.spatial}}

-

Langue: {{currentDetails.language}}

-

Date de Creation: {{currentDetails.created}}

+
+

Document details

+
+

{{modalItem.title}}

+

Description: {{modalItem.description}}

+

Interviewer: {{modalItem.interviewer}}

+

Type de Discours: {{modalItem.type}}

+

Localisation: {{modalItem.spatial}}

+

Langue: {{modalItem.language}}

+

Date de Creation: {{modalItem.created}}

{{/ember-wormhole}} diff -r f7223e2f3023 -r 62984937a062 cms/app-client/package.json --- a/cms/app-client/package.json Thu Jan 21 00:11:10 2016 +0100 +++ b/cms/app-client/package.json Thu Jan 21 21:07:02 2016 +0100 @@ -40,6 +40,7 @@ "ember-data-fixture-adapter": "1.13.0", "ember-disable-proxy-controllers": "^1.0.0", "ember-export-application-global": "^1.0.3", + "ember-lodash": "0.0.6", "ember-wormhole": "0.3.4" } }