7851 |
14 Oct 20 |
nicklas |
/* $Id $ |
7851 |
14 Oct 20 |
nicklas |
2 |
------------------------------------------------------------------ |
7851 |
14 Oct 20 |
nicklas |
Copyright (C) 2020 Nicklas Nordborg |
7851 |
14 Oct 20 |
nicklas |
4 |
|
7851 |
14 Oct 20 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7851 |
14 Oct 20 |
nicklas |
Available at http://base.thep.lu.se/ |
7851 |
14 Oct 20 |
nicklas |
7 |
|
7851 |
14 Oct 20 |
nicklas |
BASE is free software; you can redistribute it and/or |
7851 |
14 Oct 20 |
nicklas |
modify it under the terms of the GNU General Public License |
7851 |
14 Oct 20 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7851 |
14 Oct 20 |
nicklas |
of the License, or (at your option) any later version. |
7851 |
14 Oct 20 |
nicklas |
12 |
|
7851 |
14 Oct 20 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7851 |
14 Oct 20 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7851 |
14 Oct 20 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7851 |
14 Oct 20 |
nicklas |
GNU General Public License for more details. |
7851 |
14 Oct 20 |
nicklas |
17 |
|
7851 |
14 Oct 20 |
nicklas |
You should have received a copy of the GNU General Public License |
7851 |
14 Oct 20 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7851 |
14 Oct 20 |
nicklas |
20 |
------------------------------------------------------------------ |
7851 |
14 Oct 20 |
nicklas |
21 |
|
7851 |
14 Oct 20 |
nicklas |
@author Nicklas |
7851 |
14 Oct 20 |
nicklas |
23 |
*/ |
7851 |
14 Oct 20 |
nicklas |
'use strict'; |
7851 |
14 Oct 20 |
nicklas |
25 |
|
7851 |
14 Oct 20 |
nicklas |
var Configure = function() |
7851 |
14 Oct 20 |
nicklas |
27 |
{ |
7851 |
14 Oct 20 |
nicklas |
var configure = {}; |
7851 |
14 Oct 20 |
nicklas |
29 |
|
7851 |
14 Oct 20 |
nicklas |
30 |
/** |
7851 |
14 Oct 20 |
nicklas |
Initialize the page. |
7851 |
14 Oct 20 |
nicklas |
32 |
*/ |
7851 |
14 Oct 20 |
nicklas |
configure.initPage = function() |
7851 |
14 Oct 20 |
nicklas |
34 |
{ |
7853 |
19 Oct 20 |
nicklas |
Events.addEventHandler('presets', 'change', configure.presetSelected); |
7851 |
14 Oct 20 |
nicklas |
Events.addEventHandler(document.body, 'click', configure.hideMessage); |
7851 |
14 Oct 20 |
nicklas |
37 |
|
7851 |
14 Oct 20 |
nicklas |
// Buttons |
7851 |
14 Oct 20 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7851 |
14 Oct 20 |
nicklas |
Buttons.addClickHandler('btnAdd', configure.addColumn); |
7851 |
14 Oct 20 |
nicklas |
41 |
} |
7851 |
14 Oct 20 |
nicklas |
42 |
|
7853 |
19 Oct 20 |
nicklas |
configure.presetSelected = function(event) |
7853 |
19 Oct 20 |
nicklas |
44 |
{ |
7853 |
19 Oct 20 |
nicklas |
var frm = document.forms['linkedItems']; |
7853 |
19 Oct 20 |
nicklas |
46 |
|
7853 |
19 Oct 20 |
nicklas |
if (frm.presets.selectedIndex > 0) |
7853 |
19 Oct 20 |
nicklas |
48 |
{ |
7853 |
19 Oct 20 |
nicklas |
var selected = frm.presets[frm.presets.selectedIndex]; |
7853 |
19 Oct 20 |
nicklas |
frm.linkName.value = Data.get(selected, 'linkname'); |
7853 |
19 Oct 20 |
nicklas |
Forms.selectListOption(frm.targetItemType, Data.get(selected, 'targettype')); |
7853 |
19 Oct 20 |
nicklas |
frm.presets.selectedIndex = 0; |
7853 |
19 Oct 20 |
nicklas |
53 |
} |
7853 |
19 Oct 20 |
nicklas |
54 |
} |
7853 |
19 Oct 20 |
nicklas |
55 |
|
7851 |
14 Oct 20 |
nicklas |
configure.addColumn = function(event) |
7851 |
14 Oct 20 |
nicklas |
57 |
{ |
7851 |
14 Oct 20 |
nicklas |
var frm = document.forms['linkedItems']; |
7851 |
14 Oct 20 |
nicklas |
59 |
|
7851 |
14 Oct 20 |
nicklas |
var data = {}; |
7851 |
14 Oct 20 |
nicklas |
data.linkName = frm.linkName.value; |
7851 |
14 Oct 20 |
nicklas |
62 |
|
7851 |
14 Oct 20 |
nicklas |
if (!data.linkName) |
7851 |
14 Oct 20 |
nicklas |
64 |
{ |
7851 |
14 Oct 20 |
nicklas |
Forms.showNotification('linkName', 'A link name is requried!'); |
7851 |
14 Oct 20 |
nicklas |
return; |
7851 |
14 Oct 20 |
nicklas |
67 |
} |
7851 |
14 Oct 20 |
nicklas |
68 |
|
7851 |
14 Oct 20 |
nicklas |
data.targetItemType = frm.targetItemType.value; |
7851 |
14 Oct 20 |
nicklas |
data.property = '|'+data.linkName; |
7852 |
16 Oct 20 |
nicklas |
if (data.targetItemType) |
7852 |
16 Oct 20 |
nicklas |
72 |
{ |
7852 |
16 Oct 20 |
nicklas |
data.property += '|'+data.targetItemType; |
7852 |
16 Oct 20 |
nicklas |
// Store the selected target type in "recently used" list |
7852 |
16 Oct 20 |
nicklas |
var url = 'ajax.jsp?ID='+App.getSessionId(); |
7852 |
16 Oct 20 |
nicklas |
url += '&cmd=AddRecentlyUsedLinkTargetType&itemType='+encodeURIComponent(data.targetItemType); |
7852 |
16 Oct 20 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7852 |
16 Oct 20 |
nicklas |
request.open("POST", url, true); |
7852 |
16 Oct 20 |
nicklas |
request.send(null); |
7852 |
16 Oct 20 |
nicklas |
80 |
} |
7851 |
14 Oct 20 |
nicklas |
data.title = data.linkName; |
7851 |
14 Oct 20 |
nicklas |
Events.sendCustomEvent(window.opener.Doc.element('selectLinkedItemColumn'), 'base-selected', data); |
7851 |
14 Oct 20 |
nicklas |
83 |
|
7851 |
14 Oct 20 |
nicklas |
frm.linkName.value = ''; |
7851 |
14 Oct 20 |
nicklas |
frm.linkName.focus(); |
7851 |
14 Oct 20 |
nicklas |
86 |
|
7851 |
14 Oct 20 |
nicklas |
Doc.element('added-column-msg').innerHTML = '1 column has been added to the table.'; |
7851 |
14 Oct 20 |
nicklas |
Doc.show('added-column-msg'); |
7851 |
14 Oct 20 |
nicklas |
event.stopPropagation(); // To prevent the hideMessage() method from executing |
7851 |
14 Oct 20 |
nicklas |
90 |
} |
7851 |
14 Oct 20 |
nicklas |
91 |
|
7851 |
14 Oct 20 |
nicklas |
configure.hideMessage = function(event) |
7851 |
14 Oct 20 |
nicklas |
93 |
{ |
7851 |
14 Oct 20 |
nicklas |
Doc.hide('added-column-msg'); |
7851 |
14 Oct 20 |
nicklas |
95 |
} |
7851 |
14 Oct 20 |
nicklas |
96 |
|
7851 |
14 Oct 20 |
nicklas |
97 |
|
7851 |
14 Oct 20 |
nicklas |
return configure; |
7851 |
14 Oct 20 |
nicklas |
99 |
}(); |
7851 |
14 Oct 20 |
nicklas |
100 |
|
7851 |
14 Oct 20 |
nicklas |
Doc.onLoad(Configure.initPage); |