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 ReporterLists = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var reporterlists = {}; |
7604 |
25 Feb 19 |
nicklas |
var selectedReporters = null; |
7604 |
25 Feb 19 |
nicklas |
30 |
|
7604 |
25 Feb 19 |
nicklas |
31 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
33 |
*/ |
7604 |
25 Feb 19 |
nicklas |
reporterlists.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
35 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
38 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', reporterlists.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
42 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', reporterlists.validateReporterList); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
// Min count |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('minCount', 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('minCount', 'focus', reporterlists.minCountOnFocus); |
7604 |
25 Feb 19 |
nicklas |
49 |
|
7604 |
25 Feb 19 |
nicklas |
var addReportersForm = Data.get('page-data', 'add-reporters'); |
7604 |
25 Feb 19 |
nicklas |
if (addReportersForm) |
7604 |
25 Feb 19 |
nicklas |
52 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['reporterList']; |
7604 |
25 Feb 19 |
nicklas |
selectedReporters = window.opener.Table.getSelected(addReportersForm); |
7604 |
25 Feb 19 |
nicklas |
var lblSelected = Doc.element('lblSelected'); |
7604 |
25 Feb 19 |
nicklas |
if (selectedReporters.length == 0) |
7604 |
25 Feb 19 |
nicklas |
57 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.which[0].disabled = true; |
7604 |
25 Feb 19 |
nicklas |
lblSelected.disabled = true; |
7604 |
25 Feb 19 |
nicklas |
Doc.addClass(lblSelected, 'disabled'); |
7604 |
25 Feb 19 |
nicklas |
61 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
63 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.which[0].checked = true; |
7604 |
25 Feb 19 |
nicklas |
65 |
} |
7604 |
25 Feb 19 |
nicklas |
66 |
} |
7604 |
25 Feb 19 |
nicklas |
67 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
69 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'REPORTERLIST', 'item-id': itemId}; |
7604 |
25 Feb 19 |
nicklas |
72 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
83 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnMergeUnion', reporterlists.merge, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnMergeIntersection', reporterlists.merge, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnMergeComplement', reporterlists.merge, attributes); |
7604 |
25 Feb 19 |
nicklas |
87 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.reporters', reporterlists.viewReporters); |
7604 |
25 Feb 19 |
nicklas |
89 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
91 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'REPORTERLIST'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'reporterLists'}; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItem', reporterlists.newItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeleteItems', Buttons.deleteItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestoreItems', Buttons.restoreItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShareItems', Buttons.shareItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetOwner', Buttons.setOwnerOfItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnColumns', Buttons.configureColumns, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
103 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnOk', Buttons.returnSelected, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
106 |
} |
7604 |
25 Feb 19 |
nicklas |
107 |
} |
7604 |
25 Feb 19 |
nicklas |
108 |
|
7604 |
25 Feb 19 |
nicklas |
reporterlists.newItem = function() |
7604 |
25 Feb 19 |
nicklas |
110 |
{ |
7604 |
25 Feb 19 |
nicklas |
var controller = Items.getController('REPORTERLIST'); |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('reporterLists', 'NewItem', controller.width, controller.height); |
7604 |
25 Feb 19 |
nicklas |
113 |
} |
7604 |
25 Feb 19 |
nicklas |
114 |
|
7604 |
25 Feb 19 |
nicklas |
reporterlists.merge = function(event) |
7604 |
25 Feb 19 |
nicklas |
116 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = 'merge.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+Data.get(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&mergeType='+Data.get(event.currentTarget, 'merge-type'); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'MergeReporterLists', 600, 400); |
7604 |
25 Feb 19 |
nicklas |
121 |
} |
7604 |
25 Feb 19 |
nicklas |
122 |
|
7604 |
25 Feb 19 |
nicklas |
reporterlists.viewReporters = function() |
7604 |
25 Feb 19 |
nicklas |
124 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = 'reporters/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=List&reporterlist_id='+Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
128 |
} |
7604 |
25 Feb 19 |
nicklas |
129 |
|
7604 |
25 Feb 19 |
nicklas |
130 |
|
7604 |
25 Feb 19 |
nicklas |
reporterlists.validateReporterList = function() |
7604 |
25 Feb 19 |
nicklas |
132 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['reporterList']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
135 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.name, 'You must enter a name'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
138 |
} |
7604 |
25 Feb 19 |
nicklas |
if (frm.minCount) |
7604 |
25 Feb 19 |
nicklas |
140 |
{ |
7604 |
25 Feb 19 |
nicklas |
var checked = Forms.getCheckedRadio(frm.create); |
7604 |
25 Feb 19 |
nicklas |
if (checked.value == 'count') |
7604 |
25 Feb 19 |
nicklas |
143 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!Numbers.isInteger(frm.minCount.value)) |
7604 |
25 Feb 19 |
nicklas |
145 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.minCount, 'You must specify the number of reporter lists'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
148 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
150 |
{ |
7604 |
25 Feb 19 |
nicklas |
var minCount = parseInt(frm.minCount.value); |
7604 |
25 Feb 19 |
nicklas |
var numLists = Data.int('page-data', 'num-selected-lists'); |
7604 |
25 Feb 19 |
nicklas |
if (minCount < 1 || minCount > numLists) |
7604 |
25 Feb 19 |
nicklas |
154 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.minCount, 'You must specify a value between 1 and '+ numLists); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
157 |
} |
7604 |
25 Feb 19 |
nicklas |
158 |
} |
7604 |
25 Feb 19 |
nicklas |
159 |
} |
7604 |
25 Feb 19 |
nicklas |
160 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
162 |
} |
7604 |
25 Feb 19 |
nicklas |
163 |
|
7604 |
25 Feb 19 |
nicklas |
reporterlists.save = function() |
7604 |
25 Feb 19 |
nicklas |
165 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['reporterList']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
168 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (frm.which) Forms.addHidden(frm, 'items', selectedReporters.join(',')); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
171 |
} |
7604 |
25 Feb 19 |
nicklas |
172 |
} |
7604 |
25 Feb 19 |
nicklas |
173 |
|
7604 |
25 Feb 19 |
nicklas |
reporterlists.minCountOnFocus = function() |
7604 |
25 Feb 19 |
nicklas |
175 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['reporterList']; |
7604 |
25 Feb 19 |
nicklas |
Forms.checkRadio(frm.create, 'count'); |
7604 |
25 Feb 19 |
nicklas |
178 |
} |
7604 |
25 Feb 19 |
nicklas |
179 |
|
7604 |
25 Feb 19 |
nicklas |
return reporterlists; |
7604 |
25 Feb 19 |
nicklas |
181 |
}(); |
7604 |
25 Feb 19 |
nicklas |
182 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(ReporterLists.initPage); |
7604 |
25 Feb 19 |
nicklas |
184 |
|