2017-03-30 17:00:35 +02:00
|
|
|
$(document).on('turbolinks:load', init_admin);
|
2016-07-20 11:38:19 +02:00
|
|
|
|
|
|
|
function init_admin(){
|
2017-04-04 16:15:33 +02:00
|
|
|
destroy_action();
|
|
|
|
on_change_type_de_champ_select();
|
2016-07-20 11:38:19 +02:00
|
|
|
}
|
2016-02-09 12:23:49 +01:00
|
|
|
|
|
|
|
function destroy_action(){
|
2017-04-04 16:15:33 +02:00
|
|
|
$(".delete").on('click', function(){
|
|
|
|
$(this).hide();
|
|
|
|
$(this).closest('td').find(".confirm").show();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".cancel").on('click', function(){
|
|
|
|
$(this).closest('td').find(".delete").show();
|
|
|
|
$(this).closest('td').find(".confirm").hide();
|
|
|
|
});
|
|
|
|
|
2017-04-12 11:12:05 +02:00
|
|
|
$("#liste-gestionnaire #libelle").on('click', function(){
|
2017-04-04 16:15:33 +02:00
|
|
|
setTimeout(destroy_action, 500);
|
|
|
|
});
|
2016-07-20 11:38:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function on_change_type_de_champ_select (){
|
2017-04-12 11:12:05 +02:00
|
|
|
$("select.form-control.type-champ").on('change', function(e){
|
2017-04-04 16:15:33 +02:00
|
|
|
|
|
|
|
parent = $(this).parent().parent();
|
|
|
|
|
2017-04-12 11:12:05 +02:00
|
|
|
parent.removeClass('header-section');
|
|
|
|
parent.children(".drop-down-list").removeClass('show-inline');
|
2018-04-09 16:24:56 +02:00
|
|
|
parent.children(".pj-template").removeClass('show-inline');
|
|
|
|
|
2017-04-04 16:15:33 +02:00
|
|
|
$('.mandatory', parent).show();
|
|
|
|
|
|
|
|
switch(this.value){
|
|
|
|
case 'header_section':
|
2017-04-12 11:12:05 +02:00
|
|
|
parent.addClass('header-section');
|
2017-04-04 16:15:33 +02:00
|
|
|
break;
|
|
|
|
case 'drop_down_list':
|
|
|
|
case 'multiple_drop_down_list':
|
2017-04-12 11:12:05 +02:00
|
|
|
parent.children(".drop-down-list").addClass('show-inline');
|
2017-04-04 16:15:33 +02:00
|
|
|
break;
|
2018-04-09 16:24:56 +02:00
|
|
|
case 'piece_justificative':
|
|
|
|
parent.children(".pj-template").addClass('show-inline');
|
|
|
|
break;
|
2017-04-04 16:15:33 +02:00
|
|
|
case 'explication':
|
|
|
|
$('.mandatory', parent).hide();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2016-11-23 16:17:29 +01:00
|
|
|
}
|