diff --git a/fields/__init__.py b/fields/__init__.py
index 1602b41..48abca7 100644
--- a/fields/__init__.py
+++ b/fields/__init__.py
@@ -97,6 +97,28 @@ class Field:
context[k] = ctx[k]
return self.pxRender(context).encode('utf-8')
+ # Show the field content for some object on a list of referred objects
+ pxRenderAsTied = Px('''
+
+
+
+ :field.pxObjectTitle
+ :tied.title
+ :field.pxObjectActions
+
+
+
+ :_('unauthorized')
+
+
+
+ :field.pxRender
+ ''')
+
# Show the field content for some object on a list of results
pxRenderAsResult = Px('''
@@ -118,7 +140,7 @@ class Field:
+
+ :obj.pxViewAsTied
@@ -340,9 +316,9 @@ class Ref(Field):
target=ztool.getLinksTargetInfo(field.klass);
mayEdit=mayEdit|\
not field.isBack and zobj.mayEdit(field.writePermission);
- mayUnlink=False;
mayAdd=False;
mayLink=False;
+ mayUnlink=False;
navBaseCall='askRefField(%s,%s,%s,**v**)' % \
(q(ajaxHookId), q(zobj.absolute_url()), q(innerRef));
changeOrder=False;
@@ -437,10 +413,10 @@ class Ref(Field):
tiedClassLabel=_(tiedClassName);
target=ztool.getLinksTargetInfo(field.klass);
mayEdit=not field.isBack and zobj.mayEdit(field.writePermission);
- mayUnlink=mayEdit and field.getAttribute(zobj, 'unlink');
mayAdd=mayEdit and field.mayAdd(zobj, checkMayEdit=False);
mayLink=mayEdit and field.mayAdd(zobj, mode='link', \
- checkMayEdit=False);
+ checkMayEdit=False);
+ mayUnlink=mayEdit and field.getAttribute(zobj, 'unlink');
addConfirmMsg=field.addConfirm and \
_('%s_addConfirm' % field.labelId) or '';
navBaseCall='askRefField(%s,%s,%s,**v**)' % \
@@ -1290,6 +1266,26 @@ class Ref(Field):
return "var node=document.getElementById('%s_%s');%s%s" % \
(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):
'''Moves a referred object up/down/top/bottom.'''
rq = obj.REQUEST
@@ -1308,12 +1304,12 @@ class Ref(Field):
elif move == 'bottom':
newIndex = len(uids) - 1
elif move.startswith('index'):
- # New index starts at 1 (oldIndex starts at 0).
+ # New index starts at 1 (oldIndex starts at 0)
try:
newIndex = int(move.split('_')[1]) - 1
except ValueError:
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:
uids.remove(uid)
uids.insert(newIndex, uid)
@@ -1385,15 +1381,15 @@ class Ref(Field):
else:
return [tool.getObject(rv) for rv in requestValue]
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:
- # 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)
return res
uids = rq['selected'].split(',')
tool = obj.tool
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]
else:
# Replay the search in self.select to get the list of uids that were
diff --git a/fields/workflow.py b/fields/workflow.py
index c3a5e66..0e3ffbc 100644
--- a/fields/workflow.py
+++ b/fields/workflow.py
@@ -428,7 +428,7 @@ class Transition:
msg = self.trigger(name, obj, wf, rq.get('comment', ''), reindex=False)
# Reindex obj if required
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 we are viewing the object and if the logged user looses the
# permission to view it, redirect the user to its home page.
diff --git a/gen/mixins/__init__.py b/gen/mixins/__init__.py
index 91ca102..537f30b 100644
--- a/gen/mixins/__init__.py
+++ b/gen/mixins/__init__.py
@@ -701,7 +701,7 @@ class BaseMixin:
def getFieldValue(self, name, layoutType=None, outerValue=None):
'''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)
if field.type == 'Pod': return
if '*' not in name: return field.getValue(self)
diff --git a/gen/ui/appy.js b/gen/ui/appy.js
index f9ef59f..636ec5d 100644
--- a/gen/ui/appy.js
+++ b/gen/ui/appy.js
@@ -136,14 +136,13 @@ function getAjaxChunk(pos) {
if (xhrObjects[pos].xhr.readyState == 4) {
// We have received the HTML chunk
var hookElem = getAjaxHook(hook);
- var responseOk = (xhrObjects[pos].xhr.status == 200);
- if (hookElem && responseOk) {
+ if (hookElem) {
injectChunk(hookElem, xhrObjects[pos].xhr.responseText);
// Call a custom Javascript function if required
if (xhrObjects[pos].onGet) {
xhrObjects[pos].onGet(xhrObjects[pos], hookElem);
}
- // Eval inner scripts if any.
+ // Eval inner scripts if any
var innerScripts = getElementsHavingName('div', 'appyHook');
for (var i=0; i
+ style="display: inline" method="post">