[gen] Ref field improved.
This commit is contained in:
parent
b9bfee9615
commit
977cd0a225
13 changed files with 141 additions and 90 deletions
|
@ -31,7 +31,7 @@ class Action(Field):
|
|||
label=_(field.labelId)"
|
||||
id=":formId" action=":ztool.absolute_url() + '/do'">
|
||||
<input type="hidden" name="action" value="ExecuteAppyAction"/>
|
||||
<input type="hidden" name="objectUid" value=":zobj.UID()"/>
|
||||
<input type="hidden" name="objectUid" value=":zobj.id"/>
|
||||
<input type="hidden" name="fieldName" value=":name"/>
|
||||
<input if="field.confirm" type="button" class="button"
|
||||
var="labelConfirm=_(field.labelId + '_confirm')"
|
||||
|
|
|
@ -978,6 +978,7 @@ class Ref(Field):
|
|||
unlink_many, delete_many).'''
|
||||
action = rq['linkAction']
|
||||
tool = obj.getTool()
|
||||
msg = None
|
||||
if not action.endswith('_many'):
|
||||
# "link" or "unlink"
|
||||
tied = tool.getObject(rq['targetUid'])
|
||||
|
@ -1012,23 +1013,25 @@ class Ref(Field):
|
|||
# Collect this object
|
||||
target = not isObj and tool.getObject(value) or value.o
|
||||
targets.append(target)
|
||||
# Perform the action on every target. Count the number of failed
|
||||
# operations.
|
||||
mustDelete = action == 'delete_many'
|
||||
failed = 0
|
||||
for target in targets:
|
||||
if mustDelete:
|
||||
# Delete
|
||||
if target.mayDelete(): target.delete()
|
||||
else: failed += 1
|
||||
else:
|
||||
# Link or unlink
|
||||
exec 'self.%sObject(obj, target)' % action.split('_')[0]
|
||||
if not targets:
|
||||
msg = obj.translate('action_null')
|
||||
else:
|
||||
# Perform the action on every target. Count the number of failed
|
||||
# operations.
|
||||
failed = 0
|
||||
mustDelete = action == 'delete_many'
|
||||
for target in targets:
|
||||
if mustDelete:
|
||||
# Delete
|
||||
if target.mayDelete(): target.delete()
|
||||
else: failed += 1
|
||||
else:
|
||||
# Link or unlink
|
||||
exec 'self.%sObject(obj, target)' % action.split('_')[0]
|
||||
if failed:
|
||||
msg = obj.translate('action_partial', mapping={'nb':failed})
|
||||
urlBack = obj.getUrl(rq['HTTP_REFERER'])
|
||||
if not failed:
|
||||
msg = obj.translate('action_done')
|
||||
else:
|
||||
msg = obj.translate('action_partial', mapping={'nb':failed})
|
||||
if not msg: msg = obj.translate('action_done')
|
||||
obj.say(msg)
|
||||
tool.goto(urlBack)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue