diff --git a/views/basetemplates.py b/views/basetemplates.py index 50d7d3b4a41e37c059cdfbb8710aee83898af12c_dmlld3MvYmFzZXRlbXBsYXRlcy5weQ==..6695480c23c4e27dacb57b48db96afae49a98a7f_dmlld3MvYmFzZXRlbXBsYXRlcy5weQ== 100644 --- a/views/basetemplates.py +++ b/views/basetemplates.py @@ -11,6 +11,7 @@ from logilab.mtconverter import xml_escape +from cubicweb.schema import display_name from cubicweb.utils import UStringIO from cubicweb.web.views import basetemplates, \ @@ -14,7 +15,7 @@ from cubicweb.utils import UStringIO from cubicweb.web.views import basetemplates, \ - basecomponents + basecomponents, actions from cubicweb.web.views.boxes import SearchBox @@ -80,6 +81,36 @@ self.w(u'</div>\n') # closes class=row @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): if boxes: getlayout = self._cw.vreg['components'].select @@ -103,6 +134,7 @@ vtitle = self._cw.form.get('vtitle') if vtitle: w(u'<div class="vtitle">%s</div>\n' % xml_escape(vtitle)) + self.state_header() self.content_navrestriction_components(view, components) nav_html = UStringIO() if view and not view.handle_pagination: @@ -167,7 +199,8 @@ 'header-right':'navbar-right', } + @monkeypatch(basetemplates.HTMLPageHeader) def call(self, view, **kwargs): self.main_header(view) self.breadcrumbs(view) @@ -170,8 +203,7 @@ @monkeypatch(basetemplates.HTMLPageHeader) def call(self, view, **kwargs): self.main_header(view) self.breadcrumbs(view) - self.state_header() def get_components(self, view, context): ctxcomponents = self._cw.vreg['ctxcomponents'] @@ -239,27 +271,6 @@ self.w(u'</div>') 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) def call(self, **kwargs): self.w(u'<footer id="pagefooter">')