7604 |
25 Feb 19 |
nicklas |
/* $Id$ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2011 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 |
JavaScript functions for working with subtypable items |
7604 |
25 Feb 19 |
nicklas |
23 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
25 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
27 |
|
7604 |
25 Feb 19 |
nicklas |
var ItemSubtype = function() |
7604 |
25 Feb 19 |
nicklas |
29 |
{ |
7604 |
25 Feb 19 |
nicklas |
var subtype = {}; |
7604 |
25 Feb 19 |
nicklas |
var cache = []; |
7604 |
25 Feb 19 |
nicklas |
32 |
|
7604 |
25 Feb 19 |
nicklas |
33 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get the subtype of the given item. Uses an AJAX request |
7604 |
25 Feb 19 |
nicklas |
and return the subtype as an object with 'id' and 'name' |
7604 |
25 Feb 19 |
nicklas |
properties. |
7604 |
25 Feb 19 |
nicklas |
37 |
|
7604 |
25 Feb 19 |
nicklas |
@param The type of the item |
7604 |
25 Feb 19 |
nicklas |
@param The id of the item |
7604 |
25 Feb 19 |
nicklas |
40 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.getSubtype = function(itemType, itemId) |
7604 |
25 Feb 19 |
nicklas |
42 |
{ |
7604 |
25 Feb 19 |
nicklas |
var cacheKey = 'subtype.'+itemType+'.'+itemId; |
7604 |
25 Feb 19 |
nicklas |
var jsonSubtype = cache[cacheKey]; |
7604 |
25 Feb 19 |
nicklas |
if (!jsonSubtype) |
7604 |
25 Feb 19 |
nicklas |
46 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot() + 'admin/itemsubtypes/ajax.jsp?ID=' + App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetSubtypeForItem&item_id=' + itemId; |
7604 |
25 Feb 19 |
nicklas |
url += '&itemType='+itemType; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
jsonSubtype = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
cache[cacheKey] = jsonSubtype; |
7604 |
25 Feb 19 |
nicklas |
55 |
} |
7604 |
25 Feb 19 |
nicklas |
return jsonSubtype && jsonSubtype.id ? jsonSubtype : null; |
7604 |
25 Feb 19 |
nicklas |
57 |
} |
7604 |
25 Feb 19 |
nicklas |
58 |
|
7604 |
25 Feb 19 |
nicklas |
59 |
|
7604 |
25 Feb 19 |
nicklas |
60 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get the subtype that is related to the given one. |
7604 |
25 Feb 19 |
nicklas |
@param subtypeId The main subtype |
7604 |
25 Feb 19 |
nicklas |
@param relatedItemType The item type of the related subtype we are |
7604 |
25 Feb 19 |
nicklas |
looking for |
7604 |
25 Feb 19 |
nicklas |
@param defaultSubtype The id of the default subtype to return if |
7604 |
25 Feb 19 |
nicklas |
no related subtype is found (optional) |
7604 |
25 Feb 19 |
nicklas |
@return An object with the 'id' and 'name' of the related subtype or null |
7604 |
25 Feb 19 |
nicklas |
if no related subtype is found |
7604 |
25 Feb 19 |
nicklas |
69 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.getRelatedSubtype = function(subtypeId, relatedItemType, defaultSubtypeId) |
7604 |
25 Feb 19 |
nicklas |
71 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!subtypeId && !defaultSubtypeId) |
7604 |
25 Feb 19 |
nicklas |
73 |
{ |
7604 |
25 Feb 19 |
nicklas |
return null; |
7604 |
25 Feb 19 |
nicklas |
75 |
} |
7604 |
25 Feb 19 |
nicklas |
76 |
|
7604 |
25 Feb 19 |
nicklas |
var cacheKey = 'relatedsubtype.'+relatedItemType+'.'+subtypeId; |
7604 |
25 Feb 19 |
nicklas |
var jsonSubtype = cache[cacheKey]; |
7604 |
25 Feb 19 |
nicklas |
if (!jsonSubtype) |
7604 |
25 Feb 19 |
nicklas |
80 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot() + 'admin/itemsubtypes/ajax.jsp?ID=' + App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += "&cmd=GetRelatedSubtype&relatedType=" + relatedItemType; |
7604 |
25 Feb 19 |
nicklas |
if (subtypeId) |
7604 |
25 Feb 19 |
nicklas |
85 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+subtypeId; |
7604 |
25 Feb 19 |
nicklas |
87 |
} |
7604 |
25 Feb 19 |
nicklas |
if (defaultSubtypeId) |
7604 |
25 Feb 19 |
nicklas |
89 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&defaultRelatedId=' + defaultSubtypeId; |
7604 |
25 Feb 19 |
nicklas |
91 |
} |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
jsonSubtype = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
cache[cacheKey] = jsonSubtype; |
7604 |
25 Feb 19 |
nicklas |
96 |
} |
7604 |
25 Feb 19 |
nicklas |
return jsonSubtype && jsonSubtype.id ? jsonSubtype : null; |
7604 |
25 Feb 19 |
nicklas |
98 |
} |
7604 |
25 Feb 19 |
nicklas |
99 |
|
7604 |
25 Feb 19 |
nicklas |
100 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get information about project default items and recently used items |
7604 |
25 Feb 19 |
nicklas |
of the given subtype or item type. If a subtype is given, only project default |
7604 |
25 Feb 19 |
nicklas |
and recent items of the same subtype are returned, otherwise the item type |
7604 |
25 Feb 19 |
nicklas |
parameter is used and all project default items WITHOUT any subtype are returned. |
7604 |
25 Feb 19 |
nicklas |
105 |
|
7604 |
25 Feb 19 |
nicklas |
The function returns an object with the 'id' and 'name' of the subtype and |
7604 |
25 Feb 19 |
nicklas |
two arrays ('default' and 'recent') which both contain elements that are |
7604 |
25 Feb 19 |
nicklas |
objects with the 'id' and 'name' of the found items. |
7604 |
25 Feb 19 |
nicklas |
109 |
|
7604 |
25 Feb 19 |
nicklas |
@param itemType The main type of items to find |
7604 |
25 Feb 19 |
nicklas |
@param subtypeId The ID of the subtype we want to find information for |
7604 |
25 Feb 19 |
nicklas |
112 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.getProjectDefaultAndRecentItems = function(itemType, subtypeId) |
7604 |
25 Feb 19 |
nicklas |
114 |
{ |
7604 |
25 Feb 19 |
nicklas |
var cacheKey = 'defaultitems.'+itemType+'.'+subtypeId; |
7604 |
25 Feb 19 |
nicklas |
var jsonItems = cache[cacheKey]; |
7604 |
25 Feb 19 |
nicklas |
117 |
|
7604 |
25 Feb 19 |
nicklas |
if (!jsonItems) |
7604 |
25 Feb 19 |
nicklas |
119 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot() + 'admin/itemsubtypes/ajax.jsp?ID=' + App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetProjectDefaultAndRecentItems'; |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+subtypeId; |
7604 |
25 Feb 19 |
nicklas |
url += '&itemType='+itemType; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
jsonItems = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
cache[cacheKey] = jsonItems; |
7604 |
25 Feb 19 |
nicklas |
129 |
} |
7604 |
25 Feb 19 |
nicklas |
return jsonItems; |
7604 |
25 Feb 19 |
nicklas |
131 |
} |
7604 |
25 Feb 19 |
nicklas |
132 |
|
7604 |
25 Feb 19 |
nicklas |
133 |
/** |
7604 |
25 Feb 19 |
nicklas |
Utility function for finding the project default and recently used items for |
7604 |
25 Feb 19 |
nicklas |
several types of items at the same time. |
7604 |
25 Feb 19 |
nicklas |
136 |
|
7604 |
25 Feb 19 |
nicklas |
137 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.getRelatedProjectDefaultAndRecentItems = function(itemType, subtypeId, relatedItemTypes) |
7604 |
25 Feb 19 |
nicklas |
139 |
{ |
7604 |
25 Feb 19 |
nicklas |
var cacheKey = 'relateditems.'+itemType+'.'+subtypeId; |
7604 |
25 Feb 19 |
nicklas |
141 |
|
7604 |
25 Feb 19 |
nicklas |
var info = cache[cacheKey]; |
7604 |
25 Feb 19 |
nicklas |
if (info) |
7604 |
25 Feb 19 |
nicklas |
144 |
{ |
7604 |
25 Feb 19 |
nicklas |
// We have some info already, but... |
7604 |
25 Feb 19 |
nicklas |
// ...check if we are missing info about some related item types |
7604 |
25 Feb 19 |
nicklas |
var missingInfo = []; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < relatedItemTypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
149 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!info[relatedItemTypes[i]]) missingInfo[missingInfo.length] = relatedItemTypes[i]; |
7604 |
25 Feb 19 |
nicklas |
151 |
} |
7604 |
25 Feb 19 |
nicklas |
relatedItemTypes = missingInfo; |
7604 |
25 Feb 19 |
nicklas |
153 |
} |
7604 |
25 Feb 19 |
nicklas |
154 |
|
7604 |
25 Feb 19 |
nicklas |
// Get more info... |
7604 |
25 Feb 19 |
nicklas |
if (relatedItemTypes.length > 0) |
7604 |
25 Feb 19 |
nicklas |
157 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot() + 'admin/itemsubtypes/ajax.jsp?ID=' + App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetRecentAndRelated&itemType='+itemType; |
7604 |
25 Feb 19 |
nicklas |
if (subtypeId) |
7604 |
25 Feb 19 |
nicklas |
162 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+subtypeId; |
7604 |
25 Feb 19 |
nicklas |
164 |
} |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < relatedItemTypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
166 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&relatedType=' + relatedItemTypes[i]; |
7604 |
25 Feb 19 |
nicklas |
168 |
} |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
var moreInfo = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
if (!info) |
7604 |
25 Feb 19 |
nicklas |
173 |
{ |
7604 |
25 Feb 19 |
nicklas |
info = moreInfo; |
7604 |
25 Feb 19 |
nicklas |
175 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
177 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Merge the new info with the existing info |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < relatedItemTypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
180 |
{ |
7604 |
25 Feb 19 |
nicklas |
info[relatedItemTypes[i]]= moreInfo[relatedItemTypes[i]]; |
7604 |
25 Feb 19 |
nicklas |
182 |
} |
7604 |
25 Feb 19 |
nicklas |
183 |
} |
7604 |
25 Feb 19 |
nicklas |
cache[cacheKey] = info; |
7604 |
25 Feb 19 |
nicklas |
185 |
} |
7604 |
25 Feb 19 |
nicklas |
return info; |
7604 |
25 Feb 19 |
nicklas |
187 |
} |
7604 |
25 Feb 19 |
nicklas |
188 |
|
7604 |
25 Feb 19 |
nicklas |
189 |
/** |
7604 |
25 Feb 19 |
nicklas |
Utility function for getting the ID of the currently selected |
7604 |
25 Feb 19 |
nicklas |
subtype in a form. |
7604 |
25 Feb 19 |
nicklas |
@param list The ID or element of a selection list with subtype items |
7604 |
25 Feb 19 |
nicklas |
193 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.getSubtypeId = function(list) |
7604 |
25 Feb 19 |
nicklas |
195 |
{ |
7604 |
25 Feb 19 |
nicklas |
list = Doc.element(list); |
7604 |
25 Feb 19 |
nicklas |
if (!list || list.disabled || list.length == 0) return 0; |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(list.value)); |
7604 |
25 Feb 19 |
nicklas |
return id; |
7604 |
25 Feb 19 |
nicklas |
200 |
} |
7604 |
25 Feb 19 |
nicklas |
201 |
|
7604 |
25 Feb 19 |
nicklas |
202 |
/** |
7604 |
25 Feb 19 |
nicklas |
Utility function for creating a (temporary) filter string that can be added |
7604 |
25 Feb 19 |
nicklas |
to a popup URL for selecting item with a specified subtype. From the |
7604 |
25 Feb 19 |
nicklas |
currently selected subtype we find the related subtype for the associated |
7604 |
25 Feb 19 |
nicklas |
item and generate a filter based on that. For example, when selecting a FILE |
7604 |
25 Feb 19 |
nicklas |
for a PROTOCOL, we use the current subtype of the protocol to find the |
7604 |
25 Feb 19 |
nicklas |
related subtype for FILE items. |
7604 |
25 Feb 19 |
nicklas |
209 |
|
7604 |
25 Feb 19 |
nicklas |
If there is no related subtype, an empty string is returned. |
7604 |
25 Feb 19 |
nicklas |
@param list The ID or element of a selection list with subtype items |
7604 |
25 Feb 19 |
nicklas |
@param relatedItemType The item type of the related subtype we are |
7604 |
25 Feb 19 |
nicklas |
looking for |
7604 |
25 Feb 19 |
nicklas |
@param defaultSubtype The id of the default subtype to use if |
7604 |
25 Feb 19 |
nicklas |
no related subtype is found (optional) |
7604 |
25 Feb 19 |
nicklas |
216 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.createRelatedFilter = function(list, relatedItemType, defaultSubtypeId) |
7604 |
25 Feb 19 |
nicklas |
218 |
{ |
7604 |
25 Feb 19 |
nicklas |
var subtypeId = subtype.getSubtypeId(list); |
7604 |
25 Feb 19 |
nicklas |
var relatedSubtype = subtype.getRelatedSubtype(subtypeId, relatedItemType, defaultSubtypeId); |
7604 |
25 Feb 19 |
nicklas |
return relatedSubtype ? '&tmpfilter:INT:itemSubtype=' + relatedSubtype.id : ''; |
7604 |
25 Feb 19 |
nicklas |
222 |
} |
7604 |
25 Feb 19 |
nicklas |
223 |
|
7604 |
25 Feb 19 |
nicklas |
224 |
|
7604 |
25 Feb 19 |
nicklas |
225 |
/** |
7604 |
25 Feb 19 |
nicklas |
Update the selection list with 'recently used' and 'project default' items. |
7604 |
25 Feb 19 |
nicklas |
Currently existing options under those headers will be cleared. |
7604 |
25 Feb 19 |
nicklas |
228 |
*/ |
7604 |
25 Feb 19 |
nicklas |
subtype.updateSelectionList = function(list, recentItems, projectDefaults, noNoneOption) |
7604 |
25 Feb 19 |
nicklas |
230 |
{ |
7604 |
25 Feb 19 |
nicklas |
list = Doc.element(list); |
7604 |
25 Feb 19 |
nicklas |
232 |
|
7604 |
25 Feb 19 |
nicklas |
var oldSelectedValue = list.selectedIndex >= 0 ? list[list.selectedIndex].value : 0; |
7604 |
25 Feb 19 |
nicklas |
var reselectValue = 0; |
7604 |
25 Feb 19 |
nicklas |
235 |
|
7604 |
25 Feb 19 |
nicklas |
// Find the first header option |
7604 |
25 Feb 19 |
nicklas |
for (var i = noNoneOption ? 0 : 1; i < list.length; i++) |
7604 |
25 Feb 19 |
nicklas |
238 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (list[i].value == 'NaN') |
7604 |
25 Feb 19 |
nicklas |
240 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Found the header entry |
7604 |
25 Feb 19 |
nicklas |
// Remember the currently selected value if it is after header |
7604 |
25 Feb 19 |
nicklas |
if (list.selectedIndex > i) |
7604 |
25 Feb 19 |
nicklas |
244 |
{ |
7604 |
25 Feb 19 |
nicklas |
reselectValue = list[list.selectedIndex].value; |
7604 |
25 Feb 19 |
nicklas |
246 |
} |
7604 |
25 Feb 19 |
nicklas |
// Clear everything from the header and onwards |
7604 |
25 Feb 19 |
nicklas |
list.length = i; |
7604 |
25 Feb 19 |
nicklas |
249 |
} |
7604 |
25 Feb 19 |
nicklas |
250 |
} |
7604 |
25 Feb 19 |
nicklas |
251 |
|
7604 |
25 Feb 19 |
nicklas |
var firstNewIndex = list.length + 1; |
7604 |
25 Feb 19 |
nicklas |
if (recentItems && recentItems.length) |
7604 |
25 Feb 19 |
nicklas |
254 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Add recently used items |
7604 |
25 Feb 19 |
nicklas |
var recentlyUsedHeader = new Option('› recently used', 'NaN'); |
7604 |
25 Feb 19 |
nicklas |
recentlyUsedHeader.className = 'recentheader'; |
7604 |
25 Feb 19 |
nicklas |
recentlyUsedHeader.disabled = true; |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = recentlyUsedHeader; |
7604 |
25 Feb 19 |
nicklas |
260 |
|
7703 |
11 Apr 19 |
nicklas |
var cnt = 0; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < recentItems.length; i++) |
7604 |
25 Feb 19 |
nicklas |
263 |
{ |
7703 |
11 Apr 19 |
nicklas |
var item = recentItems[i]; |
7703 |
11 Apr 19 |
nicklas |
if (item.id) |
7703 |
11 Apr 19 |
nicklas |
266 |
{ |
7703 |
11 Apr 19 |
nicklas |
cnt++; |
7703 |
11 Apr 19 |
nicklas |
var selected = reselectValue == item.id; |
7703 |
11 Apr 19 |
nicklas |
var opt = new Option(cnt + '. ' + item.name, item.id, false, selected); |
7703 |
11 Apr 19 |
nicklas |
opt.className = 'selectoptionindent'; |
7703 |
11 Apr 19 |
nicklas |
list[list.length] = opt; |
7703 |
11 Apr 19 |
nicklas |
272 |
} |
7703 |
11 Apr 19 |
nicklas |
else |
7703 |
11 Apr 19 |
nicklas |
274 |
{ |
7703 |
11 Apr 19 |
nicklas |
// If there is an empty element we selected the 'none' option if it is available |
7703 |
11 Apr 19 |
nicklas |
if (!noNoneOption) firstNewIndex = 0; |
7703 |
11 Apr 19 |
nicklas |
277 |
} |
7604 |
25 Feb 19 |
nicklas |
278 |
} |
7604 |
25 Feb 19 |
nicklas |
279 |
} |
7604 |
25 Feb 19 |
nicklas |
280 |
|
7604 |
25 Feb 19 |
nicklas |
if (projectDefaults && projectDefaults.length) |
7604 |
25 Feb 19 |
nicklas |
282 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Add project default items |
7604 |
25 Feb 19 |
nicklas |
var projectDefaultHeader = new Option('› project default', 'NaN'); |
7604 |
25 Feb 19 |
nicklas |
projectDefaultHeader.className = 'defaultheader'; |
7604 |
25 Feb 19 |
nicklas |
projectDefaultHeader.disabled = true; |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = projectDefaultHeader; |
7604 |
25 Feb 19 |
nicklas |
288 |
|
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < projectDefaults.length; i++) |
7604 |
25 Feb 19 |
nicklas |
290 |
{ |
7604 |
25 Feb 19 |
nicklas |
var selected = reselectValue == projectDefaults[i].id; |
7604 |
25 Feb 19 |
nicklas |
var opt = new Option( projectDefaults[i].name, projectDefaults[i].id, false, selected); |
7604 |
25 Feb 19 |
nicklas |
opt.className = 'selectoptionindent'; |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = opt; |
7604 |
25 Feb 19 |
nicklas |
295 |
} |
7604 |
25 Feb 19 |
nicklas |
296 |
} |
7604 |
25 Feb 19 |
nicklas |
297 |
|
7604 |
25 Feb 19 |
nicklas |
// If no item is selected, select the first new item |
7604 |
25 Feb 19 |
nicklas |
if (list.selectedIndex == 0 && list.length > firstNewIndex) |
7604 |
25 Feb 19 |
nicklas |
300 |
{ |
7604 |
25 Feb 19 |
nicklas |
list.selectedIndex = firstNewIndex; |
7604 |
25 Feb 19 |
nicklas |
302 |
} |
7604 |
25 Feb 19 |
nicklas |
303 |
|
7604 |
25 Feb 19 |
nicklas |
var currentSelectedValue = list.selectedIndex >= 0 ? list[list.selectedIndex].value : 0; |
7604 |
25 Feb 19 |
nicklas |
return oldSelectedValue != currentSelectedValue; |
7604 |
25 Feb 19 |
nicklas |
306 |
} |
7604 |
25 Feb 19 |
nicklas |
307 |
|
7604 |
25 Feb 19 |
nicklas |
return subtype; |
7604 |
25 Feb 19 |
nicklas |
309 |
}(); |
7604 |
25 Feb 19 |
nicklas |
310 |
|