Permalink
Browse files

fix(project): do not override current sort criteria

  • Loading branch information...
jeremyvergnas committed Jul 20, 2016
1 parent 5e93f8d commit bfbc4095e2a832c635c9d98ce42390392f4444e5
Showing with 33 additions and 30 deletions.
  1. +31 −29 src/bootstrap/filter.html
  2. +2 −1 src/criteriaBuilder.js
@@ -1,43 +1,44 @@

<template>
<div repeat.for="filter of filters" class="filters">
<div repeat.for="filter of filters" class="filters row">
<div repeat.for="field of filter">
<div class="row col-md-12">
<div class="col-md-4">
<form-field
change.delegate="onChange($parent.$index, $index) & debounce:200"
value.bind="field.data.field"
element.bind="field.field">
change.delegate="onChange($parent.$index, $index) & debounce:200"
value.bind="field.data.field"
element.bind="field.field">
</form-field>
</div>

<div class="col-md-4">
<form-field
change.delegate="onChange($parent.$index, $index) & debounce:200"
value.bind="field.data.operator"
element.bind="field.operator">
change.delegate="onChange($parent.$index, $index) & debounce:200"
value.bind="field.data.operator"
element.bind="field.operator">
</form-field>
</div>

<div class="col-md-4">
<div class="input-group">
<form-field
keydown.delegate="onChange($parent.$index, $index, true) & debounce:500"
value.bind="field.data.value"
element.bind="field.value">
keydown.delegate="onChange($parent.$index, $index, true) & debounce:500"
value.bind="field.data.value"
element.bind="field.value">
</form-field>

<div class="input-group-btn">
<button
class="btn btn-primary add-filter "
if.bind="$last"
click.delegate="create($parent.$index)"
t="+ AND">+
class="btn btn-primary add-filter "
if.bind="$last"
click.delegate="create($parent.$index)"
t="+ AND">+
</button>
<button
class="btn btn-danger remove-filter"
if.bind="filter.length > 1"
click.delegate="destroy($parent.$index, $index)"
t="- AND">-
class="btn btn-danger remove-filter"
if.bind="filter.length > 1"
click.delegate="destroy($parent.$index, $index)"
t="- AND">-
</button>
</div>
</div>
@@ -47,9 +48,9 @@
<div if.bind="field.data.operator === 'between'" class="row col-md-12">
<div class="col-md-offset-8 col-md-4" style="margin-bottom: 15px;">
<form-field
keypress.delegate="onChange($parent.$index, $index, true) & debounce:500"
value.bind="field.data.between"
element.bind="field.value">
keypress.delegate="onChange($parent.$index, $index, true) & debounce:500"
value.bind="field.data.between"
element.bind="field.value">
</form-field>
</div>
</div>
@@ -59,16 +60,16 @@
<div class="col-md-offset-4 col-md-4">
<div class="btn-group btn-group-xs btn-group-justified">
<a
class="btn btn-primary add-block"
if.bind="$last"
click.delegate="create()"
t="+ OR">+
class="btn btn-primary add-block"
if.bind="$last"
click.delegate="create()"
t="+ OR">+
</a>
<a
class="btn btn-danger remove-block"
if.bind="filters.length > 1"
click.delegate="destroy($index)"
t="- OR">-;
class="btn btn-danger remove-block"
if.bind="filters.length > 1"
click.delegate="destroy($index)"
t="- OR">-;
</a>
</div>
</div>
@@ -78,4 +79,5 @@
<hr>
</div>
</div>
<br />
</template>
@@ -19,7 +19,8 @@ export class CriteriaBuilder {
blocks.push(filtersParsed);
});

this.criteria = (blocks.length > 1) ? {where: {or: blocks}} : {where: blocks[0]};
let currentSort = this.criteria.sort || {};
this.criteria = (blocks.length > 1) ? {where: {or: blocks}, sort: currentSort} : {where: blocks[0], sort: currentSort};
}

parseOperator(filter) {

0 comments on commit bfbc409

Please sign in to comment.