use macro registration and new view structure (cybertools.browser, main.pt) for loading dojo modules only when there are really needed
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1316 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
fd7c221a2d
commit
f8f9ee1fd8
6 changed files with 33 additions and 10 deletions
|
@ -176,18 +176,25 @@ class BaseView(GenericView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def inlineEditingActive(self):
|
def inlineEditingActive(self):
|
||||||
return False
|
#return False
|
||||||
return self.request.principal.id == 'rootadmin'
|
return self.request.principal.id == 'rootadmin'
|
||||||
# this may depend on system and user settings...
|
# this may depend on system and user settings...
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@Lazy
|
#@Lazy
|
||||||
def inlineEditable(self):
|
#def inlineEditable(self):
|
||||||
return self.inlineEditingActive and canWrite(self.context, 'title')
|
# return self.inlineEditingActive and canWrite(self.context, 'title')
|
||||||
|
|
||||||
|
inlineEditable = False
|
||||||
|
|
||||||
def inlineEdit(self, id):
|
def inlineEdit(self, id):
|
||||||
|
self.registerDojo()
|
||||||
return 'return inlineEdit("%s", "")' % id
|
return 'return inlineEdit("%s", "")' % id
|
||||||
|
|
||||||
|
def registerDojo(self):
|
||||||
|
cm = self.controller.macros
|
||||||
|
cm.register('js', 'dojo.js', resourceName='ajax.dojo/dojo.js')
|
||||||
|
|
||||||
|
|
||||||
class LoopsTerms(object):
|
class LoopsTerms(object):
|
||||||
""" Provide the ITerms interface, e.g. for usage in selection
|
""" Provide the ITerms interface, e.g. for usage in selection
|
||||||
|
|
|
@ -518,7 +518,7 @@
|
||||||
|
|
||||||
<defaultView
|
<defaultView
|
||||||
for="loops.interfaces.INode"
|
for="loops.interfaces.INode"
|
||||||
name="node.html"
|
name="main.html"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
|
|
|
@ -65,8 +65,7 @@ class NodeView(BaseView):
|
||||||
cm = self.controller.macros
|
cm = self.controller.macros
|
||||||
cm.register('css', identifier='loops.css',
|
cm.register('css', identifier='loops.css',
|
||||||
resourceName='loops.css', media='all')
|
resourceName='loops.css', media='all')
|
||||||
cm.register('js', identifier='loops.js', resourceName='loops.js')
|
cm.register('js', 'loops.js', resourceName='loops.js')
|
||||||
cm.register('js', identifier='dojo.js', resourceName='ajax.dojo/dojo.js')
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def view(self):
|
def view(self):
|
||||||
|
@ -274,8 +273,13 @@ class NodeView(BaseView):
|
||||||
return target and target.inlineEditable or False
|
return target and target.inlineEditable or False
|
||||||
|
|
||||||
def inlineEdit(self, id):
|
def inlineEdit(self, id):
|
||||||
|
self.registerDojo()
|
||||||
|
cm = self.controller.macros
|
||||||
|
jsCall = 'dojo.require("dojo.widget.Editor")'
|
||||||
|
cm.register('js-execute', jsCall, jsCall=jsCall)
|
||||||
return 'return inlineEdit("%s", "%s/inline_save")' % (id, self.virtualTargetUrl)
|
return 'return inlineEdit("%s", "%s/inline_save")' % (id, self.virtualTargetUrl)
|
||||||
|
|
||||||
|
|
||||||
# inner HTML views
|
# inner HTML views
|
||||||
|
|
||||||
class InlineEdit(NodeView):
|
class InlineEdit(NodeView):
|
||||||
|
|
|
@ -174,3 +174,8 @@ class DocumentView(ResourceView):
|
||||||
view = zapi.getMultiAdapter((removeAllProxies(source), self.request))
|
view = zapi.getMultiAdapter((removeAllProxies(source), self.request))
|
||||||
return view.render()
|
return view.render()
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def inlineEditable(self):
|
||||||
|
return (self.inlineEditingActive
|
||||||
|
and self.context.contentType == 'text/html'
|
||||||
|
and canWrite(self.context, 'data'))
|
||||||
|
|
|
@ -65,11 +65,17 @@ accessed exactly once per row:
|
||||||
2
|
2
|
||||||
|
|
||||||
To execute the search in the context of a node we have to set up a node
|
To execute the search in the context of a node we have to set up a node
|
||||||
view on our page. The submitReplacing method returns a JavaScript call
|
view for our page. The submitReplacing method returns a JavaScript call
|
||||||
that will replace the results part on the search page:
|
that will replace the results part on the search page; as this registers
|
||||||
|
the dojo library with the view's controller we also have to supply
|
||||||
|
a controller attribute for the search view.
|
||||||
|
|
||||||
>>> from loops.browser.node import NodeView
|
>>> from loops.browser.node import NodeView
|
||||||
>>> pageView = NodeView(page, TestRequest())
|
>>> request = TestRequest()
|
||||||
|
>>> pageView = NodeView(page, request)
|
||||||
|
|
||||||
|
>>> from cybertools.browser.liquid.controller import Controller
|
||||||
|
>>> searchView.controller = Controller(searchView, request)
|
||||||
|
|
||||||
>>> searchView.submitReplacing('1.results', '1.search.form', pageView)
|
>>> searchView.submitReplacing('1.results', '1.search.form', pageView)
|
||||||
'return submitReplacing("1.results", "1.search.form",
|
'return submitReplacing("1.results", "1.search.form",
|
||||||
|
|
|
@ -59,6 +59,7 @@ class Search(BaseView):
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def submitReplacing(self, targetId, formId, view):
|
def submitReplacing(self, targetId, formId, view):
|
||||||
|
self.registerDojo()
|
||||||
return 'return submitReplacing("%s", "%s", "%s")' % (
|
return 'return submitReplacing("%s", "%s", "%s")' % (
|
||||||
targetId, formId,
|
targetId, formId,
|
||||||
'%s/.target%s/@@searchresults.html' % (view.url, self.uniqueId))
|
'%s/.target%s/@@searchresults.html' % (view.url, self.uniqueId))
|
||||||
|
|
Loading…
Add table
Reference in a new issue