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):
|
def description(self):
|
||||||
return self.adapted.description
|
return self.adapted.description
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def tabTitle(self):
|
||||||
|
return u'Info'
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def additionalInfos(self):
|
def additionalInfos(self):
|
||||||
return []
|
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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -254,18 +254,35 @@ class ConceptView(BaseView):
|
||||||
result.append(view)
|
result.append(view)
|
||||||
return result
|
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
|
@Lazy
|
||||||
def adapted(self):
|
def adapted(self):
|
||||||
return adapted(self.context, self.languageInfo)
|
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
|
@Lazy
|
||||||
def targetUrl(self):
|
def targetUrl(self):
|
||||||
return self.nodeView.getUrlForTarget(self.context)
|
return self.nodeView.getUrlForTarget(self.context)
|
||||||
|
|
|
@ -267,17 +267,19 @@
|
||||||
|
|
||||||
|
|
||||||
<metal:actions define-macro="view_modes">
|
<metal:actions define-macro="view_modes">
|
||||||
<ul class="view-modes"
|
<div style="margin-bottom: 10px"
|
||||||
tal:define="viewModes view/viewModes"
|
tal:define="viewModes view/viewModes"
|
||||||
tal:condition="viewModes">
|
tal:condition="viewModes">
|
||||||
<li tal:repeat="mode viewModes"
|
<ul class="view-modes">
|
||||||
tal:attributes="class mode/cssClass">
|
<li tal:repeat="mode viewModes"
|
||||||
<a tal:attributes="href mode/url;
|
tal:attributes="class mode/cssClass">
|
||||||
title mode/description"
|
<a tal:attributes="href mode/url;
|
||||||
tal:content="mode/title"
|
title mode/description"
|
||||||
i18n:translate="" />
|
tal:content="mode/title"
|
||||||
</li>
|
i18n:translate="" />
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</metal:actions>
|
</metal:actions>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,11 @@
|
||||||
tal:condition="nothing"
|
tal:condition="nothing"
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
value params/?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"
|
<input type="hidden"
|
||||||
tal:define="sortinfo request/sortinfo_results|nothing"
|
tal:define="sortinfo request/sortinfo_results|nothing"
|
||||||
tal:condition="sortinfo"
|
tal:condition="sortinfo"
|
||||||
|
|
|
@ -57,6 +57,10 @@ class ReportView(ConceptView):
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return self.report_macros['main']
|
return self.report_macros['main']
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def tabTitle(self):
|
||||||
|
return self.report.title
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def dynamicParams(self):
|
def dynamicParams(self):
|
||||||
return self.request.form
|
return self.request.form
|
||||||
|
|
Loading…
Add table
Reference in a new issue