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:
helmutm 2006-08-19 21:00:00 +00:00
parent 8ee75bbf77
commit 5f2df98fc9
8 changed files with 67 additions and 32 deletions

View file

@ -40,9 +40,9 @@ from zope.security.proxy import removeSecurityProxy
from cybertools.browser.view import GenericView from cybertools.browser.view import GenericView
from cybertools.relation.interfaces import IRelationRegistry 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.interfaces import IView
#from loops import util from loops import util
from loops.util import _ from loops.util import _
@ -154,6 +154,13 @@ class BaseView(GenericView):
for o in objs: for o in objs:
yield BaseView(o, request) 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 @Lazy
def uniqueId(self): def uniqueId(self):
return zapi.getUtility(IRelationRegistry).getUniqueIdForObject(self.context) return zapi.getUtility(IRelationRegistry).getUniqueIdForObject(self.context)

View file

@ -23,13 +23,17 @@ function submitReplacing(targetId, formId, actionUrl) {
} }
function inlineEdit(id, saveUrl) { function inlineEdit(id, saveUrl) {
var iconNode = dojo.byId("inlineedit_icon");
iconNode.style.visibility = "hidden";
var editor = dojo.widget.fromScript("Editor", var editor = dojo.widget.fromScript("Editor",
{items: ["save", "|", "formatblock", "|", {items: ["save", "|", "formatblock", "|",
"insertunorderedlist", "insertorderedlist", "|", "insertunorderedlist", "insertorderedlist", "|",
"bold", "italic", "|", "createLink", "insertimage"], "bold", "italic", "|", "createLink", "insertimage"],
saveUrl: saveUrl, saveUrl: saveUrl,
closeOnSave: true, closeOnSave: true,
onSave: function(){this.disableToolbar(true);}, onSave: function(){
this.disableToolbar(true);
iconNode.style.visibility = "visible";}
}, dojo.byId(id)); }, dojo.byId(id));
return false; return false;
} }

View file

@ -234,6 +234,8 @@ class NodeView(BaseView):
name = zapi.getDefaultViewName(target, self.request) name = zapi.getDefaultViewName(target, self.request)
targetView = zapi.getMultiAdapter((target, self.request), targetView = zapi.getMultiAdapter((target, self.request),
name=name) name=name)
if name == 'index.html' and hasattr(targetView, 'show'):
return targetView.show()
return targetView() return targetView()
return u'' return u''

View file

@ -25,22 +25,24 @@
</div> </div>
<div tal:define="target nocall:item/target" <div tal:define="target nocall:item/target"
tal:condition="nocall:target"> tal:condition="nocall:target">
<div class="subcolumn" <metal:editicons define-macro="editicons">
tal:condition="item/xeditable | nothing"> <div class="subcolumn" id="xedit_icon"
<a href="#" title="Edit" style="padding: 5px" tal:condition="item/xeditable | nothing">
tal:attributes="href string:${item/realTargetUrl}/external_edit; <a href="#" title="Edit" style="padding: 5px"
title string:Edit ${item/title}"><img tal:attributes="href string:${item/realTargetUrl}/external_edit;
src="edit.gif" alt="Edit" title string:Edit ${item/title}"><img
tal:attributes="src context/++resource++edit.gif" /></a> src="edit.gif" alt="Edit"
</div> tal:attributes="src context/++resource++edit.gif" /></a>
<div class="subcolumn" </div>
tal:condition="item/inlineEditable"> <div class="subcolumn" id="inlineedit_icon"
<a href="#" title="Edit" style="padding: 5px" tal:condition="item/inlineEditable">
tal:attributes="title string:Edit ${item/title}; <a href="#" title="Edit" style="padding: 5px"
onclick python: item.inlineEdit(id)"><img tal:attributes="title string:Edit ${item/title};
src="edit.gif" alt="Edit" onclick python: item.inlineEdit(id)"><img
tal:attributes="src context/++resource++edit.gif" /></a> src="edit.gif" alt="Edit"
</div> tal:attributes="src context/++resource++edit.gif" /></a>
</div>
</metal:editicons>
<div class="content-1 subcolumn" id="1.body" <div class="content-1 subcolumn" id="1.body"
tal:attributes="class string:content-$level; tal:attributes="class string:content-$level;
id id; id id;
@ -121,7 +123,7 @@
<metal:resources define-macro="listresources" <metal:resources define-macro="listresources"
tal:define="target item/target"> tal:define="target nocall:item/target">
<div class="content-1" <div class="content-1"
tal:content="structure item/body" tal:content="structure item/body"
tal:attributes="ondblclick python: tal:attributes="ondblclick python:

View file

@ -1,7 +1,17 @@
<metal:block define-macro="render"> <metal:block define-macro="render">
<div tal:attributes="ondblclick python: item.openEditWindow('configure.html')"> <div tal:attributes="ondblclick python: item.openEditWindow('configure.html')">
<h3 tal:content="item/title">Title</h3> <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> </div>
</metal:block> </metal:block>

View file

@ -99,5 +99,5 @@ Before accessing the `results` property we have to prepare a catalog.
... return [] ... return []
>>> component.provideUtility(DummyCat()) >>> component.provideUtility(DummyCat())
>>> resultsView.results >>> list(resultsView.results)
[] []

View file

@ -79,19 +79,25 @@ class SearchResults(BaseView):
@Lazy @Lazy
def results(self): def results(self):
request = self.request request = self.request
type = request.get('search.1.text', 'loops:resource:*')
text = request.get('search.2.text') text = request.get('search.2.text')
if not text: if not text and '*' in type: # there should be some sort of selection...
return set() return set()
useTitle = request.get('search.2.title') useTitle = request.get('search.2.title')
useFull = request.get('search.2.full') useFull = request.get('search.2.full')
r1 = r2 = set() r1 = set()
cat = component.getUtility(ICatalog) cat = component.getUtility(ICatalog)
if useFull: if useFull and text and not type.startswith('loops:concept:'):
criteria = {'loops_resource_textng': {'query': text},} criteria = {'loops_resource_textng': {'query': text},}
r1 = set(cat.searchResults(**criteria)) r1 = set(cat.searchResults(**criteria))
if useTitle: if type.endswith('*'):
criteria = {'loops_title': text,} start = type[:-1]
r2 = set(cat.searchResults(**criteria)) end = start + '\x7f'
result = [BaseView(r, request) for r in r1.union(r2)] else:
return result 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))

View file

@ -84,8 +84,12 @@
<select name="text" <select name="text"
tal:attributes="name string:$namePrefix.text; tal:attributes="name string:$namePrefix.text;
id string:$idPrefix.text;"> id string:$idPrefix.text;">
<option value=".loops/concepts/topic">Topic</option> <tal:types repeat="type view/typesForSearch">
<option value="loops.resource.Document">Document</option> <option value="loops:*"
i18n:translate=""
tal:attributes="value type/token"
tal:content="type/title">Topic</option>
</tal:types>
</select> </select>
<input type="button" value="+" <input type="button" value="+"
title="Add type" />&nbsp; title="Add type" />&nbsp;