[gen] Ref field: allow to insert many selected items at once (Ref fields with link='list').
This commit is contained in:
parent
084f1f9a23
commit
e7c20f8d2b
16 changed files with 353 additions and 123 deletions
|
@ -66,7 +66,7 @@ img { border: 0; vertical-align: middle }
|
|||
background-color: #dbdde1; font-weight: bold }
|
||||
.navigate td { padding: 4px 9px }
|
||||
.login { margin: 3px; color: black }
|
||||
input.button { border-width: 0 !important; color: #666666; height: 23px;
|
||||
input.button { border-width: 0 !important; color: #666666; height: 24px;
|
||||
width: 150px; cursor:pointer; font-size: 90%; padding: 1px 0 0 10px;
|
||||
background-color: transparent !important }
|
||||
.buttons { margin-left: 4px }
|
||||
|
@ -157,3 +157,4 @@ td.search { padding-top: 8px }
|
|||
.error { margin: 5px }
|
||||
.podName { font-size: 90% }
|
||||
.podTable { margin-left: 15px }
|
||||
.cbCell { width: 10px; text-align: center}
|
||||
|
|
|
@ -229,13 +229,16 @@ function askRefField(hookId, objectUrl, fieldName, innerRef, startNumber,
|
|||
action, actionParams){
|
||||
// Sends an Ajax request for getting the content of a reference field.
|
||||
var startKey = hookId + '_startNumber';
|
||||
var params = {'innerRef': innerRef };
|
||||
var scope = hookId.split('_').pop();
|
||||
var params = {'innerRef': innerRef, 'scope': scope};
|
||||
params[startKey] = startNumber;
|
||||
if (action) params['action'] = action;
|
||||
if (actionParams) {
|
||||
for (key in actionParams) { params[key] = actionParams[key]; };
|
||||
}
|
||||
askAjaxChunk(hookId, 'GET', objectUrl, fieldName+':pxView', params);
|
||||
var px = (scope == 'objs')? ':pxView': ':pxViewPickList';
|
||||
askAjaxChunk(hookId, 'GET', objectUrl, fieldName + px, params, null,
|
||||
evalInnerScripts);
|
||||
}
|
||||
|
||||
function askField(hookId, objectUrl, layoutType, showChanges, masterValues,
|
||||
|
@ -251,7 +254,7 @@ function askField(hookId, objectUrl, layoutType, showChanges, masterValues,
|
|||
askAjaxChunk(hookId, 'GET', objectUrl, px, params, null, evalInnerScripts);
|
||||
}
|
||||
|
||||
// Function used by checkbox widgets for having radio-button-like behaviour
|
||||
// Used by checkbox widgets for having radio-button-like behaviour.
|
||||
function toggleCheckbox(visibleCheckbox, hiddenBoolean) {
|
||||
vis = document.getElementById(visibleCheckbox);
|
||||
hidden = document.getElementById(hiddenBoolean);
|
||||
|
@ -259,6 +262,61 @@ function toggleCheckbox(visibleCheckbox, hiddenBoolean) {
|
|||
else hidden.value = 'False';
|
||||
}
|
||||
|
||||
// (Un)checks a checkbox corresponding to a linked object.
|
||||
function toggleRefCb(checkbox) {
|
||||
var name = checkbox.getAttribute('name');
|
||||
var elems = name.split('_');
|
||||
// Get the DOM node corresponding to the Ref field.
|
||||
var node = document.getElementById(elems[0] + '_' + elems[1]);
|
||||
// Get the array that stores checkbox statuses.
|
||||
var statuses = node['_appy_' + elems[2] + '_cbs'];
|
||||
// Get the array semantics
|
||||
var semantics = node['_appy_' + elems[2] + '_sem'];
|
||||
var uid = checkbox.value;
|
||||
if (semantics == 'unchecked') {
|
||||
if (!checkbox.checked) statuses[uid] = null;
|
||||
else {if (uid in statuses) delete statuses[uid]};
|
||||
}
|
||||
else { // semantics is 'checked'
|
||||
if (checkbox.checked) statuses[uid] = null;
|
||||
else {if (uid in statuses) delete statuses[uid]};
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise checkboxes of a Ref field.
|
||||
function initRefCbs(id) {
|
||||
var elems = id.split('_');
|
||||
// Get the DOM node corresponding to the Ref field.
|
||||
var node = document.getElementById(elems[0] + '_' + elems[1]);
|
||||
// Get the array that stores checkbox statuses.
|
||||
var statuses = node['_appy_' + elems[2] + '_cbs'];
|
||||
// Get the array semantics
|
||||
var semantics = node['_appy_' + elems[2] + '_sem'];
|
||||
var value = (semantics == 'unchecked')? false: true;
|
||||
// Update visible checkboxes.
|
||||
var checkboxes = getElementsHavingName('input', id);
|
||||
for (var i=0; i < checkboxes.length; i++) {
|
||||
if (checkboxes[i].value in statuses) checkboxes[i].checked = value;
|
||||
else checkboxes[i].checked = !value;
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle all checkboxes of a Ref field.
|
||||
function toggleAllRefCbs(id) {
|
||||
var elems = id.split('_');
|
||||
// Get the DOM node corresponding to the Ref field.
|
||||
var node = document.getElementById(elems[0] + '_' + elems[1]);
|
||||
// Empty the array that stores checkbox statuses.
|
||||
var statuses = node['_appy_' + elems[2] + '_cbs'];
|
||||
for (var key in statuses) delete statuses[key];
|
||||
// Switch the array semantics.
|
||||
var semAttr = '_appy_' + elems[2] + '_sem';
|
||||
if (node[semAttr] == 'unchecked') node[semAttr] = 'checked';
|
||||
else node[semAttr] = 'unchecked';
|
||||
// Update the visible checkboxes
|
||||
initRefCbs(id);
|
||||
}
|
||||
|
||||
// Shows/hides a dropdown menu
|
||||
function toggleDropdown(dropdownId, forcedValue){
|
||||
var dropdown = document.getElementById(dropdownId);
|
||||
|
@ -456,22 +514,35 @@ function onDeleteEvent(objectUid, eventTime) {
|
|||
askConfirm('form', 'deleteEventForm', action_confirm);
|
||||
}
|
||||
|
||||
function onUnlinkObject(sourceUid, fieldName, targetUid) {
|
||||
f = document.getElementById('unlinkForm');
|
||||
f.sourceUid.value = sourceUid;
|
||||
f.fieldName.value = fieldName;
|
||||
f.targetUid.value = targetUid;
|
||||
askConfirm('form', 'unlinkForm', action_confirm);
|
||||
}
|
||||
|
||||
function onLinkObject(sourceUid, fieldName, targetUid) {
|
||||
function onLink(action, sourceUid, fieldName, targetUid) {
|
||||
f = document.getElementById('linkForm');
|
||||
f.linkAction.value = action;
|
||||
f.sourceUid.value = sourceUid;
|
||||
f.fieldName.value = fieldName;
|
||||
f.targetUid.value = targetUid;
|
||||
f.submit();
|
||||
}
|
||||
|
||||
function onLinkMany(id) {
|
||||
var elems = id.split('_');
|
||||
// Get the DOM node corresponding to the Ref field.
|
||||
var node = document.getElementById(elems[0] + '_' + elems[1]);
|
||||
// Get the uids of (un-)checked objects.
|
||||
var statuses = node['_appy_' + elems[2] + '_cbs'];
|
||||
var uids = '';
|
||||
for (var uid in statuses) uids += uid + ',';
|
||||
// Get the array semantics
|
||||
var semantics = node['_appy_' + elems[2] + '_sem'];
|
||||
// Fill the form and ask for a confirmation
|
||||
f = document.getElementById('linkForm');
|
||||
f.linkAction.value = 'link_many';
|
||||
f.sourceUid.value = elems[0];
|
||||
f.fieldName.value = elems[1];
|
||||
f.targetUid.value = uids;
|
||||
f.semantics.value = semantics;
|
||||
askConfirm('form', 'linkForm', action_confirm);
|
||||
}
|
||||
|
||||
function onUnlockPage(objectUid, pageName) {
|
||||
f = document.getElementById('unlockForm');
|
||||
f.objectUid.value = objectUid;
|
||||
|
|
BIN
gen/ui/checkall.png
Normal file
BIN
gen/ui/checkall.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 235 B |
BIN
gen/ui/linkMany.png
Normal file
BIN
gen/ui/linkMany.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 322 B |
BIN
gen/ui/unlinkUp.png
Normal file
BIN
gen/ui/unlinkUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 234 B |
Loading…
Add table
Add a link
Reference in a new issue