7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2015 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 ItemLists = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var lists = {}; |
7604 |
25 Feb 19 |
nicklas |
var selectedItemsInParentForm; |
7604 |
25 Feb 19 |
nicklas |
var subtypes; |
7604 |
25 Feb 19 |
nicklas |
31 |
|
7604 |
25 Feb 19 |
nicklas |
32 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
34 |
*/ |
7604 |
25 Feb 19 |
nicklas |
lists.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
36 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
39 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', lists.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
43 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', lists.validateList); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('settings.annotations', Annotations.onSwitchToAnnotationsTab); |
7604 |
25 Feb 19 |
nicklas |
47 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['list']; |
7604 |
25 Feb 19 |
nicklas |
if (frm.source) |
7604 |
25 Feb 19 |
nicklas |
50 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Create biomaterial list from selection of biomaterials |
7604 |
25 Feb 19 |
nicklas |
var parentForm = Data.get('sourceSelected', 'parent-form'); |
7604 |
25 Feb 19 |
nicklas |
selectedItemsInParentForm = window.opener.Table.getSelected(parentForm) |
7604 |
25 Feb 19 |
nicklas |
if (selectedItemsInParentForm.length == 0) |
7604 |
25 Feb 19 |
nicklas |
55 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.element('sourceSelected').disabled = true; |
7604 |
25 Feb 19 |
nicklas |
57 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
59 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.checkRadio(frm.source, 'selected'); |
7604 |
25 Feb 19 |
nicklas |
Doc.element('lblSelected').innerHTML += ' ['+selectedItemsInParentForm.length+']'; |
7604 |
25 Feb 19 |
nicklas |
62 |
} |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('sourceSelected', 'click', lists.sourceOnChange); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('sourcePage', 'click', lists.sourceOnChange); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('sourceAll', 'click', lists.sourceOnChange); |
7604 |
25 Feb 19 |
nicklas |
lists.sourceOnChange(); |
7604 |
25 Feb 19 |
nicklas |
67 |
} |
7604 |
25 Feb 19 |
nicklas |
68 |
|
7604 |
25 Feb 19 |
nicklas |
// Item subtype |
7604 |
25 Feb 19 |
nicklas |
subtypes = Data.json('page-data', 'subtypes'); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('memberType', 'change', lists.memberTypeOnChange); |
7604 |
25 Feb 19 |
nicklas |
lists.memberTypeOnChange(); |
7604 |
25 Feb 19 |
nicklas |
73 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
75 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'ITEMLIST', 'item-id': itemId}; |
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 |
Buttons.addClickHandler('btnMergeUnion', lists.mergeOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnMergeIntersection', lists.mergeOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnMergeComplement', lists.mergeOnClick); |
7604 |
25 Feb 19 |
nicklas |
91 |
|
7884 |
03 Dec 20 |
nicklas |
Buttons.addClickHandler('btnAddSyncFilter', lists.newSyncFilter); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRemoveSyncFilter', lists.removeSyncFilterOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnEnable', lists.enableFiltersOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDisable', lists.disableFiltersOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnResync', lists.resyncFilters); |
7604 |
25 Feb 19 |
nicklas |
// sent after syncing is complete |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnResync', 'base-notify', App.reloadWindow); |
7604 |
25 Feb 19 |
nicklas |
99 |
|
7604 |
25 Feb 19 |
nicklas |
var inSync = Data.int('sync-data', 'is-in-sync'); |
7604 |
25 Feb 19 |
nicklas |
var syncDisabled = Data.int('sync-data', 'sync-disabled'); |
7604 |
25 Feb 19 |
nicklas |
if (!syncDisabled) |
7604 |
25 Feb 19 |
nicklas |
103 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!inSync) |
7604 |
25 Feb 19 |
nicklas |
105 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('not-insync-warning', 'inline'); |
7604 |
25 Feb 19 |
nicklas |
107 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (Data.int('sync-data', 'num-syncfilters')>0) |
7604 |
25 Feb 19 |
nicklas |
109 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('insync-info', 'inline'); |
7604 |
25 Feb 19 |
nicklas |
111 |
} |
7604 |
25 Feb 19 |
nicklas |
112 |
} |
7604 |
25 Feb 19 |
nicklas |
113 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.members', lists.viewMembers); |
7604 |
25 Feb 19 |
nicklas |
if (Doc.element('main.overview')) |
7604 |
25 Feb 19 |
nicklas |
117 |
{ |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.overview', Overview.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
119 |
} |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.history', History.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
121 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
123 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'ITEMLIST'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'lists'}; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItem', lists.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 |
135 |
|
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 |
138 |
} |
7604 |
25 Feb 19 |
nicklas |
139 |
} |
7604 |
25 Feb 19 |
nicklas |
140 |
|
7604 |
25 Feb 19 |
nicklas |
lists.newItem = function() |
7604 |
25 Feb 19 |
nicklas |
142 |
{ |
7604 |
25 Feb 19 |
nicklas |
var controller = Items.getController('ITEMLIST'); |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('lists', 'NewItem', controller.width, controller.height); |
7604 |
25 Feb 19 |
nicklas |
145 |
} |
7604 |
25 Feb 19 |
nicklas |
146 |
|
7604 |
25 Feb 19 |
nicklas |
lists.viewMembers = function() |
7604 |
25 Feb 19 |
nicklas |
148 |
{ |
7604 |
25 Feb 19 |
nicklas |
var listId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'members/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=List&list_id='+listId; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
153 |
} |
7604 |
25 Feb 19 |
nicklas |
154 |
|
7604 |
25 Feb 19 |
nicklas |
lists.mergeOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
156 |
{ |
7604 |
25 Feb 19 |
nicklas |
var target = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var mergeType = Data.get(target, 'merge-type'); |
7604 |
25 Feb 19 |
nicklas |
var listId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
160 |
|
7604 |
25 Feb 19 |
nicklas |
var url = 'merge.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+listId; |
7604 |
25 Feb 19 |
nicklas |
url += '&mergeType='+mergeType; |
7604 |
25 Feb 19 |
nicklas |
164 |
|
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'Merge', 600, 400); |
7604 |
25 Feb 19 |
nicklas |
166 |
} |
7604 |
25 Feb 19 |
nicklas |
167 |
|
7884 |
03 Dec 20 |
nicklas |
lists.newSyncFilter = function(event) |
7884 |
03 Dec 20 |
nicklas |
169 |
{ |
7884 |
03 Dec 20 |
nicklas |
var extraUrl = '&list_id='+Data.get('page-data', 'item-id'); |
7884 |
03 Dec 20 |
nicklas |
var filterGroup = Data.get(event.currentTarget, 'filter-group'); |
7884 |
03 Dec 20 |
nicklas |
if (filterGroup) extraUrl += '&filterGroup='+encodeURIComponent(filterGroup); |
7884 |
03 Dec 20 |
nicklas |
Items.newItem('SYNCFILTER', extraUrl); |
7884 |
03 Dec 20 |
nicklas |
174 |
} |
7884 |
03 Dec 20 |
nicklas |
175 |
|
7604 |
25 Feb 19 |
nicklas |
lists.removeSyncFilterOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
177 |
{ |
7604 |
25 Feb 19 |
nicklas |
var tableDiv = Doc.element('tbl.syncFilters'); |
7604 |
25 Feb 19 |
nicklas |
var numSelected = Table.checkIfSelected(tableDiv); |
7604 |
25 Feb 19 |
nicklas |
if (numSelected == 0) return; |
7604 |
25 Feb 19 |
nicklas |
181 |
|
7604 |
25 Feb 19 |
nicklas |
if (!confirm('You are about to remove '+numSelected+' filters. Continue?')) |
7604 |
25 Feb 19 |
nicklas |
183 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
185 |
} |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup(tableDiv, 'DeleteItems', 300, 200); |
7604 |
25 Feb 19 |
nicklas |
187 |
} |
7604 |
25 Feb 19 |
nicklas |
188 |
|
7604 |
25 Feb 19 |
nicklas |
lists.enableFiltersOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
190 |
{ |
7604 |
25 Feb 19 |
nicklas |
var tableDiv = Doc.element('tbl.syncFilters'); |
7604 |
25 Feb 19 |
nicklas |
var numSelected = Table.checkIfSelected(tableDiv); |
7604 |
25 Feb 19 |
nicklas |
if (numSelected == 0) return; |
7604 |
25 Feb 19 |
nicklas |
194 |
|
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup(tableDiv, 'EnableFilters', 300, 200); |
7604 |
25 Feb 19 |
nicklas |
196 |
} |
7604 |
25 Feb 19 |
nicklas |
197 |
|
7604 |
25 Feb 19 |
nicklas |
lists.disableFiltersOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
199 |
{ |
7604 |
25 Feb 19 |
nicklas |
var tableDiv = Doc.element('tbl.syncFilters'); |
7604 |
25 Feb 19 |
nicklas |
var numSelected = Table.checkIfSelected(tableDiv); |
7604 |
25 Feb 19 |
nicklas |
if (numSelected == 0) return; |
7604 |
25 Feb 19 |
nicklas |
203 |
|
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup(tableDiv, 'DisableFilters', 300, 200); |
7604 |
25 Feb 19 |
nicklas |
205 |
} |
7604 |
25 Feb 19 |
nicklas |
206 |
|
7604 |
25 Feb 19 |
nicklas |
lists.resyncFilters = function() |
7604 |
25 Feb 19 |
nicklas |
208 |
{ |
7604 |
25 Feb 19 |
nicklas |
var listId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'resync.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+listId; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'ReSync', 600, 400); |
7604 |
25 Feb 19 |
nicklas |
213 |
} |
7604 |
25 Feb 19 |
nicklas |
214 |
|
7604 |
25 Feb 19 |
nicklas |
lists.validateList = function() |
7604 |
25 Feb 19 |
nicklas |
216 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['list']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
219 |
{ |
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 |
222 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
224 |
} |
7604 |
25 Feb 19 |
nicklas |
225 |
|
7604 |
25 Feb 19 |
nicklas |
// Submit the form |
7604 |
25 Feb 19 |
nicklas |
lists.save = function() |
7604 |
25 Feb 19 |
nicklas |
228 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['list']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
231 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
if (selectedItemsInParentForm) |
7604 |
25 Feb 19 |
nicklas |
234 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'items', selectedItemsInParentForm.join(',')); |
7604 |
25 Feb 19 |
nicklas |
236 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.memberType.disabled = false; |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
239 |
} |
7604 |
25 Feb 19 |
nicklas |
240 |
} |
7604 |
25 Feb 19 |
nicklas |
241 |
|
7604 |
25 Feb 19 |
nicklas |
lists.memberTypeOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
243 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['list']; |
7604 |
25 Feb 19 |
nicklas |
var memberType = frm.memberType.value; |
7604 |
25 Feb 19 |
nicklas |
246 |
|
7604 |
25 Feb 19 |
nicklas |
if (memberType == 'RAWBIOASSAY') |
7604 |
25 Feb 19 |
nicklas |
248 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('rawDataTypeRow'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('subtypeRow'); |
7604 |
25 Feb 19 |
nicklas |
251 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
253 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('rawDataTypeRow'); |
7604 |
25 Feb 19 |
nicklas |
Doc.show('subtypeRow'); |
7604 |
25 Feb 19 |
nicklas |
256 |
|
7604 |
25 Feb 19 |
nicklas |
frm.subtype_id.length = 0; |
7604 |
25 Feb 19 |
nicklas |
frm.subtype_id[0] = new Option('- any -', 0); |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < subtypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
260 |
{ |
7604 |
25 Feb 19 |
nicklas |
var subtype = subtypes[i]; |
7604 |
25 Feb 19 |
nicklas |
if (subtype.itemType == memberType) |
7604 |
25 Feb 19 |
nicklas |
263 |
{ |
7604 |
25 Feb 19 |
nicklas |
var opt = new Option(subtype.name, subtype.id, false, subtype.current); |
7604 |
25 Feb 19 |
nicklas |
if (subtype.description) opt.title = subtype.description; |
7604 |
25 Feb 19 |
nicklas |
frm.subtype_id[frm.subtype_id.length] = opt; |
7604 |
25 Feb 19 |
nicklas |
267 |
} |
7604 |
25 Feb 19 |
nicklas |
268 |
} |
7604 |
25 Feb 19 |
nicklas |
269 |
} |
7604 |
25 Feb 19 |
nicklas |
270 |
} |
7604 |
25 Feb 19 |
nicklas |
271 |
|
7604 |
25 Feb 19 |
nicklas |
lists.sourceOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
273 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['list']; |
7747 |
16 Sep 19 |
nicklas |
if (frm.syncFilter) frm.syncFilter.disabled = !Doc.element('sourceAll').checked; |
7604 |
25 Feb 19 |
nicklas |
276 |
} |
7604 |
25 Feb 19 |
nicklas |
277 |
|
7604 |
25 Feb 19 |
nicklas |
lists.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
279 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'sync-filter-edit') |
7604 |
25 Feb 19 |
nicklas |
281 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'click', lists.modifySyncFilter); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'base-selected-start', lists.syncFilterModified); |
7604 |
25 Feb 19 |
nicklas |
284 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'sync-filter-view') |
7604 |
25 Feb 19 |
nicklas |
286 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'click', lists.viewSyncFilterInTable); |
7604 |
25 Feb 19 |
nicklas |
288 |
} |
7884 |
03 Dec 20 |
nicklas |
else if (autoInit == 'new-sync-filter') |
7884 |
03 Dec 20 |
nicklas |
290 |
{ |
7884 |
03 Dec 20 |
nicklas |
Buttons.addClickHandler(element, lists.newSyncFilter); |
7884 |
03 Dec 20 |
nicklas |
292 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'clone') |
7604 |
25 Feb 19 |
nicklas |
294 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, lists.copyListOnClick); |
7604 |
25 Feb 19 |
nicklas |
296 |
} |
7604 |
25 Feb 19 |
nicklas |
297 |
} |
7604 |
25 Feb 19 |
nicklas |
298 |
|
7604 |
25 Feb 19 |
nicklas |
lists.modifySyncFilter = function(event) |
7604 |
25 Feb 19 |
nicklas |
300 |
{ |
7604 |
25 Feb 19 |
nicklas |
var target = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var syncFilterId = Data.get(target, 'syncfilter-id'); |
7604 |
25 Feb 19 |
nicklas |
var sourceItemType = Data.get(target, 'source-item-type'); |
7604 |
25 Feb 19 |
nicklas |
304 |
|
7604 |
25 Feb 19 |
nicklas |
var url = 'syncfilter/ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=CopySyncFilterToItemContext'; |
7604 |
25 Feb 19 |
nicklas |
url += '&syncfilter_id='+syncFilterId; |
7604 |
25 Feb 19 |
nicklas |
308 |
|
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, true); |
7604 |
25 Feb 19 |
nicklas |
Ajax.setReadyStateHandler(request, |
7604 |
25 Feb 19 |
nicklas |
function(request) |
7604 |
25 Feb 19 |
nicklas |
313 |
{ |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem(sourceItemType, target, 'selectfilter'); |
7604 |
25 Feb 19 |
nicklas |
315 |
}); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
317 |
} |
7604 |
25 Feb 19 |
nicklas |
318 |
|
7604 |
25 Feb 19 |
nicklas |
// When we are sure the current filter is in the item context, |
7604 |
25 Feb 19 |
nicklas |
// open the dialog |
7604 |
25 Feb 19 |
nicklas |
lists.syncFilterModified = function(event) |
7604 |
25 Feb 19 |
nicklas |
322 |
{ |
7604 |
25 Feb 19 |
nicklas |
var syncFilterId = Data.get(event.currentTarget, 'syncfilter-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'syncfilter/ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=CopyItemContextToSyncFilter'; |
7604 |
25 Feb 19 |
nicklas |
url += '&syncfilter_id='+syncFilterId; |
7604 |
25 Feb 19 |
nicklas |
327 |
|
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, true); |
7604 |
25 Feb 19 |
nicklas |
Ajax.setReadyStateHandler(request, |
7604 |
25 Feb 19 |
nicklas |
function(request) |
7604 |
25 Feb 19 |
nicklas |
332 |
{ |
7604 |
25 Feb 19 |
nicklas |
location.reload(); |
7604 |
25 Feb 19 |
nicklas |
334 |
}); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
336 |
} |
7604 |
25 Feb 19 |
nicklas |
337 |
|
7604 |
25 Feb 19 |
nicklas |
lists.viewSyncFilterInTable = function(event) |
7604 |
25 Feb 19 |
nicklas |
339 |
{ |
7604 |
25 Feb 19 |
nicklas |
var target = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var syncFilterId = Data.get(target, 'syncfilter-id'); |
7604 |
25 Feb 19 |
nicklas |
var sourceItemType = Data.get(target, 'source-item-type'); |
7604 |
25 Feb 19 |
nicklas |
343 |
|
7604 |
25 Feb 19 |
nicklas |
var url = 'syncfilter/ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=CopySyncFilterToItemContext'; |
7604 |
25 Feb 19 |
nicklas |
url += '&syncfilter_id='+syncFilterId; |
7604 |
25 Feb 19 |
nicklas |
347 |
|
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, true); |
7604 |
25 Feb 19 |
nicklas |
Ajax.setReadyStateHandler(request, |
7604 |
25 Feb 19 |
nicklas |
function(request) |
7604 |
25 Feb 19 |
nicklas |
352 |
{ |
7604 |
25 Feb 19 |
nicklas |
Items.listWithHistory(sourceItemType); |
7604 |
25 Feb 19 |
nicklas |
354 |
}); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
356 |
} |
7604 |
25 Feb 19 |
nicklas |
357 |
|
7604 |
25 Feb 19 |
nicklas |
358 |
|
7604 |
25 Feb 19 |
nicklas |
// Click handler for cloning a list |
7604 |
25 Feb 19 |
nicklas |
lists.copyListOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
361 |
{ |
7604 |
25 Feb 19 |
nicklas |
var target = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var listId = Data.get(target, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('ITEMLIST', '&clone_id='+listId); |
7604 |
25 Feb 19 |
nicklas |
365 |
} |
7604 |
25 Feb 19 |
nicklas |
366 |
|
7604 |
25 Feb 19 |
nicklas |
367 |
|
7604 |
25 Feb 19 |
nicklas |
return lists; |
7604 |
25 Feb 19 |
nicklas |
369 |
}(); |
7604 |
25 Feb 19 |
nicklas |
370 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(ItemLists.initPage); |
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(ItemLists.initElements); |