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);
$('.composition-link').removeClass('is-active');
$link.removeClass('ajax-loading').addClass('is-active');
$('.composition', $composer).replaceWith(data.compo);
if($('.composition', $composer).length){
$('.composition', $composer).replaceWith(data.compo);
}else{
$('header', $composer).after(data.compo);
}
$composer.removeClass('ajax-loading');
initDragAndDropUI();
$('body').trigger({
@@ -3,9 +3,12 @@
function template_preprocess_edlp_composition_ui(&$vars){
// dpm($vars);
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('composition');
$vars['composition'] = $view_builder->view($vars['lastcomposition'], 'studio_ui');
if($vars['lastcomposition']){
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('composition');
$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());
$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]);
@@ -154,7 +159,11 @@ class StudioUIController extends ControllerBase {
->sort('created');
$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;
}
@@ -669,24 +669,27 @@
console.log('CompoPlayer initControls()');
this.$composer = $('.composition_ui .composer');
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')
.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.$controls.addClass('ready');
this.active = true; // TODO: set active false
this.newCompo();
this.active = true; // TODO: set active false
this.newCompo();
}
},
newCompo(){
console.log('CompoPlayer newCompo()');
this.$compo = $('.composition_ui .composer .composition');
this.initControls();
this.refresh();
},
refresh(){
@@ -669,24 +669,27 @@
console.log('CompoPlayer initControls()');
this.$composer = $('.composition_ui .composer');
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')
.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.$controls.addClass('ready');
this.active = true; // TODO: set active false
this.newCompo();
this.active = true; // TODO: set active false
this.newCompo();
}
},
newCompo(){
console.log('CompoPlayer newCompo()');
this.$compo = $('.composition_ui .composer .composition');
this.initControls();
this.refresh();
},
refresh(){