Commit 714178d4 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[ui] Move binary/physical data object's relationships to a dedicated tab

Mostly because reledit doesn't support multi-valued relations.
parent cca4292b7d0f
......@@ -14,6 +14,13 @@ msgstr ""
msgid " ALT_I18N "
msgstr ""
msgid ", no relationship type specified"
msgstr ""
#, python-format
msgid ", of relationship type %s"
msgstr ""
msgid "<no value specified>"
msgstr ""
......@@ -5917,6 +5924,9 @@ msgstr ""
msgid "seda_bdo_format_identification"
msgstr ""
msgid "seda_bdo_relations"
msgstr ""
msgid "seda_binary_data_object"
msgstr ""
......
......@@ -14,6 +14,13 @@ msgstr "(attributes : %s)"
msgid " ALT_I18N "
msgstr " OU "
msgid ", no relationship type specified"
msgstr ", type de relation libre"
#, python-format
msgid ", of relationship type %s"
msgstr ", de type %s"
msgid "<no value specified>"
msgstr "<valeur libre>"
......@@ -1624,7 +1631,7 @@ msgid "SEDARelatedTransferReference_plural"
msgstr ""
msgid "SEDARelationship"
msgstr ""
msgstr "Relation"
msgid "SEDARelationshipCodeListVersion"
msgstr ""
......@@ -3953,7 +3960,7 @@ msgid "add a SEDARelatedTransferReference"
msgstr ""
msgid "add a SEDARelationship"
msgstr ""
msgstr "ajouter une relation"
msgid "add a SEDARelationshipCodeListVersion"
msgstr ""
......@@ -5920,6 +5927,9 @@ msgstr "propriétés techniques génériques"
msgid "seda_bdo_format_identification"
msgstr "format"
msgid "seda_do_relations"
msgstr "relations"
msgid "seda_binary_data_object"
msgstr ""
......@@ -6478,6 +6488,9 @@ msgctxt "SEDAManagement"
msgid "seda_dissemination_rule_object"
msgstr ""
msgid "seda_do_relations"
msgstr "relations"
msgid "seda_document_type"
msgstr ""
......@@ -8261,7 +8274,7 @@ msgid "seda_type_object"
msgstr ""
msgid "seda_type_relationship"
msgstr ""
msgstr "type de relation"
msgctxt "SEDARelationship"
msgid "seda_type_relationship"
......
......@@ -17,13 +17,14 @@
import json
from cubicweb import tags
from cubicweb.predicates import match_form_params, is_instance
from cubicweb.web.views import uicfg, tabs
from cubes.relationwidget import views as rwdg
from cubes.seda.xsd2yams import RDEF_CONSTRAINTS
from cubes.seda.views import rtags_from_xsd_element, viewlib
from cubes.seda.views import rtags_from_xsd_element, add_subobject_link, viewlib
_ = unicode
......@@ -97,8 +98,8 @@ class ContainedSearchForRelatedEntitiesView(rwdg.SearchForRelatedEntitiesView):
# hide some relation from autoform because of limitation of _container_eid
pvs.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'), 'attributes')
afs.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'), 'main', 'hidden')
pvs.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'), 'attributes')
rec.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'),
{'rvid': 'seda.reledit.complexlink',
'novalue_label': _('<unauthorized>')})
......@@ -108,13 +109,14 @@ rec.tag_subject_of(('SEDABinaryDataObject', 'seda_alt_binary_data_object_attachm
'novalue_label': _('<unauthorized>')})
for etype in ('SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
for rtype in ('seda_data_object_version_from', 'seda_relationship'):
pvs.tag_object_of(('*', rtype, etype), 'attributes')
afs.tag_object_of(('*', rtype, etype), 'main', 'hidden')
afs.tag_object_of(('*', 'seda_data_object_version_from', etype), 'main', 'hidden')
pvs.tag_object_of(('*', 'seda_data_object_version_from', etype), 'attributes')
rec.tag_object_of(('*', 'seda_data_object_version_from', etype),
{'rvid': 'seda.reledit.complexlink',
'novalue_label': _('<unauthorized>')})
# in its own tab
afs.tag_object_of(('*', 'seda_relationship', etype), 'main', 'hidden')
pvs.tag_object_of(('*', 'seda_relationship', etype), 'hidden')
def uri_cardinality_vocabulary(form, field):
......@@ -151,6 +153,7 @@ class BinaryDataObjectTabbedPrimaryView(tabs.TabbedPrimaryView):
'main_tab',
_('seda_bdo_format_identification'),
_('seda_bdo_file_information'),
_('seda_do_relations'),
]
......@@ -174,9 +177,42 @@ class PhysicalDataObjectTabbedPrimaryView(tabs.TabbedPrimaryView):
__select__ = tabs.TabbedPrimaryView.__select__ & is_instance('SEDAPhysicalDataObject')
tabs = [
'main_tab',
_('seda_do_relations'),
]
class DataObjectRelationssTab(tabs.PrimaryTab):
"""Display relations of a binary or physical data object"""
__regid__ = 'seda_do_relations'
__select__ = tabs.PrimaryTab.__select__ & is_instance('SEDABinaryDataObject',
'SEDAPhysicalDataObject')
def entity_call(self, entity):
rschema = self._cw.vreg.schema.rschema('seda_relationship')
if rschema.has_perm(self._cw, 'add', toeid=entity.eid):
urlparams = {'__redirectparams': 'tab=' + self.__regid__}
self.w(add_subobject_link(entity, 'seda_relationship', 'object', urlparams,
msg=self._cw._('add a SEDARelationship'),
klass='btn btn-success pull-right'))
self.w(tags.div(klass='clearfix'))
rset = entity.related('seda_relationship', 'object')
if rset:
self._cw.view('list', rset=rset, parent=entity, w=self.w, tabid=self.__regid__,
subvid='seda.listitem')
class RelationshipBusinessValueLinkEntityView(viewlib.BusinessValueLinkEntityView):
__select__ = viewlib.BusinessValueLinkEntityView.__select__ & is_instance('SEDARelationship')
def entity_call(self, entity):
super(RelationshipBusinessValueLinkEntityView, self).entity_call(entity)
if entity.seda_type_relationship:
concept = entity.seda_type_relationship[0]
self.w(self._cw._(', of relationship type %s') % concept.label())
else:
self.w(self._cw._(', no relationship type specified'))
class AttachmentTypedBusinessValueEntityView(viewlib.BusinessValueEntityView):
__select__ = is_instance('SEDAAttachment')
......
......@@ -106,11 +106,22 @@ class BusinessValueEntityView(EntityView):
value = None
if value:
self.w(u'<span class="value">')
self.w(value)
self.wvalue(entity, value)
self.w(u'</span>')
else:
self.wdata(self._cw._('<no value specified>'))
def wvalue(self, entity, value):
self.w(value)
class BusinessValueLinkEntityView(BusinessValueEntityView):
"""Similar to seda.business but value is enclosed in a link if specified"""
__regid__ = 'seda.business.link'
def wvalue(self, entity, value):
self.w(tags.a(value, href=entity.absolute_url()))
class TypedBusinessValueEntityView(EntityView):
"""Similar to seda.business but with type information, for use within alternative"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment