add "adopted texts" pane to pfb doc search (#974)
This commit is contained in:
parent
664974bbee
commit
be885a99cd
|
@ -56,6 +56,20 @@
|
|||
<script metal:use-macro="view/js_macros/macros/labelboxes"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function sync_from_checkboxes(elem, dummyinput)
|
||||
{
|
||||
t = '';
|
||||
$(elem).find('span.option').each(function(idx, el) {
|
||||
if ($(el).find('input').attr('checked')) {
|
||||
if (t.length > 0) {
|
||||
t = t + ', ';
|
||||
}
|
||||
t = t + $(el).find('label span').text();
|
||||
}
|
||||
});
|
||||
$(dummyinput).attr('value', t);
|
||||
}
|
||||
|
||||
function setup_appearance(index, elem)
|
||||
{
|
||||
var dummyinput = $('<input type="text" readonly="readonly"/>');
|
||||
|
|
|
@ -95,8 +95,44 @@
|
|||
|
||||
|
||||
</dd>
|
||||
<dt id="fieldset-legend-textes">Textes adoptés</dt>
|
||||
<dt id="fieldsetlegend-textes">Textes adoptés</dt>
|
||||
<dd id="fieldset-textes">
|
||||
|
||||
<form method="post" action="./#resultsbox">
|
||||
<div tal:replace="structure view/adopted_document_pfb_search_form"/>
|
||||
</form>
|
||||
|
||||
<div tal:define="search_results view/adopted_document_search_results;
|
||||
search_batch python:Batch(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-textes"/>
|
||||
<div id="resultsbox">
|
||||
<span>Nombre de résultats : <span tal:replace="python: len(search_results)"/></span>
|
||||
</div>
|
||||
|
||||
<div id="results">
|
||||
<ul>
|
||||
<tal:entry tal:repeat="item search_batch">
|
||||
<li tal:define="oddrow repeat/item/odd; object python: item.getObject()" tal:attributes="class python: oddrow and 'odd' or 'even'"><div>
|
||||
<h4><a href="#" tal:attributes="href item/getURL" tal:content="python: object.reftitle">Véronique Salvi</a></h4>
|
||||
<p class="intitule" tal:content="item/Title"/>
|
||||
<p class="authors" tal:condition="python: object.authors">Auteur(s) : <span tal:replace="python: object.get_authors_as_string()" tal:condition="python: object.authors" /></p>
|
||||
</div></li>
|
||||
</tal:entry>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div tal:define="batch search_batch">
|
||||
<div metal:use-macro="view/batch_macros/macros/navigation" />
|
||||
<div metal:use-macro="view/batch_macros/macros/feed" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
|
||||
|
@ -104,6 +140,61 @@
|
|||
|
||||
<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 sync_from_checkboxes(elem, dummyinput)
|
||||
{
|
||||
t = '';
|
||||
$(elem).find('span.option').each(function(idx, el) {
|
||||
if ($(el).find('input').attr('checked')) {
|
||||
if (t.length > 0) {
|
||||
t = t + ', ';
|
||||
}
|
||||
t = t + $(el).find('label span').text();
|
||||
}
|
||||
});
|
||||
$(dummyinput).attr('value', t);
|
||||
}
|
||||
|
||||
|
||||
function setup_appearance(index, elem)
|
||||
{
|
||||
var dummyinput = $('<input type="text" readonly="readonly"/>');
|
||||
sync_from_checkboxes(elem, dummyinput);
|
||||
dummyinput.click(function() {
|
||||
$(elem).find('div.droppedcheckboxes').toggle();
|
||||
});
|
||||
$(elem).find('.fieldErrorBox').after(dummyinput);
|
||||
$(elem).find('span.option').wrapAll('<div class="droppedcheckboxes">').click(function() {
|
||||
sync_from_checkboxes(elem, dummyinput);
|
||||
});
|
||||
$(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() {
|
||||
$('#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);
|
||||
|
||||
$('#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>
|
||||
|
||||
|
||||
|
||||
</tal:block>
|
||||
</tal:main-macro>
|
||||
|
|
|
@ -510,6 +510,55 @@ class DocumentPfbSearchForm(form.Form):
|
|||
return
|
||||
|
||||
|
||||
class IAdoptedDocumentPfbSearch(interface.Interface):
|
||||
search_type_is_adopteddocument = schema.TextLine(title=u'Search Type', default=u'1')
|
||||
|
||||
nodoc = schema.TextLine(title=_(u'Document Number'), required=False)
|
||||
l_doctypes = schema.List(title=_(u'Types'), required=False,
|
||||
value_type=schema.Choice(title=_(u'Type'), required=False,
|
||||
values=[_(u'Projets'), _(u'Propositions')]))
|
||||
ttitle = schema.TextLine(title=_(u'Title'), required=False)
|
||||
text = schema.TextLine(title=_(u'Text'), required=False)
|
||||
authors = schema.TextLine(title=_(u'Authors'), required=False)
|
||||
l_polgroups = schema.List(title=_(u'Political Groups'), required=False,
|
||||
value_type=schema.Choice(title=_(u'Political Group'),
|
||||
required=False, source=possible_polgroups))
|
||||
l_topics = schema.List(title=_(u'Topics'), required=False,
|
||||
value_type=schema.Choice(required=False,
|
||||
source=possible_topics));
|
||||
session = schema.Choice(title=_(u'Legislature / Session'), required=False,
|
||||
source=possible_sessions)
|
||||
start = schema.Date(title=_(u'Start'), required=False)
|
||||
end = schema.Date(title=_(u'End'), required=False)
|
||||
adopted = schema.Bool(title=_(u'Limit to adopted'), required=False, default=True)
|
||||
|
||||
sort_on = schema.Choice(title=_(u'Sort By'), required=True,
|
||||
default=_(u'Session'),
|
||||
values=[_(u'Session'), _(u'Type'), _(u'Number')])
|
||||
|
||||
|
||||
class AdoptedDocumentPfbSearchForm(form.Form):
|
||||
prefix = 'adopteddocument'
|
||||
fields = field.Fields(IAdoptedDocumentPfbSearch)
|
||||
fields['authors'].widgetFactory = FieldAuthorsWidget
|
||||
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')
|
||||
|
||||
def updateWidgets(self):
|
||||
super(AdoptedDocumentPfbSearchForm, self).updateWidgets()
|
||||
self.widgets['adopted'].mode = z3c.form.interfaces.HIDDEN_MODE
|
||||
self.widgets['search_type_is_adopteddocument'].mode = z3c.form.interfaces.HIDDEN_MODE
|
||||
|
||||
@button.buttonAndHandler(_(u'Submit'))
|
||||
def handleApply(self, action):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class IDeputySearch(interface.Interface):
|
||||
search_type_is_deputy = schema.TextLine(title=u'Search Type', default=u'1', required=False)
|
||||
|
||||
|
@ -555,23 +604,9 @@ class EventSearchForm(form.Form):
|
|||
pass
|
||||
|
||||
|
||||
class DeputySearchForm(form.Form):
|
||||
prefix = 'deputy'
|
||||
fields = field.Fields(IDeputySearch)
|
||||
ignoreContext = True
|
||||
template = ViewPageTemplateFile('form_templates/view_form.pt')
|
||||
|
||||
def updateWidgets(self):
|
||||
super(DeputySearchForm, self).updateWidgets()
|
||||
self.widgets['search_type_is_deputy'].mode = z3c.form.interfaces.HIDDEN_MODE
|
||||
|
||||
@button.buttonAndHandler(_(u'Submit'))
|
||||
def handleApply(self, action):
|
||||
pass
|
||||
|
||||
|
||||
class IGlobalSearchForm(interface.Interface):
|
||||
search_type_is_document = schema.TextLine(title=u'Search Type', required=False)
|
||||
search_type_is_adopteddocument = schema.TextLine(title=u'Search Type', required=False)
|
||||
search_type_is_dossier = schema.TextLine(title=u'Search Type', required=False)
|
||||
search_type_is_question = schema.TextLine(title=u'Search Type', required=False)
|
||||
|
||||
|
@ -663,7 +698,7 @@ class SearchView(BrowserView):
|
|||
return d
|
||||
|
||||
def search_results(self, search_type):
|
||||
#print 'search type:', search_type
|
||||
print 'search type:', search_type
|
||||
|
||||
if self.request.form.get('document.widgets.search_type_is_document'):
|
||||
GlobalSearchForm.prefix = 'document'
|
||||
|
@ -671,6 +706,8 @@ class SearchView(BrowserView):
|
|||
GlobalSearchForm.prefix = 'dossier'
|
||||
elif self.request.form.get('question.widgets.search_type_is_question'):
|
||||
GlobalSearchForm.prefix = 'question'
|
||||
elif self.request.form.get('adopteddocument.widgets.search_type_is_adopteddocument'):
|
||||
GlobalSearchForm.prefix = 'adopteddocument'
|
||||
|
||||
f = GlobalSearchForm(self.context, self.request)
|
||||
f.update()
|
||||
|
@ -680,6 +717,7 @@ class SearchView(BrowserView):
|
|||
|
||||
if not data.get('search_type_is_%s' % search_type):
|
||||
return None
|
||||
print 'data:', data
|
||||
|
||||
if data.get('ttitle'):
|
||||
kw['Title'] = data.get('ttitle')
|
||||
|
@ -748,6 +786,8 @@ class SearchView(BrowserView):
|
|||
|
||||
if data.get('search_type_is_document'):
|
||||
kw['portal_type'] = 'tabellio.documents.document'
|
||||
elif data.get('search_type_is_adopteddocument'):
|
||||
kw['portal_type'] = 'tabellio.documents.document'
|
||||
elif data.get('search_type_is_dossier'):
|
||||
kw['portal_type'] = 'tabellio.documents.dossier'
|
||||
elif data.get('search_type_is_question'):
|
||||
|
@ -824,6 +864,8 @@ class SearchView(BrowserView):
|
|||
if data.get('sort_on') == 'Type':
|
||||
if data.get('search_type_is_document'):
|
||||
cmp_function = cmp_doctype
|
||||
elif data.get('search_type_is_adopteddocument'):
|
||||
cmp_function = cmp_doctype
|
||||
elif data.get('search_type_is_dossier'):
|
||||
cmp_function = cmp_dostype
|
||||
elif data.get('search_type_is_question'):
|
||||
|
@ -854,6 +896,14 @@ class SearchView(BrowserView):
|
|||
def document_search_results(self):
|
||||
return self.search_results(search_type='document')
|
||||
|
||||
def adopted_document_pfb_search_form(self):
|
||||
f = AdoptedDocumentPfbSearchForm(self.context, self.request)
|
||||
f.update()
|
||||
return f.render()
|
||||
|
||||
def adopted_document_search_results(self):
|
||||
return self.search_results(search_type='adopteddocument')
|
||||
|
||||
def dossier_search_form(self):
|
||||
f = DossierSearchForm(self.context, self.request)
|
||||
f.update()
|
||||
|
|
Reference in New Issue