7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2013 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 AnalysisTree = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var analysistree = {}; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
30 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
32 |
*/ |
7604 |
25 Feb 19 |
nicklas |
analysistree.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
34 |
{ |
7604 |
25 Feb 19 |
nicklas |
var experimentId = Data.get('tree-data', 'experiment-id'); |
7604 |
25 Feb 19 |
nicklas |
var bioAssaySetId = Data.get('tree-data', 'bioassayset-id'); |
7604 |
25 Feb 19 |
nicklas |
var transformationId = Data.get('tree-data', 'transformation-id'); |
7604 |
25 Feb 19 |
nicklas |
38 |
|
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'BIOASSAYSET', 'extra-url': '&experiment_id='+experimentId}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'bioAssaySets'}; |
7604 |
25 Feb 19 |
nicklas |
41 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewRootBioAssaySet', Buttons.newItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeleteTreeItems', analysistree.deleteItems); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestoreTreeItems', Buttons.restoreItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnTreeColumns', Buttons.configureColumns, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnTreeExport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnTreeImport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnTreeRunPlugin', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
49 |
|
7604 |
25 Feb 19 |
nicklas |
IconStore.addDefaultIcons(); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('BioAssaySet', 'bioassayset.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('Transformation', 'transformation.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('Filter', 'filter.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('ExtraValue', 'extravalue.png'); |
7604 |
25 Feb 19 |
nicklas |
55 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioAssaySets', 'joust-expand', analysistree.onExpand); |
7604 |
25 Feb 19 |
nicklas |
Joust2.draw('tree-data'); |
7604 |
25 Feb 19 |
nicklas |
58 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('reloadOnNotify', 'base-notify', App.reloadWindow); |
7604 |
25 Feb 19 |
nicklas |
60 |
} |
7604 |
25 Feb 19 |
nicklas |
61 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
63 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'bioassayset-plotter') |
7604 |
25 Feb 19 |
nicklas |
65 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, analysistree.openBioAssaySetPlotter); |
7604 |
25 Feb 19 |
nicklas |
67 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'experiment-explorer') |
7604 |
25 Feb 19 |
nicklas |
69 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, analysistree.openExperimentExplorer); |
7604 |
25 Feb 19 |
nicklas |
71 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'bioassayset-plugin') |
7604 |
25 Feb 19 |
nicklas |
73 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, analysistree.runPluginForBioAssaySet); |
7604 |
25 Feb 19 |
nicklas |
75 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'copy-job') |
7604 |
25 Feb 19 |
nicklas |
77 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, analysistree.copyJob); |
7604 |
25 Feb 19 |
nicklas |
79 |
} |
7604 |
25 Feb 19 |
nicklas |
80 |
} |
7604 |
25 Feb 19 |
nicklas |
81 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.deleteItems = function() |
7604 |
25 Feb 19 |
nicklas |
83 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioAssaySets']; |
7604 |
25 Feb 19 |
nicklas |
if (Table.checkIfSelected('bioAssaySets') == 0) return; |
7604 |
25 Feb 19 |
nicklas |
86 |
|
7604 |
25 Feb 19 |
nicklas |
if (Forms.numChecked(frm, /^X:/) > 0) |
7604 |
25 Feb 19 |
nicklas |
88 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!confirm('Extra values are deleted immediately and cannot be restored. Do you want to continue?')) |
7604 |
25 Feb 19 |
nicklas |
90 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
92 |
} |
7604 |
25 Feb 19 |
nicklas |
93 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.cmd.value = 'DeleteItems'; |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
96 |
} |
7604 |
25 Feb 19 |
nicklas |
97 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.openBioAssaySetPlotter = function(event) |
7604 |
25 Feb 19 |
nicklas |
99 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../plotter/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'Plotter', 1250, 700); |
7604 |
25 Feb 19 |
nicklas |
103 |
} |
7604 |
25 Feb 19 |
nicklas |
104 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.openExperimentExplorer = function(event) |
7604 |
25 Feb 19 |
nicklas |
106 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../explorer/view/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
location.href = url; |
7604 |
25 Feb 19 |
nicklas |
110 |
} |
7604 |
25 Feb 19 |
nicklas |
111 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.runPluginForBioAssaySet = function(event) |
7604 |
25 Feb 19 |
nicklas |
113 |
{ |
7604 |
25 Feb 19 |
nicklas |
var experimentId = Data.get('tree-data', 'experiment-id'); |
7604 |
25 Feb 19 |
nicklas |
Data.define(event.currentTarget, {'item-type': 'BIOASSAYSET', 'extra-url': '&experiment_id='+experimentId}); |
7604 |
25 Feb 19 |
nicklas |
Buttons.runPlugin(event); |
7604 |
25 Feb 19 |
nicklas |
117 |
} |
7604 |
25 Feb 19 |
nicklas |
118 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.copyJob = function(event) |
7604 |
25 Feb 19 |
nicklas |
120 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../../../common/plugin/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=CopyJob&job_id='+Data.get(event.currentTarget, 'job-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_type=BIOASSAYSET&context_type=LIST' |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'CopyJob', 750, 500); |
7604 |
25 Feb 19 |
nicklas |
125 |
} |
7604 |
25 Feb 19 |
nicklas |
126 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.onExpand = function(event) |
7604 |
25 Feb 19 |
nicklas |
128 |
{ |
7604 |
25 Feb 19 |
nicklas |
var menuItem = event.target.item; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioAssaySets']; |
7604 |
25 Feb 19 |
nicklas |
if (menuItem.isOpen) |
7604 |
25 Feb 19 |
nicklas |
132 |
{ |
7604 |
25 Feb 19 |
nicklas |
analysistree.showChildren(menuItem); |
7604 |
25 Feb 19 |
nicklas |
frm.closed.value = frm.closed.value.replace(','+menuItem.id+',', ','); |
7604 |
25 Feb 19 |
nicklas |
135 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
137 |
{ |
7604 |
25 Feb 19 |
nicklas |
analysistree.hideChildren(menuItem); |
7604 |
25 Feb 19 |
nicklas |
frm.closed.value += menuItem.id+','; |
7604 |
25 Feb 19 |
nicklas |
140 |
} |
7604 |
25 Feb 19 |
nicklas |
analysistree.sendClosedWithAjax(); |
7604 |
25 Feb 19 |
nicklas |
142 |
} |
7604 |
25 Feb 19 |
nicklas |
143 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.showChildren = function(menuItem) |
7604 |
25 Feb 19 |
nicklas |
145 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!menuItem.children) return; |
7604 |
25 Feb 19 |
nicklas |
for (var childNo = 0; childNo < menuItem.children.length; childNo++) |
7604 |
25 Feb 19 |
nicklas |
148 |
{ |
7604 |
25 Feb 19 |
nicklas |
var child = menuItem.children[childNo]; |
7604 |
25 Feb 19 |
nicklas |
Doc.show('row.'+child.id); |
7604 |
25 Feb 19 |
nicklas |
if (child.isOpen) |
7604 |
25 Feb 19 |
nicklas |
152 |
{ |
7604 |
25 Feb 19 |
nicklas |
analysistree.showChildren(child); |
7604 |
25 Feb 19 |
nicklas |
154 |
} |
7604 |
25 Feb 19 |
nicklas |
155 |
} |
7604 |
25 Feb 19 |
nicklas |
156 |
} |
7604 |
25 Feb 19 |
nicklas |
157 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.hideChildren = function(menuItem) |
7604 |
25 Feb 19 |
nicklas |
159 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!menuItem.children) return; |
7604 |
25 Feb 19 |
nicklas |
for (var childNo = 0; childNo < menuItem.children.length; childNo++) |
7604 |
25 Feb 19 |
nicklas |
162 |
{ |
7604 |
25 Feb 19 |
nicklas |
var child = menuItem.children[childNo]; |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('row.'+child.id); |
7604 |
25 Feb 19 |
nicklas |
analysistree.hideChildren(child); |
7604 |
25 Feb 19 |
nicklas |
166 |
} |
7604 |
25 Feb 19 |
nicklas |
167 |
} |
7604 |
25 Feb 19 |
nicklas |
168 |
|
7604 |
25 Feb 19 |
nicklas |
analysistree.sendClosedWithAjax = function() |
7604 |
25 Feb 19 |
nicklas |
170 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioAssaySets']; |
7604 |
25 Feb 19 |
nicklas |
var url = '../bioassaysets/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=SetClosedWithAjax'; |
7604 |
25 Feb 19 |
nicklas |
request.open("POST", url, true); |
7604 |
25 Feb 19 |
nicklas |
var postdata = 'closed=' + frm.closed.value; |
7604 |
25 Feb 19 |
nicklas |
177 |
|
7604 |
25 Feb 19 |
nicklas |
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
7604 |
25 Feb 19 |
nicklas |
request.setRequestHeader("Content-length", postdata.length); |
7604 |
25 Feb 19 |
nicklas |
request.setRequestHeader("Connection", "close"); |
7604 |
25 Feb 19 |
nicklas |
request.send(postdata); |
7604 |
25 Feb 19 |
nicklas |
182 |
} |
7604 |
25 Feb 19 |
nicklas |
183 |
|
7604 |
25 Feb 19 |
nicklas |
return analysistree; |
7604 |
25 Feb 19 |
nicklas |
185 |
}(); |
7604 |
25 Feb 19 |
nicklas |
186 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(AnalysisTree.initPage); |
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(AnalysisTree.initElements); |
7604 |
25 Feb 19 |
nicklas |
189 |
|