diff --git a/browser/loops.js b/browser/loops.js index 148d0ca..1a5c06d 100644 --- a/browser/loops.js +++ b/browser/loops.js @@ -41,3 +41,12 @@ function inlineEdit(id, saveUrl) { }, dojo.byId(id)); return false; } + +function setConceptTypeForComboBox(typeId, cbId) { + var t = dojo.byId(typeId).value; + var dp = dojo.widget.manager.getWidgetById(cbId).dataProvider; + var baseUrl = dp.searchUrl.split('&')[0]; + var newUrl = baseUrl + '&searchType=' + t; + dp.searchUrl = newUrl; +} + diff --git a/query.py b/query.py index f61f0e9..83f690a 100644 --- a/query.py +++ b/query.py @@ -22,20 +22,14 @@ Query management stuff. $Id$ """ -from zope.app import zapi -from zope.component import adapts from zope.interface import Interface, Attribute, implements -from zope.i18nmessageid import MessageFactory from zope.cachedescriptors.property import Lazy from zope import schema -from zope.security.proxy import removeSecurityProxy -from cybertools.typology.type import BaseType, TypeManager from loops.interfaces import IConcept from loops.common import AdapterBase from loops.type import TypeInterfaceSourceList - -_ = MessageFactory('loops') +from loops.util import _ class IQuery(Interface): diff --git a/search/browser.py b/search/browser.py index c8234fa..72da0a0 100644 --- a/search/browser.py +++ b/search/browser.py @@ -35,11 +35,12 @@ from cybertools.ajax import innerHtml from cybertools.typology.interfaces import ITypeManager from loops.browser.common import BaseView from loops import util +from loops.util import _ -_ = MessageFactory('zope') template = ViewPageTemplateFile('search.pt') + class Search(BaseView): maxRowNum = 0 @@ -50,12 +51,6 @@ class Search(BaseView): def macro(self): return template.macros['search'] - def initDojo(self): - self.registerDojo() - cm = self.controller.macros - jsCall = 'dojo.require("dojo.widget.ComboBox")' - cm.register('js-execute', jsCall, jsCall=jsCall) - @Lazy def catalog(self): return component.getUtility(ICatalog) @@ -78,14 +73,19 @@ class Search(BaseView): for t in ITypeManager(self.context).types if 'concept' in t.qualifiers])) + def initDojo(self): + self.registerDojo() + cm = self.controller.macros + jsCall = 'dojo.require("dojo.widget.ComboBox")' + cm.register('js-execute', jsCall, jsCall=jsCall) + def listConcepts(self): + """ Used for dojo.widget.ComboBox. + """ request = self.request - request.response.setHeader('Content-Type', 'text/json; charset=UTF-8') + request.response.setHeader('Content-Type', 'text/plain; charset=UTF-8') text = request.get('searchString', '') - print 'text:', text - #if not text: - # return '' - type = request.get('search.3.type', 'loops:concept:*') + type = request.get('searchType') or 'loops:concept:*' if type.endswith('*'): start = type[:-1] end = start + '\x7f' @@ -96,8 +96,8 @@ class Search(BaseView): result = cat.searchResults(loops_type=(start, end), loops_text=text+'*') else: result = cat.searchResults(loops_type=(start, end)) - return str([[o.title.encode('UTF-8'), zapi.getName(o).encode('UTF-8')] - for o in result]) + return str(sorted([[`o.title`[2:-1], `zapi.getName(o)`[2:-1]] + for o in result])).replace('\\\\x', '\\x') def submitReplacing(self, targetId, formId, view): self.registerDojo() diff --git a/search/search.pt b/search/search.pt index 3777903..924ac30 100644 --- a/search/search.pt +++ b/search/search.pt @@ -27,6 +27,7 @@ + - - -   - - -
- - +
+
+
-
-

Type(s) to search for

- - - - - - -   -
+ + + + +   + + +
-
-

Search text

- - - -    - - -   -
+ + + +

Search text

+ + + + + + + +    + + + + + + +   + +
-
-

Search via related concepts

- -    - - -   -
- -
-
+ + + +

Search via related concepts

+ + + + + +    + + + + +   + + + + + + +
+ + +   + diff --git a/util.py b/util.py index 41d14a5..ea24d11 100644 --- a/util.py +++ b/util.py @@ -27,7 +27,8 @@ from zope.i18nmessageid import MessageFactory from zope.schema import vocabulary #from view import TargetRelation -_ = MessageFactory('loops') +#_ = MessageFactory('loops') +_ = MessageFactory('zope') # it's easier not use a special i18n domain... class KeywordVocabulary(vocabulary.SimpleVocabulary):