fixes #4945 Dejar de buscar por tag 'Nombre temporal' #1258
|
@ -0,0 +1,9 @@
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD defaultTag INT DEFAULT 56 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultTag) REFERENCES vn.tag(id);
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos';
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL`
|
||||||
|
(model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -2719,6 +2719,10 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack
|
||||||
VALUES
|
VALUES
|
||||||
(3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL);
|
(3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`)
|
||||||
|
VALUES
|
||||||
|
(0, 0, 24, '', '[1,2,3]', 2, 56);
|
||||||
|
|||||||
|
|
||||||
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
|
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
|
||||||
VALUES
|
VALUES
|
||||||
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
|
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);
|
||||||
|
|
|
@ -428,6 +428,7 @@ export default {
|
||||||
},
|
},
|
||||||
itemCreateView: {
|
itemCreateView: {
|
||||||
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
||||||
|
priority: 'vn-autocomplete[ng-model="$ctrl.item.priority"]',
|
||||||
type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]',
|
type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]',
|
||||||
intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]',
|
intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]',
|
||||||
origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]',
|
origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]',
|
||||||
|
@ -521,7 +522,7 @@ export default {
|
||||||
},
|
},
|
||||||
itemLog: {
|
itemLog: {
|
||||||
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
|
||||||
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(3) td.after',
|
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(2) td.after',
|
||||||
},
|
},
|
||||||
ticketSummary: {
|
ticketSummary: {
|
||||||
header: 'vn-ticket-summary > vn-card > h5',
|
header: 'vn-ticket-summary > vn-card > h5',
|
||||||
|
|
|
@ -36,11 +36,20 @@ describe('Item Create', () => {
|
||||||
await page.waitForState('item.create');
|
await page.waitForState('item.create');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create the Infinity Gauntlet item', async() => {
|
it('should throw an error when insert an invalid priority', async() => {
|
||||||
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
|
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
|
||||||
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
|
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
|
||||||
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
|
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
|
||||||
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
|
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
|
||||||
|
await page.clearInput(selectors.itemCreateView.priority);
|
||||||
|
await page.waitToClick(selectors.itemCreateView.createButton);
|
||||||
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('Valid priorities');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create the Infinity Gauntlet item', async() => {
|
||||||
|
await page.autocompleteSearch(selectors.itemCreateView.priority, '2');
|
||||||
await page.waitToClick(selectors.itemCreateView.createButton);
|
await page.waitToClick(selectors.itemCreateView.createButton);
|
||||||
const message = await page.waitForSnackbar();
|
const message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ module.exports = Self => {
|
||||||
'typeFk',
|
'typeFk',
|
||||||
'intrastatFk',
|
'intrastatFk',
|
||||||
'originFk',
|
'originFk',
|
||||||
'relevancy'
|
'priority',
|
||||||
jgallego
commented
perque s'ha lleva't la relevancia? perque s'ha lleva't la relevancia?
|
|||||||
|
'tag'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const key in params) {
|
for (const key in params) {
|
||||||
|
@ -46,10 +47,14 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const itemConfig = await models.ItemConfig.findOne({fields: ['validPriorities']}, myOptions);
|
||||||
|
if (!itemConfig.validPriorities.includes(params.priority))
|
||||||
jgallego
commented
açò? pregunta a Juan pero jo no ho veig, crec que deuria estar en taula config açò? pregunta a Juan pero jo no ho veig, crec que deuria estar en taula config
|
|||||||
|
throw new UserError(`Valid priorities: ${[...itemConfig.validPriorities]}`);
|
||||||
|
|
||||||
const provisionalName = params.provisionalName;
|
const provisionalName = params.provisionalName;
|
||||||
delete params.provisionalName;
|
delete params.provisionalName;
|
||||||
|
|
||||||
const itemType = await models.ItemType.findById(params.typeFk, myOptions);
|
const itemType = await models.ItemType.findById(params.typeFk, {fields: ['isLaid']}, myOptions);
|
||||||
|
|
||||||
params.isLaid = itemType.isLaid;
|
params.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
|
@ -63,13 +68,14 @@ module.exports = Self => {
|
||||||
|
|
||||||
await Self.rawSql(query, null, myOptions);
|
await Self.rawSql(query, null, myOptions);
|
||||||
|
|
||||||
let nameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}});
|
const nameTag = await models.Tag.findById(params.tag, {fields: ['id']}, myOptions);
|
||||||
|
|
||||||
let newTags = [];
|
let newTags = [];
|
||||||
|
|
||||||
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: '2'});
|
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: item.priority});
|
||||||
typeTags.forEach(typeTag => {
|
typeTags.forEach(typeTag => {
|
||||||
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
|
if (nameTag.id != typeTag.tagFk)
|
||||||
|
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.ItemTag.create(newTags, myOptions);
|
await models.ItemTag.create(newTags, myOptions);
|
||||||
|
|
|
@ -11,7 +11,8 @@ describe('item new()', () => {
|
||||||
originFk: 1,
|
originFk: 1,
|
||||||
provisionalName: 'planta',
|
provisionalName: 'planta',
|
||||||
typeFk: 2,
|
typeFk: 2,
|
||||||
relevancy: 0
|
priority: 2,
|
||||||
|
tag: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
let item = await models.Item.new(itemParams, options);
|
let item = await models.Item.new(itemParams, options);
|
||||||
|
@ -20,7 +21,7 @@ describe('item new()', () => {
|
||||||
|
|
||||||
item.isLaid = itemType.isLaid;
|
item.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options);
|
const temporalNameTag = await models.Tag.findById(itemParams.tag, {fields: ['id']}, options);
|
||||||
|
|
||||||
const temporalName = await models.ItemTag.findOne({
|
const temporalName = await models.ItemTag.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
@ -31,7 +32,7 @@ describe('item new()', () => {
|
||||||
|
|
||||||
item = await models.Item.findById(item.id, null, options);
|
item = await models.Item.findById(item.id, null, options);
|
||||||
|
|
||||||
itemType = await models.ItemType.findById(item.typeFk, options);
|
itemType = await models.ItemType.findById(item.typeFk, {fields: ['isLaid']}, options);
|
||||||
|
|
||||||
item.isLaid = itemType.isLaid;
|
item.isLaid = itemType.isLaid;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,22 @@
|
||||||
"wasteRecipients": {
|
"wasteRecipients": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Buyers waste report recipients"
|
"description": "Buyers waste report recipients"
|
||||||
|
},
|
||||||
|
"validPriorities": {
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"defaultPriority": {
|
||||||
|
"type": "int"
|
||||||
|
},
|
||||||
|
"defaultTag": {
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"tag": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Tag",
|
||||||
|
"foreignKey": "defaultTag"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,10 +16,24 @@
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Temporal name"
|
label="Name"
|
||||||
ng-model="$ctrl.item.provisionalName"
|
ng-model="$ctrl.item.provisionalName"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
|
<vn-autocomplete
|
||||||
|
ng-model="$ctrl.item.tag"
|
||||||
|
url="Tags"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id"
|
||||||
|
label="Tag">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
data="$ctrl.validPriorities"
|
||||||
|
label="Priority"
|
||||||
|
ng-model="$ctrl.item.priority"
|
||||||
|
show-field="priority"
|
||||||
|
value-field="priority">
|
||||||
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -4,9 +4,25 @@ import Section from 'salix/components/section';
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this.item = {
|
this.fetchDefaultPriorityTag();
|
||||||
relevancy: 0
|
}
|
||||||
};
|
|
||||||
jgallego
commented
Has de vore la forma de llevar el 2 del codi Has de vore la forma de llevar el 2 del codi
|
|||||||
|
fetchDefaultPriorityTag() {
|
||||||
|
this.validPriorities = [];
|
||||||
|
const filter = {fields: ['defaultPriority', 'defaultTag', 'validPriorities'], limit: 1};
|
||||||
|
this.$http.get(`ItemConfigs`, {filter})
|
||||||
|
.then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
const dataRow = res.data[0];
|
||||||
|
dataRow.validPriorities.forEach(priority => {
|
||||||
|
this.validPriorities.push({priority});
|
||||||
|
});
|
||||||
|
this.item = {
|
||||||
|
priority: dataRow.defaultPriority,
|
||||||
|
tag: dataRow.defaultTag
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
|
|
Loading…
Reference in New Issue
A comentar en Juan en la revisio semanal de hui