provide tabbed page concept type for showing sub-queries as tabs

This commit is contained in:
Helmut Merz 2013-04-27 15:07:11 +02:00
parent 5ef0c35ca0
commit 320e83c602
2 changed files with 37 additions and 1 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de # Copyright (c) 2013 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
@ -50,6 +50,7 @@ from cybertools.meta.interfaces import IOptions
from cybertools.typology.interfaces import IType, ITypeManager from cybertools.typology.interfaces import IType, ITypeManager
from cybertools.util.jeep import Jeep from cybertools.util.jeep import Jeep
from loops.browser.common import EditForm, BaseView, LoopsTerms, concept_macros from loops.browser.common import EditForm, BaseView, LoopsTerms, concept_macros
from loops.browser.common import ViewMode
from loops.common import adapted from loops.common import adapted
from loops.concept import Concept, ConceptTypeSourceList, PredicateSourceList from loops.concept import Concept, ConceptTypeSourceList, PredicateSourceList
from loops.i18n.browser import I18NView from loops.i18n.browser import I18NView
@ -746,3 +747,30 @@ class ListTypeInstances(ListChildren):
noDuplicates, useFilter, [self.typePredicate]): noDuplicates, useFilter, [self.typePredicate]):
yield c yield c
class TabbedPage(ConceptView):
@Lazy
def subpagePredicates(self):
pred = self.conceptManager.get('issubpage')
if pred is None:
pred = self.isPartOfPredicate
return [pred]
def viewModes(self):
modes = Jeep()
for s in self.getSiblings(self.subpagePredicates):
url = self.nodeView.getUrlForTarget(s)
modes.append(ViewMode(getName(s), s.title, url))
if not modes:
return modes
modes[getName(self.context)].active = True
return modes
def getSiblings(self, preds):
for p in self.context.getParents(preds):
parent = p
break
else:
return []
return p.getChildren(preds)

View file

@ -553,6 +553,14 @@
factory="loops.browser.concept.ListTypeInstances" factory="loops.browser.concept.ListTypeInstances"
permission="zope.View" /> permission="zope.View" />
<zope:adapter
name="tabbed_page.html"
for="loops.interfaces.IConcept
zope.publisher.interfaces.browser.IBrowserRequest"
provides="zope.interface.Interface"
factory="loops.browser.concept.TabbedPage"
permission="zope.View" />
<!-- dialogs/forms (end-user views) --> <!-- dialogs/forms (end-user views) -->
<page <page