integrate with pfwbged.collection table (#4052)

This commit is contained in:
Frédéric Péters 2014-01-22 12:03:29 +01:00
parent 0fd8794d83
commit 9447f9f3ab
4 changed files with 55 additions and 1 deletions

View File

@ -108,6 +108,14 @@ class Folder(Container):
return [IContentListingObject(x) for x in children]
def intid(self):
intids = component.getUtility(IIntIds)
try:
return intids.getId(self)
except KeyError:
return None
grok.templatedir('templates')
grok.context(IDexterityContainer)

View File

@ -0,0 +1,16 @@
from five import grok
from plone.indexer import indexer
from .link import ILink
from collective.dms.basecontent.dmsdocument import IDmsDocument
@indexer(IDmsDocument)
def object_folders(obj, **kw):
folders = []
for id, item in obj.contentItems():
if not ILink.providedBy(item):
continue
folders.append(str(item.folder.to_id))
return folders
grok.global_adapter(object_folders, name='object_folders')

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
<index name="object_folders" meta_type="KeywordIndex">
<indexed_attr value="object_folders"/>
</index>
</object>

View File

@ -12,8 +12,32 @@
<h1 class="documentFirstHeading" tal:content="context/Title" />
<div tal:replace="structure provider:plone.belowcontenttitle" />
<div tal:replace="structure view/table/render"/>
<input type="hidden" name="folder_intid" tal:attributes="value context/intid"/>
<div id="searchresults"/>
<script>
$.querywidget.updateSearch = function () {
var context_url = (function() {
var baseUrl, pieces;
baseUrl = $('base').attr('href');
if (!baseUrl) {
pieces = window.location.href.split('/');
pieces.pop();
baseUrl = pieces.join('/');
}
return baseUrl;
})();
var query = context_url + "/@@querybuilder_html_results?";
query += "query.i:records=object_folders&query.o:records=plone.app.querystring.operation.int.is&query.v:records:list=";
query += $("input[name='folder_intid']").val();
query += '&sort_on=sortable_title';
$.querywidget.runQuery(query);
};
$(function() {
$.querywidget.updateSearch();
});
</script>
</metal:main>
</body>