Skip to content

Commit

Permalink
Merge pull request #136 from Softcatala/aparells_canvis
Browse files Browse the repository at this point in the history
#138 solve some add aparell form issues
  • Loading branch information
paugnu committed Mar 9, 2016
2 parents 64c104d + 6801885 commit 1b8a730
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 48 deletions.
2 changes: 1 addition & 1 deletion inc/ajax_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function sc_send_aparell() {

$terms = array(
'tipus_aparell' => array($tipus_aparell),
'sistema_operatiu_aparell' => array($sistema_operatiu)
'so_aparell' => array($sistema_operatiu)
);

$metadata = array(
Expand Down
10 changes: 7 additions & 3 deletions static/js/aparells.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//Search form
jQuery(".selectpicker").on('change', function() {
jQuery("#tipus_aparell").on('change', function() {
jQuery( "#cerca_aparells" ).submit();
});

jQuery("#sistema_operatiu").on('change', function() {
jQuery( "#cerca_aparells" ).submit();
});

Expand All @@ -25,9 +29,9 @@ $contactForm.on('submit', function(ev){
//Data
post_data = new FormData();
post_data.append('nom', jQuery('input[name=nom]').val());
post_data.append('tipus_aparell', jQuery('input[name=tipus_aparell]:checked').val());
post_data.append('tipus_aparell', jQuery('#tipus_ap option:selected').val());
post_data.append('fabricant', jQuery('input[name=fabricant]').val());
post_data.append('sistema_operatiu', jQuery('input[name=sistema_operatiu]:checked').val());
post_data.append('sistema_operatiu', jQuery('#so_aparell option:selected').val());
post_data.append('versio', jQuery('input[name=versio]').val());
post_data.append('traduccio_catala', jQuery('input[name=traduccio_catala]:checked').val());
post_data.append('correccio_catala', jQuery('input[name=correccio_catala]:checked').val());
Expand Down
60 changes: 20 additions & 40 deletions templates/aparells-afegeix.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,19 @@
</div>
<!-- camp -->

<!-- camp -->
<!-- camp dropdown -->
<div class="form-group">
<label class="col-sm-3 control-label">Tipus de dispositiu *</label>
<!-- col-sm-9 -->
<div class="col-sm-9">
<div class="row">
{% for row in categories.tipus|batch((categories.tipus|length)/3) %}
<!-- col-sm-4 -->
<div class="col-sm-4">
{% for category in row %}
<div class="checkbox">
<label>
<input type="radio" name="tipus_aparell" value="{{ category.ID }}" required> {{ category.name }}
</label>
</div>
{% endfor %}
</div>
<!-- col-sm-4 -->
<div class="col-sm-6">
<select class="form-control selectpicker" name="tipus_ap" id="tipus_ap">
{% for category in categories.tipus %}
<option value="{{ category.ID }}" {% if loop.first %}selected="selected"{% endif %}>{{ category.name }}</option>
{% endfor %}
</div>
</div><!--/col-sm-9 -->
</div>
<!-- camp -->
</select>
</div>
<div class="col-sm-3">
</div>
</div><!-- /camp dropdown -->

<!-- camp -->
<div class="form-group">
Expand All @@ -68,29 +58,19 @@
</div>
<!-- camp -->

<!-- camp -->
<!-- camp dropdown -->
<div class="form-group">
<label class="col-sm-3 control-label">Sistema operatiu *</label>
<!-- col-sm-9 -->
<div class="col-sm-9">
<div class="row">
{% for row in categories.sistemesoperatius|batch((categories.sistemesoperatius|length)/3) %}
<!-- col-sm-4 -->
<div class="col-sm-4">
{% for category in row %}
<div class="checkbox">
<label>
<input type="radio" name="sistema_operatiu" value="{{ category.ID }}" required> {{ category.name }}
</label>
</div>
{% endfor %}
</div>
<!-- col-sm-4 -->
<div class="col-sm-6">
<select class="form-control selectpicker" name="so_aparell" id="so_aparell">
{% for category in categories.sistemesoperatius %}
<option value="{{ category.ID }}" {% if loop.first %}selected="selected"{% endif %}>{{ category.name }}</option>
{% endfor %}
</div>
</div><!--/col-sm-9 -->
</div>
<!-- camp -->
</select>
</div>
<div class="col-sm-3">
</div>
</div><!-- /camp dropdown -->

<!-- camp -->
<div class="form-group">
Expand Down
8 changes: 4 additions & 4 deletions templates/aparells.twig
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@
<div class="row">
<!-- dropdown sitemes operatius -->
<div class="col-sm-6">
<select class="form-control selectpicker" id="temes" name="sistema_operatiu">
<select class="form-control selectpicker" id="sistema_operatiu_afegeix" name="sistema_operatiu_afegeix">
<option value="">Tots els sistemes operatius</option>
{% for category in categories.sistemesoperatius %}
<option value="{{ category.slug }}" {% if selected_filter_so == category.slug %}selected{% endif %}>{{ category.name }}</option>
<option value="{{ category.ID }}">{{ category.name }}</option>
{% endfor %}
</select>
</div><!--/dropdown sitemes operatius -->

<!-- dropdown categories -->
<div class="col-sm-6">
<select class="form-control selectpicker" id="tipus" name="tipus_aparell">
<select class="form-control selectpicker" id="tipus_aparell_afegeix" name="tipus_aparell_afegeix">
<option value="">Totes les categories</option>
{% for category in categories.tipus %}
<option value="{{ category.slug }}" {% if selected_filter_tipus == category.slug %}selected{% endif %}>{{ category.name }}</option>
<option value="{{ category.ID }}">{{ category.name }}</option>
{% endfor %}
</select>
</div><!--/dropdown categories -->
Expand Down

0 comments on commit 1b8a730

Please sign in to comment.