web/views/editforms.py
branchstable
changeset 2370 1e8ce077b62a
parent 2365 9f5e911eab07
child 2373 50e01ff07f06
equal deleted inserted replaced
2369:5a2b8ed266ca 2370:1e8ce077b62a
    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, compute_cardinality, get_schema_property
    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
    23 from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param, uicfg
    24 from cubicweb.web.form import FormViewMixIn
    24 from cubicweb.web.form import FormViewMixIn
    25 from cubicweb.web.formfields import guess_field
    25 from cubicweb.web.formfields import guess_field
    26 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton
    26 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton
    27 from cubicweb.web.views import forms
    27 from cubicweb.web.views import forms
    28 
    28 
    85 
    85 
    86     (double-click on the field to see an appropriate edition widget)
    86     (double-click on the field to see an appropriate edition widget)
    87     """
    87     """
    88     id = 'reledit'
    88     id = 'reledit'
    89     __select__ = non_final_entity() & match_kwargs('rtype')
    89     __select__ = non_final_entity() & match_kwargs('rtype')
    90 
       
    91     # FIXME editableField class could be toggleable from userprefs
    90     # FIXME editableField class could be toggleable from userprefs
    92 
    91 
    93     _onclick = u"showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
    92     _onclick = u"showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
    94     _defaultlandingzone = u'<img title="%(msg)s" src="data/file.gif" alt="%(msg)s"/>'
    93     _defaultlandingzone = u'<img title="%(msg)s" src="data/file.gif" alt="%(msg)s"/>'
    95     _landingzonemsg = _('click to edit this field')
    94     _landingzonemsg = _('click to edit this field')
   124                 self.w(value)
   123                 self.w(value)
   125                 return
   124                 return
   126             form = self._build_attribute_form(entity, value, rtype, role, reload,
   125             form = self._build_attribute_form(entity, value, rtype, role, reload,
   127                                               row, col, default, landing_zone)
   126                                               row, col, default, landing_zone)
   128         else:
   127         else:
       
   128             vid = uicfg.primaryview_display_ctrl.etype_get(entity.e_schema,
       
   129                                                            rtype, role)
       
   130             if vid != 'reledit': # reledit explicitly disabled
       
   131                 self.wview(vid, entity.related(rtype, role))
       
   132                 return
   129             if rvid is None:
   133             if rvid is None:
   130                 rvid = self._compute_best_vid(entity, rtype, role)
   134                 rvid = self._compute_best_vid(entity, rtype, role)
   131             rset = entity.related(rtype, role)
   135             rset = entity.related(rtype, role)
   132             candidate = self.view(rvid, rset, 'null')
   136             candidate = self.view(rvid, rset, 'null')
   133             value = candidate or default
   137             value = candidate or default