addFilter
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-02-07 12:30:30 +01:00
parent 7af9aa46e9
commit 9f2ff4e4b7
4 changed files with 17 additions and 17 deletions

View File

@ -63,6 +63,6 @@ describe('Ticket index payout path', () => {
const reference = await page.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText'); const reference = await page.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText');
expect(count).toEqual(4); expect(count).toEqual(4);
expect(reference).toContain('Cash, Albaran: 7, 8Payment'); expect(reference).toContain('Cash,Albaran: 7, 8Payment');
}); });
}); });

View File

@ -40,7 +40,7 @@
ng-model="$ctrl.filter.typeFk" ng-model="$ctrl.filter.typeFk"
fields="['categoryFk']" fields="['categoryFk']"
include="'category'" include="'category'"
on-change="$ctrl.applyFilters()"> on-change="$ctrl.addFilters()">
<tpl-item> <tpl-item>
<div>{{name}}</div> <div>{{name}}</div>
<div class="text-caption text-secondary"> <div class="text-caption text-secondary">
@ -60,7 +60,7 @@
value-field="id" value-field="id"
where="{role: {inq: ['logistic', 'buyer']}}" where="{role: {inq: ['logistic', 'buyer']}}"
label="Buyer" label="Buyer"
on-change="$ctrl.applyFilters()"> on-change="$ctrl.addFilters()">
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete <vn-autocomplete
vn-id="supplier" vn-id="supplier"
@ -71,7 +71,7 @@
search-function="{or: [{nickname: {like: '%'+ $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}" search-function="{or: [{nickname: {like: '%'+ $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
show-field="name" show-field="name"
value-field="id" value-field="id"
on-change="$ctrl.applyFilters()"> on-change="$ctrl.addFilters()">
<tpl-item>{{name}}: {{nickname}}</tpl-item> <tpl-item>{{name}}: {{nickname}}</tpl-item>
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
@ -79,12 +79,12 @@
<vn-date-picker <vn-date-picker
label="From" label="From"
ng-model="$ctrl.filter.from" ng-model="$ctrl.filter.from"
on-change="$ctrl.applyFilters()"> on-change="$ctrl.addFilters()">
</vn-date-picker> </vn-date-picker>
<vn-date-picker <vn-date-picker
label="To" label="To"
ng-model="$ctrl.filter.to" ng-model="$ctrl.filter.to"
on-change="$ctrl.applyFilters()"> on-change="$ctrl.addFilters()">
</vn-date-picker> </vn-date-picker>
</vn-vertical> </vn-vertical>
<vn-horizontal class="checks"> <vn-horizontal class="checks">
@ -92,19 +92,19 @@
label="Is active" label="Is active"
ng-model="$ctrl.filter.active" ng-model="$ctrl.filter.active"
triple-state="true" triple-state="true"
ng-click="$ctrl.applyFilters()"> ng-click="$ctrl.addFilters()">
</vn-check> </vn-check>
<vn-check <vn-check
label="Is visible" label="Is visible"
ng-model="$ctrl.filter.visible" ng-model="$ctrl.filter.visible"
triple-state="true" triple-state="true"
ng-click="$ctrl.applyFilters()"> ng-click="$ctrl.addFilters()">
</vn-check> </vn-check>
<vn-check <vn-check
label="Is floramondo" label="Is floramondo"
ng-model="$ctrl.filter.floramondo" ng-model="$ctrl.filter.floramondo"
triple-state="true" triple-state="true"
ng-click="$ctrl.applyFilters()"> ng-click="$ctrl.addFilters()">
</vn-check> </vn-check>
</vn-horizontal> </vn-horizontal>
<vn-horizontal class="tags"> <vn-horizontal class="tags">
@ -139,7 +139,7 @@
ng-model="itemTag.value" ng-model="itemTag.value"
show-field="value" show-field="value"
value-field="value" value-field="value"
on-change="$ctrl.applyFilters()"> on-change="$ctrl.addFilters()">
</vn-autocomplete> </vn-autocomplete>
<vn-icon-button <vn-icon-button
vn-none vn-none

View File

@ -17,33 +17,33 @@ class Controller extends SearchPanel {
changeCategory(id) { changeCategory(id) {
if (this.filter.categoryFk != id) { if (this.filter.categoryFk != id) {
this.filter.categoryFk = id; this.filter.categoryFk = id;
this.applyFilters(); this.addFilters();
} }
} }
removeItemFilter(param) { removeItemFilter(param) {
this.filter[param] = null; this.filter[param] = null;
if (param == 'categoryFk') this.filter['typeFk'] = null; if (param == 'categoryFk') this.filter['typeFk'] = null;
this.applyFilters(); this.addFilters();
} }
removeTag(tag) { removeTag(tag) {
const index = this.filter.tags.indexOf(tag); const index = this.filter.tags.indexOf(tag);
if (index > -1) this.filter.tags.splice(index, 1); if (index > -1) this.filter.tags.splice(index, 1);
this.applyFilters(); this.addFilters();
} }
onKeyPress($event) { onKeyPress($event) {
if ($event.key === 'Enter') if ($event.key === 'Enter')
this.applyFilters(); this.addFilters();
} }
applyFilters() { addFilters() {
for (let i = 0; i < this.filter.tags.length; i++) { for (let i = 0; i < this.filter.tags.length; i++) {
if (!this.filter.tags[i].value) if (!this.filter.tags[i].value)
this.filter.tags.splice(i, 1); this.filter.tags.splice(i, 1);
} }
return this.model.applyFilter({}, this.filter); return this.model.addFilter({}, this.filter);
} }
showTagInfo(itemTag) { showTagInfo(itemTag) {

View File

@ -10,7 +10,7 @@ describe('Entry', () => {
beforeEach(angular.mock.inject($componentController => { beforeEach(angular.mock.inject($componentController => {
$element = angular.element(`<vn-latest-buys-search-panel></vn-latest-buys-search-panel>`); $element = angular.element(`<vn-latest-buys-search-panel></vn-latest-buys-search-panel>`);
controller = $componentController('vnLatestBuysSearchPanel', {$element}); controller = $componentController('vnLatestBuysSearchPanel', {$element});
controller.model = {applyFilter: () => {}}; controller.model = {addFilter: () => {}};
})); }));
describe('removeItemFilter()', () => { describe('removeItemFilter()', () => {