search and inline editing improved
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1318 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
8ee75bbf77
commit
5f2df98fc9
8 changed files with 67 additions and 32 deletions
|
@ -40,9 +40,9 @@ from zope.security.proxy import removeSecurityProxy
|
|||
|
||||
from cybertools.browser.view import GenericView
|
||||
from cybertools.relation.interfaces import IRelationRegistry
|
||||
from cybertools.typology.interfaces import IType
|
||||
from cybertools.typology.interfaces import IType, ITypeManager
|
||||
from loops.interfaces import IView
|
||||
#from loops import util
|
||||
from loops import util
|
||||
from loops.util import _
|
||||
|
||||
|
||||
|
@ -154,6 +154,13 @@ class BaseView(GenericView):
|
|||
for o in objs:
|
||||
yield BaseView(o, request)
|
||||
|
||||
def typesForSearch(self):
|
||||
general = [('loops:resource:*', 'Any Resource'),
|
||||
('loops:concept:*', 'Any Concept'),]
|
||||
return util.KeywordVocabulary(general + sorted([(t.tokenForSearch, t.title)
|
||||
for t in ITypeManager(self.context).types])
|
||||
+ [('loops:*', 'Any')])
|
||||
|
||||
@Lazy
|
||||
def uniqueId(self):
|
||||
return zapi.getUtility(IRelationRegistry).getUniqueIdForObject(self.context)
|
||||
|
|
|
@ -23,13 +23,17 @@ function submitReplacing(targetId, formId, actionUrl) {
|
|||
}
|
||||
|
||||
function inlineEdit(id, saveUrl) {
|
||||
var iconNode = dojo.byId("inlineedit_icon");
|
||||
iconNode.style.visibility = "hidden";
|
||||
var editor = dojo.widget.fromScript("Editor",
|
||||
{items: ["save", "|", "formatblock", "|",
|
||||
"insertunorderedlist", "insertorderedlist", "|",
|
||||
"bold", "italic", "|", "createLink", "insertimage"],
|
||||
saveUrl: saveUrl,
|
||||
closeOnSave: true,
|
||||
onSave: function(){this.disableToolbar(true);},
|
||||
onSave: function(){
|
||||
this.disableToolbar(true);
|
||||
iconNode.style.visibility = "visible";}
|
||||
}, dojo.byId(id));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -234,6 +234,8 @@ class NodeView(BaseView):
|
|||
name = zapi.getDefaultViewName(target, self.request)
|
||||
targetView = zapi.getMultiAdapter((target, self.request),
|
||||
name=name)
|
||||
if name == 'index.html' and hasattr(targetView, 'show'):
|
||||
return targetView.show()
|
||||
return targetView()
|
||||
return u''
|
||||
|
||||
|
|
|
@ -25,22 +25,24 @@
|
|||
</div>
|
||||
<div tal:define="target nocall:item/target"
|
||||
tal:condition="nocall:target">
|
||||
<div class="subcolumn"
|
||||
tal:condition="item/xeditable | nothing">
|
||||
<a href="#" title="Edit" style="padding: 5px"
|
||||
tal:attributes="href string:${item/realTargetUrl}/external_edit;
|
||||
title string:Edit ${item/title}"><img
|
||||
src="edit.gif" alt="Edit"
|
||||
tal:attributes="src context/++resource++edit.gif" /></a>
|
||||
</div>
|
||||
<div class="subcolumn"
|
||||
tal:condition="item/inlineEditable">
|
||||
<a href="#" title="Edit" style="padding: 5px"
|
||||
tal:attributes="title string:Edit ${item/title};
|
||||
onclick python: item.inlineEdit(id)"><img
|
||||
src="edit.gif" alt="Edit"
|
||||
tal:attributes="src context/++resource++edit.gif" /></a>
|
||||
</div>
|
||||
<metal:editicons define-macro="editicons">
|
||||
<div class="subcolumn" id="xedit_icon"
|
||||
tal:condition="item/xeditable | nothing">
|
||||
<a href="#" title="Edit" style="padding: 5px"
|
||||
tal:attributes="href string:${item/realTargetUrl}/external_edit;
|
||||
title string:Edit ${item/title}"><img
|
||||
src="edit.gif" alt="Edit"
|
||||
tal:attributes="src context/++resource++edit.gif" /></a>
|
||||
</div>
|
||||
<div class="subcolumn" id="inlineedit_icon"
|
||||
tal:condition="item/inlineEditable">
|
||||
<a href="#" title="Edit" style="padding: 5px"
|
||||
tal:attributes="title string:Edit ${item/title};
|
||||
onclick python: item.inlineEdit(id)"><img
|
||||
src="edit.gif" alt="Edit"
|
||||
tal:attributes="src context/++resource++edit.gif" /></a>
|
||||
</div>
|
||||
</metal:editicons>
|
||||
<div class="content-1 subcolumn" id="1.body"
|
||||
tal:attributes="class string:content-$level;
|
||||
id id;
|
||||
|
@ -121,7 +123,7 @@
|
|||
|
||||
|
||||
<metal:resources define-macro="listresources"
|
||||
tal:define="target item/target">
|
||||
tal:define="target nocall:item/target">
|
||||
<div class="content-1"
|
||||
tal:content="structure item/body"
|
||||
tal:attributes="ondblclick python:
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
<metal:block define-macro="render">
|
||||
<div tal:attributes="ondblclick python: item.openEditWindow('configure.html')">
|
||||
<h3 tal:content="item/title">Title</h3>
|
||||
<span tal:replace="structure item/render" />
|
||||
<tal:body define="itemNum view/itemNum;
|
||||
id string:$itemNum.body;">
|
||||
<tal:edit define="item nocall:view">
|
||||
<div metal:use-macro="views/node_macros/editicons" />
|
||||
</tal:edit>
|
||||
<div class="content-1" id="1.body"
|
||||
tal:attributes="id id;"
|
||||
tal:content="structure item/render">
|
||||
The body
|
||||
</div>
|
||||
</tal:body>
|
||||
</div>
|
||||
</metal:block>
|
||||
|
||||
|
|
|
@ -99,5 +99,5 @@ Before accessing the `results` property we have to prepare a catalog.
|
|||
... return []
|
||||
>>> component.provideUtility(DummyCat())
|
||||
|
||||
>>> resultsView.results
|
||||
>>> list(resultsView.results)
|
||||
[]
|
||||
|
|
|
@ -79,19 +79,25 @@ class SearchResults(BaseView):
|
|||
@Lazy
|
||||
def results(self):
|
||||
request = self.request
|
||||
type = request.get('search.1.text', 'loops:resource:*')
|
||||
text = request.get('search.2.text')
|
||||
if not text:
|
||||
if not text and '*' in type: # there should be some sort of selection...
|
||||
return set()
|
||||
useTitle = request.get('search.2.title')
|
||||
useFull = request.get('search.2.full')
|
||||
r1 = r2 = set()
|
||||
r1 = set()
|
||||
cat = component.getUtility(ICatalog)
|
||||
if useFull:
|
||||
if useFull and text and not type.startswith('loops:concept:'):
|
||||
criteria = {'loops_resource_textng': {'query': text},}
|
||||
r1 = set(cat.searchResults(**criteria))
|
||||
if useTitle:
|
||||
criteria = {'loops_title': text,}
|
||||
r2 = set(cat.searchResults(**criteria))
|
||||
result = [BaseView(r, request) for r in r1.union(r2)]
|
||||
return result
|
||||
if type.endswith('*'):
|
||||
start = type[:-1]
|
||||
end = start + '\x7f'
|
||||
else:
|
||||
start = end = type
|
||||
criteria = {'loops_type': (start, end),}
|
||||
if useTitle and text:
|
||||
criteria['loops_title'] = text
|
||||
r2 = set(cat.searchResults(**criteria))
|
||||
return self.viewIterator(r1.union(r2))
|
||||
|
||||
|
|
|
@ -84,8 +84,12 @@
|
|||
<select name="text"
|
||||
tal:attributes="name string:$namePrefix.text;
|
||||
id string:$idPrefix.text;">
|
||||
<option value=".loops/concepts/topic">Topic</option>
|
||||
<option value="loops.resource.Document">Document</option>
|
||||
<tal:types repeat="type view/typesForSearch">
|
||||
<option value="loops:*"
|
||||
i18n:translate=""
|
||||
tal:attributes="value type/token"
|
||||
tal:content="type/title">Topic</option>
|
||||
</tal:types>
|
||||
</select>
|
||||
<input type="button" value="+"
|
||||
title="Add type" />
|
||||
|
|
Loading…
Add table
Reference in a new issue