7801 |
30 Apr 20 |
nicklas |
/* $Id $ |
7801 |
30 Apr 20 |
nicklas |
2 |
------------------------------------------------------------------ |
7801 |
30 Apr 20 |
nicklas |
Copyright (C) 2020 Nicklas Nordborg |
7801 |
30 Apr 20 |
nicklas |
4 |
|
7801 |
30 Apr 20 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7801 |
30 Apr 20 |
nicklas |
Available at http://base.thep.lu.se/ |
7801 |
30 Apr 20 |
nicklas |
7 |
|
7801 |
30 Apr 20 |
nicklas |
BASE is free software; you can redistribute it and/or |
7801 |
30 Apr 20 |
nicklas |
modify it under the terms of the GNU General Public License |
7801 |
30 Apr 20 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7801 |
30 Apr 20 |
nicklas |
of the License, or (at your option) any later version. |
7801 |
30 Apr 20 |
nicklas |
12 |
|
7801 |
30 Apr 20 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7801 |
30 Apr 20 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7801 |
30 Apr 20 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7801 |
30 Apr 20 |
nicklas |
GNU General Public License for more details. |
7801 |
30 Apr 20 |
nicklas |
17 |
|
7801 |
30 Apr 20 |
nicklas |
You should have received a copy of the GNU General Public License |
7801 |
30 Apr 20 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7801 |
30 Apr 20 |
nicklas |
20 |
------------------------------------------------------------------ |
7801 |
30 Apr 20 |
nicklas |
21 |
|
7801 |
30 Apr 20 |
nicklas |
@author Nicklas |
7801 |
30 Apr 20 |
nicklas |
23 |
*/ |
7801 |
30 Apr 20 |
nicklas |
'use strict'; |
7801 |
30 Apr 20 |
nicklas |
25 |
|
7801 |
30 Apr 20 |
nicklas |
var AddItems = function() |
7801 |
30 Apr 20 |
nicklas |
27 |
{ |
7801 |
30 Apr 20 |
nicklas |
var additems = {}; |
7801 |
30 Apr 20 |
nicklas |
29 |
|
7801 |
30 Apr 20 |
nicklas |
additems.initPage = function() |
7801 |
30 Apr 20 |
nicklas |
31 |
{ |
7803 |
04 May 20 |
nicklas |
// ItemList |
7803 |
04 May 20 |
nicklas |
Buttons.addClickHandler('item_id.select', additems.selectList); |
7803 |
04 May 20 |
nicklas |
Events.addEventHandler('item_id', 'base-selected', Items.onItemSelected); |
7803 |
04 May 20 |
nicklas |
35 |
|
7801 |
30 Apr 20 |
nicklas |
// Find out what is selected in the parent form |
7801 |
30 Apr 20 |
nicklas |
var frm = document.forms['additems']; |
7801 |
30 Apr 20 |
nicklas |
var parentForm = Data.get('sourceSelected', 'parent-form'); |
7801 |
30 Apr 20 |
nicklas |
var selectedItemsInParentForm = window.opener.Table.getSelected(parentForm) |
7801 |
30 Apr 20 |
nicklas |
if (selectedItemsInParentForm.length == 0) |
7801 |
30 Apr 20 |
nicklas |
41 |
{ |
7801 |
30 Apr 20 |
nicklas |
Doc.element('sourceSelected').disabled = true; |
7801 |
30 Apr 20 |
nicklas |
43 |
} |
7801 |
30 Apr 20 |
nicklas |
else |
7801 |
30 Apr 20 |
nicklas |
45 |
{ |
7801 |
30 Apr 20 |
nicklas |
Forms.checkRadio(frm.source, 'selected'); |
7801 |
30 Apr 20 |
nicklas |
Doc.element('lblSelected').innerHTML += ' ['+selectedItemsInParentForm.length+']'; |
7801 |
30 Apr 20 |
nicklas |
Forms.addHidden(frm, 'items', selectedItemsInParentForm.join(',')); |
7801 |
30 Apr 20 |
nicklas |
49 |
} |
7801 |
30 Apr 20 |
nicklas |
50 |
|
7801 |
30 Apr 20 |
nicklas |
// Save + Close buttons |
7801 |
30 Apr 20 |
nicklas |
Buttons.addClickHandler('btnAdd', additems.save); |
7801 |
30 Apr 20 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7801 |
30 Apr 20 |
nicklas |
54 |
} |
7801 |
30 Apr 20 |
nicklas |
55 |
|
7803 |
04 May 20 |
nicklas |
additems.selectList = function() |
7803 |
04 May 20 |
nicklas |
57 |
{ |
7803 |
04 May 20 |
nicklas |
var frm = document.forms['additems']; |
7803 |
04 May 20 |
nicklas |
var url = '&resetTemporary=1'; |
7803 |
04 May 20 |
nicklas |
url += '&tmpfilter:BOOLEAN:disableManualMembers=0'; |
7803 |
04 May 20 |
nicklas |
url += '&tmpfilter:INT:memberType='+Data.get('page-data', 'member-type'); |
7803 |
04 May 20 |
nicklas |
if (frm.item_id.length > 0) |
7803 |
04 May 20 |
nicklas |
63 |
{ |
7803 |
04 May 20 |
nicklas |
var id = Math.abs(parseInt(frm.item_id[0].value)); |
7803 |
04 May 20 |
nicklas |
url += '&item_id='+id; |
7803 |
04 May 20 |
nicklas |
66 |
} |
7803 |
04 May 20 |
nicklas |
Dialogs.selectItem('ITEMLIST', 'item_id', 0, url); |
7803 |
04 May 20 |
nicklas |
68 |
} |
7803 |
04 May 20 |
nicklas |
69 |
|
7801 |
30 Apr 20 |
nicklas |
// Submit the form |
7801 |
30 Apr 20 |
nicklas |
additems.save = function() |
7801 |
30 Apr 20 |
nicklas |
72 |
{ |
7801 |
30 Apr 20 |
nicklas |
var frm = document.forms['additems']; |
7801 |
30 Apr 20 |
nicklas |
if (Strings.trim(frm.item_id.value) == '') |
7801 |
30 Apr 20 |
nicklas |
75 |
{ |
7801 |
30 Apr 20 |
nicklas |
Forms.showNotification(frm.item_id, 'No item list is selected'); |
7801 |
30 Apr 20 |
nicklas |
return false; |
7801 |
30 Apr 20 |
nicklas |
78 |
} |
7801 |
30 Apr 20 |
nicklas |
frm.submit(); |
7801 |
30 Apr 20 |
nicklas |
80 |
} |
7801 |
30 Apr 20 |
nicklas |
81 |
|
7801 |
30 Apr 20 |
nicklas |
return additems; |
7801 |
30 Apr 20 |
nicklas |
83 |
}(); |
7801 |
30 Apr 20 |
nicklas |
84 |
|
7801 |
30 Apr 20 |
nicklas |
Doc.onLoad(AddItems.initPage); |