refactor(worker_new): remove roleFk and profileType
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2cc89d9ae7
commit
ecfad94057
|
@ -1,22 +1,3 @@
|
|||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ProfileType', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
CREATE TABLE `vn`.`newWorkerConfig` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`street` VARCHAR(25) NULL,
|
||||
`provinceFk` smallint(6) unsigned NULL,
|
||||
`companyFk` smallint(5) unsigned NULL,
|
||||
`profileTypeFk` INT(11) NULL,
|
||||
`roleFk` int(10) unsigned NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `newWorkerConfig_province_fk` FOREIGN KEY (`provinceFk`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `newWorkerConfig_company_fk` FOREIGN KEY (`companyFk`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `newWorkerConfig_profileType_fk` FOREIGN KEY (`profileTypeFk`) REFERENCES `vn`.`profileType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `newWorkerConfig_role_fk` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
UPDATE `salix`.`ACL`
|
||||
SET accessType='READ'
|
||||
WHERE model='Worker'
|
||||
|
@ -36,8 +17,8 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
|
|||
('Worker', 'new', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Role', '*', 'READ', 'ALLOW', 'ROLE', 'hr');
|
||||
|
||||
/*
|
||||
INSERT INTO `vn`.`newWorkerConfig` (`id`, `street`, `provinceFk`, `companyFk`, `profileTypeFk`, `roleFk`)
|
||||
VALUES
|
||||
(1, 'C/ ', 57, 442, 1, 1);
|
||||
*/
|
||||
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;
|
||||
|
||||
|
|
|
@ -2769,3 +2769,7 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
|
|||
VALUES
|
||||
(1, 1);
|
||||
|
||||
INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
|
||||
VALUES
|
||||
(1, NULL, 1);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Worker calendar path', () => {
|
||||
describe('Worker create path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
let newWorker;
|
||||
|
@ -23,13 +23,12 @@ describe('Worker calendar path', () => {
|
|||
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, 'Doomstadt');
|
||||
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');
|
||||
});
|
||||
|
||||
it('should check for autocompleted worker code and worker user name', async() => {
|
||||
// should check for autocompleted worker code and worker user name
|
||||
const workerCode = await page
|
||||
.waitToGetProperty(selectors.workerCreate.code, 'value');
|
||||
|
||||
|
@ -38,34 +37,30 @@ describe('Worker calendar path', () => {
|
|||
|
||||
expect(workerCode).toEqual('VVD');
|
||||
expect(newWorker).toContain('victorvd');
|
||||
});
|
||||
|
||||
it('should fail if necessary data is void', async() => {
|
||||
// should fail if necessary data is void
|
||||
await page.waitToClick(selectors.workerCreate.createButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
let message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('is a required argument');
|
||||
});
|
||||
|
||||
it('should create a new worker and go to worker basic data', async() => {
|
||||
// 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.role, 'Jefe de personal de reparto');
|
||||
await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryBoss');
|
||||
await page.waitToClick(selectors.workerCreate.createButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
message = await page.waitForSnackbar();
|
||||
await page.waitForState('worker.card.basicData');
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('rollback', async() => {
|
||||
// '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);
|
||||
let message = await page.waitForSnackbar();
|
||||
message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('User deactivated!');
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/* eslint max-len: ["error", { "code": 130 }]*/
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('new', {
|
||||
description: 'Creates a new ticket and returns the id',
|
||||
description: 'Creates a new worker and returns the id',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
|
@ -35,12 +36,6 @@ module.exports = Self => {
|
|||
description: `The worker email`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'roleFk',
|
||||
type: 'number',
|
||||
description: `The worker role`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'street',
|
||||
type: 'string',
|
||||
|
@ -106,12 +101,6 @@ module.exports = Self => {
|
|||
type: 'date',
|
||||
description: `The worker birth`,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'profileTypeFk',
|
||||
type: 'number',
|
||||
description: `The worker profile type ¿DELETE?`,
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -150,6 +139,7 @@ module.exports = Self => {
|
|||
|
||||
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;'
|
||||
);
|
||||
|
@ -160,7 +150,7 @@ module.exports = Self => {
|
|||
nickname,
|
||||
password: randomPassword.password,
|
||||
email: args.email,
|
||||
role: args.roleFk,
|
||||
roleFk: workerConfig.roleFk,
|
||||
},
|
||||
myOptions
|
||||
);
|
||||
|
@ -198,13 +188,17 @@ module.exports = Self => {
|
|||
provinceFk: args.provinceFk,
|
||||
postalCode: args.postalCode,
|
||||
mobile: args.phone,
|
||||
nickname: 'TR ' + nickname,
|
||||
nickname: nickname,
|
||||
isDefaultAddress: true,
|
||||
},
|
||||
myOptions
|
||||
);
|
||||
|
||||
client = await models.Client.findById(user.id, null, myOptions);
|
||||
client = await models.Client.findById(
|
||||
user.id,
|
||||
{fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk']},
|
||||
myOptions
|
||||
);
|
||||
|
||||
await client.updateAttributes(
|
||||
{
|
||||
|
|
|
@ -24,7 +24,6 @@ describe('Worker new', () => {
|
|||
firstName: 'default',
|
||||
lastNames: 'worker',
|
||||
email: 'defaultWorker@mydomain.com',
|
||||
roleFk: 1,
|
||||
street: 'S/ defaultWorkerStreet',
|
||||
city: 'defaultWorkerCity',
|
||||
provinceFk: 1,
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
"Journey": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NewWorkerConfig":{
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ProfileType":{
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -41,36 +38,42 @@
|
|||
"WorkCenterHoliday": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDms": {
|
||||
"Worker": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Worker": {
|
||||
"WorkerConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDepartment": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDisableExcluded": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDms": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerLabour": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerLog": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerMana": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerMedia": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerTeam": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerTeamCollegues": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerMedia": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDepartment": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerTimeControl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerLog": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerTimeControlConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -79,9 +82,6 @@
|
|||
},
|
||||
"WorkerTimeControlMail": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"WorkerDisableExcluded": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "NewWorkerConfig",
|
||||
"name": "WorkerConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "newWorkerConfig"
|
||||
"table": "workerConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
@ -12,18 +12,6 @@
|
|||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"street": {
|
||||
"type": "string"
|
||||
},
|
||||
"provinceFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"companyFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"profileTypeFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"roleFk": {
|
||||
"type": "number"
|
||||
}
|
|
@ -52,19 +52,9 @@
|
|||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<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-datalist
|
||||
label="Postcode"
|
||||
vn-two
|
||||
vn-one
|
||||
ng-model="$ctrl.worker.postcode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
|
@ -87,6 +77,16 @@
|
|||
</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
|
||||
|
@ -120,14 +120,6 @@
|
|||
ng-model="$ctrl.worker.email"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
label="Access permission"
|
||||
ng-model="$ctrl.worker.roleFk"
|
||||
value-field="id"
|
||||
show-field="description"
|
||||
url="Roles"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
|
@ -148,15 +140,6 @@
|
|||
where="{role: 'employee'}"
|
||||
label="Boss">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="profileType"
|
||||
ng-model="$ctrl.worker.profileTypeFk"
|
||||
url="ProfileTypes"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="ProfileType">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
|
|
|
@ -4,9 +4,7 @@ import Section from 'salix/components/section';
|
|||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.$http.get('NewWorkerConfigs/findOne').then(res => {
|
||||
return this.worker = Object.assign({}, res.data);
|
||||
});
|
||||
this.worker = {companyFk: this.vnConfig.user.companyFk};
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
|
@ -45,6 +43,9 @@ export default class Controller extends Section {
|
|||
|
||||
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() {
|
||||
|
|
|
@ -23,6 +23,7 @@ describe('Worker', () => {
|
|||
const $element = angular.element('<vn-worker-create></vn-worker-create>');
|
||||
controller = $componentController('vnWorkerCreate', {$element, $scope});
|
||||
controller.worker = {};
|
||||
controller.vnConfig = {user: {companyFk: 1}};
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
|
@ -115,7 +116,7 @@ describe('Worker', () => {
|
|||
});
|
||||
|
||||
describe('generateCodeUser()', () => {
|
||||
it(`should generate worker code and name `, () => {
|
||||
it(`should generate worker code, name and company `, () => {
|
||||
controller.worker = {
|
||||
firstName: 'default',
|
||||
lastNames: 'generate worker'
|
||||
|
@ -125,6 +126,7 @@ describe('Worker', () => {
|
|||
|
||||
expect(controller.worker.code).toEqual('DGW');
|
||||
expect(controller.worker.name).toEqual('defaultgw');
|
||||
expect(controller.worker.companyFk).toEqual(controller.vnConfig.user.companyFk);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue