Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2425-ticket_descriptor_menu
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-11-11 07:34:34 +01:00
commit d959dbc058
17 changed files with 191 additions and 6984 deletions

View File

@ -24,8 +24,6 @@ module.exports = Self => {
const conn = Self.dataSource.connector;
const minDate = new Date();
minDate.setFullYear(minDate.getFullYear() - 1);
minDate.setMonth(0);
minDate.setDate(1);
const where = {dated: {gte: minDate}};
filter = mergeFilters(filter, {where});

View File

@ -718,11 +718,13 @@ INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
VALUES
('YEL', 'Yellow', 1, 1, 'F4D03F'),
('BLU', 'Blue', 1, 2, '5DADE2'),
('RED', 'Red', 1, 3, 'EC7063'),
('SLV', 'Silver', 1, 4, 'CACFD2'),
('BRW', 'Brown', 1, 5, 'DC7633');
('YEL', 'Yellow', 1, 1, 'F4D03F'),
('BLU', 'Blue', 1, 2, '5DADE2'),
('RED', 'Red', 1, 3, 'EC7063'),
('SLV', 'Silver', 1, 4, 'CACFD2'),
('BRW', 'Brown', 1, 5, 'DC7633'),
('BLK', 'Black', 1, 6, '000000'),
('BAS', 'Blue/Silver', 1, 7, '5DADE2');
INSERT INTO `vn`.`origin`(`id`,`code`, `name`)
VALUES

5148
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -69,12 +69,14 @@
<vn-date-picker
vn-one
label="From"
ng-model="filter.from">
ng-model="filter.from"
on-change="$ctrl.onChangeDate(value)">
</vn-date-picker>
<vn-date-picker
vn-one
label="To"
ng-model="filter.to">
ng-model="filter.to"
on-change="$ctrl.onChangeDate(value)">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal class="vn-mt-lg">

View File

@ -5,16 +5,34 @@ class Controller extends SearchPanel {
constructor($, $element) {
super($, $element);
this.getUpcomingCampaing();
this.filter = this.$.filter;
if (!this.dateParams)
this.getUpcomingCampaing();
}
get dateParams() {
if (this.$params.q) {
const params = JSON.parse(this.$params.q);
if (params.from || params.to)
return true;
}
return false;
}
getUpcomingCampaing() {
this.$http.get('Campaigns/upcoming').then(res => {
const filter = this.$.filter;
filter.campaign = res.data.id;
this.filter.campaign = res.data.id;
});
}
onChangeDate(value) {
if (value)
this.filter.campaign = null;
}
get campaignSelection() {
return this._campaignSelection;
}
@ -22,14 +40,13 @@ class Controller extends SearchPanel {
set campaignSelection(value) {
this._campaignSelection = value;
if (!value) return;
if (value) {
const from = new Date(value.dated);
from.setDate(from.getDate() - value.scopeDays);
const filter = this.$.filter;
const from = new Date(value.dated);
from.setDate(from.getDate() - value.scopeDays);
filter.to = value.dated;
filter.from = from;
this.filter.to = value.dated;
this.filter.from = from;
}
}
}

View File

@ -13,6 +13,10 @@ class Controller extends Section {
}
};
this.setDefaultFilter();
}
setDefaultFilter() {
const minDate = new Date();
minDate.setHours(0, 0, 0, 0);
minDate.setMonth(minDate.getMonth() - 2);

View File

@ -0,0 +1,51 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('filterValue', {
description: 'Returns a list of tag values',
accepts: [{
arg: 'id',
type: 'Number',
required: true,
description: 'The tag id',
http: {source: 'path'}
}, {
arg: 'filter',
type: 'Object',
description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string`
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/:id/filterValue`,
verb: 'GET'
}
});
Self.filterValue = async(id, filter) => {
const conn = Self.dataSource.connector;
const tag = await Self.findById(id);
let stmt;
if (!tag.isFree && tag.sourceTable) {
stmt = new ParameterizedSQL(
`SELECT value FROM (
SELECT name AS value FROM ${tag.sourceTable}) v`);
} else
stmt = new ParameterizedSQL(`SELECT value FROM itemTag`);
let where = filter.where;
if (where && where.value) {
stmt.merge(conn.makeWhere({value: {like: `%${where.value}%`}}));
stmt.merge(`
ORDER BY value LIKE '${where.value}' DESC,
value LIKE '${where.value}%' DESC`);
}
stmt.merge(conn.makeLimit(filter));
return conn.executeStmt(stmt);
};
};

View File

@ -0,0 +1,37 @@
const app = require('vn-loopback/server/server');
describe('tag filterValue()', () => {
const colorTagId = 1;
it('should return a list of color values', async() => {
const filter = {limit: 5};
const result = await app.models.Tag.filterValue(colorTagId, filter);
expect(result.length).toEqual(5);
});
it('should return the values matching color "Blue"', async() => {
const filter = {where: {value: 'Blue'}, limit: 5};
const result = await app.models.Tag.filterValue(colorTagId, filter);
expect(result.length).toEqual(2);
expect(result[0].value).toEqual('Blue');
expect(result[1].value).toEqual('Blue/Silver');
});
it('should return the values matching color "Blue/Silver"', async() => {
const filter = {where: {value: 'Blue/Silver'}, limit: 5};
const result = await app.models.Tag.filterValue(colorTagId, filter);
expect(result.length).toEqual(1);
expect(result[0].value).toEqual('Blue/Silver');
});
it('should return the values matching color "Silver"', async() => {
const filter = {where: {value: 'Silver'}, limit: 5};
const result = await app.models.Tag.filterValue(colorTagId, filter);
expect(result.length).toEqual(2);
expect(result[0].value).toEqual('Silver');
expect(result[1].value).toEqual('Blue/Silver');
});
});

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/tag/filterValue')(Self);
};

