Skip to content
Snippets Groups Projects
Commit 6695480c23c4 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

[stateheader] make stateheader more user friendly (related to #3597030)

parent 50d7d3b4a41e
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
from logilab.mtconverter import xml_escape from logilab.mtconverter import xml_escape
from cubicweb.schema import display_name
from cubicweb.utils import UStringIO from cubicweb.utils import UStringIO
from cubicweb.web.views import basetemplates, \ from cubicweb.web.views import basetemplates, \
...@@ -14,7 +15,7 @@ ...@@ -14,7 +15,7 @@
from cubicweb.utils import UStringIO from cubicweb.utils import UStringIO
from cubicweb.web.views import basetemplates, \ from cubicweb.web.views import basetemplates, \
basecomponents basecomponents, actions
from cubicweb.web.views.boxes import SearchBox from cubicweb.web.views.boxes import SearchBox
...@@ -80,6 +81,36 @@ ...@@ -80,6 +81,36 @@
self.w(u'</div>\n') # closes class=row self.w(u'</div>\n') # closes class=row
@monkeypatch(basetemplates.TheMainTemplate) @monkeypatch(basetemplates.TheMainTemplate)
def get_components(self, view, context):
ctxcomponents = self._cw.vreg['ctxcomponents']
return ctxcomponents.poss_visible_objects(self._cw,
rset=self.cw_rset,
view=view,
context=context)
@monkeypatch(basetemplates.TheMainTemplate)
def state_header(self):
state = self._cw.search_state
if state[0] == 'normal':
return
_ = self._cw._
value = self._cw.view('oneline', self._cw.eid_rset(state[1][1]))
target, eid, r_type, searched_type = self._cw.search_state[1]
cancel_link = u'<a href="%(url)s" role="button" class="btn btn-default" title="%(title)s">%(title)s</a>' % {
'url' : self._cw.build_url(str(eid),
vid='edition', __mode='normal'),
'title': _('cancel')}
msg = ' '.join((_("searching for"),
'<strong>"%s"</strong>' % \
display_name(self._cw, state[1][3]),
_("to associate with"), value,
_("by relation"),
'<strong>"%s"</strong>' % \
display_name(self._cw, state[1][2], state[1][0]),
cancel_link))
return self.w(u'<div class="alert alert-info">%s</div>' % msg)
@monkeypatch(basetemplates.TheMainTemplate)
def nav_column(self, view, boxes, context): def nav_column(self, view, boxes, context):
if boxes: if boxes:
getlayout = self._cw.vreg['components'].select getlayout = self._cw.vreg['components'].select
...@@ -103,6 +134,7 @@ ...@@ -103,6 +134,7 @@
vtitle = self._cw.form.get('vtitle') vtitle = self._cw.form.get('vtitle')
if vtitle: if vtitle:
w(u'<div class="vtitle">%s</div>\n' % xml_escape(vtitle)) w(u'<div class="vtitle">%s</div>\n' % xml_escape(vtitle))
self.state_header()
self.content_navrestriction_components(view, components) self.content_navrestriction_components(view, components)
nav_html = UStringIO() nav_html = UStringIO()
if view and not view.handle_pagination: if view and not view.handle_pagination:
...@@ -167,7 +199,8 @@ ...@@ -167,7 +199,8 @@
'header-right':'navbar-right', 'header-right':'navbar-right',
} }
@monkeypatch(basetemplates.HTMLPageHeader) @monkeypatch(basetemplates.HTMLPageHeader)
def call(self, view, **kwargs): def call(self, view, **kwargs):
self.main_header(view) self.main_header(view)
self.breadcrumbs(view) self.breadcrumbs(view)
...@@ -170,8 +203,7 @@ ...@@ -170,8 +203,7 @@
@monkeypatch(basetemplates.HTMLPageHeader) @monkeypatch(basetemplates.HTMLPageHeader)
def call(self, view, **kwargs): def call(self, view, **kwargs):
self.main_header(view) self.main_header(view)
self.breadcrumbs(view) self.breadcrumbs(view)
self.state_header()
def get_components(self, view, context): def get_components(self, view, context):
ctxcomponents = self._cw.vreg['ctxcomponents'] ctxcomponents = self._cw.vreg['ctxcomponents']
...@@ -239,27 +271,6 @@ ...@@ -239,27 +271,6 @@
self.w(u'</div>') self.w(u'</div>')
self.w(u'</nav>') self.w(u'</nav>')
@monkeypatch(basetemplates.HTMLPageHeader)
def state_header(self):
state = self._cw.search_state
if state[0] == 'normal':
return
_ = self._cw._
value = self._cw.view('oneline', self._cw.eid_rset(state[1][1]))
target, eid, r_type, searched_type = self._cw.search_state[1]
cancel_link = u'<a href="%(url)s" role="button" title="%(title)s">[%(title)s]</a>' % {
'url' : self._cw.build_url(str(eid),
vid='edition', __mode='normal'),
'title': _('cancel')}
msg = ' '.join((_("searching for"),
display_name(self._cw, state[1][3]),
_("to associate with"), value,
_("by relation"),
'<strong>"%s"</strong>' % \
display_name(self._cw, state[1][2], state[1][0]),
cancel_link))
return self.w(u'<div class="alert alert-info">%s</div>' % msg)
@monkeypatch(basetemplates.HTMLPageFooter) @monkeypatch(basetemplates.HTMLPageFooter)
def call(self, **kwargs): def call(self, **kwargs):
self.w(u'<footer id="pagefooter">') self.w(u'<footer id="pagefooter">')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment