From 636def8d243201a8301dddf672ae7077b4a67545 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Tue, 5 Aug 2014 09:48:05 +0200 Subject: [PATCH] [gen] Updated the Ajax system to be able to call a method on a Appy wrapper instead of a Zope object. --- fields/__init__.py | 5 +++-- gen/ui/appy.js | 18 +++++++++--------- gen/wrappers/__init__.py | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fields/__init__.py b/fields/__init__.py index 936fb6d..5a50bcc 100644 --- a/fields/__init__.py +++ b/fields/__init__.py @@ -39,6 +39,7 @@ class Field: # field, keyed by layoutType. cssFiles = {} jsFiles = {} + bLayouts = Table('lrv-f', width=None) dLayouts = 'lrv-d-f' hLayouts = 'lhrv-f' wLayouts = Table('lrv-f') @@ -98,10 +99,10 @@ class Field: # Button for showing changes to the field. pxChanges = Px('''''') diff --git a/gen/ui/appy.js b/gen/ui/appy.js index 3dc9fd8..58ca81c 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -280,8 +280,8 @@ function askRefField(hookId, objectUrl, innerRef, startNumber, action, evalInnerScripts); } -function askField(hookId, objectUrl, layoutType, showChanges, masterValues, - requestValue, error, className, customParams){ +function askField(hookId, objectUrl, layoutType, customParams, showChanges, + masterValues, requestValue, error, className){ // Sends an Ajax request for getting the content of any field. var fieldName = hookId.split('_')[1]; var params = {'layoutType': layoutType, 'showChanges': showChanges}; @@ -530,8 +530,8 @@ function updateSlaves(master, slave, objectUrl, layoutType, requestValues, var err = null; if (errors && (slaveName in errors)) err = errors[slaveName]; - askField(slaveId, objectUrl, layoutType, false, masterValues, reqValue, - err, className); + askField(slaveId, objectUrl, layoutType, null, false, masterValues, + reqValue, err, className); } } } @@ -1052,12 +1052,12 @@ function onSelectObjects(nodeId, objectUrl, mode, sortKey, sortOrder, if (mode == 'repl') { /* Link the selected objects (and unlink the potentially already linked ones) and refresh the Ref edit widget. */ - askField(':'+nodeId,objectUrl,'edit',null,null,null,null,null,params); + askField(':'+nodeId, objectUrl, 'edit', params, false); } else { // Link the selected objects and refresh the Ref view widget. params['action'] = 'onSelectFromPopup'; - askField(':'+nodeId,objectUrl,'view',null,null,null,null,null,params); + askField(':'+nodeId, objectUrl, 'view', params, false); } } @@ -1073,10 +1073,10 @@ function onSelectObject(tdId, nodeId, objectUrl) { else { /* Close the popup and directly refresh the initiator field with the selected object. */ - var uids=checkbox.value; + var uids = checkbox.value; closePopup('iframePopup'); - askField(':'+nodeId, objectUrl, 'edit', null, null, null, null, null, - {'selected': uids, 'semantics': 'checked'}); + var params = {'selected': uids, 'semantics': 'checked'}; + askField(':'+nodeId, objectUrl, 'edit', params, false); } } diff --git a/gen/wrappers/__init__.py b/gen/wrappers/__init__.py index 45ea513..06b49e6 100644 --- a/gen/wrappers/__init__.py +++ b/gen/wrappers/__init__.py @@ -632,6 +632,7 @@ class AbstractWrapper(object): dummy=setattr(req, 'pxContext', _ctx_); lang=ztool.getUserLanguage(); q=ztool.quote; action=req.get('action', None); + actionObj=(action and action.startswith(':')) and obj or zobj; px=req['px'].split(':'); inPopup=req.get('popup') == '1'; className=(len(px) == 3) and px[0] or None; @@ -646,8 +647,8 @@ class AbstractWrapper(object): x=resp.setHeader('CacheControl', 'no-cache')"> - - + + :getattr(obj, px[0])