refs #4945 added defaultTag, validPriorities, defaultPriority in itemConfig
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-01-18 13:14:49 +01:00
parent 77eb9c8013
commit be5f987b0a
7 changed files with 52 additions and 16 deletions

View File

@ -0,0 +1,8 @@
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;
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
(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`)
VALUES
(9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL);

View File

@ -522,7 +522,7 @@ export default {
},
itemLog: {
anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr',
fourthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(4) 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: {
header: 'vn-ticket-summary > vn-card > h5',

View File

@ -48,17 +48,17 @@ describe('Item log path', () => {
await page.accessToSection('item.card.log');
});
it(`should confirm the log is showing 4 entries`, async() => {
it(`should confirm the log is showing 5 entries`, async() => {
await page.waitForSelector(selectors.itemLog.anyLineCreated);
const anyLineCreatedCount = await page.countElement(selectors.itemLog.anyLineCreated);
expect(anyLineCreatedCount).toEqual(4);
expect(anyLineCreatedCount).toEqual(5);
});
it(`should confirm the log is showing the intrastat for the created item`, async() => {
const fourthLineCreatedProperty = await page
.waitToGetProperty(selectors.itemLog.fourthLineCreatedProperty, 'innerText');
const fifthLineCreatedProperty = await page
.waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText');
expect(fourthLineCreatedProperty).toEqual('Coral y materiales similares');
expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares');
});
});

View File

@ -37,7 +37,6 @@ module.exports = Self => {
'typeFk',
'intrastatFk',
'originFk',
'relevancy',
'priority',
'tag'
];
@ -48,9 +47,9 @@ module.exports = Self => {
}
try {
const validPriorities = new Set([1, 2, 3]);
if (!validPriorities.has(params.priority))
throw new UserError(`Valid priorities: ${[...validPriorities]}`);
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;
delete params.provisionalName;

View File

@ -16,6 +16,22 @@
"wasteRecipients": {
"type": "string",
"description": "Buyers waste report recipients"
},
"validPriorities": {
"type": "array"
},
"defaultPriority": {
"type": "int"
},
"defaultTag": {
"type": "int"
}
},
"relations": {
"tag": {
"type": "belongsTo",
"model": "Tag",
"foreignKey": "defaultTag"
}
}
}
}

View File

@ -4,11 +4,20 @@ import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.item = {
relevancy: 0,
priority: 2,
tag: 1
};
this.fetchDefaultPriorityTag();
}
fetchDefaultPriorityTag() {
const filter = {fields: ['defaultPriority', 'defaultTag'], limit: 1};
this.$http.get(`ItemConfigs`, {filter})
.then(res => {
if (res.data) {
this.item = {
priority: res.data[0].defaultPriority,
tag: res.data[0].defaultTag
};
}
});
}
onSubmit() {