# HG changeset patch # User Laure Bourgois <Laure.Bourgois@logilab.fr> # Date 1226499647 -3600 # Wed Nov 12 15:20:47 2008 +0100 # Node ID e6cb9507e0748b72420096be151246d38ea4dac8 # Parent 480ce788c1b16ee598e499bb53a143786fa8cd8c comment cancel (javascript solution) diff --git a/views.py b/views.py --- a/views.py +++ b/views.py @@ -147,20 +147,21 @@ id = 'inlinecommentform' title = None # hidden requires = ('Comment',) + accepts = ('Comment',) __selectors__ = (kwargs_selector,) expected_kwargs = ('commented',) EDITION_BODY = u""" - <div id="comment%(eid)sSlot">%(attrform)s <div id="comment%(eid)sbbar"><button onclick="%(onclick)s" tabindex="%(tabindex1)s">%(validate)s</button> - <button onclick="javascript:window.history.go(-1)" tabindex="%(tabindex2)s">%(cancel)s</button> + <button onclick="%(oncancelclick)s" tabindex="%(tabindex2)s">%(cancel)s</button> + </div> </div> """ def call(self, commented): - self.req.add_js('cubes.comment.js') + self.req.add_js('cubicweb.ajax.js','cubes.comment.js') newcomment = self.vreg.etype_class('Comment')(self.req, None, None) newcomment.eid = 'INLINE' # hack to avoid tabindex conflicts caused by Ajax requests @@ -168,7 +169,8 @@ self._hiddens = [] attrform = self.attributes_form(newcomment, {}) onclick = html_escape("processComment(%s, 'add_comment')" % dumps(commented.eid)) - self.w(self.EDITION_BODY % dict(attrform=attrform, onclick=onclick, + oncancelclick = html_escape("processComment(%s, '')" % dumps(commented.eid)) + self.w(self.EDITION_BODY % dict(attrform=attrform, onclick=onclick, oncancelclick=oncancelclick, eid=commented.eid, tabindex1=self.req.next_tabindex(), tabindex2=self.req.next_tabindex(),