Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 4927-permitir-razonSocial-duplicada
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
07d3fef8f0
|
@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [2304.01] - 2023-02-09
|
## [2304.01] - 2023-02-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
-
|
- (Trabajadores -> Nuevo trabajador) Nueva sección
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-
|
-
|
||||||
|
|
|
@ -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');
|
|
@ -0,0 +1,24 @@
|
||||||
|
UPDATE `salix`.`ACL`
|
||||||
|
SET accessType='READ'
|
||||||
|
WHERE model='Worker'
|
||||||
|
AND property='*'
|
||||||
|
AND accessType='*'
|
||||||
|
AND permission='ALLOW'
|
||||||
|
AND principalType='ROLE'
|
||||||
|
AND principalId='employee';
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Worker', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Worker', 'createAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'updateAbsence', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'deleteAbsence', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||||
|
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr');
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`workerConfig` ADD roleFk int(10) unsigned NOT NULL COMMENT 'Rol por defecto al dar de alta un trabajador nuevo';
|
||||||
|
UPDATE `vn`.`workerConfig`
|
||||||
|
SET roleFk = 1
|
||||||
|
WHERE id = 1;
|
||||||
|
|
|
@ -2629,7 +2629,7 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||||
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
||||||
|
|
||||||
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
||||||
|
@ -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);
|
||||||
|
@ -2747,10 +2751,14 @@ INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`)
|
||||||
VALUES
|
VALUES
|
||||||
('foo', 'master', NULL, NULL),
|
('foo', 'master', NULL, NULL),
|
||||||
('bar', 'test', 9, util.VN_NOW());
|
('bar', 'test', 9, util.VN_NOW());
|
||||||
INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`)
|
|
||||||
VALUES
|
|
||||||
(1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1);
|
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`profileType` (`id`, `name`)
|
||||||
|
VALUES
|
||||||
|
(1, 'working');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`)
|
||||||
|
VALUES
|
||||||
|
(1, 'S/ ', 1, 442, 1, 1);
|
||||||
|
|
||||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2761,3 +2769,7 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1);
|
(1, 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
|
||||||
|
VALUES
|
||||||
|
(1, NULL, 1);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ export default {
|
||||||
deleteAccount: '.vn-menu [name="deleteUser"]',
|
deleteAccount: '.vn-menu [name="deleteUser"]',
|
||||||
setPassword: '.vn-menu [name="setPassword"]',
|
setPassword: '.vn-menu [name="setPassword"]',
|
||||||
activateAccount: '.vn-menu [name="enableAccount"]',
|
activateAccount: '.vn-menu [name="enableAccount"]',
|
||||||
|
disableAccount: '.vn-menu [name="disableAccount"]',
|
||||||
activateUser: '.vn-menu [name="activateUser"]',
|
activateUser: '.vn-menu [name="activateUser"]',
|
||||||
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
deactivateUser: '.vn-menu [name="deactivateUser"]',
|
||||||
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]',
|
||||||
|
@ -428,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"]',
|
||||||
|
@ -521,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',
|
||||||
|
@ -968,6 +970,7 @@ export default {
|
||||||
confirmButton: '.vn-confirm.shown button[response="accept"]'
|
confirmButton: '.vn-confirm.shown button[response="accept"]'
|
||||||
},
|
},
|
||||||
workerSummary: {
|
workerSummary: {
|
||||||
|
summaryIcon: 'vn-worker-descriptor a[title="Go to module summary"]',
|
||||||
header: 'vn-worker-summary h5',
|
header: 'vn-worker-summary h5',
|
||||||
id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span',
|
id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span',
|
||||||
email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span',
|
email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span',
|
||||||
|
@ -1020,6 +1023,25 @@ export default {
|
||||||
furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)',
|
furlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(4)',
|
||||||
halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)',
|
halfFurlough: 'vn-worker-calendar > vn-side-menu [name="absenceTypes"] > vn-chip:nth-child(5)',
|
||||||
},
|
},
|
||||||
|
workerCreate: {
|
||||||
|
newWorkerButton: 'vn-worker-index a[ui-sref="worker.create"]',
|
||||||
|
firstname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.firstName"]',
|
||||||
|
lastname: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.lastNames"]',
|
||||||
|
birth: 'vn-worker-create vn-date-picker[ng-model="$ctrl.worker.birth"]',
|
||||||
|
fi: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.fi"]',
|
||||||
|
code: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.code"]',
|
||||||
|
phone: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.phone"]',
|
||||||
|
city: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.city"]',
|
||||||
|
postcode: 'vn-worker-create vn-datalist[ng-model="$ctrl.worker.postcode"]',
|
||||||
|
street: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.street"]',
|
||||||
|
user: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.name"]',
|
||||||
|
email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]',
|
||||||
|
boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]',
|
||||||
|
role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]',
|
||||||
|
iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]',
|
||||||
|
switft: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bankEntityFk"]',
|
||||||
|
createButton: 'vn-worker-create vn-submit[label="Create"]',
|
||||||
|
},
|
||||||
invoiceOutIndex: {
|
invoiceOutIndex: {
|
||||||
topbarSearch: 'vn-searchbar',
|
topbarSearch: 'vn-searchbar',
|
||||||
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
|
searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
import selectors from '../../helpers/selectors.js';
|
||||||
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
|
describe('Worker create path', () => {
|
||||||
|
let browser;
|
||||||
|
let page;
|
||||||
|
let newWorker;
|
||||||
|
beforeAll(async() => {
|
||||||
|
browser = await getBrowser();
|
||||||
|
page = browser.page;
|
||||||
|
await page.loginAndModule('hr', 'worker');
|
||||||
|
await page.waitToClick(selectors.workerCreate.newWorkerButton);
|
||||||
|
await page.waitForState('worker.create');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async() => {
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should insert default data', async() => {
|
||||||
|
await page.write(selectors.workerCreate.firstname, 'Victor');
|
||||||
|
await page.write(selectors.workerCreate.lastname, 'Von Doom');
|
||||||
|
await page.write(selectors.workerCreate.fi, '78457139E');
|
||||||
|
await page.write(selectors.workerCreate.phone, '12356789');
|
||||||
|
await page.write(selectors.workerCreate.postcode, '46680');
|
||||||
|
await page.write(selectors.workerCreate.street, 'S/ Doomstadt');
|
||||||
|
await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com');
|
||||||
|
await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332');
|
||||||
|
await page.autocompleteSearch(selectors.workerCreate.switft, 'BBKKESMMMMM');
|
||||||
|
|
||||||
|
// should check for autocompleted worker code and worker user name
|
||||||
|
const workerCode = await page
|
||||||
|
.waitToGetProperty(selectors.workerCreate.code, 'value');
|
||||||
|
|
||||||
|
newWorker = await page
|
||||||
|
.waitToGetProperty(selectors.workerCreate.user, 'value');
|
||||||
|
|
||||||
|
expect(workerCode).toEqual('VVD');
|
||||||
|
expect(newWorker).toContain('victorvd');
|
||||||
|
|
||||||
|
// should fail if necessary data is void
|
||||||
|
await page.waitToClick(selectors.workerCreate.createButton);
|
||||||
|
let message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('is a required argument');
|
||||||
|
|
||||||
|
// should create a new worker and go to worker basic data'
|
||||||
|
await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5));
|
||||||
|
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss');
|
||||||
|
await page.waitToClick(selectors.workerCreate.createButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
await page.waitForState('worker.card.basicData');
|
||||||
|
|
||||||
|
expect(message.text).toContain('Data saved!');
|
||||||
|
|
||||||
|
// 'rollback'
|
||||||
|
await page.loginAndModule('sysadmin', 'account');
|
||||||
|
await page.accessToSearchResult(newWorker);
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.deactivateUser);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('User deactivated!');
|
||||||
|
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.menuButton);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.disableAccount);
|
||||||
|
await page.waitToClick(selectors.accountDescriptor.acceptButton);
|
||||||
|
message = await page.waitForSnackbar();
|
||||||
|
|
||||||
|
expect(message.text).toContain('Account disabled!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Reset password: Restrablecer contraseña
|
Reset password: Restrablecer contraseña
|
||||||
New password: Nueva contraseña
|
New password: Nueva contraseña
|
||||||
Repeat password: Repetir contraseñaç
|
Repeat password: Repetir contraseña
|
||||||
Password changed!: ¡Contraseña cambiada!
|
Password changed!: ¡Contraseña cambiada!
|
||||||
Password requirements: >
|
Password requirements: >
|
||||||
La contraseña debe tener al menos {{ length }} caracteres de longitud,
|
La contraseña debe tener al menos {{ length }} caracteres de longitud,
|
||||||
|
|
|
@ -252,6 +252,9 @@
|
||||||
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
"Receipt's bank was not found": "No se encontró el banco del recibo",
|
||||||
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
||||||
"Client's email was not found": "No se encontró el email del cliente",
|
"Client's email was not found": "No se encontró el email del cliente",
|
||||||
|
"This worker code already exists": "Este codigo de trabajador ya existe",
|
||||||
|
"This personal mail already exists": "Este correo personal ya existe",
|
||||||
|
"This worker already exists": "Este trabajador ya existe",
|
||||||
"App name does not exist": "El nombre de aplicación no es válido",
|
"App name does not exist": "El nombre de aplicación no es válido",
|
||||||
"Try again": "Vuelve a intentarlo",
|
"Try again": "Vuelve a intentarlo",
|
||||||
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
||||||
|
@ -259,3 +262,4 @@
|
||||||
"The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists",
|
"The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists",
|
||||||
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país."
|
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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
|
}
|
||||||
};
|
|
||||||
|
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() {
|
||||||
|
|
|
@ -0,0 +1,256 @@
|
||||||
|
/* eslint max-len: ["error", { "code": 130 }]*/
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('new', {
|
||||||
|
description: 'Creates a new worker and returns the id',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'fi',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker fi`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'name',
|
||||||
|
type: 'string',
|
||||||
|
description: `The user name`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'firstName',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker firstname`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'lastNames',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker lastnames`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'email',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker email`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'street',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker address`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'city',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker city`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'provinceFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker province`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'iban',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker iban`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'bankEntityFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker bank entity`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'companyFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker company`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'postcode',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker postcode`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'phone',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker phone`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'code',
|
||||||
|
type: 'string',
|
||||||
|
description: `The worker code`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'bossFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `The worker boss`,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'birth',
|
||||||
|
type: 'date',
|
||||||
|
description: `The worker birth`,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'number',
|
||||||
|
root: true,
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/new`,
|
||||||
|
verb: 'POST',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.new = async(ctx, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const myOptions = {};
|
||||||
|
const args = ctx.args;
|
||||||
|
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object') Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
let client;
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await models.Client.findOne(
|
||||||
|
{
|
||||||
|
where: {fi: args.fi},
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!client) {
|
||||||
|
const nickname = args.firstName.concat(' ', args.lastNames);
|
||||||
|
const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk']});
|
||||||
|
const [randomPassword] = await models.Worker.rawSql(
|
||||||
|
'SELECT account.passwordGenerate() as password;'
|
||||||
|
);
|
||||||
|
|
||||||
|
const user = await models.Account.create(
|
||||||
|
{
|
||||||
|
name: args.name,
|
||||||
|
nickname,
|
||||||
|
password: randomPassword.password,
|
||||||
|
email: args.email,
|
||||||
|
roleFk: workerConfig.roleFk,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await models.UserAccount.create(
|
||||||
|
{
|
||||||
|
id: user.id,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await models.Worker.rawSql(
|
||||||
|
'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
[
|
||||||
|
args.firstName,
|
||||||
|
args.lastNames,
|
||||||
|
args.fi,
|
||||||
|
args.street,
|
||||||
|
args.postalCode,
|
||||||
|
args.city,
|
||||||
|
args.provinceFk,
|
||||||
|
args.companyFk,
|
||||||
|
args.phone,
|
||||||
|
args.email,
|
||||||
|
user.id,
|
||||||
|
],
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
const address = await models.Address.create(
|
||||||
|
{
|
||||||
|
clientFk: user.id,
|
||||||
|
street: args.street,
|
||||||
|
city: args.city,
|
||||||
|
provinceFk: args.provinceFk,
|
||||||
|
postalCode: args.postalCode,
|
||||||
|
mobile: args.phone,
|
||||||
|
nickname: nickname,
|
||||||
|
isDefaultAddress: true,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
client = await models.Client.findById(
|
||||||
|
user.id,
|
||||||
|
{fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk']},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
await client.updateAttributes(
|
||||||
|
{
|
||||||
|
iban: args.iban,
|
||||||
|
bankEntityFk: args.bankEntityFk,
|
||||||
|
defaultAddressFk: address.id,
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await models.Account.findById(client.id, null, myOptions);
|
||||||
|
await user.updateAttribute('email', args.email, myOptions);
|
||||||
|
|
||||||
|
await models.Worker.rawSql(
|
||||||
|
'CALL vn.workerCreate(?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
[
|
||||||
|
args.firstName,
|
||||||
|
args.lastNames,
|
||||||
|
args.code,
|
||||||
|
args.bossFk,
|
||||||
|
client.id,
|
||||||
|
args.fi,
|
||||||
|
args.birth,
|
||||||
|
],
|
||||||
|
myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (error) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
const code = error.code;
|
||||||
|
const message = error.sqlMessage;
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`for key 'mail'`))
|
||||||
|
throw new UserError(`This personal mail already exists`);
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`))
|
||||||
|
throw new UserError(`This worker code already exists`);
|
||||||
|
|
||||||
|
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`))
|
||||||
|
throw new UserError(`This worker already exists`);
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
await models.user.resetPassword({
|
||||||
|
email: args.email,
|
||||||
|
emailTemplate: 'worker-welcome',
|
||||||
|
id: client.id
|
||||||
|
});
|
||||||
|
|
||||||
|
return {id: client.id};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,139 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
|
describe('Worker new', () => {
|
||||||
|
beforeAll(async() => {
|
||||||
|
const activeCtx = {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
http: {
|
||||||
|
req: {
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const employeeId = 1;
|
||||||
|
const defaultWorker = {
|
||||||
|
fi: '78457139E',
|
||||||
|
name: 'defaultWorker',
|
||||||
|
firstName: 'default',
|
||||||
|
lastNames: 'worker',
|
||||||
|
email: 'defaultWorker@mydomain.com',
|
||||||
|
street: 'S/ defaultWorkerStreet',
|
||||||
|
city: 'defaultWorkerCity',
|
||||||
|
provinceFk: 1,
|
||||||
|
iban: 'ES8304879798578129532677',
|
||||||
|
bankEntityFk: 128,
|
||||||
|
companyFk: 442,
|
||||||
|
postcode: '46680',
|
||||||
|
phone: '123456789',
|
||||||
|
code: 'DWW',
|
||||||
|
bossFk: 9,
|
||||||
|
birth: '2022-12-11T23:00:00.000Z'
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should return error if personal mail already exists', async() => {
|
||||||
|
const user = await models.Account.findById(employeeId, {fields: ['email']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {email: user.email})
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This personal mail already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error if worker code already exists', async() => {
|
||||||
|
const worker = await models.Worker.findById(employeeId, {fields: ['code']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {code: worker.code})
|
||||||
|
};
|
||||||
|
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This worker code already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error if worker already exists', async() => {
|
||||||
|
const worker = await models.Client.findById(employeeId, {fields: ['fi']});
|
||||||
|
|
||||||
|
const tx = await models.Worker.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ctx = {
|
||||||
|
args: Object.assign({}, defaultWorker, {fi: worker.fi})
|
||||||
|
};
|
||||||
|
await models.Worker.new(ctx, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual('This worker already exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new worker', async() => {
|
||||||
|
const newWorker = await models.Worker.new({args: defaultWorker});
|
||||||
|
|
||||||
|
await models.Worker.destroyById(newWorker.id);
|
||||||
|
await models.Address.destroyAll({clientFk: newWorker.id});
|
||||||
|
await models.Mandate.destroyAll({clientFk: newWorker.id});
|
||||||
|
await models.Client.destroyById(newWorker.id);
|
||||||
|
await models.Account.destroyById(newWorker.id);
|
||||||
|
|
||||||
|
expect(newWorker.id).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create a new worker in client', async() => {
|
||||||
|
const bruceWayneId = 1101;
|
||||||
|
const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']});
|
||||||
|
|
||||||
|
const newWorkerData = {
|
||||||
|
args: Object.assign(
|
||||||
|
{},
|
||||||
|
defaultWorker,
|
||||||
|
{
|
||||||
|
fi: client.fi,
|
||||||
|
email: client.email
|
||||||
|
})
|
||||||
|
};
|
||||||
|
const newWorker = await models.Worker.new(newWorkerData);
|
||||||
|
|
||||||
|
await models.Worker.destroyById(newWorker.id);
|
||||||
|
|
||||||
|
expect(newWorker.id).toEqual(bruceWayneId);
|
||||||
|
});
|
||||||
|
});
|
|
@ -17,12 +17,18 @@
|
||||||
"Department": {
|
"Department": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"Device": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"EducationLevel": {
|
"EducationLevel": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Journey": {
|
"Journey": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"ProfileType":{
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"Time": {
|
"Time": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
@ -32,39 +38,42 @@
|
||||||
"WorkCenterHoliday": {
|
"WorkCenterHoliday": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerDms": {
|
"Worker": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Worker": {
|
"WorkerConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDepartment": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDisableExcluded": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerDms": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerLabour": {
|
"WorkerLabour": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerLog": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerMana": {
|
"WorkerMana": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerMedia": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerTeam": {
|
"WorkerTeam": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerTeamCollegues": {
|
"WorkerTeamCollegues": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"WorkerMedia": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerDepartment": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerTimeControl": {
|
"WorkerTimeControl": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Device": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerLog": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"WorkerTimeControlConfig": {
|
"WorkerTimeControlConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
@ -73,9 +82,6 @@
|
||||||
},
|
},
|
||||||
"WorkerTimeControlMail": {
|
"WorkerTimeControlMail": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
|
||||||
"WorkerDisableExcluded": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "ProfileType",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "profileType"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"roleFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -13,4 +13,5 @@ module.exports = Self => {
|
||||||
require('../methods/worker/contracts')(Self);
|
require('../methods/worker/contracts')(Self);
|
||||||
require('../methods/worker/holidays')(Self);
|
require('../methods/worker/holidays')(Self);
|
||||||
require('../methods/worker/activeContract')(Self);
|
require('../methods/worker/activeContract')(Self);
|
||||||
|
require('../methods/worker/new')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
},
|
},
|
||||||
"mobileExtension": {
|
"mobileExtension": {
|
||||||
"type" : "number"
|
"type" : "number"
|
||||||
|
},
|
||||||
|
"code": {
|
||||||
|
"type" : "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -0,0 +1,194 @@
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
url="Workers/new"
|
||||||
|
data="$ctrl.worker"
|
||||||
|
insert-mode="true"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<form name="form" vn-http-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||||
|
<vn-card class="vn-pa-lg">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Firstname"
|
||||||
|
ng-model="$ctrl.worker.firstName"
|
||||||
|
rule
|
||||||
|
on-change="$ctrl.generateCodeUser()"
|
||||||
|
vn-focus>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Lastname"
|
||||||
|
on-change="$ctrl.generateCodeUser()"
|
||||||
|
ng-model="$ctrl.worker.lastNames"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-date-picker
|
||||||
|
vn-one
|
||||||
|
label="Birth"
|
||||||
|
ng-model="$ctrl.worker.birth">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Fi"
|
||||||
|
ng-model="$ctrl.worker.fi"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Code"
|
||||||
|
ng-model="$ctrl.worker.code"
|
||||||
|
maxLength="3"
|
||||||
|
on-change="$ctrl.worker.code = $ctrl.worker.code.toUpperCase()"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Phone"
|
||||||
|
ng-model="$ctrl.worker.phone"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-datalist
|
||||||
|
label="Postcode"
|
||||||
|
vn-one
|
||||||
|
ng-model="$ctrl.worker.postcode"
|
||||||
|
selection="$ctrl.postcode"
|
||||||
|
url="Postcodes/location"
|
||||||
|
fields="['code','townFk']"
|
||||||
|
order="code, townFk"
|
||||||
|
value-field="code"
|
||||||
|
show-field="code"
|
||||||
|
rule>
|
||||||
|
<tpl-item>
|
||||||
|
{{code}} - {{town.name}} ({{town.province.name}},
|
||||||
|
{{town.province.country.country}})
|
||||||
|
</tpl-item>
|
||||||
|
<append>
|
||||||
|
<vn-icon-button
|
||||||
|
icon="add_circle"
|
||||||
|
vn-tooltip="New postcode"
|
||||||
|
ng-click="postcode.open()"
|
||||||
|
vn-acl="deliveryBoss"
|
||||||
|
vn-acl-action="remove">
|
||||||
|
</vn-icon-button>
|
||||||
|
</append>
|
||||||
|
</vn-datalist>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-id="province"
|
||||||
|
label="Province"
|
||||||
|
ng-model="$ctrl.worker.provinceFk"
|
||||||
|
selection="$ctrl.province"
|
||||||
|
url="Provinces/location"
|
||||||
|
fields="['id', 'name', 'countryFk']"
|
||||||
|
rule>
|
||||||
|
<tpl-item>{{name}} ({{country.country}})</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-datalist
|
||||||
|
vn-id="town"
|
||||||
|
label="City"
|
||||||
|
ng-model="$ctrl.worker.city"
|
||||||
|
selection="$ctrl.town"
|
||||||
|
url="Towns/location"
|
||||||
|
fields="['id', 'name', 'provinceFk']"
|
||||||
|
value-field="name">
|
||||||
|
<tpl-item>
|
||||||
|
{{name}}, {{province.name}}
|
||||||
|
({{province.country.country}})
|
||||||
|
</tpl-item>
|
||||||
|
</vn-datalist>
|
||||||
|
<vn-textfield
|
||||||
|
vn-two
|
||||||
|
label="Street"
|
||||||
|
ng-model="$ctrl.worker.street"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
label="Web user"
|
||||||
|
ng-model="$ctrl.worker.name"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-textfield
|
||||||
|
label="Personal email"
|
||||||
|
ng-model="$ctrl.worker.email"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
vn-id="company"
|
||||||
|
ng-model="$ctrl.worker.companyFk"
|
||||||
|
url="Companies"
|
||||||
|
show-field="code"
|
||||||
|
value-field="id"
|
||||||
|
label="Company">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
ng-model="$ctrl.worker.bossFk"
|
||||||
|
url="Workers/activeWithInheritedRole"
|
||||||
|
show-field="nickname"
|
||||||
|
search-function="{firstName: $search}"
|
||||||
|
where="{role: 'employee'}"
|
||||||
|
label="Boss">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="IBAN"
|
||||||
|
ng-model="$ctrl.worker.iban"
|
||||||
|
rule
|
||||||
|
on-change="$ctrl.autofillBic()">
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Swift / BIC"
|
||||||
|
url="BankEntities"
|
||||||
|
ng-model="$ctrl.worker.bankEntityFk"
|
||||||
|
fields="['name']"
|
||||||
|
initial-data="$ctrl.worker.bankEntityFk"
|
||||||
|
on-change="$ctrl.autofillBic()"
|
||||||
|
search-function="{or: [{bic: {like: $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}"
|
||||||
|
value-field="id"
|
||||||
|
show-field="bic"
|
||||||
|
vn-acl="salesAssistant, hr"
|
||||||
|
disabled="$ctrl.ibanCountry == 'ES'">
|
||||||
|
<tpl-item>{{bic}} {{name}}</tpl-item>
|
||||||
|
<append>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-auto
|
||||||
|
icon="add_circle"
|
||||||
|
vn-click-stop="bankEntity.show({countryFk: $ctrl.worker.countryFk})"
|
||||||
|
vn-tooltip="New bank entity"
|
||||||
|
vn-acl="salesAssistant, hr">
|
||||||
|
</vn-icon-button>
|
||||||
|
</append>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit
|
||||||
|
disabled="!watcher.dataChanged()"
|
||||||
|
label="Create">
|
||||||
|
</vn-submit>
|
||||||
|
<vn-button
|
||||||
|
class="cancel"
|
||||||
|
label="Cancel"
|
||||||
|
ui-sref="worker.index">
|
||||||
|
</vn-button>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
||||||
|
<!-- New postcode dialog -->
|
||||||
|
<vn-geo-postcode
|
||||||
|
vn-id="postcode"
|
||||||
|
on-response="$ctrl.onResponse($response)">
|
||||||
|
</vn-geo-postcode>
|
|
@ -0,0 +1,127 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.worker = {companyFk: this.vnConfig.user.companyFk};
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
return this.$.watcher.submit().then(json => {
|
||||||
|
this.$state.go('worker.card.basicData', {id: json.data.id});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
autofillBic() {
|
||||||
|
if (!this.worker || !this.worker.iban) return;
|
||||||
|
|
||||||
|
let bankEntityId = parseInt(this.worker.iban.substr(4, 4));
|
||||||
|
let filter = {where: {id: bankEntityId}};
|
||||||
|
|
||||||
|
if (this.ibanCountry != 'ES') return;
|
||||||
|
|
||||||
|
this.$http.get(`BankEntities`, {filter}).then(response => {
|
||||||
|
const hasData = response.data && response.data[0];
|
||||||
|
|
||||||
|
if (hasData)
|
||||||
|
this.worker.bankEntityFk = response.data[0].id;
|
||||||
|
else if (!hasData)
|
||||||
|
this.worker.bankEntityFk = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
generateCodeUser() {
|
||||||
|
if (!this.worker.firstName || !this.worker.lastNames) return;
|
||||||
|
|
||||||
|
const totalName = this.worker.firstName.concat(' ' + this.worker.lastNames).toLowerCase();
|
||||||
|
const totalNameArray = totalName.split(' ');
|
||||||
|
let newCode = '';
|
||||||
|
|
||||||
|
for (let part of totalNameArray)
|
||||||
|
newCode += part.charAt(0);
|
||||||
|
|
||||||
|
this.worker.code = newCode.toUpperCase().slice(0, 3);
|
||||||
|
this.worker.name = totalNameArray[0] + newCode.slice(1);
|
||||||
|
|
||||||
|
if (!this.worker.companyFk)
|
||||||
|
this.worker.companyFk = this.vnConfig.user.companyFk;
|
||||||
|
}
|
||||||
|
|
||||||
|
get province() {
|
||||||
|
return this._province;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Province auto complete
|
||||||
|
set province(selection) {
|
||||||
|
this._province = selection;
|
||||||
|
|
||||||
|
if (!selection) return;
|
||||||
|
|
||||||
|
const country = selection.country;
|
||||||
|
|
||||||
|
if (!this.worker.countryFk)
|
||||||
|
this.worker.countryFk = country.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get town() {
|
||||||
|
return this._town;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Town auto complete
|
||||||
|
set town(selection) {
|
||||||
|
this._town = selection;
|
||||||
|
|
||||||
|
if (!selection) return;
|
||||||
|
|
||||||
|
const province = selection.province;
|
||||||
|
const country = province.country;
|
||||||
|
const postcodes = selection.postcodes;
|
||||||
|
|
||||||
|
if (!this.worker.provinceFk)
|
||||||
|
this.worker.provinceFk = province.id;
|
||||||
|
|
||||||
|
if (!this.worker.countryFk)
|
||||||
|
this.worker.countryFk = country.id;
|
||||||
|
|
||||||
|
if (postcodes.length === 1)
|
||||||
|
this.worker.postcode = postcodes[0].code;
|
||||||
|
}
|
||||||
|
|
||||||
|
get postcode() {
|
||||||
|
return this._postcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Postcode auto complete
|
||||||
|
set postcode(selection) {
|
||||||
|
this._postcode = selection;
|
||||||
|
|
||||||
|
if (!selection) return;
|
||||||
|
|
||||||
|
const town = selection.town;
|
||||||
|
const province = town.province;
|
||||||
|
const country = province.country;
|
||||||
|
|
||||||
|
if (!this.worker.city)
|
||||||
|
this.worker.city = town.name;
|
||||||
|
|
||||||
|
if (!this.worker.provinceFk)
|
||||||
|
this.worker.provinceFk = province.id;
|
||||||
|
|
||||||
|
if (!this.worker.countryFk)
|
||||||
|
this.worker.countryFk = country.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
onResponse(response) {
|
||||||
|
this.worker.postcode = response.code;
|
||||||
|
this.worker.city = response.city;
|
||||||
|
this.worker.provinceFk = response.provinceFk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.$inject = ['$element', '$scope'];
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnWorkerCreate', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1,133 @@
|
||||||
|
import './index';
|
||||||
|
|
||||||
|
describe('Worker', () => {
|
||||||
|
describe('Component vnWorkerCreate', () => {
|
||||||
|
let $scope;
|
||||||
|
let $state;
|
||||||
|
let controller;
|
||||||
|
|
||||||
|
beforeEach(ngModule('worker'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$state = _$state_;
|
||||||
|
$scope.watcher = {
|
||||||
|
submit: () => {
|
||||||
|
return {
|
||||||
|
then: callback => {
|
||||||
|
callback({data: {id: '1234'}});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const $element = angular.element('<vn-worker-create></vn-worker-create>');
|
||||||
|
controller = $componentController('vnWorkerCreate', {$element, $scope});
|
||||||
|
controller.worker = {};
|
||||||
|
controller.vnConfig = {user: {companyFk: 1}};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
|
jest.spyOn($state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('worker.card.basicData', {id: '1234'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('province() setter', () => {
|
||||||
|
it(`should set countryFk property`, () => {
|
||||||
|
controller.worker.countryFk = null;
|
||||||
|
controller.province = {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.countryFk).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('town() setter', () => {
|
||||||
|
it(`should set provinceFk property`, () => {
|
||||||
|
controller.town = {
|
||||||
|
provinceFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
postcodes: []
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.provinceFk).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||||
|
controller.town = {
|
||||||
|
provinceFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
postcodes: [{code: '46001'}]
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.provinceFk).toEqual(1);
|
||||||
|
expect(controller.worker.postcode).toEqual('46001');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('postcode() setter', () => {
|
||||||
|
it(`should set the town, provinceFk and contryFk properties`, () => {
|
||||||
|
controller.postcode = {
|
||||||
|
townFk: 1,
|
||||||
|
code: 46001,
|
||||||
|
town: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New York',
|
||||||
|
province: {
|
||||||
|
id: 1,
|
||||||
|
name: 'New york',
|
||||||
|
country: {
|
||||||
|
id: 2,
|
||||||
|
name: 'USA'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.worker.city).toEqual('New York');
|
||||||
|
expect(controller.worker.provinceFk).toEqual(1);
|
||||||
|
expect(controller.worker.countryFk).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('generateCodeUser()', () => {
|
||||||
|
it(`should generate worker code, name and company `, () => {
|
||||||
|
controller.worker = {
|
||||||
|
firstName: 'default',
|
||||||
|
lastNames: 'generate worker'
|
||||||
|
};
|
||||||
|
|
||||||
|
controller.generateCodeUser();
|
||||||
|
|
||||||
|
expect(controller.worker.code).toEqual('DGW');
|
||||||
|
expect(controller.worker.name).toEqual('defaultgw');
|
||||||
|
expect(controller.worker.companyFk).toEqual(controller.vnConfig.user.companyFk);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,12 @@
|
||||||
|
Firstname: Nombre
|
||||||
|
Lastname: Apellidos
|
||||||
|
Fi: DNI/NIF/NIE
|
||||||
|
Birth: Fecha de nacimiento
|
||||||
|
Code: Código de trabajador
|
||||||
|
Province: Provincia
|
||||||
|
City: Población
|
||||||
|
ProfileType: Tipo de perfil
|
||||||
|
Street: Dirección
|
||||||
|
Postcode: Código postal
|
||||||
|
Web user: Usuario Web
|
||||||
|
Access permission: Permiso de acceso
|
|
@ -4,6 +4,7 @@ import './main';
|
||||||
import './index/';
|
import './index/';
|
||||||
import './summary';
|
import './summary';
|
||||||
import './card';
|
import './card';
|
||||||
|
import './create';
|
||||||
import './descriptor';
|
import './descriptor';
|
||||||
import './descriptor-popover';
|
import './descriptor-popover';
|
||||||
import './search-panel';
|
import './search-panel';
|
||||||
|
|
|
@ -42,6 +42,14 @@
|
||||||
</div>
|
</div>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
|
<a ui-sref="worker.create"
|
||||||
|
vn-tooltip="New worker"
|
||||||
|
vn-bind="+"
|
||||||
|
vn-acl="hr"
|
||||||
|
vn-acl-action="remove"
|
||||||
|
fixed-bottom-right>
|
||||||
|
<vn-float-button icon="person_add"></vn-float-button>
|
||||||
|
</a>
|
||||||
<vn-popup vn-id="preview">
|
<vn-popup vn-id="preview">
|
||||||
<vn-worker-summary
|
<vn-worker-summary
|
||||||
worker="$ctrl.selectedWorker">
|
worker="$ctrl.selectedWorker">
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
New worker: Nuevo trabajador
|
|
@ -134,6 +134,13 @@
|
||||||
"worker": "$ctrl.worker"
|
"worker": "$ctrl.worker"
|
||||||
},
|
},
|
||||||
"acl": ["hr"]
|
"acl": ["hr"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/create",
|
||||||
|
"state": "worker.create",
|
||||||
|
"component": "vn-worker-create",
|
||||||
|
"description": "New worker",
|
||||||
|
"acl": ["hr"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
url: {
|
url: {
|
||||||
type: [String],
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
url: {
|
url: {
|
||||||
type: [String],
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
|
module.exports = new Stylesheet([
|
||||||
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
|
`${vnPrintPath}/common/css/email.css`])
|
||||||
|
.mergeStyles();
|
|
@ -0,0 +1,8 @@
|
||||||
|
subject: Bienvenido a Verdnatura
|
||||||
|
title: "¡Te damos la bienvenida!"
|
||||||
|
dearWorker: Estimado trabajador
|
||||||
|
workerData: 'Estos son los datos de tu usuario de Verdnatura.
|
||||||
|
Usuario: <strong>{0}</strong>. Haz click aquí para
|
||||||
|
<a href="{1}"
|
||||||
|
title="Cambiar contraseña" target="_blank" style="color: #8dba25">establecer tu contraseña
|
||||||
|
</a>.'
|
|
@ -0,0 +1,7 @@
|
||||||
|
SELECT
|
||||||
|
u.id,
|
||||||
|
u.name,
|
||||||
|
e.email
|
||||||
|
FROM account.user u
|
||||||
|
LEFT JOIN account.emailUser e ON e.userFk = u.id
|
||||||
|
WHERE u.id = ?;
|
|
@ -0,0 +1,9 @@
|
||||||
|
<email-body v-bind="$props">
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="grid-block vn-pa-ml">
|
||||||
|
<h1>{{ $t('title', [id]) }}</h1>
|
||||||
|
<p>{{ $t('dearWorker') }},</p>
|
||||||
|
<p v-html="$t('workerData', [this.worker.name, this.url])"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</email-body>
|
|
@ -0,0 +1,27 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const emailBody = new Component('email-body');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'worker-welcome',
|
||||||
|
async serverPrefetch() {
|
||||||
|
this.worker = await this.fetchWorker(this.id);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchWorker(id) {
|
||||||
|
return this.findOneFromDef('worker', [id]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'email-body': emailBody.build(),
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
id: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue