merge stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Mon, 30 Nov 2009 17:48:24 +0100
branchstable
changeset 3950 a014b886b8b4
parent 3949 808aef800909 (current diff)
parent 3948 24a25b676671 (diff)
child 3951 b64c73bdb37b
merge
--- a/web/data/cubicweb.edition.js	Mon Nov 30 17:48:01 2009 +0100
+++ b/web/data/cubicweb.edition.js	Mon Nov 30 17:48:24 2009 +0100
@@ -270,11 +270,14 @@
 /*
  * removes the part of the form used to edit an inlined entity
  */
-function removeInlineForm(peid, rtype, eid) {
+function removeInlineForm(peid, rtype, eid, showaddnewlink) {
     jqNode(['div', peid, rtype, eid].join('-')).slideUp('fast', function() {
 	$(this).remove();
 	updateInlinedEntitiesCounters(rtype);
     });
+    if (showaddnewlink) {
+	toggleVisibility(showaddnewlink);
+    }
 }
 
 /*
--- a/web/views/editforms.py	Mon Nov 30 17:48:01 2009 +0100
+++ b/web/views/editforms.py	Mon Nov 30 17:48:24 2009 +0100
@@ -559,7 +559,20 @@
     __select__ = (match_kwargs('peid', 'rtype')
                   & specified_etype_implements('Any'))
     _select_attrs = InlineEntityEditionFormView._select_attrs + ('etype',)
-    removejs = "removeInlineForm('%s', '%s', '%s')"
+
+    @property
+    def removejs(self):
+        entity = self._entity()
+        card = entity.e_schema.role_rproperty(neg_role(self.role), self.rtype, 'cardinality')
+        card = card[self.role == 'object']
+        # when one is adding an inline entity for a relation of a single card,
+        # the 'add a new xxx' link disappears. If the user then cancel the addition,
+        # we have to make this link appears back. This is done by giving add new link
+        # id to removeInlineForm.
+        if card not in '?1':
+            return "removeInlineForm('%s', '%s', '%s')"
+        divid = "addNew%s%s%s:%s" % (self.etype, self.rtype, self.role, self.peid)
+        return "removeInlineForm('%%s', '%%s', '%%s', '%s')" % divid
 
     @cached
     def _entity(self):
--- a/web/views/workflow.py	Mon Nov 30 17:48:01 2009 +0100
+++ b/web/views/workflow.py	Mon Nov 30 17:48:24 2009 +0100
@@ -17,7 +17,7 @@
 from cubicweb import Unauthorized, view
 from cubicweb.selectors import (implements, has_related_entities, one_line_rset,
                                 relation_possible, match_form_params,
-                                entity_implements)
+                                entity_implements, score_entity)
 from cubicweb.interfaces import IWorkflowable
 from cubicweb.view import EntityView
 from cubicweb.schema import display_name
@@ -77,7 +77,8 @@
 
 class WFHistoryView(EntityView):
     id = 'wfhistory'
-    __select__ = relation_possible('wf_info_for', role='object')
+    __select__ = relation_possible('wf_info_for', role='object') & \
+                 score_entity(lambda x: x.workflow_history)
     title = _('Workflow history')
 
     def cell_call(self, row, col, view=None):