Fixed conflicts
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-03-25 13:44:51 +01:00
parent 5b5d7787ee
commit c8b6c3f7f3
5 changed files with 50 additions and 54 deletions

View File

@ -81,7 +81,7 @@ describe('Order edit basic data path', () => {
await page.waitToClick(selectors.orderBasicData.saveButton); await page.waitToClick(selectors.orderBasicData.saveButton);
const result = await page.waitForLastSnackbar(); const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toContain('Data saved!');
}); });
it('should now confirm the client have been edited', async() => { it('should now confirm the client have been edited', async() => {

View File

@ -69,8 +69,9 @@ describe('Order catalog', () => {
}); });
it('should search for an item by id', async() => { it('should search for an item by id', async() => {
await page.write(selectors.orderCatalog.itemId, '2'); // await page.write(selectors.orderCatalog.itemId, '2');
await page.keyboard.press('Enter'); await page.accessToSearchResult('2');
// await page.keyboard.press('Enter');
await page.waitForNumberOfElements('section.product', 1); await page.waitForNumberOfElements('section.product', 1);
const result = await page.countElement('section.product'); const result = await page.countElement('section.product');

View File

@ -12,11 +12,12 @@
data="$ctrl.items"> data="$ctrl.items">
</vn-crud-model> </vn-crud-model>
<vn-portal slot="topbar"> <vn-portal slot="topbar">
<vn-searchbar info="Search by item id or name"></vn-searchbar> <vn-searchbar
auto-state="false"
info="Search by item id or name"
on-search="$ctrl.onSearch($params)">
</vn-searchbar>
</vn-portal> </vn-portal>
<vn-auto-search
on-search="$ctrl.onSearch($params)">
</vn-auto-search>
<vn-order-catalog-view model="model" <vn-order-catalog-view model="model"
order="$ctrl.order"> order="$ctrl.order">
@ -83,14 +84,6 @@
</div> </div>
</vn-vertical> </vn-vertical>
<vn-vertical class="input vn-pt-md"> <vn-vertical class="input vn-pt-md">
<!-- <vn-textfield vn-id="itemId"
ng-keyUp="$ctrl.onSearchById($event)"
label="Item id">
<prepend>
<vn-icon icon="icon-item"></vn-icon>
</prepend>
</vn-textfield> -->
<vn-datalist vn-one <vn-datalist vn-one
vn-id="search" vn-id="search"
data="$ctrl.tagValues" data="$ctrl.tagValues"
@ -123,10 +116,19 @@
ng-if="$ctrl.itemId" ng-if="$ctrl.itemId"
removable="true" removable="true"
translate-attr="{title: 'Item'}" translate-attr="{title: 'Item'}"
on-remove="$ctrl.itemId = null" on-remove="$ctrl.removeItemId()"
class="colored"> class="colored">
<span>Id: {{$ctrl.itemId}}</span> <span>Id: {{$ctrl.itemId}}</span>
</vn-chip> </vn-chip>
<vn-chip
ng-if="$ctrl.itemName"
removable="true"
translate-attr="{title: 'Item'}"
on-remove="$ctrl.removeItemName()"
class="colored">
<span translate>Name</span>
<span>: {{$ctrl.itemName}}</span>
</vn-chip>
<vn-chip <vn-chip
ng-if="category.selection" ng-if="category.selection"
removable="true" removable="true"

View File

@ -109,28 +109,6 @@ class Controller extends Section {
this.applyFilters(); this.applyFilters();
} }
get itemId() {
return this._itemId;
}
set itemId(value) {
this._itemId = value;
this.updateStateParams();
this.applyFilters();
}
get itemName() {
return this._itemName;
}
set itemName(value) {
this._itemName = value;
this.updateStateParams();
this.applyFilters();
}
get tags() { get tags() {
return this._tags; return this._tags;
} }
@ -239,9 +217,19 @@ class Controller extends Section {
this.applyFilters(); this.applyFilters();
} }
applyFilters() { removeItemId() {
this.itemId = null;
this.applyFilters();
}
removeItemName() {
this.itemName = null;
this.applyFilters();
}
applyFilters(filter = {}) {
let newParams = {}; let newParams = {};
let newFilter = {}; let newFilter = Object.assign({}, filter);
const model = this.$.model; const model = this.$.model;
if (this.categoryId) if (this.categoryId)
@ -250,11 +238,11 @@ class Controller extends Section {
if (this.typeId) if (this.typeId)
newFilter.typeFk = this.typeId; newFilter.typeFk = this.typeId;
if (this.itemId) /* if (this.itemId)
newFilter = {'i.id': this.itemId}; newFilter = {'i.id': this.itemId};
if (this.itemName) if (this.itemName)
newFilter = {'i.name': {like: `%${this.itemName}%`}}; newFilter = {'i.name': {like: `%${this.itemName}%`}}; */
newParams = { newParams = {
orderFk: this.$params.id, orderFk: this.$params.id,
@ -262,7 +250,9 @@ class Controller extends Section {
tags: this.tags, tags: this.tags,
}; };
model.applyFilter({where: newFilter}, newParams); console.log(newFilter);
return model.applyFilter({where: newFilter}, newParams);
} }
openPanel(event) { openPanel(event) {
@ -294,14 +284,6 @@ class Controller extends Section {
if (this.typeId) if (this.typeId)
params.typeId = this.typeId; params.typeId = this.typeId;
params.itemId = undefined;
if (this.itemId)
params.itemId = this.itemId;
params.itemName = undefined;
if (this.itemName)
params.itemName = this.itemName;
params.tags = undefined; params.tags = undefined;
if (this.tags.length) { if (this.tags.length) {
const tags = []; const tags = [];
@ -362,15 +344,24 @@ class Controller extends Section {
} }
onSearch(params) { onSearch(params) {
if (!params) return;
this.itemId = null;
this.itemName = null;
if (params.search) { if (params.search) {
if (/^\d+$/.test(params.search)) { if (/^\d+$/.test(params.search)) {
this.itemId = params.search; this.itemId = params.search;
this.itemName = null; return this.applyFilters({
'i.id': params.search
});
} else { } else {
this.itemId = null;
this.itemName = params.search; this.itemName = params.search;
return this.applyFilters({
'i.name': {like: `%${params.search}%`}
});
} }
} } else return this.applyFilters();
} }
} }

View File

@ -0,0 +1,2 @@
Name: Nombre
Search by item id or name: Buscar por id de artículo o nombre