@@ -813,6 +813,7 @@ function buildTiles(list) {
813
813
814
814
this.addQuestion = function () {
815
815
var form = $('form[data-itemtype="PluginFormcreatorQuestion"]');
816
+ var that = this;
816
817
$.ajax({
817
818
url: formcreatorRootDoc + '/ajax/question_add.php',
818
819
type: "POST",
@@ -839,12 +840,14 @@ function buildTiles(list) {
839
840
1
840
841
);
841
842
modalWindow.dialog('close');
843
+ that.resetTabs();
842
844
});
843
845
}
844
846
845
847
this.editQuestion = function () {
846
848
var form = $('form[data-itemtype="PluginFormcreatorQuestion"]');
847
849
var questionId = form.find('[name="id"]').val();
850
+ var that = this;
848
851
$.ajax({
849
852
url: formcreatorRootDoc + '/ajax/question_update.php',
850
853
type: "POST",
@@ -857,12 +860,14 @@ function buildTiles(list) {
857
860
var question = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorQuestion"][data-id="' + questionId + '"]');
858
861
question.find('[data-field="name"]').text(data)
859
862
modalWindow.dialog('close');
863
+ that.resetTabs();
860
864
});
861
865
}
862
866
863
867
this.duplicateQuestion = function (target) {
864
868
var item = $(target).closest('.grid-stack-item');
865
869
var id = item.attr('data-id');
870
+ var that = this;
866
871
if (typeof(id) === 'undefined') {
867
872
return;
868
873
}
@@ -891,6 +896,7 @@ function buildTiles(list) {
891
896
1,
892
897
1
893
898
);
899
+ that.resetTabs();
894
900
});
895
901
};
896
902
@@ -945,6 +951,7 @@ function buildTiles(list) {
945
951
if(confirm("<?php echo Toolbox::addslashes_deep (__ ('Are you sure you want to delete this section? ' , 'formcreator ' )); ?> ")) {
946
952
var section = $(item).closest('#plugin_formcreator_form.plugin_formcreator_form_design [data-itemtype="PluginFormcreatorSection"]');
947
953
var sectionId = section.attr('data-id');
954
+ var that = this;
948
955
$.ajax({
949
956
url: formcreatorRootDoc + '/ajax/section_delete.php',
950
957
type: "POST",
@@ -954,6 +961,7 @@ function buildTiles(list) {
954
961
}).done(function() {
955
962
section.remove();
956
963
plugin_formcreator.updateSectionControls();
964
+ that.resetTabs();
957
965
}).fail(function(data) {
958
966
alert(data.responseText);
959
967
});
@@ -1005,6 +1013,7 @@ function buildTiles(list) {
1005
1013
this.duplicateSection = function (item) {
1006
1014
var section = $(item).closest('#plugin_formcreator_form.plugin_formcreator_form_design [data-itemtype="PluginFormcreatorSection"]');
1007
1015
var sectionId = section.attr('data-id');
1016
+ var that = this;
1008
1017
$.ajax({
1009
1018
url: formcreatorRootDoc + '/ajax/section_duplicate.php',
1010
1019
type: "POST",
@@ -1018,6 +1027,7 @@ function buildTiles(list) {
1018
1027
sectionId = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorSection"]').last().attr('data-id');
1019
1028
plugin_formcreator.initGridStack(sectionId);
1020
1029
plugin_formcreator.updateSectionControls();
1030
+ that.resetTabs();
1021
1031
}).fail(function(data) {
1022
1032
alert(data.responseText);
1023
1033
});
@@ -1035,6 +1045,7 @@ function buildTiles(list) {
1035
1045
1036
1046
this.addSection = function () {
1037
1047
var form = $('form[data-itemtype="PluginFormcreatorSection"]');
1048
+ var that = this;
1038
1049
$.ajax({
1039
1050
url: formcreatorRootDoc + '/ajax/section_add.php',
1040
1051
type: "POST",
@@ -1049,12 +1060,14 @@ function buildTiles(list) {
1049
1060
plugin_formcreator.initGridStack(sectionId);
1050
1061
plugin_formcreator.updateSectionControls();
1051
1062
modalWindow.dialog('close');
1063
+ that.resetTabs();
1052
1064
});
1053
1065
}
1054
1066
1055
1067
this.editSection = function () {
1056
1068
var form = $('form[data-itemtype="PluginFormcreatorSection"]');
1057
1069
var sectionId = form.find('[name="id"]').val();
1070
+ var that = this;
1058
1071
$.ajax({
1059
1072
url: formcreatorRootDoc + '/ajax/section_update.php',
1060
1073
type: "POST",
@@ -1066,6 +1079,7 @@ function buildTiles(list) {
1066
1079
var section = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorSection"][data-id="' + sectionId + '"]');
1067
1080
section.find('> [data-field="name"]').text(data);
1068
1081
modalWindow.dialog('close');
1082
+ that.resetTabs();
1069
1083
});
1070
1084
}
1071
1085
@@ -1101,6 +1115,20 @@ function buildTiles(list) {
1101
1115
}
1102
1116
);
1103
1117
}
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
+ }
1104
1132
}
1105
1133
1106
1134
// === TARGETS ===
0 commit comments