diff --git a/templates/contactslist.html b/templates/contactslist.html index b1c7741731a533ff526d0945c3dd4e4ac720fd74..ff3641e2dabdf5f02883ed49cbea8518d8955129 100644 --- a/templates/contactslist.html +++ b/templates/contactslist.html @@ -10,8 +10,9 @@
@@ -39,16 +40,15 @@ $(document).ready(function() { }); $('select.filter').change(function() { - var filter_group = $(this).val(); - contacts = contacts.filter(function(contact) { - var keep = false - contact['groups'].forEach(function(group) { - if (group['id'] === Number(filter_group)) { - keep = true; - }; - }); - return keep; - }); + // We must get the contact list as it is before apllying this specific filter + // Meaning, the full contact list plus all the other filter. + // We just need to call it on all the select elements. + contacts = JSON.parse(contacts_json); + $('select.filter').each(function() { + var filter = $(this); + var filter_group = $(this).val(); + contacts = contacts.filter(filter_mep, filter); + }); list_meps(contacts, wrapper); }); @@ -69,6 +69,20 @@ $(document).ready(function() { $('select').material_select(); }); +function filter_mep(contact) { + var filter_group = $(this).val(); + if (Number(filter_group) === -1) { + return true + }; + var keep = false + contact['groups'].forEach(function(group) { + if (group['id'] === Number(filter_group)) { + keep = true; + }; + }); + return keep; +} + function random_mep() { var random = Math.floor((Math.random() * $('.collection-item').length)); update_mep($('.collection-item').eq(random)); @@ -108,13 +122,13 @@ function display_mep(contact) { return group['type'] === 'group'; }); if ( group.length > 0 ) { - var group_src = 'http://www.europarl.europa.eu/ep_framework/img/group/group_iconsmall_' + var group_src = 'https://www.europarl.europa.eu/ep_framework/img/group/group_iconsmall_' + group[0]['name'].toLowerCase().replace('/','') + '.png'; $('').attr('src', group_src) .appendTo(li); }; if ( country.length > 0 ) { - var country_src = 'http://www.europarl.europa.eu/ep_framework/img/flag/flag_icon_' + var country_src = 'https://www.europarl.europa.eu/ep_framework/img/flag/flag_icon_' + country[0]['name'].toLowerCase().replace('/','') + '.gif'; $('').addClass('circle') .attr('src', country_src)