This commit is contained in:
parent
98f73fc5d2
commit
12308de5d1
|
@ -41,11 +41,18 @@
|
||||||
</t-right-icons>
|
</t-right-icons>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="input">
|
<vn-vertical class="input">
|
||||||
<vn-textfield
|
<vn-textfield vn-one
|
||||||
vn-one
|
ng-keyUp="$ctrl.onSearchById($event)"
|
||||||
|
label="Item id"
|
||||||
|
model="$ctrl.itemFk">
|
||||||
|
<t-left-icons>
|
||||||
|
<vn-icon icon="icon-item"></vn-icon>
|
||||||
|
</t-left-icons>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield vn-one
|
||||||
vn-id="search"
|
vn-id="search"
|
||||||
ng-keyUp="$ctrl.onSearch($event)"
|
ng-keyUp="$ctrl.onSearchByTag($event)"
|
||||||
label="Search tag"
|
label="Search tag"
|
||||||
model="$ctrl.value">
|
model="$ctrl.value">
|
||||||
<t-left-icons>
|
<t-left-icons>
|
||||||
|
@ -59,7 +66,7 @@
|
||||||
</i>
|
</i>
|
||||||
</t-right-icons>
|
</t-right-icons>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-vertical>
|
||||||
<vn-popover
|
<vn-popover
|
||||||
vn-id="popover"
|
vn-id="popover"
|
||||||
on-close="$ctrl.onPopoverClose()">
|
on-close="$ctrl.onPopoverClose()">
|
||||||
|
|
|
@ -96,8 +96,13 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearch(event) {
|
onSearchById(event) {
|
||||||
if (event.key !== 'Enter') return;
|
if (event.key !== 'Enter' || !this.itemFk) return;
|
||||||
|
this.applyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
onSearchByTag(event) {
|
||||||
|
if (event.key !== 'Enter' || !this.value) return;
|
||||||
this.tags.push({
|
this.tags.push({
|
||||||
value: this.value,
|
value: this.value,
|
||||||
});
|
});
|
||||||
|
@ -114,7 +119,7 @@ class Controller {
|
||||||
|
|
||||||
applyFilters() {
|
applyFilters() {
|
||||||
let newParams = {};
|
let newParams = {};
|
||||||
const newFilter = {};
|
let newFilter = {};
|
||||||
const model = this.catalog.$scope.model;
|
const model = this.catalog.$scope.model;
|
||||||
|
|
||||||
if (this.category)
|
if (this.category)
|
||||||
|
@ -123,6 +128,9 @@ class Controller {
|
||||||
if (this.type)
|
if (this.type)
|
||||||
newFilter.typeFk = this.type.id;
|
newFilter.typeFk = this.type.id;
|
||||||
|
|
||||||
|
if (this.itemFk)
|
||||||
|
newFilter = {'i.id': this.itemFk};
|
||||||
|
|
||||||
newParams = {
|
newParams = {
|
||||||
orderFk: this.order.id,
|
orderFk: this.order.id,
|
||||||
orderBy: this.catalog.getOrderBy(),
|
orderBy: this.catalog.getOrderBy(),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
import crudModel from 'core/mocks/crud-model';
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
describe('Order', () => {
|
fdescribe('Order', () => {
|
||||||
describe('Component vnCatalogFilter', () => {
|
describe('Component vnCatalogFilter', () => {
|
||||||
let $scope;
|
let $scope;
|
||||||
let $state;
|
let $state;
|
||||||
|
@ -79,12 +79,12 @@ describe('Order', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSearch()', () => {
|
describe('onSearchByTag()', () => {
|
||||||
it(`should not add a new tag if the event key code doesn't equals to 'Enter'`, () => {
|
it(`should not add a new tag if the event key code doesn't equals to 'Enter'`, () => {
|
||||||
spyOn(controller, 'applyFilters');
|
spyOn(controller, 'applyFilters');
|
||||||
controller.order = {id: 4};
|
controller.order = {id: 4};
|
||||||
controller.value = 'Color';
|
controller.value = 'Color';
|
||||||
controller.onSearch({key: 'Tab'});
|
controller.onSearchByTag({key: 'Tab'});
|
||||||
|
|
||||||
expect(controller.applyFilters).not.toHaveBeenCalledWith();
|
expect(controller.applyFilters).not.toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
@ -93,7 +93,27 @@ describe('Order', () => {
|
||||||
spyOn(controller, 'applyFilters');
|
spyOn(controller, 'applyFilters');
|
||||||
controller.order = {id: 4};
|
controller.order = {id: 4};
|
||||||
controller.value = 'Color';
|
controller.value = 'Color';
|
||||||
controller.onSearch({key: 'Enter'});
|
|
||||||
|
controller.onSearchByTag({key: 'Enter'});
|
||||||
|
|
||||||
|
expect(controller.applyFilters).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onSearchById()', () => {
|
||||||
|
it(`should not filter by id if the event key code doesn't equals to 'Enter'`, () => {
|
||||||
|
spyOn(controller, 'applyFilters');
|
||||||
|
controller.itemFk = 1;
|
||||||
|
controller.onSearchById({key: 'Tab'});
|
||||||
|
|
||||||
|
expect(controller.applyFilters).not.toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should filter by id if the event key code equals to 'Enter' an then call applyFilters()`, () => {
|
||||||
|
spyOn(controller, 'applyFilters');
|
||||||
|
controller.itemFk = 1;
|
||||||
|
|
||||||
|
controller.onSearchById({key: 'Enter'});
|
||||||
|
|
||||||
expect(controller.applyFilters).toHaveBeenCalledWith();
|
expect(controller.applyFilters).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ Lines: Lineas
|
||||||
Accessories: Complemento
|
Accessories: Complemento
|
||||||
Category: Reino
|
Category: Reino
|
||||||
Search tag: Buscar etiqueta
|
Search tag: Buscar etiqueta
|
||||||
|
Item id: Id de artículo
|
||||||
Order by: Ordenar por
|
Order by: Ordenar por
|
||||||
Order: Orden
|
Order: Orden
|
||||||
Price: Precio
|
Price: Precio
|
||||||
|
|
Loading…
Reference in New Issue