web/component.py
changeset 6490 34359fbde6ef
parent 6489 6ea74c34fc25
child 6543 66145280a7e6
equal deleted inserted replaced
6489:6ea74c34fc25 6490:34359fbde6ef
    25 from warnings import warn
    25 from warnings import warn
    26 
    26 
    27 from logilab.common.deprecation import class_deprecated, class_renamed
    27 from logilab.common.deprecation import class_deprecated, class_renamed
    28 from logilab.mtconverter import xml_escape
    28 from logilab.mtconverter import xml_escape
    29 
    29 
    30 from cubicweb import Unauthorized, role, tags
    30 from cubicweb import Unauthorized, role, target, tags
       
    31 from cubicweb.schema import display_name
    31 from cubicweb.uilib import js, domid
    32 from cubicweb.uilib import js, domid
    32 from cubicweb.utils import json_dumps
    33 from cubicweb.utils import json_dumps
    33 from cubicweb.view import ReloadableMixIn, Component
    34 from cubicweb.view import ReloadableMixIn, Component
    34 from cubicweb.selectors import (no_cnx, paginated_rset, one_line_rset,
    35 from cubicweb.selectors import (no_cnx, paginated_rset, one_line_rset,
    35                                 non_final_entity, partial_relation_possible,
    36                                 non_final_entity, partial_relation_possible,
    36                                 partial_has_related_entities)
    37                                 partial_has_related_entities)
    37 from cubicweb.appobject import AppObject
    38 from cubicweb.appobject import AppObject
    38 from cubicweb.web import htmlwidgets, stdmsgs
    39 from cubicweb.web import INTERNAL_FIELD_VALUE, htmlwidgets, stdmsgs
    39 
    40 
    40 
    41 
    41 # abstract base class for navigation components ################################
    42 # abstract base class for navigation components ################################
    42 
    43 
    43 class NavigationComponent(Component):
    44 class NavigationComponent(Component):
   360 
   361 
   361 
   362 
   362 class EditRelationMixIn(ReloadableMixIn):
   363 class EditRelationMixIn(ReloadableMixIn):
   363     def box_item(self, entity, etarget, rql, label):
   364     def box_item(self, entity, etarget, rql, label):
   364         """builds HTML link to edit relation between `entity` and `etarget`"""
   365         """builds HTML link to edit relation between `entity` and `etarget`"""
   365         args = {role(self)[0] : entity.eid, get_target(self)[0] : etarget.eid}
   366         args = {role(self)[0] : entity.eid, target(self)[0] : etarget.eid}
   366         url = self._cw.user_rql_callback((rql, args))
   367         url = self._cw.user_rql_callback((rql, args))
   367         # for each target, provide a link to edit the relation
   368         # for each target, provide a link to edit the relation
   368         return u'[<a href="%s">%s</a>] %s' % (xml_escape(url), label,
   369         return u'[<a href="%s">%s</a>] %s' % (xml_escape(url), label,
   369                                               etarget.view('incontext'))
   370                                               etarget.view('incontext'))
   370 
   371