Skip to content

Commit

Permalink
fix(question): uniformuze question and section JS code
Browse files Browse the repository at this point in the history
to be continued when question design will be converted into twig
  • Loading branch information
btry committed Jan 31, 2022
1 parent 2d961c7 commit 4e997e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ajax/question_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
}

if (!$question->add($_REQUEST)) {
http_response_code(400);
http_response_code(500);
Session::addMessageAfterRedirect(__('Could not add the question', 'formcreator'), false, ERROR);
exit;
}
$json = [
Expand Down
4 changes: 3 additions & 1 deletion inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,9 @@ public function showForm($ID, $options = []) {

echo '<tr>';
echo '<td colspan="4" class="center">';
echo Html::hidden('id', ['value' => $ID]);
if ($ID > 0) {
echo Html::hidden('id', ['value' => $ID]);
}
echo Html::hidden('uuid', ['value' => $this->fields['uuid']]);
echo '</td>';
echo '</tr>';
Expand Down
4 changes: 1 addition & 3 deletions js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ var plugin_formcreator = new function() {
);
that.resetTabs();
});
glpi_close_all_dialogs();
}

this.editQuestion = function () {
Expand All @@ -724,7 +723,6 @@ var plugin_formcreator = new function() {
}).done(function(data) {
var question = $('.plugin_formcreator_form_design[data-itemtype="PluginFormcreatorForm"] [data-itemtype="PluginFormcreatorQuestion"][data-id="' + questionId + '"]');
question.find('[data-field="name"]').text(data['name'])
glpi_close_all_dialogs();
that.resetTabs();
});

Expand Down Expand Up @@ -1683,7 +1681,7 @@ function pluginFormcreatorInitializeUrgency(fieldName, rand) {
}

function plugin_formcreator_changeQuestionType(rand) {
var questionId = $('form[name="asset_form"][data-itemtype="PluginFormcreatorQuestion"] [name="id"]').val();
var questionId = $('form[name="asset_form"][data-itemtype="PluginFormcreatorQuestion"] [name="id"]').val() || 0;
var questionType = $('form[name="asset_form"][data-itemtype="PluginFormcreatorQuestion"] [name="fieldtype"]').val();

$.post({
Expand Down

0 comments on commit 4e997e5

Please sign in to comment.