diff --git a/tabellio/searchform/docsearchpfb.pt b/tabellio/searchform/docsearchpfb.pt
index 11d9eb6..f7fd4e6 100644
--- a/tabellio/searchform/docsearchpfb.pt
+++ b/tabellio/searchform/docsearchpfb.pt
@@ -136,7 +136,6 @@ function sync_from_checkboxes(elem, dummyinput)
function setup_appearance(index, elem)
{
var dummyinput = $('');
- console.log('dummy input:', dummyinput);
sync_from_checkboxes(elem, dummyinput);
dummyinput.click(function() {
$(elem).find('div.droppedcheckboxes').toggle();
@@ -148,6 +147,15 @@ function setup_appearance(index, elem)
$(elem).find('div.droppedcheckboxes').hide();
}
+function setup_sort_on(index, elem)
+{
+ $(elem).find('label.horizontal').click(function() {
+ $(elem).find('div.droppedradios').toggle();
+ });
+ $(elem).find('span.option').wrapAll('
');
+ $(elem).find('div.droppedradios').hide();
+}
+
(function($) {
$().ready(function() {
$('.author-autocomplete').autocomplete('./listAuthors', {
@@ -155,6 +163,7 @@ function setup_appearance(index, elem)
$('#formfield-document-widgets-l_doctypes').each(setup_appearance);
$('#formfield-document-widgets-l_topics').each(setup_appearance);
$('#formfield-document-widgets-l_polgroups').each(setup_appearance);
+ $('#formfield-document-widgets-sort_on').each(setup_sort_on);
});
})(jQuery);
diff --git a/tabellio/searchform/form.py b/tabellio/searchform/form.py
index 0566943..bf5eb9b 100644
--- a/tabellio/searchform/form.py
+++ b/tabellio/searchform/form.py
@@ -17,6 +17,7 @@ from z3c.form.browser import text
from z3c.form import widget
from z3c.form.interfaces import ITextWidget
from z3c.form.browser.checkbox import CheckBoxWidget
+from z3c.form.browser.radio import RadioWidget
from z3c.relationfield.schema import RelationChoice, RelationList
from plone.formwidget.contenttree import ObjPathSourceBinder
@@ -176,6 +177,9 @@ def FieldTopicsWidget(field, request):
def FieldDroppedCheckboxWidget(field, request):
return widget.FieldWidget(field, CheckBoxWidget(request))
+def FieldRadioboxesWidget(field, request):
+ return widget.FieldWidget(field, RadioWidget(request))
+
class IFolderWithDocuments(interface.Interface):
pass
@@ -405,6 +409,7 @@ class IDocumentPfbSearch(interface.Interface):
end = schema.Date(title=_(u'End'), required=False)
sort_on = schema.Choice(title=_(u'Sort By'), required=True,
+ default=_(u'Type'),
values=[_(u'Type'), _(u'Number'), _(u'Session')])
@@ -416,6 +421,7 @@ class DocumentPfbSearchForm(form.Form):
fields['l_doctypes'].widgetFactory = FieldDroppedCheckboxWidget
fields['l_polgroups'].widgetFactory = FieldDroppedCheckboxWidget
fields['l_topics'].widgetFactory = FieldDroppedCheckboxWidget
+ fields['sort_on'].widgetFactory = FieldRadioboxesWidget
ignoreContext = True
template = ViewPageTemplateFile('form_templates/view_pfbdocsearch.pt')