Merge branch 'master' of ssh://git.cy55.de/home/helmutm/git/loops into bbmaster
This commit is contained in:
commit
6d5f273f28
7 changed files with 109 additions and 48 deletions
|
@ -6,6 +6,9 @@ $Id$
|
||||||
1.1
|
1.1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
- Lobo layout: provide new part: image grid; make sure image is not repeated if
|
||||||
|
it already appears in header part
|
||||||
|
- new special view 'listsubobjects' for nodes
|
||||||
- allow for adoption of relations to a predicate interface;
|
- allow for adoption of relations to a predicate interface;
|
||||||
with example implementation for a 'has Role' predicate in loops.organize
|
with example implementation for a 'has Role' predicate in loops.organize
|
||||||
- external collection: provide functionality for automatically populate
|
- external collection: provide functionality for automatically populate
|
||||||
|
|
|
@ -486,6 +486,14 @@
|
||||||
factory="loops.browser.node.ListResources"
|
factory="loops.browser.node.ListResources"
|
||||||
permission="zope.View" />
|
permission="zope.View" />
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
name="listsubobjects"
|
||||||
|
for="loops.interfaces.INode
|
||||||
|
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
provides="zope.interface.Interface"
|
||||||
|
factory="loops.browser.node.ListSubobjects"
|
||||||
|
permission="zope.View" />
|
||||||
|
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
name="listchildren"
|
name="listchildren"
|
||||||
for="loops.interfaces.INode
|
for="loops.interfaces.INode
|
||||||
|
|
|
@ -66,11 +66,11 @@
|
||||||
<!-- parts for displaying resources -->
|
<!-- parts for displaying resources -->
|
||||||
|
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
name="lobo_rg3"
|
name="lobo_ig3"
|
||||||
for="loops.interfaces.IConcept
|
for="loops.interfaces.IConcept
|
||||||
loops.browser.skin.Lobo"
|
loops.browser.skin.Lobo"
|
||||||
provides="zope.interface.Interface"
|
provides="zope.interface.Interface"
|
||||||
factory="loops.browser.lobo.standard.ResourceGrid3"
|
factory="loops.browser.lobo.standard.ImageGrid3"
|
||||||
permission="zope.View" />
|
permission="zope.View" />
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
|
@ -67,18 +67,16 @@
|
||||||
|
|
||||||
<!-- resources listing macros -->
|
<!-- resources listing macros -->
|
||||||
|
|
||||||
<metal:block define-macro="rgrid">
|
<metal:block define-macro="imagegrid"
|
||||||
<tal:cell repeat="cell part/getResources">
|
tal:define="showImageLink python:True">
|
||||||
|
<tal:cell repeat="cell part/getImages">
|
||||||
<div tal:attributes="class cell/cssClass;
|
<div tal:attributes="class cell/cssClass;
|
||||||
style cell/style">
|
style cell/style">
|
||||||
<a tal:attributes="href cell/targetUrl;
|
|
||||||
title cell/description">
|
|
||||||
<metal:image use-macro="item/macros/image" />
|
<metal:image use-macro="item/macros/image" />
|
||||||
<div class="legend">
|
<div class="legend">
|
||||||
<b tal:content="cell/title" /><br />
|
<b tal:content="cell/title" /><br />
|
||||||
<i tal:content="cell/description" />
|
<i tal:content="cell/description" />
|
||||||
</div>
|
</div>
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</tal:cell>
|
</tal:cell>
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|
|
@ -31,7 +31,6 @@ from cybertools.typology.interfaces import IType
|
||||||
from loops.browser.concept import ConceptView as BaseConceptView
|
from loops.browser.concept import ConceptView as BaseConceptView
|
||||||
from loops.browser.concept import ConceptRelationView as BaseConceptRelationView
|
from loops.browser.concept import ConceptRelationView as BaseConceptRelationView
|
||||||
from loops.browser.resource import ResourceView as BaseResourceView
|
from loops.browser.resource import ResourceView as BaseResourceView
|
||||||
from loops.browser.resource import ResourceRelationView as BaseResourceRelationView
|
|
||||||
from loops.common import adapted, baseObject
|
from loops.common import adapted, baseObject
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ class ConceptView(BaseConceptView):
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
super(ConceptView, self).__init__(baseObject(context), request)
|
super(ConceptView, self).__init__(baseObject(context), request)
|
||||||
self.adapted = context
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def resources(self):
|
def resources(self):
|
||||||
|
@ -78,6 +76,11 @@ class ConceptView(BaseConceptView):
|
||||||
result['files'].append(r)
|
result['files'].append(r)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def images(self):
|
||||||
|
for r in self.resources['images']:
|
||||||
|
yield r
|
||||||
|
|
||||||
# properties from base class: title, description, renderedDescription
|
# properties from base class: title, description, renderedDescription
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -113,23 +116,15 @@ class ConceptView(BaseConceptView):
|
||||||
@Lazy
|
@Lazy
|
||||||
def img(self):
|
def img(self):
|
||||||
self.registerDojoLightbox() # also provides access to info popup
|
self.registerDojoLightbox() # also provides access to info popup
|
||||||
for r in self.resources['images']:
|
for r in self.parentView.parent.images:
|
||||||
url = self.nodeView.getUrlForTarget(r)
|
# fetch from iterator on layout object: avoid duplicates
|
||||||
src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize))
|
url = self.nodeView.getUrlForTarget(r)
|
||||||
return dict(src=src, url=url,
|
src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize))
|
||||||
cssClass=self.parentView.imageCssClass)
|
return dict(src=src, url=url,
|
||||||
|
cssClass=self.parentView.imageCssClass)
|
||||||
|
|
||||||
|
|
||||||
class ConceptRelationView(BaseConceptRelationView, ConceptView):
|
class Layout(Base, ConceptView):
|
||||||
|
|
||||||
def __init__(self, relation, request, contextIsSecond=False,
|
|
||||||
parent=None, idx=0):
|
|
||||||
BaseConceptRelationView.__init__(self, relation, request, contextIsSecond)
|
|
||||||
self.parentView = parent
|
|
||||||
self.idx = idx
|
|
||||||
|
|
||||||
|
|
||||||
class Layout(Base):
|
|
||||||
|
|
||||||
macroName = 'layout'
|
macroName = 'layout'
|
||||||
|
|
||||||
|
@ -140,11 +135,13 @@ class Layout(Base):
|
||||||
parts = (self.options('parts') or
|
parts = (self.options('parts') or
|
||||||
self.typeOptions('parts') or
|
self.typeOptions('parts') or
|
||||||
['h1', 'g3'])
|
['h1', 'g3'])
|
||||||
|
ti = adapted(self.context.conceptType).typeInterface
|
||||||
for p in parts:
|
for p in parts:
|
||||||
viewName = 'lobo_' + p
|
viewName = 'lobo_' + p
|
||||||
view = component.queryMultiAdapter((self.context, self.request),
|
view = component.queryMultiAdapter((self.context, self.request),
|
||||||
name=viewName)
|
name=viewName)
|
||||||
if view is not None:
|
if view is not None:
|
||||||
|
view.parent = self
|
||||||
result.append(view)
|
result.append(view)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -175,6 +172,12 @@ class BasePart(Base):
|
||||||
view.parentView = self
|
view.parentView = self
|
||||||
return view
|
return view
|
||||||
|
|
||||||
|
def getImages(self):
|
||||||
|
result = []
|
||||||
|
for idx, img in enumerate(self.parent.images):
|
||||||
|
result.append(ResourceView(img, self.request, parent=self, idx=idx))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Grid3(BasePart):
|
class Grid3(BasePart):
|
||||||
|
|
||||||
|
@ -212,13 +215,41 @@ class Header2(BasePart):
|
||||||
cssClass = ['span-4', 'span-2 last', 'clear']
|
cssClass = ['span-4', 'span-2 last', 'clear']
|
||||||
|
|
||||||
|
|
||||||
# layout components for presenting lists of resources
|
# resource parts
|
||||||
|
|
||||||
class ResourceRelationView(BaseResourceRelationView):
|
|
||||||
|
class ImageGrid3(BasePart):
|
||||||
|
|
||||||
|
macroName = 'imagegrid'
|
||||||
|
imageSize = 'small'
|
||||||
|
height = 'auto; padding-bottom: 10px'
|
||||||
|
gridPattern = ['span-2', 'span-2', 'span-2 last']
|
||||||
|
|
||||||
|
|
||||||
|
# relation views, used for cells (components) of lists and grids
|
||||||
|
|
||||||
|
class ConceptRelationView(BaseConceptRelationView, ConceptView):
|
||||||
|
|
||||||
def __init__(self, relation, request, contextIsSecond=False,
|
def __init__(self, relation, request, contextIsSecond=False,
|
||||||
parent=None, idx=0):
|
parent=None, idx=0):
|
||||||
BaseResourceRelationView.__init__(self, relation, request, contextIsSecond)
|
BaseConceptRelationView.__init__(self, relation, request, contextIsSecond)
|
||||||
|
self.parentView = parent
|
||||||
|
self.idx = idx
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def img(self):
|
||||||
|
self.registerDojoLightbox() # also provides access to info popup
|
||||||
|
for r in self.images:
|
||||||
|
url = self.nodeView.getUrlForTarget(r)
|
||||||
|
src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize))
|
||||||
|
return dict(src=src, url=url,
|
||||||
|
cssClass=self.parentView.imageCssClass)
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceView(BaseResourceView):
|
||||||
|
|
||||||
|
def __init__(self, resource, request, parent=None, idx=0):
|
||||||
|
BaseResourceView.__init__(self, resource, request)
|
||||||
self.parentView = parent
|
self.parentView = parent
|
||||||
self.idx = idx
|
self.idx = idx
|
||||||
|
|
||||||
|
@ -244,22 +275,3 @@ class ResourceRelationView(BaseResourceRelationView):
|
||||||
return dict(src=src, url=url,
|
return dict(src=src, url=url,
|
||||||
cssClass=self.parentView.imageCssClass)
|
cssClass=self.parentView.imageCssClass)
|
||||||
|
|
||||||
class ResourcesPart(BasePart):
|
|
||||||
|
|
||||||
def getResources(self):
|
|
||||||
result = []
|
|
||||||
resourceRels = self.context.getResourceRelations()
|
|
||||||
for idx, r in enumerate(resourceRels):
|
|
||||||
result.append(ResourceRelationView(r, self.request,
|
|
||||||
contextIsSecond=True, parent=self, idx=idx))
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceGrid3(ResourcesPart):
|
|
||||||
|
|
||||||
macroName = 'rgrid'
|
|
||||||
imageSize = 'small'
|
|
||||||
height = 'auto; padding-bottom: 10px'
|
|
||||||
gridPattern = ['span-2', 'span-2', 'span-2 last']
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2011 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
|
||||||
|
@ -677,6 +677,11 @@ class ListChildren(SpecialNodeView):
|
||||||
macroName = 'listchildren'
|
macroName = 'listchildren'
|
||||||
|
|
||||||
|
|
||||||
|
class ListSubobjects(SpecialNodeView):
|
||||||
|
|
||||||
|
macroName = 'listsubobjects'
|
||||||
|
|
||||||
|
|
||||||
class ConfigureView(NodeView):
|
class ConfigureView(NodeView):
|
||||||
""" An editing view for configuring a node, optionally creating
|
""" An editing view for configuring a node, optionally creating
|
||||||
a target object.
|
a target object.
|
||||||
|
|
|
@ -166,12 +166,47 @@
|
||||||
<a href="#"
|
<a href="#"
|
||||||
tal:attributes="href string:${view/url}/.${related/uniqueId};
|
tal:attributes="href string:${view/url}/.${related/uniqueId};
|
||||||
title related/description"
|
title related/description"
|
||||||
tal:content="related/title">Resource Title</a>
|
tal:content="related/title">Concept Title</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</metal:children>
|
</metal:children>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:subobjects define-macro="listsubobjects"
|
||||||
|
tal:define="target nocall:item/targetObjectView">
|
||||||
|
<div class="content-1"
|
||||||
|
tal:content="structure item/body"
|
||||||
|
tal:attributes="ondblclick python:
|
||||||
|
target and target.openEditWindow('configure.html')
|
||||||
|
or item.openEditWindow();
|
||||||
|
id string:${view/itemNum}.body;">
|
||||||
|
Listing
|
||||||
|
</div>
|
||||||
|
<div tal:condition="nocall:target">
|
||||||
|
<div tal:attributes="ondblclick python: target.openEditWindow('configure.html')"
|
||||||
|
tal:define="children python:list(target.children())"
|
||||||
|
tal:condition="children">
|
||||||
|
<h3 i18n:translate="">Children</h3>
|
||||||
|
<div tal:repeat="related children">
|
||||||
|
<a tal:attributes="href python:view.getUrlForTarget(related);
|
||||||
|
title related/description"
|
||||||
|
tal:content="related/title">Concept Title</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div tal:attributes="ondblclick python: target.openEditWindow('resources.html')"
|
||||||
|
tal:define="resources python:list(target.resources())"
|
||||||
|
tal:condition="resources">
|
||||||
|
<h3 i18n:translate="">Resources</h3>
|
||||||
|
<div tal:repeat="related resources">
|
||||||
|
<a tal:attributes="href python:view.getUrlForTarget(related);
|
||||||
|
title related/description"
|
||||||
|
tal:content="related/title">Resource Title</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</metal:subobjects>
|
||||||
|
|
||||||
|
|
||||||
<!-- menu -->
|
<!-- menu -->
|
||||||
|
|
||||||
<metal:menu define-macro="menu"
|
<metal:menu define-macro="menu"
|
||||||
|
|
Loading…
Add table
Reference in a new issue