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 Projects = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var projects = {}; |
7604 |
25 Feb 19 |
nicklas |
var Permission = {}; |
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 |
projects.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 |
Permission.READ = Data.int('page-data', 'read'); |
7604 |
25 Feb 19 |
nicklas |
Permission.USE = Data.int('page-data', 'use'); |
7604 |
25 Feb 19 |
nicklas |
Permission.RESTRICTED_WRITE = Data.int('page-data', 'restricted-write'); |
7604 |
25 Feb 19 |
nicklas |
Permission.WRITE = Data.int('page-data', 'write'); |
7604 |
25 Feb 19 |
nicklas |
Permission.DELETE = Data.int('page-data', 'delete'); |
7604 |
25 Feb 19 |
nicklas |
Permission.SET_OWNER = Data.int('page-data', 'set-owner'); |
7604 |
25 Feb 19 |
nicklas |
Permission.SET_PERMISSION = Data.int('page-data', 'set-permission'); |
7604 |
25 Feb 19 |
nicklas |
46 |
|
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', projects.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
50 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', projects.validateProject); |
7703 |
11 Apr 19 |
nicklas |
TabControl.addTabActivateListener('settings.annotations', Annotations.onSwitchToAnnotationsTab); |
7604 |
25 Feb 19 |
nicklas |
54 |
|
7604 |
25 Feb 19 |
nicklas |
// Members |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddUsers', projects.addUsers); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddUsers', 'base-selected', projects.addUserCallback); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddGroups', projects.addGroups); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddGroups', 'base-selected', projects.addGroupCallback); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('members', 'change', projects.membersOnChange); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('members', 'base-removed', projects.memberRemoved); |
7604 |
25 Feb 19 |
nicklas |
62 |
|
7604 |
25 Feb 19 |
nicklas |
// Permissions |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('read', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('use', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('restricted_write', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('write', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('delete', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('setOwner', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('setPermission', 'click', projects.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
71 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoRead', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoUse', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoRestrictedWrite', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoWrite', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoDelete', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoSetOwner', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('autoSetPermission', 'click', projects.autoPermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
79 |
|
7604 |
25 Feb 19 |
nicklas |
// Permission templates |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('permissiontemplate_id.select', projects.selectPermissionTemplate); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('permissiontemplate_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('permissiontemplate_id', 'change', projects.permissionTemplateOnChange); |
7604 |
25 Feb 19 |
nicklas |
projects.permissionTemplateOnChange(); |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
projects.showPermissions(parseInt(frm.autoPermissions.value), 'auto_'); |
7604 |
25 Feb 19 |
nicklas |
87 |
|
7604 |
25 Feb 19 |
nicklas |
88 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
90 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'PROJECT', '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('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('btnSetActive', projects.setActive, attributes); |
7604 |
25 Feb 19 |
nicklas |
103 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.items', projects.viewItems); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.history', History.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
107 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
109 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'PROJECT'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'projects'}; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItem', Buttons.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('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 |
120 |
|
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 |
123 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'set-active') |
7604 |
25 Feb 19 |
nicklas |
125 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
window.opener.location.reload(); |
7604 |
25 Feb 19 |
nicklas |
setTimeout(App.closeWindow, 500); |
7604 |
25 Feb 19 |
nicklas |
129 |
} |
7604 |
25 Feb 19 |
nicklas |
130 |
} |
7604 |
25 Feb 19 |
nicklas |
131 |
|
7604 |
25 Feb 19 |
nicklas |
projects.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'set-active') |
7604 |
25 Feb 19 |
nicklas |
135 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, projects.setActive); |
7604 |
25 Feb 19 |
nicklas |
137 |
} |
7604 |
25 Feb 19 |
nicklas |
138 |
} |
7604 |
25 Feb 19 |
nicklas |
139 |
|
7604 |
25 Feb 19 |
nicklas |
projects.setActive = function(event) |
7604 |
25 Feb 19 |
nicklas |
141 |
{ |
7604 |
25 Feb 19 |
nicklas |
var projectId = Data.get(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'set_active.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&project_id='+projectId; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'SetActiveProject', 300, 200); |
7604 |
25 Feb 19 |
nicklas |
146 |
} |
7604 |
25 Feb 19 |
nicklas |
147 |
|
7604 |
25 Feb 19 |
nicklas |
projects.viewItems = function() |
7604 |
25 Feb 19 |
nicklas |
149 |
{ |
7604 |
25 Feb 19 |
nicklas |
var projectId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'items/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=List&project_id='+projectId; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
154 |
} |
7604 |
25 Feb 19 |
nicklas |
155 |
|
7604 |
25 Feb 19 |
nicklas |
projects.validateProject = function() |
7604 |
25 Feb 19 |
nicklas |
157 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
160 |
{ |
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 |
163 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
165 |
} |
7604 |
25 Feb 19 |
nicklas |
166 |
|
7604 |
25 Feb 19 |
nicklas |
projects.save = function() |
7604 |
25 Feb 19 |
nicklas |
168 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
171 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
Link.exportActions('defaultItems'); |
7604 |
25 Feb 19 |
nicklas |
Link.exportActions('members', '!'); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
176 |
} |
7604 |
25 Feb 19 |
nicklas |
177 |
} |
7604 |
25 Feb 19 |
nicklas |
178 |
|
7604 |
25 Feb 19 |
nicklas |
projects.getPermissionCode = function(prefix) |
7604 |
25 Feb 19 |
nicklas |
180 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!prefix) prefix = ''; |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = 0; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'read'].checked) permissionCode += Permission.READ; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'use'].checked) permissionCode += Permission.USE; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'restricted_write'].checked) permissionCode += Permission.RESTRICTED_WRITE; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'write'].checked) permissionCode += Permission.WRITE; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'delete'].checked) permissionCode += Permission.DELETE; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'set_owner'].checked) permissionCode += Permission.SET_OWNER; |
7604 |
25 Feb 19 |
nicklas |
if (frm[prefix+'set_permission'].checked) permissionCode += Permission.SET_PERMISSION; |
7604 |
25 Feb 19 |
nicklas |
return permissionCode; |
7604 |
25 Feb 19 |
nicklas |
192 |
} |
7604 |
25 Feb 19 |
nicklas |
193 |
|
7604 |
25 Feb 19 |
nicklas |
projects.getPermissionString = function(permissionCode) |
7604 |
25 Feb 19 |
nicklas |
195 |
{ |
7604 |
25 Feb 19 |
nicklas |
var s = ''; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.READ ? "R" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.USE ? "U" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.RESTRICTED_WRITE ? "A" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.WRITE ? "W" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.DELETE ? "D" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.SET_OWNER ? "O" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.SET_PERMISSION ? "P" : "-"; |
7604 |
25 Feb 19 |
nicklas |
return s; |
7604 |
25 Feb 19 |
nicklas |
205 |
} |
7604 |
25 Feb 19 |
nicklas |
206 |
|
7604 |
25 Feb 19 |
nicklas |
projects.showPermissions = function(permissionCode, prefix) |
7604 |
25 Feb 19 |
nicklas |
208 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!prefix) prefix = ''; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'read'].checked = permissionCode & Permission.READ; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'use'].checked = permissionCode & Permission.USE; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'restricted_write'].checked = permissionCode & Permission.RESTRICTED_WRITE; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'write'].checked = permissionCode & Permission.WRITE; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'delete'].checked = permissionCode & Permission.DELETE; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'set_owner'].checked = permissionCode & Permission.SET_OWNER; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'set_permission'].checked = permissionCode & Permission.SET_PERMISSION; |
7604 |
25 Feb 19 |
nicklas |
218 |
} |
7604 |
25 Feb 19 |
nicklas |
219 |
|
7604 |
25 Feb 19 |
nicklas |
220 |
/** |
7604 |
25 Feb 19 |
nicklas |
Makes sure all permission checkboxes are in a consistent state with each other. |
7604 |
25 Feb 19 |
nicklas |
222 |
*/ |
7604 |
25 Feb 19 |
nicklas |
projects.ensureImpliedPermissions = function(checked, prefix) |
7604 |
25 Feb 19 |
nicklas |
224 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!prefix) prefix = ''; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
if (checked) |
7604 |
25 Feb 19 |
nicklas |
228 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'write'].checked = frm[prefix+'write'].checked || frm[prefix+'delete'].checked || frm[prefix+'set_owner'].checked || frm[prefix+'set_permission'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'restricted_write'].checked = frm[prefix+'restricted_write'].checked || frm[prefix+'write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'use'].checked = frm[prefix+'use'].checked || frm[prefix+'write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'read'].checked = frm[prefix+'read'].checked || frm[prefix+'use'].checked || frm[prefix+'restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
233 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
235 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'use'].checked = frm[prefix+'use'].checked && frm[prefix+'read'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'restricted_write'].checked = frm[prefix+'restricted_write'].checked && frm[prefix+'read'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'write'].checked = frm[prefix+'write'].checked && frm[prefix+'use'].checked && frm[prefix+'restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'delete'].checked = frm[prefix+'delete'].checked && frm[prefix+'write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'set_owner'].checked = frm[prefix+'set_owner'].checked && frm[prefix+'write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm[prefix+'set_permission'].checked = frm[prefix+'set_permission'].checked && frm[prefix+'write'].checked; |
7604 |
25 Feb 19 |
nicklas |
242 |
} |
7604 |
25 Feb 19 |
nicklas |
243 |
} |
7604 |
25 Feb 19 |
nicklas |
244 |
|
7604 |
25 Feb 19 |
nicklas |
projects.permissionsOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
246 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var radio = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
projects.ensureImpliedPermissions(radio.checked); |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = projects.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionString = projects.getPermissionString(permissionCode); |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.members.length; i++) |
7604 |
25 Feb 19 |
nicklas |
253 |
{ |
7604 |
25 Feb 19 |
nicklas |
var option = frm.members[i]; |
7604 |
25 Feb 19 |
nicklas |
if (option.selected && option.item.id) |
7604 |
25 Feb 19 |
nicklas |
256 |
{ |
7604 |
25 Feb 19 |
nicklas |
option.item.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
var text = option.text.replace(/\[.*\]/, '['+permissionString+']'); |
7604 |
25 Feb 19 |
nicklas |
option.text = text; |
7604 |
25 Feb 19 |
nicklas |
260 |
} |
7604 |
25 Feb 19 |
nicklas |
261 |
} |
7604 |
25 Feb 19 |
nicklas |
262 |
} |
7604 |
25 Feb 19 |
nicklas |
263 |
|
7604 |
25 Feb 19 |
nicklas |
projects.autoPermissionsOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
265 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var radio = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
projects.ensureImpliedPermissions(radio.checked, 'auto_'); |
7604 |
25 Feb 19 |
nicklas |
frm.autoPermissions.value = projects.getPermissionCode('auto_'); |
7604 |
25 Feb 19 |
nicklas |
270 |
} |
7604 |
25 Feb 19 |
nicklas |
271 |
|
7604 |
25 Feb 19 |
nicklas |
272 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog for selecting users. |
7604 |
25 Feb 19 |
nicklas |
274 |
*/ |
7604 |
25 Feb 19 |
nicklas |
projects.addUsers = function(event) |
7604 |
25 Feb 19 |
nicklas |
276 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var current = Link.getIdsInList(frm.members, 'USER'); |
7604 |
25 Feb 19 |
nicklas |
var url = "&exclude="+current.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += '&permission=READ'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('USER', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
282 |
} |
7604 |
25 Feb 19 |
nicklas |
283 |
|
7604 |
25 Feb 19 |
nicklas |
projects.addUserCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
285 |
{ |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = projects.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionString = projects.getPermissionString(permissionCode); |
7604 |
25 Feb 19 |
nicklas |
288 |
|
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' ['+permissionString+']'; |
7604 |
25 Feb 19 |
nicklas |
event.detail.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
event.detail.originalValue = 0; |
7604 |
25 Feb 19 |
nicklas |
292 |
|
7604 |
25 Feb 19 |
nicklas |
Link.addItem('members', 'USER', event.detail); |
7604 |
25 Feb 19 |
nicklas |
294 |
} |
7604 |
25 Feb 19 |
nicklas |
295 |
|
7604 |
25 Feb 19 |
nicklas |
296 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog for selecting groups. |
7604 |
25 Feb 19 |
nicklas |
298 |
*/ |
7604 |
25 Feb 19 |
nicklas |
projects.addGroups = function(event) |
7604 |
25 Feb 19 |
nicklas |
300 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var current = Link.getIdsInList(frm.members, 'GROUP'); |
7604 |
25 Feb 19 |
nicklas |
if (!Data.int('page-data', 'share-to-everyone')) |
7604 |
25 Feb 19 |
nicklas |
304 |
{ |
7604 |
25 Feb 19 |
nicklas |
current[current.length] = Data.int('page-data', 'everyone-id'); |
7604 |
25 Feb 19 |
nicklas |
306 |
} |
7604 |
25 Feb 19 |
nicklas |
var url = "&exclude="+current.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += '&permission=READ'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('GROUP', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
310 |
} |
7604 |
25 Feb 19 |
nicklas |
311 |
|
7604 |
25 Feb 19 |
nicklas |
projects.addGroupCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
313 |
{ |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = projects.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionString = projects.getPermissionString(permissionCode); |
7604 |
25 Feb 19 |
nicklas |
316 |
|
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' ['+permissionString+']'; |
7604 |
25 Feb 19 |
nicklas |
event.detail.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
event.detail.originalValue = 0; |
7604 |
25 Feb 19 |
nicklas |
320 |
|
7604 |
25 Feb 19 |
nicklas |
Link.addItem('members', 'GROUP', event.detail); |
7604 |
25 Feb 19 |
nicklas |
322 |
} |
7604 |
25 Feb 19 |
nicklas |
323 |
|
7604 |
25 Feb 19 |
nicklas |
324 |
/** |
7604 |
25 Feb 19 |
nicklas |
Set the permission value to 0 when an item is removed |
7604 |
25 Feb 19 |
nicklas |
326 |
*/ |
7604 |
25 Feb 19 |
nicklas |
projects.memberRemoved = function(event) |
7604 |
25 Feb 19 |
nicklas |
328 |
{ |
7604 |
25 Feb 19 |
nicklas |
event.detail.item.value = 0; |
7604 |
25 Feb 19 |
nicklas |
330 |
} |
7604 |
25 Feb 19 |
nicklas |
331 |
|
7604 |
25 Feb 19 |
nicklas |
332 |
/** |
7604 |
25 Feb 19 |
nicklas |
Update permission checkboxes for the current selected member. |
7604 |
25 Feb 19 |
nicklas |
334 |
*/ |
7604 |
25 Feb 19 |
nicklas |
projects.membersOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
336 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var item = frm.members[frm.members.selectedIndex].item; |
7604 |
25 Feb 19 |
nicklas |
projects.showPermissions(item && item.id ? item.value : 0); |
7604 |
25 Feb 19 |
nicklas |
340 |
} |
7604 |
25 Feb 19 |
nicklas |
341 |
|
7604 |
25 Feb 19 |
nicklas |
projects.selectPermissionTemplate = function() |
7604 |
25 Feb 19 |
nicklas |
343 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
if (frm.permissiontemplate_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
347 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.permissiontemplate_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
350 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PERMISSIONTEMPLATE', 'permissiontemplate_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
352 |
} |
7604 |
25 Feb 19 |
nicklas |
353 |
|
7604 |
25 Feb 19 |
nicklas |
projects.permissionTemplateOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
355 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['project']; |
7604 |
25 Feb 19 |
nicklas |
var hasTemplate = frm.permissiontemplate_id.selectedIndex > 0; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_read.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_use.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_restricted_write.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_write.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_delete.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_set_owner.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
frm.auto_set_permission.disabled = hasTemplate; |
7604 |
25 Feb 19 |
nicklas |
365 |
} |
7604 |
25 Feb 19 |
nicklas |
366 |
|
7604 |
25 Feb 19 |
nicklas |
367 |
|
7604 |
25 Feb 19 |
nicklas |
return projects; |
7604 |
25 Feb 19 |
nicklas |
369 |
}(); |
7604 |
25 Feb 19 |
nicklas |
370 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Projects.initPage); |
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(Projects.initElements); |