Skip to content

Commit

Permalink
#147 solved some issues with filters
Browse files Browse the repository at this point in the history
  • Loading branch information
paugnu committed Mar 13, 2016
1 parent b1e2ce0 commit ce9e6d9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
3 changes: 1 addition & 2 deletions archive-programa.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@
$query['sistema_operatiu'] = $sistema_operatiu;
$args_so_baixades = get_post_query_args( 'baixada', SearchQueryType::Baixada, $query['sistema_operatiu'] );


$baixades_posts = get_posts( $args_so_baixades );
$programes_baixades_ids = array_map( "extract_post_ids_program", $baixades_posts );


if( isset( $args ) ) {
$args['posts_per_page'] = -1;
$all_programs = get_posts( $args );
$all_programs_ids = array_map("extract_post_ids", $all_programs);

Expand Down
13 changes: 13 additions & 0 deletions static/js/programes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ jQuery( document ).ready(function() {
});

/** Cerca **/
var $cerca_form = jQuery('#cerca_programes');
$cerca_form.on('submit', function(){
disable_empty_fields();
return true;
});

function disable_empty_fields() {
jQuery('#cerca_programes').find('input, select').each(function(_, inp) {
if (jQuery(inp).val() === '' || jQuery(inp).val() === null || jQuery(inp).val() === '0')
inp.disabled = true;
});
}

jQuery(".selectpicker").on('change', function() {
jQuery( "#cerca_programes" ).submit();
});
Expand Down
4 changes: 3 additions & 1 deletion templates/ajax/programs-list.twig
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<ul class="cont-llista">
{% for program in programs %}
{% if loop.index == 5 %}
{% if loop.index == 6 %}
<div id="mesprogrames" class="collapse">
{% endif %}
<li><i class="fa fa-chevron-right"></i>{{ program }}</li>
{% if loop.last %}
</div>
{% endif %}
{% if loop.index > 5 and loop.last %}
<br/>
<button data-toggle="collapse" class="bt-basic bt-mes intern-center" type="button" href="#mesprogrames">més<i class="fa fa-angle-down"></i></button>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/archive-programa.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- .contingut-header -->
<header class="contingut-header">
<!-- .filtres -->
<form class="searchform" method="get" id="cerca_programes" role="search" action="{{ search_params.current_url }}">
<form class="searchform" method="get" id="cerca_programes" role="search" action="/programes">
<div class="filtres row">
<div class="col-sm-10">
<div class="input-group">
Expand All @@ -35,7 +35,7 @@
<!-- dropdown categories -->
<div class="col-sm-6">
<select class="form-control selectpicker" id="sistema_operatiu" name="sistema_operatiu">
<option value="{% if current_url_params %}/programes/{{ search_params.current_url_params }}{% endif %}">Tots els sistemes operatius</option>
<option value="">Tots els sistemes operatius</option>
{% for category in categories.sistemes_operatius %}
<option value="{{ category.slug }}" {% if selected_filter_so == category.slug %}selected{% endif %}>{{ category.name }}</option>
{% endfor %}
Expand Down

0 comments on commit ce9e6d9

Please sign in to comment.