summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-03-22 12:41:58 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-03-22 12:41:58 (GMT)
commit6cc4ba3c17f20877dedaac9d04b349e3ba94ee77 (patch)
tree87274d222dc3105507a8f1d49886c97d40047c64
parentc009f039897bc9ac82482f7dd07be3b673a3fa91 (diff)
downloadwelco-0.23.zip
welco-0.23.tar.gz
welco-0.23.tar.bz2
mail: replace formdef filter by a category filter (#10099)v0.23
-rw-r--r--welco/sources/mail/templates/welco/mail_home.html5
-rw-r--r--welco/static/css/style.css4
-rw-r--r--welco/static/js/welco.js30
3 files changed, 21 insertions, 18 deletions
diff --git a/welco/sources/mail/templates/welco/mail_home.html b/welco/sources/mail/templates/welco/mail_home.html
index d10d938..851de09 100644
--- a/welco/sources/mail/templates/welco/mail_home.html
+++ b/welco/sources/mail/templates/welco/mail_home.html
@@ -3,7 +3,7 @@
<div data-source-type="{{ source_type.id }}">
<div id="source-sidebar" class="mails">
{% if display_filter %}
- <select id="formdef-filter"></select>
+ <select id="category-filter"></select>
{% endif %}
<ul>
{% for mail in mails %}
@@ -16,6 +16,9 @@
{% for association in mail.associations.all %}
/ <span data-formdef-reference="{{association.formdef_reference}}">{{association.formdef_name}}</span>
{% endfor %}
+ {% for category in mail.categories %}
+ <span style="display: none" data-category-name="{{category}}"></span>
+ {% endfor %}
</li>
{% endfor %}
</ul>
diff --git a/welco/static/css/style.css b/welco/static/css/style.css
index be35234..8e77610 100644
--- a/welco/static/css/style.css
+++ b/welco/static/css/style.css
@@ -95,7 +95,7 @@ div#content .cell.document iframe {
}
div#content #source-sidebar {
- min-width: 20em;
+ width: 25em;
display: none; /* only displayed when on top */
}
@@ -440,7 +440,7 @@ form#note textarea {
height: 8em;
}
-#formdef-filter {
+#category-filter {
width: 100%;
}
diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js
index 1d740ef..be7aff8 100644
--- a/welco/static/js/welco.js
+++ b/welco/static/js/welco.js
@@ -364,37 +364,37 @@ $(function() {
$('#postit').on('click', window.displayPopup);
$('#id_post_date').datepicker($.datepicker.regional["fr"]);
- if ($('#formdef-filter').length) {
- var known_formdefs = Object();
- $('[data-formdef-reference]').each(function(index, elem) {
- known_formdefs[$(elem).data('formdef-reference')] = $(elem).text();
+ if ($('#category-filter').length) {
+ var known_categories = Object();
+ $('[data-category-name]').each(function(index, elem) {
+ known_categories[$(elem).data('category-name')] = $(elem).data('category-name');
});
var options = Array();
- $(Object.keys(known_formdefs)).each(function(index, elem) {
- options.push({'key': elem, 'value': known_formdefs[elem]});
+ $(Object.keys(known_categories)).each(function(index, elem) {
+ options.push({'key': elem, 'value': known_categories[elem]});
});
options.sort(function(x, y) {
if (x.value > y.value) return 1;
if (x.value < y.value) return -1;
return 0;
});
- $('#formdef-filter').empty();
+ $('#category-filter').empty();
/* TODO: should use javascript i18n */
- $('<option value="">Tout</option>').appendTo($('#formdef-filter'));
+ $('<option value="">Toutes</option>').appendTo($('#category-filter'));
$(options).each(function(index, elem) {
- $('<option value="' + elem.key + '">' + elem.value + '</option>').appendTo($('#formdef-filter'));
+ $('<option value="' + elem.key + '">' + elem.value + '</option>').appendTo($('#category-filter'));
});
- $('#formdef-filter').on('change', function() {
- var selected_formdef = $(this).val();
- if (selected_formdef == '') {
+ $('#category-filter').on('change', function() {
+ var selected_category = $(this).val();
+ if (selected_category == '') {
$('#source-sidebar li').removeClass('li-visible');
$('#source-sidebar li').show();
} else {
$('#source-sidebar li').each(function(index, elem) {
- var formdef_references = $(elem).find('[data-formdef-reference]').map(function(idx, elem) {
- return $(elem).data('formdef-reference');
+ var category_references = $(elem).find('[data-category-name]').map(function(idx, elem) {
+ return $(elem).data('category-name');
}).toArray();
- if (formdef_references.indexOf(selected_formdef) == -1) {
+ if (category_references.indexOf(selected_category) == -1) {
$(elem).removeClass('li-visible');
$(elem).hide();
} else {