summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@0d.be>2011-12-04 10:21:07 (GMT)
committerFrédéric Péters <fpeters@0d.be>2011-12-04 10:21:07 (GMT)
commit7fdd9f23c3160e22eb5451027504fb49d0f2f43d (patch)
treee393fbde561895c2ec21d81c3667a84ad5c10dba
parentc4b7cf6f367ad40ca833ccbb71cd638c1d9be5c7 (diff)
downloadtabellio.searchform-7fdd9f23c3160e22eb5451027504fb49d0f2f43d.zip
tabellio.searchform-7fdd9f23c3160e22eb5451027504fb49d0f2f43d.tar.gz
tabellio.searchform-7fdd9f23c3160e22eb5451027504fb49d0f2f43d.tar.bz2
add sort select to pfb doc search
-rw-r--r--tabellio/searchform/docsearch.pt27
-rw-r--r--tabellio/searchform/docsearchpfb.pt21
-rw-r--r--tabellio/searchform/form.py3
-rw-r--r--tabellio/searchform/js_macros.pt27
4 files changed, 33 insertions, 45 deletions
diff --git a/tabellio/searchform/docsearch.pt b/tabellio/searchform/docsearch.pt
index 2cbc9bc..22b20cf 100644
--- a/tabellio/searchform/docsearch.pt
+++ b/tabellio/searchform/docsearch.pt
@@ -185,32 +185,7 @@
<script type="text/javascript" tal:content="string: var PORTAL_URL='${view/portal_url}';"></script>
<script metal:use-macro="view/js_macros/macros/labelboxes"></script>
-<script type="text/javascript">
-(function($) {
- $().ready(function() {
- $('#formfield-document-widgets-sort_on').hide();
- $('#formfield-dossier-widgets-sort_on').hide();
- $('#formfield-question-widgets-sort_on').hide();
- $('#resultsbox').each(function() {
- form = $($(this).prevAll('input').attr('value')).find('form');
- console.log('form:', form);
- field_array = $(form).find('div.field');
- sort_on_options = $(field_array[field_array.length-1]).find('option').clone();
- $('#sorton select').append(sort_on_options).change(function() {
- selected_option = $(this).val();
- $(field_array[field_array.length-1]).find('option').each(function() {
- if ($(this).attr('value') == selected_option) {
- $(this).attr('selected', 'selected');
- $(form).submit();
- } else {
- $(this).attr('selected', null);
- }
- });
- });
- });
- });
-})(jQuery);
-</script>
+<script metal:use-macro="view/js_macros/macros/sorton"></script>
</tal:block>
</tal:main-macro>
diff --git a/tabellio/searchform/docsearchpfb.pt b/tabellio/searchform/docsearchpfb.pt
index 9365b35..9049f0e 100644
--- a/tabellio/searchform/docsearchpfb.pt
+++ b/tabellio/searchform/docsearchpfb.pt
@@ -35,6 +35,8 @@
search_batch python:Batch(list(search_results or []), b_size, int(b_start), orphan=1);"
tal:condition="python: search_results is not None">
+ <input name="fieldset.current" type="hidden" value="#fieldset-documents"/>
+ <div id="sorton"><select><option disabled="disabled">Trier par</option></select></div>
<div id="resultsbox">
<span>Nombre de résultats : <span tal:content="python: len(search_results)"/></span>
</div>
@@ -72,6 +74,7 @@
tal:condition="python: search_results is not None">
<input name="fieldset.current" type="hidden" value="#fieldset-questions"/>
+ <div id="sorton"><select><option disabled="disabled">Trier par</option></select></div>
<div id="resultsbox">
<span>Nombre de résultats : <span tal:replace="python: len(search_results)"/></span>
</div>
@@ -110,6 +113,7 @@
tal:condition="python: search_results is not None">
<input name="fieldset.current" type="hidden" value="#fieldset-textes"/>
+ <div id="sorton"><select><option disabled="disabled">Trier par</option></select></div>
<div id="resultsbox">
<span>Nombre de résultats : <span tal:replace="python: len(search_results)"/></span>
</div>
@@ -164,7 +168,7 @@ ministres interrogés</li>
<li>Rapport de commission : compte-rendu synthétique des discussions tenues en
commission sur un projet ou une proposition de décret ou de règlement ou à la
suite d'auditions</li>
-</ul>
+</ul></dd>
</dl>
</div>
@@ -240,6 +244,7 @@ la séance plénière, les députés peuvent interroger le(s) ministre(s) lors d
celle-ci</li>
</ul>
</dd>
+</dl>
</div>
@@ -279,15 +284,6 @@ 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 setup_default_session(index, elem)
{
if ($(elem).find('option[selected]').length == 0) {
@@ -320,7 +316,6 @@ function setup_help_icon(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);
$('#document-widgets-session').each(setup_default_session);
$('#question-widgets-session').each(setup_default_session);
$('#adopteddocument-widgets-session').each(setup_default_session);
@@ -337,12 +332,10 @@ function setup_help_icon(index, elem)
$('#formfield-adopteddocument-widgets-l_doctypes').each(setup_appearance);
$('#formfield-adopteddocument-widgets-l_topics').each(setup_appearance);
$('#formfield-adopteddocument-widgets-l_polgroups').each(setup_appearance);
- $('#formfield-adopteddocument-widgets-sort_on').each(setup_sort_on);
});
})(jQuery);
</script>
-
-
+<script metal:use-macro="view/js_macros/macros/sorton"></script>
</tal:block>
</tal:main-macro>
diff --git a/tabellio/searchform/form.py b/tabellio/searchform/form.py
index f5e7a4e..77dc1b8 100644
--- a/tabellio/searchform/form.py
+++ b/tabellio/searchform/form.py
@@ -448,7 +448,6 @@ class QuestionSearchForm(form.Form):
class QuestionPfbSearchForm(QuestionSearchForm):
fields = field.Fields(IQuestionSearch)
fields['authors'].title = _(u'Author(s)')
- fields['sort_on'].widgetFactory = FieldRadioboxesWidget
@button.buttonAndHandler(_(u'Submit'))
def handleApply(self, action):
@@ -488,7 +487,6 @@ 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_form.pt')
@@ -535,7 +533,6 @@ class AdoptedDocumentPfbSearchForm(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_form.pt')
diff --git a/tabellio/searchform/js_macros.pt b/tabellio/searchform/js_macros.pt
index 59ec18f..dcfaa76 100644
--- a/tabellio/searchform/js_macros.pt
+++ b/tabellio/searchform/js_macros.pt
@@ -97,8 +97,31 @@ function load_results(elem)
})(jQuery);
</script>
-<!-- TODO -->
-<script tppe="text/javascript" metal:define-macro="droppedradios">
+<script tppe="text/javascript" metal:define-macro="sorton">
+(function($) {
+ $().ready(function() {
+ $('#formfield-document-widgets-sort_on').hide();
+ $('#formfield-dossier-widgets-sort_on').hide();
+ $('#formfield-question-widgets-sort_on').hide();
+ $('#resultsbox').each(function() {
+ form = $($(this).prevAll('input').attr('value')).find('form');
+ field_array = $(form).find('div.field');
+ sort_on_options = $(field_array[field_array.length-1]).find('option').clone();
+ $('#sorton select').append(sort_on_options).change(function() {
+ selected_option = $(this).val();
+ $(field_array[field_array.length-1]).find('option').each(function() {
+ if ($(this).attr('value') == selected_option) {
+ $(this).attr('selected', 'selected');
+ $(form).submit();
+ } else {
+ $(this).attr('selected', null);
+ }
+ });
+ });
+ });
+ });
+})(jQuery);
+
</script>