Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-08-29 13:16:53 +02:00
commit 8dbcf917a3
5 changed files with 16 additions and 5 deletions

View File

@ -11,6 +11,7 @@ describe('Item summary path', () => {
it('should search for an item', async() => { it('should search for an item', async() => {
const result = await nightmare const result = await nightmare
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon longbow 2m') .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon longbow 2m')
.waitToClick(selectors.itemsIndex.searchButton) .waitToClick(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)

View File

@ -11,6 +11,7 @@ describe('Item Create/Clone path', () => {
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
const result = await nightmare const result = await nightmare
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.waitToClick(selectors.itemsIndex.searchButton) .waitToClick(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
@ -95,6 +96,7 @@ describe('Item Create/Clone path', () => {
it(`should search for the item Infinity Gauntlet`, async() => { it(`should search for the item Infinity Gauntlet`, async() => {
const result = await nightmare const result = await nightmare
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.waitToClick(selectors.itemsIndex.searchButton) .waitToClick(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
@ -117,6 +119,7 @@ describe('Item Create/Clone path', () => {
it('should search for the item Infinity Gauntlet and find two', async() => { it('should search for the item Infinity Gauntlet and find two', async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton) .waitToClick(selectors.itemTags.goToItemIndexButton)
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.waitToClick(selectors.itemsIndex.searchButton) .waitToClick(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)

View File

@ -29,6 +29,7 @@ describe('Item regularize path', () => {
it('should search for the item', async() => { it('should search for the item', async() => {
const resultCount = await nightmare const resultCount = await nightmare
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm')
.waitToClick(selectors.itemsIndex.searchButton) .waitToClick(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
@ -134,6 +135,7 @@ describe('Item regularize path', () => {
it('should search for the item once again', async() => { it('should search for the item once again', async() => {
const resultCount = await nightmare const resultCount = await nightmare
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm')
.waitToClick(selectors.itemsIndex.searchButton) .waitToClick(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)

View File

@ -28,7 +28,6 @@ export default class Controller extends Component {
() => this.onStateChange()); () => this.onStateChange());
this._filter = null; this._filter = null;
this.searchString = '';
this.autoLoad = false; this.autoLoad = false;
} }
@ -58,6 +57,10 @@ export default class Controller extends Component {
this.doSearch(); this.doSearch();
} }
get shownFilter() {
return this._filter != null ? this._filter : this.suggestedFilter;
}
openPanel(event) { openPanel(event) {
if (event.defaultPrevented) return; if (event.defaultPrevented) return;
event.preventDefault(); event.preventDefault();
@ -65,7 +68,8 @@ export default class Controller extends Component {
this.$panelScope = this.$.$new(); this.$panelScope = this.$.$new();
this.$panel = this.$compile(`<${this.panel}/>`)(this.$panelScope); this.$panel = this.$compile(`<${this.panel}/>`)(this.$panelScope);
let panel = this.$panel.isolateScope().$ctrl; let panel = this.$panel.isolateScope().$ctrl;
panel.filter = this._filter; if (this.shownFilter)
panel.filter = JSON.parse(JSON.stringify(this.shownFilter));
panel.onSubmit = filter => this.onPanelSubmit(filter); panel.onSubmit = filter => this.onPanelSubmit(filter);
this.$.popover.parent = this.element; this.$.popover.parent = this.element;
@ -94,13 +98,12 @@ export default class Controller extends Component {
} }
doSearch() { doSearch() {
let filter = this._filter; this.searchString = this.getStringFromObject(this.shownFilter);
let filter = this._filter;
if (filter == null && this.autoload) if (filter == null && this.autoload)
filter = {}; filter = {};
this.searchString = this.getStringFromObject(filter);
if (this.onSearch) if (this.onSearch)
this.onSearch({$params: filter}); this.onSearch({$params: filter});
@ -214,6 +217,7 @@ ngModule.component('vnSearchbar', {
template: require('./searchbar.html'), template: require('./searchbar.html'),
bindings: { bindings: {
filter: '<?', filter: '<?',
suggestedFilter: '<?',
onSearch: '&?', onSearch: '&?',
panel: '@', panel: '@',
model: '<?', model: '<?',

View File

@ -15,6 +15,7 @@
panel="vn-item-search-panel" panel="vn-item-search-panel"
on-search="$ctrl.onSearch($params)" on-search="$ctrl.onSearch($params)"
info="Search items by id, name or barcode" info="Search items by id, name or barcode"
suggested-filter="{isActive: true}"
vn-focus> vn-focus>
</vn-searchbar> </vn-searchbar>
<vn-icon-menu <vn-icon-menu