diff --git a/css/backoffice/pages/_all.scss b/css/backoffice/pages/_all.scss
index 513923a5b..90ffc7679 100644
--- a/css/backoffice/pages/_all.scss
+++ b/css/backoffice/pages/_all.scss
@@ -1,25 +1,11 @@
/*!
- * Copyright (C) 2013-2020 Combodo SARL
- *
- * This file is part of iTop.
- *
- * iTop is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * iTop is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
+ * @copyright Copyright (C) 2010-2021 Combodo SARL
+ * @license http://opensource.org/licenses/AGPL-3.0
*/
@import "base";
@import "preferences";
@import "attachments";
-@import "tabularfieldsselector";
@import "impact-analysis";
@import "audit";
@import "data-synchro";
\ No newline at end of file
diff --git a/css/backoffice/pages/_tabularfieldsselector.scss b/css/backoffice/pages/_tabularfieldsselector.scss
deleted file mode 100644
index e550608fa..000000000
--- a/css/backoffice/pages/_tabularfieldsselector.scss
+++ /dev/null
@@ -1,35 +0,0 @@
-/*!
- * @copyright Copyright (C) 2010-2021 Combodo SARL
- * @license http://opensource.org/licenses/AGPL-3.0
- */
-
-.ibo-table-preview {
- margin-top: 20px;
-
- th {
- padding: 5px;
- border-width: 1px 1px 0;
- border-style: groove groove none;
- background: $ibo-body-background-color;
- }
-
- td {
- padding-right: 5px;
- padding-left: 5px;
- border-width: 0 1px;
- border-style: none groove;
- }
-
- tr:last-child td {
- border-bottom-width: 1px;
- border-bottom-style: groove;
- }
-}
-
-.ibo-preview-header {
- margin-bottom: 5px;
-}
-
-#form_part_interactive_fields_xlsx, #form_part_interactive_fields_csv, #form_part_interactive_fields_pdf {
- margin-top: $ibo-panel--spacing-top;
-}
diff --git a/js/tabularfieldsselector.js b/js/tabularfieldsselector.js
index 86a6f81cf..7fb2a0894 100644
--- a/js/tabularfieldsselector.js
+++ b/js/tabularfieldsselector.js
@@ -1,68 +1,72 @@
+/*
+ * @copyright Copyright (C) 2010-2021 Combodo SARL
+ * @license http://opensource.org/licenses/AGPL-3.0
+ */
+
// jQuery UI style "widget" for managing the "xlsx-exporter"
-$(function()
-{
+$(function () {
// the widget definition, where "itop" is the namespace,
// "tabularfieldsselector" the widget name
- $.widget( "itop.tabularfieldsselector",
- {
- // default options
- options:
+ $.widget("itop.tabularfieldsselector",
{
- fields: [],
- value_holder: '#tabular_fields',
- sample_data: [],
- total_count: 0,
- preview_limit: 3,
- labels: {
- preview_header: "Drag and drop the columns to change their order. Preview of %1$s lines. Total number of lines to export: %2$s",
- empty_preview: "Select the columns to be exported from the list above",
- columns_order: "Columns order",
- columns_selection: 'Available columns from %1$s',
- check_all: 'Check all',
- uncheck_all: 'Uncheck all',
- no_field_selected: 'Select at least one column to be exported'
- }
- },
+ // default options
+ options:
+ {
+ fields: [],
+ value_holder: '#tabular_fields',
+ sample_data: [],
+ total_count: 0,
+ preview_limit: 3,
+ labels: {
+ preview_header: "Drag and drop the columns to change their order. Preview of %1$s lines. Total number of lines to export: %2$s",
+ empty_preview: "Select the columns to be exported from the list above",
+ columns_order: "Columns order",
+ columns_selection: 'Available columns from %1$s',
+ check_all: 'Check all',
+ uncheck_all: 'Uncheck all',
+ no_field_selected: 'Select at least one column to be exported'
+ }
+ },
- // the constructor
- _create: function () {
- var me = this;
- this._flatten_fields(this.options.fields);
- this.sId = this.element.attr('id');
- this.element.addClass('itop-tabularfieldsselector');
- this.element.parent().bind('form-part-activate', function () {
- me._update_from_holder();
- me._update_preview();
- });
- this.element.parent().bind('validate', function () {
- me.validate();
- });
+ // the constructor
+ _create: function () {
+ var me = this;
+ this._flatten_fields(this.options.fields);
+ this.sId = this.element.attr('id');
+ this.element.addClass('itop-tabularfieldsselector');
+ this.element.parent().bind('form-part-activate', function () {
+ me._update_from_holder();
+ me._update_preview();
+ });
+ this.element.parent().bind('validate', function () {
+ me.validate();
+ });
- this.aSelected = [];
+ this.aSelected = [];
- for (var i in this.options.fields) {
- var sContent = `
+ for (var i in this.options.fields) {
+ var sContent = `
';
+ this.element.append(sContent);
- this._update_from_holder();
+ this._update_from_holder();
- $('body').on('click change', '.tfs_checkbox', function () {
- var sInstanceId = $(this).attr('data-instance-id');
- if (sInstanceId != me.sId) {
- return;
- }
- me._on_click($(this));
- });
+ $('body').on('click change', '.tfs_checkbox', function () {
+ var sInstanceId = $(this).attr('data-instance-id');
+ if (sInstanceId != me.sId) {
+ return;
+ }
+ me._on_click($(this));
+ });
- var maxWidth = 0;
- $('#'+this.sId+' .tfs_checkbox, #'+this.sId+' .tfs_checkbox_multi').each(function () {
- maxWidth = Math.max(maxWidth, $(this).parent().width());
- });
- $('#'+this.sId+' .tfs_checkbox, #'+this.sId+' .tfs_checkbox_multi').each(function () {
- $(this).parent().parent().width(maxWidth).css({display: 'inline-block'});
- });
+ var maxWidth = 0;
+ $('#'+this.sId+' .tfs_checkbox, #'+this.sId+' .tfs_checkbox_multi').each(function () {
+ maxWidth = Math.max(maxWidth, $(this).parent().width());
+ });
+ $('#'+this.sId+' .tfs_checkbox, #'+this.sId+' .tfs_checkbox_multi').each(function () {
+ $(this).parent().parent().width(maxWidth).css({display: 'inline-block'});
+ });
- $('#'+this.sId+' .tfs_checkbox_multi').click(function () {
- me._on_multi_click($(this).val(), this.checked);
- });
- $('#'+this.sId+' .check_all').click(function () {
- me._on_check_all($(this).closest('.ibo-panel'), true);
- });
- $('#'+this.sId+' .uncheck_all').click(function () {
- me._on_check_all($(this).closest('.ibo-panel'), false);
- });
+ $('#'+this.sId+' .tfs_checkbox_multi').click(function () {
+ me._on_multi_click($(this).val(), this.checked);
+ });
+ $('#'+this.sId+' .check_all').click(function () {
+ me._on_check_all($(this).closest('.ibo-panel'), true);
+ });
+ $('#'+this.sId+' .uncheck_all').click(function () {
+ me._on_check_all($(this).closest('.ibo-panel'), false);
+ });
- this._update_preview();
- this._make_tooltips();
- },
- _on_click: function (jItemClicked) {
+ this._update_preview();
+ this._make_tooltips();
+ },
+ _on_click: function (jItemClicked) {
- var bChecked = jItemClicked.prop('checked');
- var sValue = jItemClicked.val();
- this._mark_as_selected(sValue, bChecked);
- this._update_holder();
- this._update_preview();
- var sDataParent = jItemClicked.attr('data-parent');
- if (sDataParent != '') {
- this._update_tristate(sDataParent+'_multi');
- }
- },
- _on_multi_click: function (sMultiFieldCode, bChecked) {
- var oField = this._get_main_field_by_code(sMultiFieldCode);
- if (oField != null) {
- var sPrefix = '#tfs_'+this.sId+'_';
- for (var k in oField.subattr) {
- this._mark_as_selected(oField.subattr[k].code, bChecked);
- // In case the tooltip is visible, also update the checkboxes
- sElementId = (sPrefix+oField.subattr[k].code).replace('.', '_');
- $(sElementId).prop('checked', bChecked);
- }
+ var bChecked = jItemClicked.prop('checked');
+ var sValue = jItemClicked.val();
+ this._mark_as_selected(sValue, bChecked);
this._update_holder();
this._update_preview();
- }
- },
- _on_check_all: function (jSelector, bChecked) {
- var me = this;
- jSelector.find('.tfs_checkbox').each(function () {
- $(this).prop('checked', bChecked);
- me._mark_as_selected($(this).val(), bChecked);
- });
- jSelector.find('.tfs_checkbox_multi').each(function () {
- var oField = me._get_main_field_by_code($(this).val());
+ var sDataParent = jItemClicked.attr('data-parent');
+ if (sDataParent != '') {
+ this._update_tristate(sDataParent+'_multi');
+ }
+ },
+ _on_multi_click: function (sMultiFieldCode, bChecked) {
+ var oField = this._get_main_field_by_code(sMultiFieldCode);
if (oField != null) {
- $(this).prop('checked', bChecked);
- $(this).prop('indeterminate', false);
var sPrefix = '#tfs_'+this.sId+'_';
for (var k in oField.subattr) {
- me._mark_as_selected(oField.subattr[k].code, bChecked);
+ this._mark_as_selected(oField.subattr[k].code, bChecked);
// In case the tooltip is visible, also update the checkboxes
sElementId = (sPrefix+oField.subattr[k].code).replace('.', '_');
$(sElementId).prop('checked', bChecked);
}
- }
- });
- this._update_holder();
- this._update_preview();
- },
- _update_tristate: function (sParentId) {
- // Check if the parent is checked, unchecked or indeterminate
- var sParentId = sParentId.replace('.', '_');
- var sAttCode = $('#'+sParentId).val();
- var oField = this._get_main_field_by_code(sAttCode);
- if (oField != null) {
- var iNbChecked = 0;
- var aDebug = [];
- for (var j in oField.subattr) {
- if ($.inArray(oField.subattr[j].code, this.aSelected) != -1) {
- aDebug.push(oField.subattr[j].code);
- iNbChecked++;
- }
- }
- if (iNbChecked == oField.subattr.length) {
- $('#'+sParentId).prop('checked', true);
- $('#'+sParentId).prop('indeterminate', false);
- } else if (iNbChecked == 0) {
- $('#'+sParentId).prop('checked', false);
- $('#'+sParentId).prop('indeterminate', false);
- } else {
- $('#'+sParentId).prop('checked', false);
- $('#'+sParentId).prop('indeterminate', true);
- }
- }
- },
- _mark_as_selected: function (sValue, bSelected) {
- if (bSelected) {
- if ($.inArray(sValue, this.aSelected) == -1) {
- this.aSelected.push(sValue);
- }
- } else {
- aSelected = [];
- for (var k in this.aSelected) {
- if (this.aSelected[k] != sValue) {
- aSelected.push(this.aSelected[k]);
- }
- }
- this.aSelected = aSelected;
- }
- },
- _update_holder: function () {
- $(this.options.value_holder).val(this.aSelected.join(','));
- },
- _update_from_holder: function () {
- var sFields = $(this.options.value_holder).val();
- var bAdvanced = parseInt($(this.options.advanced_holder).val(), 10);
-
- if (sFields != '') {
- this.aSelected = sFields.split(',');
- var safeSelected = [];
- var me = this;
- var bModified = false;
- for (var k in this.aSelected) {
- var oField = this._get_field_by_code(this.aSelected[k])
- if (oField == null) {
- // Invalid field code supplied, don't copy it
- bModified = true;
- } else {
- safeSelected.push(this.aSelected[k]);
- }
- }
- if (bModified) {
- this.aSelected = safeSelected;
this._update_holder();
+ this._update_preview();
}
- $('#'+this.sId+' .tfs_checkbox').each(function () {
- if ($.inArray($(this).val(), me.aSelected) != -1) {
- $(this).prop('checked', true);
- } else {
- $(this).prop('checked', false);
+ },
+ _on_check_all: function (jSelector, bChecked) {
+ var me = this;
+ jSelector.find('.tfs_checkbox').each(function () {
+ $(this).prop('checked', bChecked);
+ me._mark_as_selected($(this).val(), bChecked);
+ });
+ jSelector.find('.tfs_checkbox_multi').each(function () {
+ var oField = me._get_main_field_by_code($(this).val());
+ if (oField != null) {
+ $(this).prop('checked', bChecked);
+ $(this).prop('indeterminate', false);
+ var sPrefix = '#tfs_'+this.sId+'_';
+ for (var k in oField.subattr) {
+ me._mark_as_selected(oField.subattr[k].code, bChecked);
+ // In case the tooltip is visible, also update the checkboxes
+ sElementId = (sPrefix+oField.subattr[k].code).replace('.', '_');
+ $(sElementId).prop('checked', bChecked);
+ }
}
});
- }
- var me = this;
- $('#'+this.sId+' .tfs_checkbox_multi').each(function () {
- me._update_tristate($(this).attr('id'));
- });
-
- },
- _update_preview: function () {
- var sHtml = '';
- if (this.aSelected.length > 0) {
- sHtml += '
';
- for (var k in this.aSelected) {
- var sField = this.aSelected[k];
- if ($.inArray(sField, this.aSelected) != -1) {
- var sRemoveBtn = ' ×';
- sHtml += '