# HG changeset patch # User sand # Date 1269367353 -3600 # Tue Mar 23 19:02:33 2010 +0100 # Branch stable # Node ID 1f15b0fcb6146e58c6c160b707fd9481e8f753b6 # Parent 4626b0715934952211a24f7a55b49c9dc52d51dc ticket#475022, cancelling a comment should not closes all open forms diff --git a/data/cubes.comment.js b/data/cubes.comment.js --- a/data/cubes.comment.js +++ b/data/cubes.comment.js @@ -1,6 +1,6 @@ /* * :organization: Logilab - * :copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. + * :copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. * :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr */ @@ -10,10 +10,10 @@ function _getText(textarea) { if (typeof(FCKeditor) != 'undefined') { - var fck = FCKeditorAPI.GetInstance(textarea.id); - if (fck) { - return fck.GetHTML(); - } + var fck = FCKeditorAPI.GetInstance(textarea.id); + if (fck) { + return fck.GetHTML(); + } } return textarea.value; } @@ -28,21 +28,21 @@ var textarea = divNode.find('textarea')[0]; var comment = _getText(textarea); if (funcname) { - // store original value for edit cancel - textarea.setAttribute('cubicweb:origval', comment); - var format = 'text/html'; // no select widget if fckeditor is used - var select = divNode.find('select')[0]; - if (select) { - format = firstSelected(select); - } - d = asyncRemoteExec(funcname, eid, comment, format); - d.addCallback(function () { - var rooteid = getNode('commentsectionComponent').getAttribute('cubicweb:rooteid'); - reloadComponent('commentsection', rql_for_eid(rooteid), 'contentnavigation'); - }); - } else { // this is of course terrbily inefficient since we reload the whole tree - var rooteid = getNode('commentsectionComponent').getAttribute('cubicweb:rooteid'); - reloadComponent('commentsection', rql_for_eid(rooteid), 'contentnavigation'); + // store original value for edit cancel + textarea.setAttribute('cubicweb:origval', comment); + var format = 'text/html'; // no select widget if fckeditor is used + var select = divNode.find('select')[0]; + if (select) { + format = firstSelected(select); + } + d = asyncRemoteExec(funcname, eid, comment, format); + d.addCallback(function () { + var rooteid = getNode('commentsectionComponent').getAttribute('cubicweb:rooteid'); + reloadComponent('commentsection', rql_for_eid(rooteid), 'contentnavigation'); + }); + } else { // comment cancelled, close div holding the form + var comment = jQuery('#comment' + eid + 'Slot'); + comment.remove(); } } diff --git a/views.py b/views.py --- a/views.py +++ b/views.py @@ -197,9 +197,10 @@ # hack to avoid tabindex conflicts caused by Ajax requests self._cw.next_tabindex = count(20).next jseid = dumps(commented.eid) + cancel_action = self.jsfunc % (jseid, '') buttons = [Button(onclick=self.jsfunc % (jseid, self.jsonmeth)), Button(stdmsgs.BUTTON_CANCEL, - onclick=self.jsfunc % (jseid, ''))] + onclick=cancel_action)] form = self._cw.vreg['forms'].select('edition', self._cw, entity=newcomment, form_buttons=buttons)