[gen] Ajaxified query result and tied object rows.
This commit is contained in:
parent
1bd6cf29a3
commit
45192ca4bc
|
@ -97,6 +97,28 @@ class Field:
|
||||||
context[k] = ctx[k]
|
context[k] = ctx[k]
|
||||||
return self.pxRender(context).encode('utf-8')
|
return self.pxRender(context).encode('utf-8')
|
||||||
|
|
||||||
|
# Show the field content for some object on a list of referred objects
|
||||||
|
pxRenderAsTied = Px('''
|
||||||
|
<!-- The "title" field -->
|
||||||
|
<x if="refField.name == 'title'">
|
||||||
|
<x if="mayView">
|
||||||
|
<x if="not field.menuUrlMethod">:field.pxObjectTitle</x>
|
||||||
|
<a if="field.menuUrlMethod"
|
||||||
|
var2="info=field.getMenuUrl(zobj, tied)"
|
||||||
|
href=":info[0]" target=":info[1]">:tied.title</a>
|
||||||
|
<x if="tied.o.mayAct()">:field.pxObjectActions</x>
|
||||||
|
</x>
|
||||||
|
<div if="not mayView">
|
||||||
|
<img src=":url('fake')" style="margin-right: 5px"/>
|
||||||
|
<x>:_('unauthorized')</x></div>
|
||||||
|
</x>
|
||||||
|
<!-- Any other field -->
|
||||||
|
<x if="(refField.name != 'title') and mayView">
|
||||||
|
<x var="zobj=tied.o; obj=tied; layoutType='cell';
|
||||||
|
innerRef=True; field=refField"
|
||||||
|
if="field.isShowable(zobj, 'result')">:field.pxRender</x>
|
||||||
|
</x>''')
|
||||||
|
|
||||||
# Show the field content for some object on a list of results
|
# Show the field content for some object on a list of results
|
||||||
pxRenderAsResult = Px('''
|
pxRenderAsResult = Px('''
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
|
|
|
@ -31,19 +31,18 @@ class Action(Field):
|
||||||
label=_(field.labelId);
|
label=_(field.labelId);
|
||||||
descr=field.hasDescr and _(field.descrId) or None;
|
descr=field.hasDescr and _(field.descrId) or None;
|
||||||
smallButtons=smallButtons|False;
|
smallButtons=smallButtons|False;
|
||||||
css=ztool.getButtonCss(label, smallButtons)"
|
css=ztool.getButtonCss(label, smallButtons);
|
||||||
|
back=(layoutType == 'cell') and q(zobj.id) or 'null'"
|
||||||
id=":formId" action=":zobj.absolute_url() + '/onExecuteAction'"
|
id=":formId" action=":zobj.absolute_url() + '/onExecuteAction'"
|
||||||
style="display:inline">
|
style="display:inline">
|
||||||
<input type="hidden" name="fieldName" value=":name"/>
|
<input type="hidden" name="fieldName" value=":name"/>
|
||||||
<input type="hidden" name="comment" value=""/>
|
<input type="hidden" name="comment" value=""/>
|
||||||
<input if="field.confirm" type="button" class=":css" title=":descr"
|
<input type="button" class=":css" title=":descr"
|
||||||
var="labelConfirm=_(field.labelId + '_confirm');
|
var="textConfirm=field.confirm and _(field.labelId+'_confirm') or '';
|
||||||
commentParam=(field.confirm == 'text') and 'true' or 'false'"
|
showComment=(field.confirm == 'text') and 'true' or 'false'"
|
||||||
value=":label" style=":url(field.icon, bg=True)"
|
value=":label" style=":url(field.icon, bg=True)"
|
||||||
onclick=":'askConfirm(%s,%s,%s,%s)' % (q('form'), q(formId), \
|
onclick=":'submitForm(%s,%s,%s,%s)' % (q(formId), q(textConfirm), \
|
||||||
q(labelConfirm), commentParam)"/>
|
showComment, back)"/>
|
||||||
<input if="not field.confirm" type="submit" class=":css" name="do"
|
|
||||||
value=":label" title=":descr" style=":url(field.icon, bg=True)"/>
|
|
||||||
</form>''')
|
</form>''')
|
||||||
|
|
||||||
# It is not possible to edit an action, not to search it
|
# It is not possible to edit an action, not to search it
|
||||||
|
@ -145,6 +144,8 @@ class Action(Field):
|
||||||
suffix = successfull and 'done' or 'ko'
|
suffix = successfull and 'done' or 'ko'
|
||||||
msg = obj.translate('action_%s' % suffix)
|
msg = obj.translate('action_%s' % suffix)
|
||||||
if (self.result == 'computation') or not successfull:
|
if (self.result == 'computation') or not successfull:
|
||||||
|
# If we are called from an Ajax request, simply return msg
|
||||||
|
if hasattr(rq, 'pxContext') and rq.pxContext['ajax']: return msg
|
||||||
obj.say(msg)
|
obj.say(msg)
|
||||||
return obj.goto(obj.getUrl(rq['HTTP_REFERER']))
|
return obj.goto(obj.getUrl(rq['HTTP_REFERER']))
|
||||||
elif self.result == 'file':
|
elif self.result == 'file':
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Ref(Field):
|
||||||
# defined. If we are on a forward reference, the "nav" parameter is added to
|
# defined. If we are on a forward reference, the "nav" parameter is added to
|
||||||
# the URL for allowing to navigate from one object to the next/previous one.
|
# the URL for allowing to navigate from one object to the next/previous one.
|
||||||
pxObjectTitle = Px('''
|
pxObjectTitle = Px('''
|
||||||
<x var="navInfo=field.getNavInfo(zobj, loop.tied.nb + 1 + startNumber, \
|
<x var="navInfo=field.getNavInfo(zobj, startNumber + currentNumber, \
|
||||||
totalNumber, inPickList);
|
totalNumber, inPickList);
|
||||||
pageName=field.isBack and field.back.pageName or 'main'">
|
pageName=field.isBack and field.back.pageName or 'main'">
|
||||||
<x>::tied.o.getSupTitle(navInfo)</x>
|
<x>::tied.o.getSupTitle(navInfo)</x>
|
||||||
|
@ -106,7 +106,7 @@ class Ref(Field):
|
||||||
</x>
|
</x>
|
||||||
<!-- Edit -->
|
<!-- Edit -->
|
||||||
<a if="not field.noForm and tied.o.mayEdit()"
|
<a if="not field.noForm and tied.o.mayEdit()"
|
||||||
var2="navInfo=field.getNavInfo(zobj, loop.tied.nb + 1 + startNumber, \
|
var2="navInfo=field.getNavInfo(zobj, startNumber + currentNumber, \
|
||||||
totalNumber);
|
totalNumber);
|
||||||
linkInPopup=inPopup or (target.target != '_self')"
|
linkInPopup=inPopup or (target.target != '_self')"
|
||||||
href=":tied.o.getUrl(mode='edit', page='main', nav=navInfo, \
|
href=":tied.o.getUrl(mode='edit', page='main', nav=navInfo, \
|
||||||
|
@ -204,7 +204,7 @@ class Ref(Field):
|
||||||
q(sortConfirm))"/>
|
q(sortConfirm))"/>
|
||||||
</x>''')
|
</x>''')
|
||||||
|
|
||||||
# Shows the object number in a numbered list of tied objects.
|
# Shows the object number in a numbered list of tied objects
|
||||||
pxNumber = Px('''
|
pxNumber = Px('''
|
||||||
<x if="not changeNumber">:objectIndex+1</x>
|
<x if="not changeNumber">:objectIndex+1</x>
|
||||||
<div if="changeNumber" class="dropdownMenu"
|
<div if="changeNumber" class="dropdownMenu"
|
||||||
|
@ -258,7 +258,14 @@ class Ref(Field):
|
||||||
class=":not innerRef and 'list' or ''"
|
class=":not innerRef and 'list' or ''"
|
||||||
width=":innerRef and '100%' or field.layouts['view'].width"
|
width=":innerRef and '100%' or field.layouts['view'].width"
|
||||||
var2="columns=ztool.getColumnsSpecifiers(tiedClassName, \
|
var2="columns=ztool.getColumnsSpecifiers(tiedClassName, \
|
||||||
field.getAttribute(obj, 'shownInfo'), dir)">
|
field.getAttribute(obj, 'shownInfo'), dir);
|
||||||
|
currentNumber=0">
|
||||||
|
<script>:field.getAjaxData(ajaxHookId, zobj, popup=inPopup, \
|
||||||
|
checkboxes=checkboxes, startNumber=startNumber, \
|
||||||
|
totalNumber=totalNumber, sourceId=zobj.id, \
|
||||||
|
refFieldName=field.name, inPickList=inPickList, \
|
||||||
|
numbered=numbered, navBaseCall=navBaseCall)</script>
|
||||||
|
|
||||||
<tr if="field.showHeaders">
|
<tr if="field.showHeaders">
|
||||||
<th if="not inPickList and numbered" width=":numbered"></th>
|
<th if="not inPickList and numbered" width=":numbered"></th>
|
||||||
<th if="checkboxes" class="cbCell">
|
<th if="checkboxes" class="cbCell">
|
||||||
|
@ -274,41 +281,10 @@ class Ref(Field):
|
||||||
field=refField">:tool.pxShowDetails</x>
|
field=refField">:tool.pxShowDetails</x>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Loop on every (tied or selectable) object. -->
|
<!-- Loop on every (tied or selectable) object -->
|
||||||
<tr for="tied in objects" valign="top"
|
<x for="tied in objects"
|
||||||
class=":loop.tied.odd and 'even' or 'odd'"
|
var2="@currentNumber=currentNumber + 1;
|
||||||
var2="tiedUid=tied.o.id;
|
rowCss=loop.tied.odd and 'even' or 'odd'">:obj.pxViewAsTied</x>
|
||||||
objectIndex=field.getIndexOf(zobj, tiedUid)|None;
|
|
||||||
mayView=tied.o.mayView()"
|
|
||||||
id=":'%s_%s' % (ajaxHookId, tiedUid)">
|
|
||||||
<td if="not inPickList and numbered">:field.pxNumber</td>
|
|
||||||
<td if="checkboxes" class="cbCell">
|
|
||||||
<input if="mayView" type="checkbox" name=":ajaxHookId" checked="checked"
|
|
||||||
value=":tiedUid" onclick="toggleCb(this)"/>
|
|
||||||
</td>
|
|
||||||
<td for="column in columns" width=":column.width" align=":column.align"
|
|
||||||
var2="refField=column.field">
|
|
||||||
<!-- The "title" field -->
|
|
||||||
<x if="refField.name == 'title'">
|
|
||||||
<x if="mayView">
|
|
||||||
<x if="not field.menuUrlMethod">:field.pxObjectTitle</x>
|
|
||||||
<a if="field.menuUrlMethod"
|
|
||||||
var2="info=field.getMenuUrl(zobj, tied)"
|
|
||||||
href=":info[0]" target=":info[1]">:tied.title</a>
|
|
||||||
<x if="tied.o.mayAct()">:field.pxObjectActions</x>
|
|
||||||
</x>
|
|
||||||
<div if="not mayView">
|
|
||||||
<img src=":url('fake')" style="margin-right: 5px"/>
|
|
||||||
<x>:_('unauthorized')</x></div>
|
|
||||||
</x>
|
|
||||||
<!-- Any other field -->
|
|
||||||
<x if="(refField.name != 'title') and mayView">
|
|
||||||
<x var="zobj=tied.o; obj=tied; layoutType='cell';
|
|
||||||
innerRef=True; field=refField"
|
|
||||||
if="field.isShowable(zobj, 'result')">:field.pxRender</x>
|
|
||||||
</x>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- Global actions -->
|
<!-- Global actions -->
|
||||||
|
@ -340,9 +316,9 @@ class Ref(Field):
|
||||||
target=ztool.getLinksTargetInfo(field.klass);
|
target=ztool.getLinksTargetInfo(field.klass);
|
||||||
mayEdit=mayEdit|\
|
mayEdit=mayEdit|\
|
||||||
not field.isBack and zobj.mayEdit(field.writePermission);
|
not field.isBack and zobj.mayEdit(field.writePermission);
|
||||||
mayUnlink=False;
|
|
||||||
mayAdd=False;
|
mayAdd=False;
|
||||||
mayLink=False;
|
mayLink=False;
|
||||||
|
mayUnlink=False;
|
||||||
navBaseCall='askRefField(%s,%s,%s,**v**)' % \
|
navBaseCall='askRefField(%s,%s,%s,**v**)' % \
|
||||||
(q(ajaxHookId), q(zobj.absolute_url()), q(innerRef));
|
(q(ajaxHookId), q(zobj.absolute_url()), q(innerRef));
|
||||||
changeOrder=False;
|
changeOrder=False;
|
||||||
|
@ -437,10 +413,10 @@ class Ref(Field):
|
||||||
tiedClassLabel=_(tiedClassName);
|
tiedClassLabel=_(tiedClassName);
|
||||||
target=ztool.getLinksTargetInfo(field.klass);
|
target=ztool.getLinksTargetInfo(field.klass);
|
||||||
mayEdit=not field.isBack and zobj.mayEdit(field.writePermission);
|
mayEdit=not field.isBack and zobj.mayEdit(field.writePermission);
|
||||||
mayUnlink=mayEdit and field.getAttribute(zobj, 'unlink');
|
|
||||||
mayAdd=mayEdit and field.mayAdd(zobj, checkMayEdit=False);
|
mayAdd=mayEdit and field.mayAdd(zobj, checkMayEdit=False);
|
||||||
mayLink=mayEdit and field.mayAdd(zobj, mode='link', \
|
mayLink=mayEdit and field.mayAdd(zobj, mode='link', \
|
||||||
checkMayEdit=False);
|
checkMayEdit=False);
|
||||||
|
mayUnlink=mayEdit and field.getAttribute(zobj, 'unlink');
|
||||||
addConfirmMsg=field.addConfirm and \
|
addConfirmMsg=field.addConfirm and \
|
||||||
_('%s_addConfirm' % field.labelId) or '';
|
_('%s_addConfirm' % field.labelId) or '';
|
||||||
navBaseCall='askRefField(%s,%s,%s,**v**)' % \
|
navBaseCall='askRefField(%s,%s,%s,**v**)' % \
|
||||||
|
@ -1290,6 +1266,26 @@ class Ref(Field):
|
||||||
return "var node=document.getElementById('%s_%s');%s%s" % \
|
return "var node=document.getElementById('%s_%s');%s%s" % \
|
||||||
(obj.id, self.name, code % ('objs', 'objs'), poss)
|
(obj.id, self.name, code % ('objs', 'objs'), poss)
|
||||||
|
|
||||||
|
def getAjaxData(self, hook, zobj, **params):
|
||||||
|
'''Initializes an AjaxData object on the DOM node corresponding to
|
||||||
|
p_hook = the whole search result.'''
|
||||||
|
# Complete params with default parameters
|
||||||
|
params['ajaxHookId'] = hook;
|
||||||
|
params = sutils.getStringDict(params)
|
||||||
|
px = hook.endswith('_poss') and 'pxViewPickList' or 'pxView'
|
||||||
|
px = '%s:%s' % (self.name, px)
|
||||||
|
return "document.getElementById('%s')['ajax']=new AjaxData('%s', " \
|
||||||
|
"'%s', %s, null, '%s')" % \
|
||||||
|
(hook, hook, px, params, zobj.absolute_url())
|
||||||
|
|
||||||
|
def getAjaxDataRow(self, obj, parentHook, **params):
|
||||||
|
'''Initializes an AjaxData object on the DOM node corresponding to
|
||||||
|
p_hook = a row within the list of referred objects.'''
|
||||||
|
hook = obj.id
|
||||||
|
return "document.getElementById('%s')['ajax']=new AjaxData('%s', " \
|
||||||
|
"'pxViewAsTiedFromAjax',%s,'%s','%s')" % \
|
||||||
|
(hook, hook, sutils.getStringDict(params), parentHook, obj.url)
|
||||||
|
|
||||||
def doChangeOrder(self, obj):
|
def doChangeOrder(self, obj):
|
||||||
'''Moves a referred object up/down/top/bottom.'''
|
'''Moves a referred object up/down/top/bottom.'''
|
||||||
rq = obj.REQUEST
|
rq = obj.REQUEST
|
||||||
|
@ -1308,12 +1304,12 @@ class Ref(Field):
|
||||||
elif move == 'bottom':
|
elif move == 'bottom':
|
||||||
newIndex = len(uids) - 1
|
newIndex = len(uids) - 1
|
||||||
elif move.startswith('index'):
|
elif move.startswith('index'):
|
||||||
# New index starts at 1 (oldIndex starts at 0).
|
# New index starts at 1 (oldIndex starts at 0)
|
||||||
try:
|
try:
|
||||||
newIndex = int(move.split('_')[1]) - 1
|
newIndex = int(move.split('_')[1]) - 1
|
||||||
except ValueError:
|
except ValueError:
|
||||||
newIndex = -1
|
newIndex = -1
|
||||||
# If newIndex is negative, it means that the move can't occur.
|
# If newIndex is negative, it means that the move can't occur
|
||||||
if newIndex > -1:
|
if newIndex > -1:
|
||||||
uids.remove(uid)
|
uids.remove(uid)
|
||||||
uids.insert(newIndex, uid)
|
uids.insert(newIndex, uid)
|
||||||
|
@ -1385,15 +1381,15 @@ class Ref(Field):
|
||||||
else:
|
else:
|
||||||
return [tool.getObject(rv) for rv in requestValue]
|
return [tool.getObject(rv) for rv in requestValue]
|
||||||
res = []
|
res = []
|
||||||
# No object can be selected if the popup has not been opened yet.
|
# No object can be selected if the popup has not been opened yet
|
||||||
if 'semantics' not in rq:
|
if 'semantics' not in rq:
|
||||||
# In this case, display already linked objects if any.
|
# In this case, display already linked objects if any
|
||||||
if not obj.isEmpty(self.name): return self.getValue(obj.o)
|
if not obj.isEmpty(self.name): return self.getValue(obj.o)
|
||||||
return res
|
return res
|
||||||
uids = rq['selected'].split(',')
|
uids = rq['selected'].split(',')
|
||||||
tool = obj.tool
|
tool = obj.tool
|
||||||
if rq['semantics'] == 'checked':
|
if rq['semantics'] == 'checked':
|
||||||
# Simply get the selected objects from their uid.
|
# Simply get the selected objects from their uid
|
||||||
return [tool.getObject(uid) for uid in uids]
|
return [tool.getObject(uid) for uid in uids]
|
||||||
else:
|
else:
|
||||||
# Replay the search in self.select to get the list of uids that were
|
# Replay the search in self.select to get the list of uids that were
|
||||||
|
|
|
@ -428,7 +428,7 @@ class Transition:
|
||||||
msg = self.trigger(name, obj, wf, rq.get('comment', ''), reindex=False)
|
msg = self.trigger(name, obj, wf, rq.get('comment', ''), reindex=False)
|
||||||
# Reindex obj if required
|
# Reindex obj if required
|
||||||
if not obj.isTemporary(): obj.reindex()
|
if not obj.isTemporary(): obj.reindex()
|
||||||
# If we are called from an Ajax request, return a message
|
# If we are called from an Ajax request, simply return msg
|
||||||
if hasattr(rq, 'pxContext') and rq.pxContext['ajax']: return msg
|
if hasattr(rq, 'pxContext') and rq.pxContext['ajax']: return msg
|
||||||
# If we are viewing the object and if the logged user looses the
|
# If we are viewing the object and if the logged user looses the
|
||||||
# permission to view it, redirect the user to its home page.
|
# permission to view it, redirect the user to its home page.
|
||||||
|
|
|
@ -701,7 +701,7 @@ class BaseMixin:
|
||||||
|
|
||||||
def getFieldValue(self, name, layoutType=None, outerValue=None):
|
def getFieldValue(self, name, layoutType=None, outerValue=None):
|
||||||
'''Returns the database value of field named p_name for p_self.'''
|
'''Returns the database value of field named p_name for p_self.'''
|
||||||
if layoutType == 'search': return # No object in search screens.
|
if layoutType == 'search': return # No object in search screens
|
||||||
field = self.getAppyType(name)
|
field = self.getAppyType(name)
|
||||||
if field.type == 'Pod': return
|
if field.type == 'Pod': return
|
||||||
if '*' not in name: return field.getValue(self)
|
if '*' not in name: return field.getValue(self)
|
||||||
|
|
|
@ -136,14 +136,13 @@ function getAjaxChunk(pos) {
|
||||||
if (xhrObjects[pos].xhr.readyState == 4) {
|
if (xhrObjects[pos].xhr.readyState == 4) {
|
||||||
// We have received the HTML chunk
|
// We have received the HTML chunk
|
||||||
var hookElem = getAjaxHook(hook);
|
var hookElem = getAjaxHook(hook);
|
||||||
var responseOk = (xhrObjects[pos].xhr.status == 200);
|
if (hookElem) {
|
||||||
if (hookElem && responseOk) {
|
|
||||||
injectChunk(hookElem, xhrObjects[pos].xhr.responseText);
|
injectChunk(hookElem, xhrObjects[pos].xhr.responseText);
|
||||||
// Call a custom Javascript function if required
|
// Call a custom Javascript function if required
|
||||||
if (xhrObjects[pos].onGet) {
|
if (xhrObjects[pos].onGet) {
|
||||||
xhrObjects[pos].onGet(xhrObjects[pos], hookElem);
|
xhrObjects[pos].onGet(xhrObjects[pos], hookElem);
|
||||||
}
|
}
|
||||||
// Eval inner scripts if any.
|
// Eval inner scripts if any
|
||||||
var innerScripts = getElementsHavingName('div', 'appyHook');
|
var innerScripts = getElementsHavingName('div', 'appyHook');
|
||||||
for (var i=0; i<innerScripts.length; i++) {
|
for (var i=0; i<innerScripts.length; i++) {
|
||||||
eval(innerScripts[i].innerHTML);
|
eval(innerScripts[i].innerHTML);
|
||||||
|
@ -152,7 +151,7 @@ function getAjaxChunk(pos) {
|
||||||
var msg = xhrObjects[pos].xhr.getResponseHeader('Appy-Message');
|
var msg = xhrObjects[pos].xhr.getResponseHeader('Appy-Message');
|
||||||
if (msg) showAppyMessage(decodeURIComponent(escape(msg)));
|
if (msg) showAppyMessage(decodeURIComponent(escape(msg)));
|
||||||
}
|
}
|
||||||
if (responseOk) xhrObjects[pos].freed = 1;
|
xhrObjects[pos].freed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,7 +307,7 @@ function askRefField(hookId, objectUrl, innerRef, startNumber, action,
|
||||||
actionParams){
|
actionParams){
|
||||||
var hookElems = hookId.split('_');
|
var hookElems = hookId.split('_');
|
||||||
var fieldName = hookElems[1];
|
var fieldName = hookElems[1];
|
||||||
// Sends an Ajax request for getting the content of a reference field.
|
// Sends an Ajax request for getting the content of a reference field
|
||||||
var startKey = hookId + '_startNumber';
|
var startKey = hookId + '_startNumber';
|
||||||
var scope = hookElems.pop();
|
var scope = hookElems.pop();
|
||||||
var params = {'innerRef': innerRef, 'scope': scope};
|
var params = {'innerRef': innerRef, 'scope': scope};
|
||||||
|
@ -631,12 +630,10 @@ function submitAppyForm(button) {
|
||||||
theForm.submit();
|
theForm.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function used for triggering a workflow transition
|
function submitForm(formId, msg, showComment, back) {
|
||||||
function triggerTransition(formId, transitionId, msg, back) {
|
|
||||||
var f = document.getElementById(formId);
|
var f = document.getElementById(formId);
|
||||||
f.transition.value = transitionId;
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
/* We must submit the form and either refresh the entire page (back is null)
|
/* Submit the form and either refresh the entire page (back is null)
|
||||||
or ajax-refresh a given part only (p_back corresponds to the id of the
|
or ajax-refresh a given part only (p_back corresponds to the id of the
|
||||||
DOM node to be refreshed. */
|
DOM node to be refreshed. */
|
||||||
if (back) askAjax(back, formId);
|
if (back) askAjax(back, formId);
|
||||||
|
@ -646,11 +643,18 @@ function triggerTransition(formId, transitionId, msg, back) {
|
||||||
// Ask a confirmation to the user before proceeding
|
// Ask a confirmation to the user before proceeding
|
||||||
if (back) {
|
if (back) {
|
||||||
var js = "askAjax('"+back+"', '"+formId+"');"
|
var js = "askAjax('"+back+"', '"+formId+"');"
|
||||||
askConfirm('script', js, msg, true) }
|
askConfirm('script', js, msg, showComment) }
|
||||||
else askConfirm('form', formId, msg, true);
|
else askConfirm('form', formId, msg, showComment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function used for triggering a workflow transition
|
||||||
|
function triggerTransition(formId, transitionId, msg, back) {
|
||||||
|
var f = document.getElementById(formId);
|
||||||
|
f.transition.value = transitionId;
|
||||||
|
submitForm(formId, msg, true, back);
|
||||||
|
}
|
||||||
|
|
||||||
function onDeleteObject(objectUid) {
|
function onDeleteObject(objectUid) {
|
||||||
f = document.getElementById('deleteForm');
|
f = document.getElementById('deleteForm');
|
||||||
f.objectUid.value = objectUid;
|
f.objectUid.value = objectUid;
|
||||||
|
|
|
@ -374,9 +374,10 @@ class AbstractWrapper(object):
|
||||||
|
|
||||||
pxTransitions = Px('''
|
pxTransitions = Px('''
|
||||||
<form var="transitions=targetObj.getTransitions()" if="transitions"
|
<form var="transitions=targetObj.getTransitions()" if="transitions"
|
||||||
var2="formId='trigger_%s' % targetObj.id" method="post"
|
var2="formId='trigger_%s' % targetObj.id;
|
||||||
|
zobj=targetObj"
|
||||||
id=":formId" action=":targetObj.absolute_url() + '/onTrigger'"
|
id=":formId" action=":targetObj.absolute_url() + '/onTrigger'"
|
||||||
style="display: inline">
|
style="display: inline" method="post">
|
||||||
<input type="hidden" name="transition"/>
|
<input type="hidden" name="transition"/>
|
||||||
<!-- Input field for storing the comment coming from the popup -->
|
<!-- Input field for storing the comment coming from the popup -->
|
||||||
<textarea id="comment" name="comment" cols="30" rows="3"
|
<textarea id="comment" name="comment" cols="30" rows="3"
|
||||||
|
@ -575,6 +576,53 @@ class AbstractWrapper(object):
|
||||||
</table>
|
</table>
|
||||||
</form>''')
|
</form>''')
|
||||||
|
|
||||||
|
# The object, as shown in a list of referred (tied) objects
|
||||||
|
pxViewAsTied = Px('''
|
||||||
|
<tr valign="top" class=":rowCss"
|
||||||
|
var2="tiedUid=tied.o.id;
|
||||||
|
objectIndex=field.getIndexOf(zobj, tiedUid)|None;
|
||||||
|
mayView=tied.o.mayView()"
|
||||||
|
id=":tiedUid">
|
||||||
|
<td if="not inPickList and numbered">:field.pxNumber</td>
|
||||||
|
<td if="checkboxes" class="cbCell">
|
||||||
|
<input if="mayView" type="checkbox" name=":ajaxHookId" checked="checked"
|
||||||
|
value=":tiedUid" onclick="toggleCb(this)"/>
|
||||||
|
</td>
|
||||||
|
<td for="column in columns" width=":column.width" align=":column.align"
|
||||||
|
var2="refField=column.field">:refField.pxRenderAsTied</td>
|
||||||
|
<!-- Store data in this tr node allowing to ajax-refresh it -->
|
||||||
|
<script>:field.getAjaxDataRow(tied, ajaxHookId, rowCss=rowCss, \
|
||||||
|
currentNumber=currentNumber)</script>
|
||||||
|
</tr>''')
|
||||||
|
|
||||||
|
# When calling pxViewAsTied from Ajax, this surrounding PX is called to
|
||||||
|
# define the appropriate variables based on request values.
|
||||||
|
pxViewAsTiedFromAjax = Px('''
|
||||||
|
<x var="dummy=ztool.updatePxContextFromRequest();
|
||||||
|
tied=obj;
|
||||||
|
zobj=ztool.getObject(sourceId);
|
||||||
|
obj=zobj.appy();
|
||||||
|
field=zobj.getAppyType(refFieldName);
|
||||||
|
layoutType='view';
|
||||||
|
render=field.getRenderMode(layoutType);
|
||||||
|
linkList=field.link == 'list';
|
||||||
|
numberWidth=len(str(totalNumber));
|
||||||
|
tiedClassName=ztool.getPortalType(field.klass);
|
||||||
|
target=ztool.getLinksTargetInfo(field.klass);
|
||||||
|
mayEdit=not field.isBack and zobj.mayEdit(field.writePermission);
|
||||||
|
mayLink=not inPickList and mayEdit and \
|
||||||
|
field.mayAdd(zobj, mode='link', checkMayEdit=False);
|
||||||
|
mayUnlink=not inPickList and mayEdit and \
|
||||||
|
field.getAttribute(zobj, 'unlink');
|
||||||
|
gotoNumber=numbered;
|
||||||
|
changeOrder=not inPickList and mayEdit and \
|
||||||
|
field.getAttribute(zobj, 'changeOrder');
|
||||||
|
changeNumber=not inPickList and numbered and changeOrder and \
|
||||||
|
(totalNumber > 3);
|
||||||
|
columns=ztool.getColumnsSpecifiers(tiedClassName, \
|
||||||
|
field.getAttribute(obj, 'shownInfo'), dir);
|
||||||
|
showSubTitles=showSubTitles|True">:obj.pxViewAsTied</x>''')
|
||||||
|
|
||||||
# The object, as shown in a list of query results
|
# The object, as shown in a list of query results
|
||||||
pxViewAsResult = Px('''
|
pxViewAsResult = Px('''
|
||||||
<tr var2="obj=zobj.appy(); mayView=zobj.mayView();
|
<tr var2="obj=zobj.appy(); mayView=zobj.mayView();
|
||||||
|
|
Loading…
Reference in a new issue