turn "sort on" widget in a droppable radio boxes thingie

This commit is contained in:
Frédéric Péters 2011-11-20 15:28:21 +01:00
parent a347f719de
commit 14c9b33cb9
2 changed files with 16 additions and 1 deletions

View File

@ -136,7 +136,6 @@ function sync_from_checkboxes(elem, dummyinput)
function setup_appearance(index, elem)
{
var dummyinput = $('<input type="text" readonly="readonly"/>');
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('<div class="droppedradios">');
$(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);
</script>

View File

@ -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')