15 |
15 |
16 from logilab.mtconverter import xml_escape |
16 from logilab.mtconverter import xml_escape |
17 |
17 |
18 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity, |
18 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity, |
19 specified_etype_implements, yes) |
19 specified_etype_implements, yes) |
20 from cubicweb.utils import make_uid, compute_cardinality, get_schema_property |
20 from cubicweb.utils import make_uid |
21 from cubicweb.view import EntityView |
21 from cubicweb.view import EntityView |
22 from cubicweb.common import tags |
22 from cubicweb.common import tags |
23 from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param, uicfg |
23 from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param, uicfg |
24 from cubicweb.web.form import FormViewMixIn, FieldNotFound |
24 from cubicweb.web.form import FormViewMixIn, FieldNotFound |
25 from cubicweb.web.formfields import guess_field |
25 from cubicweb.web.formfields import guess_field |
114 _landingzonemsg = _('click to edit this field') |
114 _landingzonemsg = _('click to edit this field') |
115 # default relation vids according to cardinality |
115 # default relation vids according to cardinality |
116 _one_rvid = 'incontext' |
116 _one_rvid = 'incontext' |
117 _many_rvid = 'csv' |
117 _many_rvid = 'csv' |
118 |
118 |
119 def _compute_best_vid(self, entity, rtype, role): |
119 def _compute_best_vid(self, eschema, rschema, role): |
120 if compute_cardinality(entity.e_schema, |
120 if eschema.cardinality(rschema, role) in '+*': |
121 entity.schema.rschema(rtype), |
|
122 role) in '+*': |
|
123 return self._many_rvid |
121 return self._many_rvid |
124 return self._one_rvid |
122 return self._one_rvid |
125 |
123 |
126 def _build_landing_zone(self, lzone): |
124 def _build_landing_zone(self, lzone): |
127 return lzone or self._defaultlandingzone % {'msg' : xml_escape(self.req._(self._landingzonemsg))} |
125 return lzone or self._defaultlandingzone % {'msg' : xml_escape(self.req._(self._landingzonemsg))} |