better control of filtering (ignore filters and hinding of children in management views); use additional predicates for listings in lobo layouts

This commit is contained in:
Helmut Merz 2011-11-08 15:02:34 +01:00
parent e59356f627
commit ef334a50fb
4 changed files with 27 additions and 12 deletions

View file

@ -11,7 +11,8 @@
<div class="row"> <div class="row">
<span class="label">Sub-Concepts</span>: <span class="label">Sub-Concepts</span>:
<span class="field" <span class="field"
tal:repeat="concept view/children"> tal:repeat="concept python:
view.getChildren(topLevelOnly=False, useFilter=False)">
<a href="#" <a href="#"
tal:attributes="href concept/url" tal:attributes="href concept/url"
tal:content="concept/title">subtask</a> tal:content="concept/title">subtask</a>

View file

@ -276,7 +276,8 @@ class ConceptView(BaseView):
if r.order != pos: if r.order != pos:
r.order = pos r.order = pos
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True): def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True,
useFilter=True):
form = self.request.form form = self.request.form
#if form.get('loops.viewName') == 'index.html' and self.editable: #if form.get('loops.viewName') == 'index.html' and self.editable:
if self.editable: if self.editable:
@ -311,10 +312,12 @@ class ConceptView(BaseView):
break break
if skip: if skip:
continue continue
if useFilter:
options = IOptions(adapted(r.predicate), None) options = IOptions(adapted(r.predicate), None)
if options is not None and options('hide_children'): if options is not None and options('hide_children'):
continue continue
if fv.check(r.context): if not fv.check(r.context):
continue
yield r yield r
def checkCriteria(self, relation, criteria): def checkCriteria(self, relation, criteria):
@ -347,9 +350,10 @@ class ConceptView(BaseView):
return result return result
def isHidden(self, pr): def isHidden(self, pr):
if (getName(pr.second.conceptType) in predOptions = IOptions(adapted(pr.predicate))
IOptions(adapted(pr.predicate))('hide_parents_for', [])): if predOptions('hide_parents'):
#IOptions(pr.predicate)('hide_parents_for', [])): return True
if (getName(pr.second.conceptType) in predOptions('hide_parents_for', [])):
return True return True
hideRoles = None hideRoles = None
options = component.queryAdapter(adapted(pr.first), IOptions) options = component.queryAdapter(adapted(pr.first), IOptions)

View file

@ -23,7 +23,8 @@
</div> </div>
<div metal:use-macro="views/relation_macros/clients" /> <div metal:use-macro="views/relation_macros/clients" />
<div tal:define="items view/children; <div tal:define="items python:
view.getChildren(topLevelOnly=False, useFilter=False);
action string:remove; action string:remove;
qualifier string:children; qualifier string:children;
summary string:Currently assigned objects; summary string:Currently assigned objects;

View file

@ -159,11 +159,20 @@ class BasePart(Base):
gridPattern = [] gridPattern = []
showImage = True showImage = True
@Lazy
def childPredicates(self):
preds = [self.defaultPredicate]
for name in ['ispartof', 'hasoverview']:
pred = self.conceptManager.get(name)
if pred is not None:
preds.append(pred)
return preds
def getChildren(self): def getChildren(self):
subtypeNames = (self.params.get('subtypes') or [''])[0].split(',') subtypeNames = (self.params.get('subtypes') or [''])[0].split(',')
subtypes = [self.conceptManager[st] for st in subtypeNames if st] subtypes = [self.conceptManager[st] for st in subtypeNames if st]
result = [] result = []
childRels = self.context.getChildRelations([self.defaultPredicate]) childRels = self.context.getChildRelations(self.childPredicates)
if subtypes: if subtypes:
childRels = [r for r in childRels childRels = [r for r in childRels
if r.second.conceptType in subtypes] if r.second.conceptType in subtypes]