[gen] Improved performance of the Ref field and added an icon for dissociating referred objects.

This commit is contained in:
Gaetan Delannay 2012-10-08 10:08:54 +02:00
parent 872b77208b
commit 9954edf71a
9 changed files with 71 additions and 19 deletions

View file

@ -318,6 +318,14 @@ function onDeleteObject(objectUid) {
askConfirm('form', 'deleteForm', delete_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', unlink_confirm);
}
function createCookie(name, value, days) {
if (days) {
var date = new Date();

View file

@ -18,6 +18,13 @@
<input type="hidden" name="action" value="Delete"/>
<input type="hidden" name="objectUid"/>
</form>
<tal:comment replace="nothing">Global form for unlinking an object</tal:comment>
<form id="unlinkForm" method="post" action="do">
<input type="hidden" name="action" value="Unlink"/>
<input type="hidden" name="sourceUid"/>
<input type="hidden" name="fieldName"/>
<input type="hidden" name="targetUid"/>
</form>
<tal:comment replace="nothing">Global form for generating a document from a pod template</tal:comment>
<form name="podTemplateForm" method="post"
tal:attributes="action python: tool.absolute_url() + '/generateDocument'">

BIN
gen/ui/unlink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

View file

@ -19,10 +19,11 @@
<metal:objectActions define-macro="objectActions">
<tal:comment replace="nothing">Displays icons for triggering actions on a given
referenced object (edit, delete, etc).</tal:comment>
<table class="noStyle">
<tr>
<table class="noStyle"
tal:define="isBack appyType/isBack">
<tr>
<tal:comment replace="nothing">Arrows for moving objects up or down</tal:comment>
<td tal:condition="python: not appyType['isBack'] and (len(objs)&gt;1) and changeOrder and context.allows('Modify portal content')">
<td tal:condition="python: not isBack and (len(objs)&gt;1) and changeOrder and canWrite">
<tal:moveRef define="objectIndex python: contextObj.getAppyRefIndex(fieldName, obj);
ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'ChangeRefOrder\', {\'refObjectUid\':\'%s\', \'move\':\'**v**\'}' % (startNumber, obj.UID()))">
<tal:comment replace="nothing">Move up</tal:comment>
@ -39,23 +40,29 @@
style="cursor:pointer"/>
</tal:moveRef>
</td>
<tal:comment replace="nothing">Edit the element</tal:comment>
<td tal:condition="python: not appyType['noForm'] and obj.mayEdit()">
<tal:comment replace="nothing">Edit</tal:comment>
<td tal:condition="python: not appyType['noForm'] and obj.mayEdit() and appyType['delete']">
<a tal:define="navInfo python:'ref.%s.%s:%s.%d.%d' % (contextObj.UID(), fieldName, appyType['pageName'], repeat['obj'].number()+startNumber, totalNumber);"
tal:attributes="href python: obj.getUrl(mode='edit', page='main', nav=navInfo)">
<img tal:attributes="src string: $appUrl/ui/edit.gif;
title python: _('object_edit')"/>
</a>
</td>
<tal:comment replace="nothing">Delete the element</tal:comment>
<td>
<tal:comment replace="nothing">Delete</tal:comment>
<td tal:condition="python: not isBack and appyType['delete'] and canWrite and obj.mayDelete()">
<img style="cursor:pointer"
tal:condition="python: not appyType['isBack'] and obj.mayDelete()"
tal:attributes="src string: $appUrl/ui/delete.png;
onClick python:'onDeleteObject(\'%s\')' % obj.UID();
title python: _('object_delete')"/>
</td>
</tr>
<tal:comment replace="nothing">Unlink</tal:comment>
<td tal:condition="python: not isBack and appyType['unlink'] and canWrite">
<img style="cursor:pointer"
tal:attributes="src string: $appUrl/ui/unlink.png;
onClick python:'onUnlinkObject(\'%s\',\'%s\',\'%s\')' % (contextObj.UID(), appyType['name'], obj.UID());
title python: _('object_unlink')"/>
</td>
</tr>
</table>
</metal:objectActions>