Merge branch 'dev' into 4658-createWorker
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-01-23 07:12:26 +00:00
commit ce06274d0a
10 changed files with 94 additions and 18 deletions

View File

@ -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');

View File

@ -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);

View File

@ -429,6 +429,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"]',
@ -522,7 +523,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',

View File

@ -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();

View File

@ -37,7 +37,8 @@ module.exports = Self => {
'typeFk', 'typeFk',
'intrastatFk', 'intrastatFk',
'originFk', 'originFk',
'relevancy' 'priority',
'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))
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);

View File

@ -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;

View File

@ -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"
} }
} }
} }

View File

@ -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

View File

@ -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 }
};
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() {

View File

@ -8,8 +8,8 @@ description:
<a href='https://www.youtube.com/watch?v=qhb0kgQF3o8' title='Youtube' target='_blank' <a href='https://www.youtube.com/watch?v=qhb0kgQF3o8' title='Youtube' target='_blank'
style='color:#8dba25'>https://www.youtube.com/watch?v=qhb0kgQF3o8</a>. También style='color:#8dba25'>https://www.youtube.com/watch?v=qhb0kgQF3o8</a>. También
necesitarás el QLabel, el programa para imprimir las cintas. necesitarás el QLabel, el programa para imprimir las cintas.
downloadFrom: Puedes descargarlo desde este enlace <a href='https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01' downloadFrom: Puedes descargarlo desde este enlace <a href='https://cdn.verdnatura.es/public/QLabel_IV_V1.37_Install_en.exe'
title='Descargar QLabel' target='_blank' style='color:#8dba25'>https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01</a> title='Descargar QLabel' target='_blank' style='color:#8dba25'>https://cdn.verdnatura.es/public/QLabel_IV_V1.37_Install_en.exe</a>
downloadDriver: En este enlace puedes descargar el driver de la impresora <a href='https://es.seagullscientific.com/support/downloads/drivers/godex/download/' downloadDriver: En este enlace puedes descargar el driver de la impresora <a href='https://es.seagullscientific.com/support/downloads/drivers/godex/download/'
title='Descargar driver' target='_blank' style='color:#8dba25'>https://es.seagullscientific.com/support/downloads/drivers/godex/download/</a> title='Descargar driver' target='_blank' style='color:#8dba25'>https://es.seagullscientific.com/support/downloads/drivers/godex/download/</a>
sections: sections: