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