[gen] FInalized ajaxification of search rows and rows of tied objects in Refs.

This commit is contained in:
Gaetan Delannay 2015-02-04 18:33:27 +01:00
parent f44bb4e06b
commit a6645f33ff
7 changed files with 87 additions and 58 deletions

View file

@ -1242,13 +1242,13 @@ class ToolMixin(BaseMixin):
if len(label) < 15: return 'buttonFixed button'
return 'button'
def getLinksTargetInfo(self, klass):
def getLinksTargetInfo(self, klass, back=None):
'''Appy allows to open links to view or edit instances of p_klass
either via the same browser window, or via a popup. This method
returns info about that, as an object having 2 attributes:
- target is "_self" if the link leads to the same browser window,
"appyIFrame" if the link must be opened in a popup;
- openPopup is unused if target is "_self" and contains the
- openPopup is unused if target is "_self" or contains the
Javascript code to open the popup.'''
res = Object(target='_self', openPopup='')
if hasattr(klass, 'popup'):
@ -1256,10 +1256,14 @@ class ToolMixin(BaseMixin):
d = klass.popup
if isinstance(d, basestring):
# Width only
params = int(d[:-2])
params = d[:-2]
else:
# Width and height
params = "%s, %s" % (d[0][:-2], d[1][:-2])
# If "back" is specified, it corresponds to some tag on the main
# page, that must be ajax-refreshed when coming back from the popup.
# Else, when back, the entire page will be reloaded.
if back: params += ", '%s'" % back
res.openPopup = "openPopup('iframePopup',null,%s)" % params
return res

View file

@ -151,17 +151,22 @@ class BaseMixin:
self.getParentNode().manage_delObjects([self.id])
def onDelete(self):
'''Called when an object deletion is triggered from the ui.'''
'''Called when an object deletion is triggered from the ui'''
rq = self.REQUEST
self.delete()
if self.getUrl(rq['HTTP_REFERER'],mode='raw') ==self.getUrl(mode='raw'):
tool = self.getTool()
obj = tool.getObject(rq['uid'])
obj.delete()
msg = obj.translate('action_done')
# If we are called from an Ajax request, simply return msg
if hasattr(rq, 'pxContext') and rq.pxContext['ajax']: return msg
if obj.getUrl(rq['HTTP_REFERER'], mode='raw') == obj.getUrl(mode='raw'):
# We were consulting the object that has been deleted. Go back to
# the main page.
urlBack = self.getTool().getSiteUrl()
urlBack = tool.getSiteUrl()
else:
urlBack = self.getUrl(rq['HTTP_REFERER'])
self.say(self.translate('action_done'))
self.goto(urlBack)
urlBack = obj.getUrl(rq['HTTP_REFERER'])
obj.say(msg)
obj.goto(urlBack)
def onDeleteEvent(self):
'''Called when an event (from object history) deletion is triggered
@ -395,7 +400,7 @@ class BaseMixin:
else:
if isNew: urlBack = tool.getHomePage() # Go back to home page
else:
# Return to the same page, excepted if unshowable on view.
# Return to the same page, excepted if unshowable on view
phaseObj = self.getAppyPhases(True, 'view')
pageInfo = phaseObj.getPageInfo(rq['page'], 'view')
if not pageInfo: urlBack = tool.getHomePage()