move handling of portlet actions to browser.action; add links (still dummy) for creating and editing knowledge.glossary objects
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2194 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
9fa0cc512c
commit
8fcb2712bb
7 changed files with 57 additions and 41 deletions
|
@ -597,7 +597,7 @@ Actions
|
|||
|
||||
>>> actions = view.getActions('portlet')
|
||||
>>> len(actions)
|
||||
1
|
||||
2
|
||||
|
||||
Clean-up:
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
alt action/description" /><span
|
||||
i18n:translate=""
|
||||
tal:condition="action/title"
|
||||
tal:content="action/title">Action Title</span>
|
||||
</a>
|
||||
tal:content="action/title">Action Title</span></a>
|
||||
</div>
|
||||
<span id="inner.Id"
|
||||
tal:condition="action/innerHtmlId"
|
||||
|
|
|
@ -377,16 +377,14 @@ class BaseView(GenericView):
|
|||
cm.register('js', 'dojo.js', resourceName='ajax.dojo/dojo.js')
|
||||
|
||||
|
||||
# actions
|
||||
# actions - obsolete, see loops.browser.action
|
||||
|
||||
class Action(object):
|
||||
#class Action(object):
|
||||
|
||||
def __init__(self, renderer, url, **kw):
|
||||
self.renderer = renderer
|
||||
self.url = url
|
||||
self.__dict__.update(kw)
|
||||
#for k in kw:
|
||||
# setattr(self, k, kw[k])
|
||||
# def __init__(self, renderer, url, **kw):
|
||||
# self.renderer = renderer
|
||||
# self.url = url
|
||||
# self.__dict__.update(kw)
|
||||
|
||||
|
||||
# vocabulary stuff
|
||||
|
|
|
@ -347,11 +347,16 @@ class NodeView(BaseView):
|
|||
|
||||
def getPortletActions(self):
|
||||
actions = []
|
||||
actions.append(Action(self,
|
||||
targetWindow='loops_cme',
|
||||
title='Edit Concept Map',
|
||||
description='Open concept map editor in new window',
|
||||
url=self.conceptMapEditorUrl))
|
||||
actions.append(Action(self, title='Edit Concept Map',
|
||||
targetWindow='loops_cme',
|
||||
description='Open concept map editor in new window',
|
||||
url=self.conceptMapEditorUrl))
|
||||
actions.append(Action(self, title='Create Resource...',
|
||||
description='Create a new resource object.',
|
||||
url='create_object.html',
|
||||
onClick="objectDialog('create', '%s/create_object.html'); "
|
||||
"return false;" % self.virtualTargetUrl,
|
||||
innerHtmlId='dialog.create'))
|
||||
return actions
|
||||
|
||||
actions = dict(portlet=getPortletActions)
|
||||
|
|
|
@ -211,31 +211,6 @@
|
|||
<tal:actions repeat="action python:view.getActions('portlet')">
|
||||
<metal:action use-macro="action/macro" />
|
||||
</tal:actions>
|
||||
<tal:actions define="dummy view/registerDojo;
|
||||
url view/virtualTargetUrl">
|
||||
<div>
|
||||
<a href="create_object.html" i18n:translate=""
|
||||
onclick="objectDialog('create', 'create_object.html'); return false;"
|
||||
tal:attributes="onClick
|
||||
string:objectDialog('create', '$url/create_object.html');;
|
||||
return false;;">
|
||||
Create Resource...
|
||||
</a>
|
||||
</div>
|
||||
<div tal:condition="view/hasEditableTarget">
|
||||
<a href="edit_object.html" i18n:translate=""
|
||||
onclick="objectDialog('edit', 'edit_object.html'); return false;"
|
||||
tal:define="version request/version|nothing;
|
||||
versionPar python: version and '?version=' + version or ''"
|
||||
tal:attributes="onClick
|
||||
string:objectDialog('edit', '$url/edit_object.html$versionPar');;
|
||||
return false;;">
|
||||
Edit Resource...
|
||||
</a>
|
||||
</div>
|
||||
</tal:actions>
|
||||
<span id="dialog.create"></span>
|
||||
<span id="dialog.edit"></span>
|
||||
</metal:actions>
|
||||
|
||||
|
||||
|
|
|
@ -182,6 +182,18 @@ class ResourceView(BaseView):
|
|||
ct = self.context.contentType
|
||||
return ct.startswith('image/') or ct == 'application/pdf'
|
||||
|
||||
# actions
|
||||
|
||||
def getPortletActions(self, page=None):
|
||||
actions = []
|
||||
actions.append(Action(self, title='Edit Resource...',
|
||||
description='Modify resource object.',
|
||||
url='edit_object.html',
|
||||
onClick="objectDialog('edit', '%s/edit_object.html'); "
|
||||
"return false;" % page.virtualTargetUrl,
|
||||
innerHtmlId='dialog.edit'))
|
||||
return actions
|
||||
|
||||
def getObjectActions(self, page=None):
|
||||
actions = []
|
||||
if page is None:
|
||||
|
@ -192,6 +204,10 @@ class ResourceView(BaseView):
|
|||
# actions.append(factory(self, page=view,))
|
||||
return actions
|
||||
|
||||
actions = dict(portlet=getPortletActions, object=getObjectActions)
|
||||
|
||||
# relations
|
||||
|
||||
def concepts(self):
|
||||
for r in self.context.getConceptRelations():
|
||||
yield ConceptRelationView(r, self.request)
|
||||
|
|
|
@ -26,6 +26,7 @@ $Id$
|
|||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
|
||||
from loops.browser.action import Action
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.common import adapted
|
||||
from loops import util
|
||||
|
@ -40,6 +41,17 @@ class GlossaryView(ConceptView):
|
|||
def macro(self):
|
||||
return template.macros['glossary']
|
||||
|
||||
def getActions(self, category='object', page=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(Action(self, title='Create Glossary Item...',
|
||||
description='Create a new glossary item.',
|
||||
url='create_glossaryitem.html',
|
||||
onClick="objectDialog('create', '%s/create_object.html'); "
|
||||
"return false;" % self.virtualTargetUrl,
|
||||
innerHtmlId='dialog.create'))
|
||||
return actions
|
||||
|
||||
|
||||
class GlossaryItemView(ConceptView):
|
||||
|
||||
|
@ -47,3 +59,14 @@ class GlossaryItemView(ConceptView):
|
|||
def macro(self):
|
||||
return template.macros['glossaryitem']
|
||||
|
||||
def getActions(self, category='object', page=None):
|
||||
actions = []
|
||||
if category == 'portlet':
|
||||
actions.append(Action(self, title='Create Glossary Item...',
|
||||
description='Create a new glossary item.',
|
||||
url='create_glossaryitem.html'))
|
||||
actions.append(Action(self, title='Edit Glossary Item...',
|
||||
description='Modify glossary item.',
|
||||
url='edit_glossaryitem.html'))
|
||||
return actions
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue