studio ui fix

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-27 16:38:10 +02:00
parent 09f25ef4ef
commit 849ab4f4b0
5 changed files with 52 additions and 31 deletions
@@ -123,8 +123,11 @@
console.log('onActionToCompoDone',data); console.log('onActionToCompoDone',data);
$('.composition-link').removeClass('is-active'); $('.composition-link').removeClass('is-active');
$link.removeClass('ajax-loading').addClass('is-active'); $link.removeClass('ajax-loading').addClass('is-active');
if($('.composition', $composer).length){
$('.composition', $composer).replaceWith(data.compo); $('.composition', $composer).replaceWith(data.compo);
}else{
$('header', $composer).after(data.compo);
}
$composer.removeClass('ajax-loading'); $composer.removeClass('ajax-loading');
initDragAndDropUI(); initDragAndDropUI();
$('body').trigger({ $('body').trigger({
@@ -3,9 +3,12 @@
function template_preprocess_edlp_composition_ui(&$vars){ function template_preprocess_edlp_composition_ui(&$vars){
// dpm($vars); // dpm($vars);
if($vars['lastcomposition']){
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('composition'); $view_builder = \Drupal::entityTypeManager()->getViewBuilder('composition');
$vars['composition'] = $view_builder->view($vars['lastcomposition'], 'studio_ui'); $vars['composition'] = $view_builder->view($vars['lastcomposition'], 'studio_ui');
}else{
$vars['composition'] = null;
}
} }
@@ -135,7 +135,12 @@ class StudioUIController extends ControllerBase {
->condition('user_id', $this->user->id()); ->condition('user_id', $this->user->id());
$compos_ids = $query->execute(); $compos_ids = $query->execute();
$compos = entity_load_multiple('composition', $compos_ids); // dpm($compos_ids);
if(count($compos_ids)){
$compos = entity_load_multiple('composition', $compos_ids);
}else{
$compos = array();
}
$createurl = Url::fromRoute('edlp_studio.composition_controller_action_ajax', ['action' => 'create'], ['absolute' => TRUE]); $createurl = Url::fromRoute('edlp_studio.composition_controller_action_ajax', ['action' => 'create'], ['absolute' => TRUE]);
@@ -154,7 +159,11 @@ class StudioUIController extends ControllerBase {
->sort('created'); ->sort('created');
$compos_id = $query->execute(); $compos_id = $query->execute();
$lastcompo = entity_load('composition', array_pop($compos_id)); if(count($compos_id)){
$lastcompo = entity_load('composition', array_pop($compos_id));
}else{
$lastcompo = null;
}
return $lastcompo; return $lastcompo;
} }
@@ -669,24 +669,27 @@
console.log('CompoPlayer initControls()'); console.log('CompoPlayer initControls()');
this.$composer = $('.composition_ui .composer'); this.$composer = $('.composition_ui .composer');
this.$controls = $('.composition_ui .composer .compo-player-controls'); this.$controls = $('.composition_ui .composer .compo-player-controls');
if(!this.$controls.is('.ready') && this.$compo){
this.$previous = $('<div>').addClass('previous')
.on('click', this.prev.bind(this))
.appendTo(this.$controls);
this.$playpause = $('<div>').addClass('play-pause')
.on('click', this.togglePlayPause.bind(this))
.appendTo(this.$controls);
this.$next = $('<div>').addClass('next')
.on('click', this.next.bind(this))
.appendTo(this.$controls);
this.$previous = $('<div>').addClass('previous') this.$controls.addClass('ready');
.on('click', this.prev.bind(this))
.appendTo(this.$controls);
this.$playpause = $('<div>').addClass('play-pause')
.on('click', this.togglePlayPause.bind(this))
.appendTo(this.$controls);
this.$next = $('<div>').addClass('next')
.on('click', this.next.bind(this))
.appendTo(this.$controls);
this.active = true; // TODO: set active false this.active = true; // TODO: set active false
this.newCompo();
this.newCompo(); }
}, },
newCompo(){ newCompo(){
console.log('CompoPlayer newCompo()'); console.log('CompoPlayer newCompo()');
this.$compo = $('.composition_ui .composer .composition'); this.$compo = $('.composition_ui .composer .composition');
this.initControls();
this.refresh(); this.refresh();
}, },
refresh(){ refresh(){
@@ -669,24 +669,27 @@
console.log('CompoPlayer initControls()'); console.log('CompoPlayer initControls()');
this.$composer = $('.composition_ui .composer'); this.$composer = $('.composition_ui .composer');
this.$controls = $('.composition_ui .composer .compo-player-controls'); this.$controls = $('.composition_ui .composer .compo-player-controls');
if(!this.$controls.is('.ready') && this.$compo){
this.$previous = $('<div>').addClass('previous')
.on('click', this.prev.bind(this))
.appendTo(this.$controls);
this.$playpause = $('<div>').addClass('play-pause')
.on('click', this.togglePlayPause.bind(this))
.appendTo(this.$controls);
this.$next = $('<div>').addClass('next')
.on('click', this.next.bind(this))
.appendTo(this.$controls);
this.$previous = $('<div>').addClass('previous') this.$controls.addClass('ready');
.on('click', this.prev.bind(this))
.appendTo(this.$controls);
this.$playpause = $('<div>').addClass('play-pause')
.on('click', this.togglePlayPause.bind(this))
.appendTo(this.$controls);
this.$next = $('<div>').addClass('next')
.on('click', this.next.bind(this))
.appendTo(this.$controls);
this.active = true; // TODO: set active false this.active = true; // TODO: set active false
this.newCompo();
this.newCompo(); }
}, },
newCompo(){ newCompo(){
console.log('CompoPlayer newCompo()'); console.log('CompoPlayer newCompo()');
this.$compo = $('.composition_ui .composer .composition'); this.$compo = $('.composition_ui .composer .composition');
this.initControls();
this.refresh(); this.refresh();
}, },
refresh(){ refresh(){