dynamically create tabs on concept views via options
This commit is contained in:
parent
665c0271fd
commit
22d1d44560
5 changed files with 52 additions and 20 deletions
|
@ -459,6 +459,10 @@ class BaseView(GenericView, I18NView, SortableMixin):
|
|||
def description(self):
|
||||
return self.adapted.description
|
||||
|
||||
@Lazy
|
||||
def tabTitle(self):
|
||||
return u'Info'
|
||||
|
||||
@Lazy
|
||||
def additionalInfos(self):
|
||||
return []
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -254,18 +254,35 @@ class ConceptView(BaseView):
|
|||
result.append(view)
|
||||
return result
|
||||
|
||||
def viewModes(self):
|
||||
modes = Jeep()
|
||||
current = self.request.form.get('loops.viewName')
|
||||
parts = (self.options('view_tabs') or
|
||||
self.typeOptions('view_tabs') or [])
|
||||
if not parts:
|
||||
return modes
|
||||
activeMode = None
|
||||
for p in parts:
|
||||
view = component.queryMultiAdapter(
|
||||
(self.adapted, self.request), name=p)
|
||||
if view is None:
|
||||
view = component.queryMultiAdapter(
|
||||
(self.context, self.request), name=p)
|
||||
if view is None:
|
||||
continue
|
||||
active = (activeMode is None and p == current)
|
||||
if active:
|
||||
activeMode = p
|
||||
url = '%s?loops.viewName=%s' % (self.request.URL, p)
|
||||
modes.append(ViewMode(p, view.tabTitle, url, active))
|
||||
if activeMode is None:
|
||||
modes[0].active = True
|
||||
return modes
|
||||
|
||||
@Lazy
|
||||
def adapted(self):
|
||||
return adapted(self.context, self.languageInfo)
|
||||
|
||||
@Lazy
|
||||
def title(self):
|
||||
return self.adapted.title or getName(self.context)
|
||||
|
||||
@Lazy
|
||||
def description(self):
|
||||
return self.adapted.description
|
||||
|
||||
@Lazy
|
||||
def targetUrl(self):
|
||||
return self.nodeView.getUrlForTarget(self.context)
|
||||
|
|
|
@ -267,9 +267,10 @@
|
|||
|
||||
|
||||
<metal:actions define-macro="view_modes">
|
||||
<ul class="view-modes"
|
||||
<div style="margin-bottom: 10px"
|
||||
tal:define="viewModes view/viewModes"
|
||||
tal:condition="viewModes">
|
||||
<ul class="view-modes">
|
||||
<li tal:repeat="mode viewModes"
|
||||
tal:attributes="class mode/cssClass">
|
||||
<a tal:attributes="href mode/url;
|
||||
|
@ -278,6 +279,7 @@
|
|||
i18n:translate="" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</metal:actions>
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
tal:condition="nothing"
|
||||
tal:attributes="name name;
|
||||
value params/?name" />
|
||||
<input type="hidden"
|
||||
tal:define="viewName request/loops.viewName|nothing"
|
||||
tal:condition="viewName"
|
||||
tal:attributes="name string:loops.viewName;
|
||||
value viewName" />
|
||||
<input type="hidden"
|
||||
tal:define="sortinfo request/sortinfo_results|nothing"
|
||||
tal:condition="sortinfo"
|
||||
|
|
|
@ -57,6 +57,10 @@ class ReportView(ConceptView):
|
|||
def macro(self):
|
||||
return self.report_macros['main']
|
||||
|
||||
@Lazy
|
||||
def tabTitle(self):
|
||||
return self.report.title
|
||||
|
||||
@Lazy
|
||||
def dynamicParams(self):
|
||||
return self.request.form
|
||||
|
|
Loading…
Add table
Reference in a new issue