7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2012 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Configure = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var columnDefs; |
7604 |
25 Feb 19 |
nicklas |
var currentColumns; |
7982 |
14 Jun 21 |
nicklas |
var currentStickyColumn; |
7604 |
25 Feb 19 |
nicklas |
31 |
|
7604 |
25 Feb 19 |
nicklas |
var configure = {}; |
7604 |
25 Feb 19 |
nicklas |
33 |
|
7604 |
25 Feb 19 |
nicklas |
34 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
36 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
38 |
{ |
7604 |
25 Feb 19 |
nicklas |
var tableId = Data.get('page-data', 'table-id'); |
7604 |
25 Feb 19 |
nicklas |
40 |
|
7604 |
25 Feb 19 |
nicklas |
// Load default and currently visible columns |
7604 |
25 Feb 19 |
nicklas |
columnDefs = window.opener.Table.getColumnDefs(tableId); |
7604 |
25 Feb 19 |
nicklas |
currentColumns = window.opener.Table.getColumns(tableId); |
7982 |
14 Jun 21 |
nicklas |
currentStickyColumn = window.opener.Table.getStickyColumn(tableId); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
// Initialize the visible and hidden columns lists |
7982 |
14 Jun 21 |
nicklas |
configure.initColumns(currentColumns, currentStickyColumn); |
7604 |
25 Feb 19 |
nicklas |
48 |
|
7604 |
25 Feb 19 |
nicklas |
// Buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', configure.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSavePreset', configure.savePresetAs); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('presets', 'change', configure.presetOnChange); |
7604 |
25 Feb 19 |
nicklas |
if (Doc.element('selectAnnotationTypes')) |
7604 |
25 Feb 19 |
nicklas |
55 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('selectAnnotationTypes', configure.selectAnnotationTypes); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('selectAnnotationTypes', 'base-selected', configure.annotationTypeSelected); |
7604 |
25 Feb 19 |
nicklas |
58 |
} |
7842 |
01 Sep 20 |
nicklas |
if (Doc.element('selectRelatedItemColumn')) |
7773 |
17 Feb 20 |
nicklas |
60 |
{ |
7842 |
01 Sep 20 |
nicklas |
Buttons.addClickHandler('selectRelatedItemColumn', configure.selectRelatedItemColumn); |
7842 |
01 Sep 20 |
nicklas |
Events.addEventHandler('selectRelatedItemColumn', 'base-selected', configure.relatedItemColumnSelected); |
7773 |
17 Feb 20 |
nicklas |
63 |
} |
7851 |
14 Oct 20 |
nicklas |
if (Doc.element('selectLinkedItemColumn')) |
7851 |
14 Oct 20 |
nicklas |
65 |
{ |
7851 |
14 Oct 20 |
nicklas |
Buttons.addClickHandler('selectLinkedItemColumn', configure.selectLinkedItemColumn); |
7851 |
14 Oct 20 |
nicklas |
Events.addEventHandler('selectLinkedItemColumn', 'base-selected', configure.linkedItemColumnSelected); |
7851 |
14 Oct 20 |
nicklas |
68 |
} |
7604 |
25 Feb 19 |
nicklas |
69 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('moveUp', configure.moveVisibleUpOrDown); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('moveDown', configure.moveVisibleUpOrDown); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('moveLeft', configure.moveToVisible); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('moveRight', configure.moveToHidden); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('visible', 'dblclick', configure.moveToHidden); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('hidden', 'dblclick', configure.moveToVisible); |
7604 |
25 Feb 19 |
nicklas |
76 |
} |
7604 |
25 Feb 19 |
nicklas |
77 |
|
7604 |
25 Feb 19 |
nicklas |
78 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the visible and hidden columns lists. |
7604 |
25 Feb 19 |
nicklas |
@param columns A comma-separated string with visible columns |
7604 |
25 Feb 19 |
nicklas |
81 |
*/ |
7982 |
14 Jun 21 |
nicklas |
configure.initColumns = function(columns, stickyColumn) |
7604 |
25 Feb 19 |
nicklas |
83 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['columns']; |
7982 |
14 Jun 21 |
nicklas |
// Remove all entries from the 'visible', 'hidden' and 'sticky' lists |
7604 |
25 Feb 19 |
nicklas |
var visible = frm.visible; |
7604 |
25 Feb 19 |
nicklas |
var hidden = frm.hidden; |
7982 |
14 Jun 21 |
nicklas |
var sticky = frm.sticky; |
7604 |
25 Feb 19 |
nicklas |
visible.length = 0; |
7604 |
25 Feb 19 |
nicklas |
hidden.length = 0; |
7982 |
14 Jun 21 |
nicklas |
if (sticky) |
7982 |
14 Jun 21 |
nicklas |
92 |
{ |
7982 |
14 Jun 21 |
nicklas |
sticky.length = 0; |
7982 |
14 Jun 21 |
nicklas |
sticky[0] = new Option('- none -', '_'); |
7982 |
14 Jun 21 |
nicklas |
95 |
} |
7604 |
25 Feb 19 |
nicklas |
96 |
|
7604 |
25 Feb 19 |
nicklas |
// The visibled columns (comma-separated) |
7604 |
25 Feb 19 |
nicklas |
var allVisible = columns == 'all'; |
7604 |
25 Feb 19 |
nicklas |
var visibleCols = columns.split(','); |
7604 |
25 Feb 19 |
nicklas |
100 |
|
7604 |
25 Feb 19 |
nicklas |
// Put all column in the hidden or visible list |
7604 |
25 Feb 19 |
nicklas |
var toList = allVisible ? visible : hidden; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < columnDefs.length; i++) |
7604 |
25 Feb 19 |
nicklas |
104 |
{ |
7604 |
25 Feb 19 |
nicklas |
var col = columnDefs[i]; |
7982 |
14 Jun 21 |
nicklas |
if (!col.alwaysHide) |
7982 |
14 Jun 21 |
nicklas |
107 |
{ |
7982 |
14 Jun 21 |
nicklas |
configure.addColumn(toList, col); |
7982 |
14 Jun 21 |
nicklas |
if (sticky) |
7982 |
14 Jun 21 |
nicklas |
110 |
{ |
7982 |
14 Jun 21 |
nicklas |
configure.addColumn(sticky, col); |
7982 |
14 Jun 21 |
nicklas |
if (col.id == stickyColumn) sticky.selectedIndex = sticky.length-1; |
7982 |
14 Jun 21 |
nicklas |
113 |
} |
7982 |
14 Jun 21 |
nicklas |
114 |
} |
7604 |
25 Feb 19 |
nicklas |
115 |
} |
7604 |
25 Feb 19 |
nicklas |
116 |
|
7604 |
25 Feb 19 |
nicklas |
// Move visible columns to the visible list |
7604 |
25 Feb 19 |
nicklas |
if (!allVisible) |
7604 |
25 Feb 19 |
nicklas |
119 |
{ |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < visibleCols.length; i++) |
7604 |
25 Feb 19 |
nicklas |
121 |
{ |
7604 |
25 Feb 19 |
nicklas |
var colId = visibleCols[i]; |
7604 |
25 Feb 19 |
nicklas |
var col = columnDefs['id'+colId]; |
7604 |
25 Feb 19 |
nicklas |
for (var j = 0; j < hidden.length; j++) |
7604 |
25 Feb 19 |
nicklas |
125 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (hidden[j].value == colId) |
7604 |
25 Feb 19 |
nicklas |
127 |
{ |
7604 |
25 Feb 19 |
nicklas |
configure.addColumn(visible, col); |
7604 |
25 Feb 19 |
nicklas |
hidden[j] = null; |
7604 |
25 Feb 19 |
nicklas |
j = hidden.length; |
7604 |
25 Feb 19 |
nicklas |
131 |
} |
7604 |
25 Feb 19 |
nicklas |
132 |
} |
7604 |
25 Feb 19 |
nicklas |
133 |
} |
7604 |
25 Feb 19 |
nicklas |
134 |
|
7604 |
25 Feb 19 |
nicklas |
// Move columns that must be visible to the visible list |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < hidden.length; i++) |
7604 |
25 Feb 19 |
nicklas |
137 |
{ |
7604 |
25 Feb 19 |
nicklas |
var col = columnDefs['id'+hidden.options[i].value]; |
7604 |
25 Feb 19 |
nicklas |
if (col && col.alwaysShow) |
7604 |
25 Feb 19 |
nicklas |
140 |
{ |
7604 |
25 Feb 19 |
nicklas |
configure.addColumn(visible, col); |
7604 |
25 Feb 19 |
nicklas |
hidden[i] = null; |
7604 |
25 Feb 19 |
nicklas |
i--; |
7604 |
25 Feb 19 |
nicklas |
144 |
} |
7604 |
25 Feb 19 |
nicklas |
145 |
} |
7604 |
25 Feb 19 |
nicklas |
146 |
} |
7604 |
25 Feb 19 |
nicklas |
147 |
|
7604 |
25 Feb 19 |
nicklas |
148 |
} |
7604 |
25 Feb 19 |
nicklas |
149 |
|
7604 |
25 Feb 19 |
nicklas |
150 |
/** |
7604 |
25 Feb 19 |
nicklas |
Add a column to a list control. |
7604 |
25 Feb 19 |
nicklas |
152 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.addColumn = function(list, column) |
7604 |
25 Feb 19 |
nicklas |
154 |
{ |
7604 |
25 Feb 19 |
nicklas |
var option = new Option(column.title, column.id); |
7604 |
25 Feb 19 |
nicklas |
option.title = column.title; |
7982 |
14 Jun 21 |
nicklas |
if (column.alwaysShow && list.multiple) |
7604 |
25 Feb 19 |
nicklas |
158 |
{ |
7604 |
25 Feb 19 |
nicklas |
option.style.fontWeight = 'bold'; |
7604 |
25 Feb 19 |
nicklas |
option.text = option.text+' ×'; |
7604 |
25 Feb 19 |
nicklas |
161 |
} |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = option; |
7604 |
25 Feb 19 |
nicklas |
163 |
} |
7604 |
25 Feb 19 |
nicklas |
164 |
|
7604 |
25 Feb 19 |
nicklas |
165 |
/** |
7604 |
25 Feb 19 |
nicklas |
Event handler that updates the visible and hidden columns lists |
7604 |
25 Feb 19 |
nicklas |
with the seleted preset. |
7604 |
25 Feb 19 |
nicklas |
168 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.presetOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
170 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['columns']; |
7604 |
25 Feb 19 |
nicklas |
var presets = frm.presets; |
7604 |
25 Feb 19 |
nicklas |
var columns = presets.value; |
7982 |
14 Jun 21 |
nicklas |
var stickyColumn = Data.get(presets[presets.selectedIndex], 'sticky-column'); |
7604 |
25 Feb 19 |
nicklas |
if (columns == '') return; |
7982 |
14 Jun 21 |
nicklas |
if (columns == '_default_') |
7982 |
14 Jun 21 |
nicklas |
177 |
{ |
7982 |
14 Jun 21 |
nicklas |
columns = Data.get('page-data', 'default-columns'); |
7982 |
14 Jun 21 |
nicklas |
stickyColumn = Data.get('page-data', 'default-sticky'); |
7982 |
14 Jun 21 |
nicklas |
180 |
} |
7982 |
14 Jun 21 |
nicklas |
if (columns == '_current_') |
7982 |
14 Jun 21 |
nicklas |
182 |
{ |
7982 |
14 Jun 21 |
nicklas |
columns = currentColumns; |
7982 |
14 Jun 21 |
nicklas |
stickyColumn = currentStickyColumn; |
7982 |
14 Jun 21 |
nicklas |
185 |
} |
7604 |
25 Feb 19 |
nicklas |
if (columns == '_minimal_') |
7604 |
25 Feb 19 |
nicklas |
187 |
{ |
7604 |
25 Feb 19 |
nicklas |
var temp = []; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < columnDefs.length; i++) |
7604 |
25 Feb 19 |
nicklas |
190 |
{ |
7604 |
25 Feb 19 |
nicklas |
var col = columnDefs[i]; |
7604 |
25 Feb 19 |
nicklas |
if (col.alwaysShow) temp[temp.length] = col.id; |
7604 |
25 Feb 19 |
nicklas |
193 |
} |
7604 |
25 Feb 19 |
nicklas |
columns = temp.join(','); |
7604 |
25 Feb 19 |
nicklas |
195 |
} |
7982 |
14 Jun 21 |
nicklas |
if (stickyColumn == null && frm.sticky) stickyColumn = frm.sticky.value; |
7982 |
14 Jun 21 |
nicklas |
configure.initColumns(columns, stickyColumn); |
7604 |
25 Feb 19 |
nicklas |
presets.selectedIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
199 |
} |
7604 |
25 Feb 19 |
nicklas |
200 |
|
7604 |
25 Feb 19 |
nicklas |
201 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog that saves the current visible columns as a preset. |
7604 |
25 Feb 19 |
nicklas |
203 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.savePresetAs = function() |
7604 |
25 Feb 19 |
nicklas |
205 |
{ |
7604 |
25 Feb 19 |
nicklas |
var visible = configure.getVisibleColumns(); |
7982 |
14 Jun 21 |
nicklas |
var frm = document.forms['columns']; |
7982 |
14 Jun 21 |
nicklas |
208 |
|
7604 |
25 Feb 19 |
nicklas |
var url = 'save_preset.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_type='+Data.get('page-data', 'item-type'); |
7604 |
25 Feb 19 |
nicklas |
url += '&subcontext='+Data.get('page-data', 'subcontext', ''); |
7604 |
25 Feb 19 |
nicklas |
url += '&settingName='+Data.get('page-data', 'setting-name'); |
7982 |
14 Jun 21 |
nicklas |
url += '&columns='+encodeURIComponent(visible); |
7982 |
14 Jun 21 |
nicklas |
if (frm.sticky) url += '&stickyColumn='+encodeURIComponent(frm.sticky.value) |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'SavePreset', 450, 300); |
7604 |
25 Feb 19 |
nicklas |
216 |
} |
7604 |
25 Feb 19 |
nicklas |
217 |
|
7604 |
25 Feb 19 |
nicklas |
218 |
|
7604 |
25 Feb 19 |
nicklas |
configure.selectAnnotationTypes = function(event) |
7604 |
25 Feb 19 |
nicklas |
220 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['columns']; |
7604 |
25 Feb 19 |
nicklas |
var exclude = []; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.visible.length; i++) |
7604 |
25 Feb 19 |
nicklas |
224 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (frm.visible[i].value.indexOf('ia')==0) |
7604 |
25 Feb 19 |
nicklas |
226 |
{ |
7604 |
25 Feb 19 |
nicklas |
exclude[exclude.length] = frm.visible[i].value.substring(2); |
7604 |
25 Feb 19 |
nicklas |
228 |
} |
7604 |
25 Feb 19 |
nicklas |
229 |
} |
7604 |
25 Feb 19 |
nicklas |
var url = '&exclude='+exclude.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += '&resetTemporary=1&tmpfilter:BOOLEAN:disableInheritance=false'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('ANNOTATIONTYPE', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
233 |
} |
7604 |
25 Feb 19 |
nicklas |
234 |
|
7604 |
25 Feb 19 |
nicklas |
configure.annotationTypeSelected = function(event) |
7604 |
25 Feb 19 |
nicklas |
236 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['columns']; |
7604 |
25 Feb 19 |
nicklas |
var item = event.detail; |
7604 |
25 Feb 19 |
nicklas |
var colId = 'ia'+item.id; |
7604 |
25 Feb 19 |
nicklas |
// Remove from 'hidden' list |
7604 |
25 Feb 19 |
nicklas |
for (var i = frm.hidden.length-1; i >= 0; i--) |
7604 |
25 Feb 19 |
nicklas |
242 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (frm.hidden[i].value == colId) frm.hidden[i] = null; |
7604 |
25 Feb 19 |
nicklas |
244 |
} |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption(frm.visible, new Option(item.name + ' [I]', colId)); |
7982 |
14 Jun 21 |
nicklas |
if (frm.sticky) |
7982 |
14 Jun 21 |
nicklas |
247 |
{ |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption(frm.sticky, new Option(item.name + ' [I]', colId)); |
7982 |
14 Jun 21 |
nicklas |
249 |
} |
7982 |
14 Jun 21 |
nicklas |
250 |
|
7604 |
25 Feb 19 |
nicklas |
251 |
} |
7604 |
25 Feb 19 |
nicklas |
252 |
|
7773 |
17 Feb 20 |
nicklas |
253 |
|
7842 |
01 Sep 20 |
nicklas |
configure.selectRelatedItemColumn = function(event) |
7773 |
17 Feb 20 |
nicklas |
255 |
{ |
7773 |
17 Feb 20 |
nicklas |
var frm = document.forms['columns']; |
7842 |
01 Sep 20 |
nicklas |
var url = 'add_relateditem_column.jsp?ID='+App.getSessionId(); |
7773 |
17 Feb 20 |
nicklas |
url += '&item_type='+Data.get('page-data', 'item-type'); |
8083 |
20 Oct 22 |
nicklas |
Dialogs.openPopup(url, 'SelectRelatedItemColumn', 750, 500); |
7773 |
17 Feb 20 |
nicklas |
260 |
} |
7773 |
17 Feb 20 |
nicklas |
261 |
|
7842 |
01 Sep 20 |
nicklas |
configure.relatedItemColumnSelected = function(event) |
7773 |
17 Feb 20 |
nicklas |
263 |
{ |
7773 |
17 Feb 20 |
nicklas |
var frm = document.forms['columns']; |
7773 |
17 Feb 20 |
nicklas |
var data = event.detail; |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption(frm.visible, new Option(data.title, data.property)); |
7982 |
14 Jun 21 |
nicklas |
if (frm.sticky) |
7773 |
17 Feb 20 |
nicklas |
268 |
{ |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption(frm.sticky, new Option(data.title, data.property)); |
7773 |
17 Feb 20 |
nicklas |
270 |
} |
7851 |
14 Oct 20 |
nicklas |
271 |
} |
7851 |
14 Oct 20 |
nicklas |
272 |
|
7851 |
14 Oct 20 |
nicklas |
configure.selectLinkedItemColumn = function(event) |
7851 |
14 Oct 20 |
nicklas |
274 |
{ |
7851 |
14 Oct 20 |
nicklas |
var frm = document.forms['columns']; |
7851 |
14 Oct 20 |
nicklas |
var url = 'add_linkeditem_column.jsp?ID='+App.getSessionId(); |
7851 |
14 Oct 20 |
nicklas |
url += '&item_type='+Data.get('page-data', 'item-type'); |
7853 |
19 Oct 20 |
nicklas |
url += '&subcontext='+encodeURIComponent(Data.get('page-data', 'subcontext') || ''); |
7851 |
14 Oct 20 |
nicklas |
Dialogs.openPopup(url, 'SelectLinkedItemColumn', 600, 400); |
7851 |
14 Oct 20 |
nicklas |
280 |
} |
7773 |
17 Feb 20 |
nicklas |
281 |
|
7851 |
14 Oct 20 |
nicklas |
configure.linkedItemColumnSelected = function(event) |
7851 |
14 Oct 20 |
nicklas |
283 |
{ |
7851 |
14 Oct 20 |
nicklas |
var frm = document.forms['columns']; |
7851 |
14 Oct 20 |
nicklas |
var data = event.detail; |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption(frm.visible, new Option(data.title, data.property)); |
7982 |
14 Jun 21 |
nicklas |
if (frm.sticky) |
7851 |
14 Oct 20 |
nicklas |
288 |
{ |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption(frm.sticky, new Option(data.title, data.property)); |
7851 |
14 Oct 20 |
nicklas |
290 |
} |
7773 |
17 Feb 20 |
nicklas |
291 |
} |
7773 |
17 Feb 20 |
nicklas |
292 |
|
7604 |
25 Feb 19 |
nicklas |
293 |
/** |
7982 |
14 Jun 21 |
nicklas |
Add the option to the list if there is no other options with the |
7982 |
14 Jun 21 |
nicklas |
same value. |
7982 |
14 Jun 21 |
nicklas |
296 |
*/ |
7982 |
14 Jun 21 |
nicklas |
configure.addUniqueOption = function(list, option) |
7982 |
14 Jun 21 |
nicklas |
298 |
{ |
7982 |
14 Jun 21 |
nicklas |
for (var i = 0; i < list.length; i++) |
7982 |
14 Jun 21 |
nicklas |
300 |
{ |
7982 |
14 Jun 21 |
nicklas |
if (list[i].value == option.value) return; |
7982 |
14 Jun 21 |
nicklas |
302 |
} |
7982 |
14 Jun 21 |
nicklas |
list[list.length] = option; |
7982 |
14 Jun 21 |
nicklas |
304 |
} |
7982 |
14 Jun 21 |
nicklas |
305 |
|
7982 |
14 Jun 21 |
nicklas |
306 |
/** |
7604 |
25 Feb 19 |
nicklas |
Save the current selection and close the dialog. |
7604 |
25 Feb 19 |
nicklas |
308 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.save = function() |
7604 |
25 Feb 19 |
nicklas |
310 |
{ |
7982 |
14 Jun 21 |
nicklas |
var frm = document.forms['columns']; |
7604 |
25 Feb 19 |
nicklas |
var tableId = Data.get('page-data', 'table-id'); |
7604 |
25 Feb 19 |
nicklas |
var visible = configure.getVisibleColumns(); |
7982 |
14 Jun 21 |
nicklas |
window.opener.Table.setColumns(tableId, visible, frm.sticky ? frm.sticky.value : null); |
7604 |
25 Feb 19 |
nicklas |
window.close(); |
7604 |
25 Feb 19 |
nicklas |
316 |
} |
7604 |
25 Feb 19 |
nicklas |
317 |
|
7604 |
25 Feb 19 |
nicklas |
318 |
|
7604 |
25 Feb 19 |
nicklas |
// Get all visible columns as a comma-separated string |
7604 |
25 Feb 19 |
nicklas |
configure.getVisibleColumns = function() |
7604 |
25 Feb 19 |
nicklas |
321 |
{ |
7604 |
25 Feb 19 |
nicklas |
var list = document.forms['columns'].visible; |
7604 |
25 Feb 19 |
nicklas |
var visible = []; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < list.options.length; i++) |
7604 |
25 Feb 19 |
nicklas |
325 |
{ |
7604 |
25 Feb 19 |
nicklas |
visible[visible.length] = list.options[i].value; |
7604 |
25 Feb 19 |
nicklas |
327 |
} |
7604 |
25 Feb 19 |
nicklas |
return visible.join(','); |
7604 |
25 Feb 19 |
nicklas |
329 |
} |
7604 |
25 Feb 19 |
nicklas |
330 |
|
7604 |
25 Feb 19 |
nicklas |
331 |
/** |
7604 |
25 Feb 19 |
nicklas |
Move the selected options in the 'visible' list up or down. |
7604 |
25 Feb 19 |
nicklas |
333 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.moveVisibleUpOrDown = function(event) |
7604 |
25 Feb 19 |
nicklas |
335 |
{ |
7604 |
25 Feb 19 |
nicklas |
var moveDown = Data.int(event.currentTarget, 'down'); |
7604 |
25 Feb 19 |
nicklas |
Forms.moveListOptions('visible', moveDown); |
7604 |
25 Feb 19 |
nicklas |
338 |
} |
7604 |
25 Feb 19 |
nicklas |
339 |
|
7604 |
25 Feb 19 |
nicklas |
340 |
/** |
7604 |
25 Feb 19 |
nicklas |
Move the selected options in the 'hidden' list to the 'visible' list. |
7604 |
25 Feb 19 |
nicklas |
342 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.moveToVisible = function() |
7604 |
25 Feb 19 |
nicklas |
344 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['columns']; |
7604 |
25 Feb 19 |
nicklas |
Forms.moveSelected(frm.hidden, frm.visible); |
7604 |
25 Feb 19 |
nicklas |
347 |
} |
7604 |
25 Feb 19 |
nicklas |
348 |
|
7604 |
25 Feb 19 |
nicklas |
349 |
/** |
7604 |
25 Feb 19 |
nicklas |
Move the selected options in the 'visible' list to the 'hidden' list. |
7604 |
25 Feb 19 |
nicklas |
351 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.moveToHidden = function() |
7604 |
25 Feb 19 |
nicklas |
353 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['columns']; |
7604 |
25 Feb 19 |
nicklas |
Forms.moveSelected(frm.visible, frm.hidden); |
7604 |
25 Feb 19 |
nicklas |
356 |
} |
7604 |
25 Feb 19 |
nicklas |
357 |
|
7604 |
25 Feb 19 |
nicklas |
358 |
|
7604 |
25 Feb 19 |
nicklas |
return configure; |
7604 |
25 Feb 19 |
nicklas |
360 |
}(); |
7604 |
25 Feb 19 |
nicklas |
361 |
|
6186 |
29 Oct 12 |
nicklas |
Doc.onLoad(Configure.initPage); |