Skip to content

Commit 75d6768

Browse files
committed
fix: reset obsoleted tabs
Signed-off-by: Thierry Bugier <[email protected]>
1 parent f5d9e5c commit 75d6768

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

js/scripts.js.php

+28
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ function buildTiles(list) {
813813

814814
this.addQuestion = function () {
815815
var form = $('form[data-itemtype="PluginFormcreatorQuestion"]');
816+
var that = this;
816817
$.ajax({
817818
url: formcreatorRootDoc + '/ajax/question_add.php',
818819
type: "POST",
@@ -839,12 +840,14 @@ function buildTiles(list) {
839840
1
840841
);
841842
modalWindow.dialog('close');
843+
that.resetTabs();
842844
});
843845
}
844846

845847
this.editQuestion = function () {
846848
var form = $('form[data-itemtype="PluginFormcreatorQuestion"]');
847849
var questionId = form.find('[name="id"]').val();
850+
var that = this;
848851
$.ajax({
849852
url: formcreatorRootDoc + '/ajax/question_update.php',
850853
type: "POST",
@@ -857,12 +860,14 @@ function buildTiles(list) {
857860
var question = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorQuestion"][data-id="' + questionId + '"]');
858861
question.find('[data-field="name"]').text(data)
859862
modalWindow.dialog('close');
863+
that.resetTabs();
860864
});
861865
}
862866

863867
this.duplicateQuestion = function (target) {
864868
var item = $(target).closest('.grid-stack-item');
865869
var id = item.attr('data-id');
870+
var that = this;
866871
if (typeof(id) === 'undefined') {
867872
return;
868873
}
@@ -891,6 +896,7 @@ function buildTiles(list) {
891896
1,
892897
1
893898
);
899+
that.resetTabs();
894900
});
895901
};
896902

@@ -945,6 +951,7 @@ function buildTiles(list) {
945951
if(confirm("<?php echo Toolbox::addslashes_deep(__('Are you sure you want to delete this section?', 'formcreator')); ?> ")) {
946952
var section = $(item).closest('#plugin_formcreator_form.plugin_formcreator_form_design [data-itemtype="PluginFormcreatorSection"]');
947953
var sectionId = section.attr('data-id');
954+
var that = this;
948955
$.ajax({
949956
url: formcreatorRootDoc + '/ajax/section_delete.php',
950957
type: "POST",
@@ -954,6 +961,7 @@ function buildTiles(list) {
954961
}).done(function() {
955962
section.remove();
956963
plugin_formcreator.updateSectionControls();
964+
that.resetTabs();
957965
}).fail(function(data) {
958966
alert(data.responseText);
959967
});
@@ -1005,6 +1013,7 @@ function buildTiles(list) {
10051013
this.duplicateSection = function (item) {
10061014
var section = $(item).closest('#plugin_formcreator_form.plugin_formcreator_form_design [data-itemtype="PluginFormcreatorSection"]');
10071015
var sectionId = section.attr('data-id');
1016+
var that = this;
10081017
$.ajax({
10091018
url: formcreatorRootDoc + '/ajax/section_duplicate.php',
10101019
type: "POST",
@@ -1018,6 +1027,7 @@ function buildTiles(list) {
10181027
sectionId = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorSection"]').last().attr('data-id');
10191028
plugin_formcreator.initGridStack(sectionId);
10201029
plugin_formcreator.updateSectionControls();
1030+
that.resetTabs();
10211031
}).fail(function(data) {
10221032
alert(data.responseText);
10231033
});
@@ -1035,6 +1045,7 @@ function buildTiles(list) {
10351045

10361046
this.addSection = function () {
10371047
var form = $('form[data-itemtype="PluginFormcreatorSection"]');
1048+
var that = this;
10381049
$.ajax({
10391050
url: formcreatorRootDoc + '/ajax/section_add.php',
10401051
type: "POST",
@@ -1049,12 +1060,14 @@ function buildTiles(list) {
10491060
plugin_formcreator.initGridStack(sectionId);
10501061
plugin_formcreator.updateSectionControls();
10511062
modalWindow.dialog('close');
1063+
that.resetTabs();
10521064
});
10531065
}
10541066

10551067
this.editSection = function () {
10561068
var form = $('form[data-itemtype="PluginFormcreatorSection"]');
10571069
var sectionId = form.find('[name="id"]').val();
1070+
var that = this;
10581071
$.ajax({
10591072
url: formcreatorRootDoc + '/ajax/section_update.php',
10601073
type: "POST",
@@ -1066,6 +1079,7 @@ function buildTiles(list) {
10661079
var section = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorSection"][data-id="' + sectionId + '"]');
10671080
section.find('> [data-field="name"]').text(data);
10681081
modalWindow.dialog('close');
1082+
that.resetTabs();
10691083
});
10701084
}
10711085

@@ -1101,6 +1115,20 @@ function buildTiles(list) {
11011115
}
11021116
);
11031117
}
1118+
1119+
/**
1120+
* Put a spinner inside the given selector
1121+
*/
1122+
this.showSpinner = function (selector) {
1123+
return $(selector).html('<img class="plugin_formcreator_spinner" src="../../../pics/spinner.48.gif">');
1124+
}
1125+
1126+
/**
1127+
* destroy hidden tabs. Useful when their content is obsoleted
1128+
*/
1129+
this.resetTabs = function () {
1130+
$('.glpi_tabs [role="tabpanel"][aria-hidden="true"] ').empty();
1131+
}
11041132
}
11051133

11061134
// === TARGETS ===

0 commit comments

Comments
 (0)