View File

@ -40,12 +40,12 @@
</vn-textfield>
<vn-autocomplete vn-three
ng-show="tag.selection.isFree === false"
url="{{$ctrl.sourceTables[itemTag.id].url}}"
search-function="{name: {like: $search +'%'}}"
url="{{'Tags/' + itemTag.tagFk + '/filterValue'}}"
search-function="{value: $search}"
label="Value"
ng-model="itemTag.value"
show-field="{{$ctrl.sourceTables[itemTag.id].field}}"
value-field="{{$ctrl.sourceTables[itemTag.id].field}}"
show-field="value"
value-field="value"
rule>
</vn-autocomplete>
<vn-input-number vn-one

View File

@ -10,40 +10,6 @@ class Controller extends Section {
fields: ['id', 'name', 'isFree', 'sourceTable']
}
};
this.sourceTables = {};
}
set itemTags(value) {
if (value) {
value.forEach(tag => {
this.getSourceTable(tag);
});
this._itemTags = value;
}
}
get itemTags() {
return this._itemTags;
}
getSourceTable(obj) {
let sourceTable;
this.sourceTables[obj.id] = {};
let tag = obj.tag || obj.selection;
if (!tag || !tag.sourceTable && (tag.isFree === true || tag.isFree === undefined))
sourceTable = null;
else if (tag.sourceTable) {
sourceTable = '' + tag.sourceTable.charAt(0).toUpperCase() +
tag.sourceTable.substring(1) + 's';
this.sourceTables[obj.id].field = 'name';
} else {
sourceTable = `ItemTags/filterItemTags/${tag.id}`;
this.sourceTables[obj.id].field = 'value';
}
this.sourceTables[obj.id].url = sourceTable;
}
add() {

View File

@ -16,46 +16,6 @@ describe('Item', () => {
controller = $componentController('vnItemTags', {$element, $scope});
}));
describe('itemTags setter', () => {
it('should call getSourceTable one time for each element in the value array', () => {
jest.spyOn(controller, 'getSourceTable');
let itemTags = [
{id: 1},
{id: 2},
{id: 3},
{id: 4}
];
controller.itemTags = itemTags;
expect(controller.getSourceTable.mock.calls.length).toEqual(4);
expect(controller.itemTags).toEqual(itemTags);
});
});
describe('getSourceTable', () => {
it('should return null when the property isFree equals true', () => {
let tag = {id: 1};
controller.getSourceTable(tag);
expect(controller.sourceTables[1].url).toBe(null);
});
it('should return the route of the model in loopback with the first char of the string uppercase and adding a s', () => {
let tag = {id: 1, tag: {sourceTable: 'ink'}};
controller.getSourceTable(tag);
expect(controller.sourceTables[1].url).toBe('Inks');
});
it('should return the route filteritemtags with the id of the selection', () => {
let tag = {id: 1, tag: {id: 3, sourceTable: null, isFree: false}};
controller.getSourceTable(tag);
expect(controller.sourceTables[1].url).toBe('ItemTags/filterItemTags/3');
});
});
describe('getHighestPriority', () => {
it('should return the highest priority value + 1 from the array', () => {
let result = controller.getHighestPriority();

View File

@ -23,11 +23,12 @@
<vn-autocomplete
vn-one
ng-show="tag.selection.isFree == false"
url="{{$ctrl.getSourceTable(tag.selection)}}"
url="{{'Tags/' + tag.selection.id + '/filterValue'}}"
search-function="{value: $search}"
label="Value"
ng-model="tagValue.value"
show-field="name"
value-field="name">
show-field="value"
value-field="value">
</vn-autocomplete>
<vn-icon-button
vn-none

View File

@ -21,18 +21,6 @@ class Controller extends SearchPanel {
this.$.filter = value;
}
getSourceTable(selection) {
if (!selection || selection.isFree == true)
return null;
if (selection.sourceTable) {
return ''
+ selection.sourceTable.charAt(0).toUpperCase()
+ selection.sourceTable.substring(1) + 's';
} else if (selection.sourceTable == null)
return `ItemTags/filterItemTags/${selection.id}`;
}
addValue() {
this.filter.values.push({});
setTimeout(() => this.popover.relocate());

View File

@ -1,4 +1,5 @@
Address phone: Tel. consignatario
Address mobile: Móv. consignatario
Client phone: Tel. cliente
Client mobile: Móv. cliente
Client mobile: Móv. cliente
Go to ticket summary: Ir a la vista previa del ticket

28
package-lock.json generated
View File

@ -7175,7 +7175,7 @@
},
"browserify-rsa": {
"version": "4.0.1",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true,
"requires": {
@ -7235,7 +7235,7 @@
},
"buffer": {
"version": "4.9.1",
"resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
"requires": {
"base64-js": "^1.0.2",
@ -7436,7 +7436,7 @@
},
"camelcase-keys": {
"version": "2.1.0",
"resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
"resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
"integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=",
"dev": true,
"requires": {
@ -8710,7 +8710,7 @@
},
"readable-stream": {
"version": "1.1.14",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
@ -11226,7 +11226,7 @@
},
"globby": {
"version": "5.0.0",
"resolved": "http://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
"resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
"integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=",
"dev": true,
"requires": {
@ -13346,7 +13346,7 @@
},
"is-obj": {
"version": "1.0.1",
"resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8="
},
"is-path-cwd": {
@ -18776,7 +18776,7 @@
},
"load-json-file": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
"dev": true,
"requires": {
@ -19719,7 +19719,7 @@
},
"media-typer": {
"version": "0.3.0",
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"mem": {
@ -19744,7 +19744,7 @@
},
"meow": {
"version": "3.7.0",
"resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
"resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
"integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=",
"dev": true,
"requires": {
@ -20193,7 +20193,7 @@
},
"multipipe": {
"version": "0.1.2",
"resolved": "http://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz",
"resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz",
"integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=",
"dev": true,
"requires": {
@ -21106,7 +21106,7 @@
},
"os-homedir": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"dev": true
},
@ -21122,7 +21122,7 @@
},
"os-tmpdir": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"dev": true
},
@ -24763,7 +24763,7 @@
},
"through": {
"version": "2.3.8",
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"through2": {
@ -25042,7 +25042,7 @@
},
"tty-browserify": {
"version": "0.0.0",
"resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
"dev": true
},

1743
print/package-lock.json generated

File diff suppressed because it is too large Load Diff