diff --git a/ajax/form_toggle.php b/ajax/form_toggle.php new file mode 100644 index 000000000..4402666f2 --- /dev/null +++ b/ajax/form_toggle.php @@ -0,0 +1,44 @@ +. + * --------------------------------------------------------------------- + * @copyright Copyright © 2011 - 2021 Teclib' + * @license http://www.gnu.org/licenses/gpl.txt GPLv3+ + * @link https://github.com/pluginsGLPI/formcreator/ + * @link https://pluginsglpi.github.io/formcreator/ + * @link http://plugins.glpi-project.org/#/plugin/formcreator + * --------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); +Session::checkRight('entity', UPDATE); + +$form = new PluginFormcreatorForm(); + +$success = $form->update([ + 'id' => $_POST['id'], + 'toggle' => 'toggle', +]); + +if (!$success) { + http_response_code(500); +} \ No newline at end of file diff --git a/css/styles.css b/css/styles.css index 4ff900acc..d5facbffe 100644 --- a/css/styles.css +++ b/css/styles.css @@ -1589,10 +1589,12 @@ span.fc_list_icon { /* Active / inactive light for forms */ .plugin-forcreator-active { + cursor: pointer; color: #009933; } .plugin-forcreator-inactive { + cursor: pointer; color: #a0a0a0; } diff --git a/inc/form.class.php b/inc/form.class.php index 29027ba41..017a92fbd 100644 --- a/inc/form.class.php +++ b/inc/form.class.php @@ -338,7 +338,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options $output = ''; - $output = '
' . $output . '
'; + $output = '
' . $output . '
'; return $output; break; @@ -1400,6 +1400,14 @@ public function post_updateItem($history = 1) { * @return array the modified $input array */ public function prepareInputForUpdate($input) { + if (isset($input['toggle'])) { + // Enable / disable form + return [ + 'id' => $input['id'], + 'is_active' => $this->fields['is_active'] == '0' ? '1' : '0', + ]; + } + if (isset($input['access_rights']) || isset($_POST['massiveaction']) || isset($input['usage_count'])) { diff --git a/js/scripts.js.php b/js/scripts.js.php index 628d245d1..97dc45222 100644 --- a/js/scripts.js.php +++ b/js/scripts.js.php @@ -1061,6 +1061,19 @@ function buildTiles(list) { sections.find('.moveDown').show(); sections.last().find('.moveDown').hide(); } + + this.toggleForm = function (id) { + $.ajax({ + url: formcreatorRootDoc + '/ajax/form_toggle.php', + type: 'POST', + data: { + toggle: 'toggle', + id: id + } + }).success(function () { + location.reload(); + }); + } } // === TARGETS ===