From 0d6b248f768c4d6bb8e722948c645f41ece4703f Mon Sep 17 00:00:00 2001
From: joan
Date: Tue, 4 Apr 2023 14:59:33 +0200
Subject: [PATCH 001/143] feat(2fa): email 2fa Refs #5475
---
db/changes/231401/00-user.sql | 3 ++
front/salix/components/index.js | 1 +
.../components/validate-email/index.html | 19 ++++++++
.../salix/components/validate-email/index.js | 48 +++++++++++++++++++
.../components/validate-email/locale/en.yml | 4 ++
.../components/validate-email/locale/es.yml | 8 ++++
.../components/validate-email/style.scss | 24 ++++++++++
front/salix/routes.js | 6 +++
8 files changed, 113 insertions(+)
create mode 100644 db/changes/231401/00-user.sql
create mode 100644 front/salix/components/validate-email/index.html
create mode 100644 front/salix/components/validate-email/index.js
create mode 100644 front/salix/components/validate-email/locale/en.yml
create mode 100644 front/salix/components/validate-email/locale/es.yml
create mode 100644 front/salix/components/validate-email/style.scss
diff --git a/db/changes/231401/00-user.sql b/db/changes/231401/00-user.sql
new file mode 100644
index 000000000..2c457c14e
--- /dev/null
+++ b/db/changes/231401/00-user.sql
@@ -0,0 +1,3 @@
+alter table `account`.`user`
+ add `2FA` ENUM ('email') null comment 'Two factor auth type';
+
diff --git a/front/salix/components/index.js b/front/salix/components/index.js
index 8f5724862..5851f9e94 100644
--- a/front/salix/components/index.js
+++ b/front/salix/components/index.js
@@ -9,6 +9,7 @@ import './login';
import './outLayout';
import './recover-password';
import './reset-password';
+import './validate-email';
import './module-card';
import './module-main';
import './side-menu/side-menu';
diff --git a/front/salix/components/validate-email/index.html b/front/salix/components/validate-email/index.html
new file mode 100644
index 000000000..bdbdc113e
--- /dev/null
+++ b/front/salix/components/validate-email/index.html
@@ -0,0 +1,19 @@
+Reset password
+
+
+
+
+
diff --git a/front/salix/components/validate-email/index.js b/front/salix/components/validate-email/index.js
new file mode 100644
index 000000000..c10e1b2b0
--- /dev/null
+++ b/front/salix/components/validate-email/index.js
@@ -0,0 +1,48 @@
+import ngModule from '../../module';
+import './style.scss';
+
+export default class Controller {
+ constructor($scope, $element, $http, vnApp, $translate, $state, $location) {
+ Object.assign(this, {
+ $scope,
+ $element,
+ $http,
+ vnApp,
+ $translate,
+ $state,
+ $location
+ });
+ }
+
+ $onInit() {
+ this.$http.get('UserPasswords/findOne')
+ .then(res => {
+ this.passRequirements = res.data;
+ });
+ }
+
+ submit() {
+ if (!this.newPassword)
+ throw new UserError(`You must enter a new password`);
+ if (this.newPassword != this.repeatPassword)
+ throw new UserError(`Passwords don't match`);
+
+ const headers = {
+ Authorization: this.$location.$$search.access_token
+ };
+
+ const newPassword = this.newPassword;
+
+ this.$http.post('users/reset-password', {newPassword}, {headers})
+ .then(() => {
+ this.vnApp.showSuccess(this.$translate.instant('Password changed!'));
+ this.$state.go('login');
+ });
+ }
+}
+Controller.$inject = ['$scope', '$element', '$http', 'vnApp', '$translate', '$state', '$location'];
+
+ngModule.vnComponent('vnValidateEmail', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/front/salix/components/validate-email/locale/en.yml b/front/salix/components/validate-email/locale/en.yml
new file mode 100644
index 000000000..e5419e1c8
--- /dev/null
+++ b/front/salix/components/validate-email/locale/en.yml
@@ -0,0 +1,4 @@
+Password requirements: >
+ The password must have at least {{ length }} length characters,
+ {{nAlpha}} alphabetic characters, {{nUpper}} capital letters, {{nDigits}}
+ digits and {{nPunct}} symbols (Ex: $%&.)
diff --git a/front/salix/components/validate-email/locale/es.yml b/front/salix/components/validate-email/locale/es.yml
new file mode 100644
index 000000000..30893a152
--- /dev/null
+++ b/front/salix/components/validate-email/locale/es.yml
@@ -0,0 +1,8 @@
+Reset password: Restrablecer contraseña
+New password: Nueva contraseña
+Repeat password: Repetir contraseña
+Password changed!: ¡Contraseña cambiada!
+Password requirements: >
+ La contraseña debe tener al menos {{ length }} caracteres de longitud,
+ {{nAlpha}} caracteres alfabéticos, {{nUpper}} letras mayúsculas, {{nDigits}}
+ dígitos y {{nPunct}} símbolos (Ej: $%&.)
diff --git a/front/salix/components/validate-email/style.scss b/front/salix/components/validate-email/style.scss
new file mode 100644
index 000000000..87e4adc8c
--- /dev/null
+++ b/front/salix/components/validate-email/style.scss
@@ -0,0 +1,24 @@
+@import "variables";
+
+vn-reset-password{
+ .footer {
+ margin-top: 32px;
+ text-align: center;
+ position: relative;
+ & > .vn-submit {
+ display: block;
+
+ & > input {
+ display: block;
+ width: 100%;
+ }
+ }
+ & > .spinner-wrapper {
+ position: absolute;
+ width: 0;
+ top: 3px;
+ right: -8px;
+ overflow: visible;
+ }
+ }
+}
diff --git a/front/salix/routes.js b/front/salix/routes.js
index f32c143ef..9498e84d9 100644
--- a/front/salix/routes.js
+++ b/front/salix/routes.js
@@ -33,6 +33,12 @@ function config($stateProvider, $urlRouterProvider) {
description: 'Reset password',
template: ''
})
+ .state('validate-email', {
+ parent: 'outLayout',
+ url: '/validate-email',
+ description: 'Validate email auth',
+ template: ''
+ })
.state('home', {
parent: 'layout',
url: '/',
From 902709d61b0b9309a72419c1cec274c4f49bb39b Mon Sep 17 00:00:00 2001
From: joan
Date: Wed, 5 Apr 2023 15:22:09 +0200
Subject: [PATCH 002/143] Added authCode table
---
db/changes/231401/00-authCode.sql | 13 +++++++++++++
front/core/services/auth.js | 2 +-
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 db/changes/231401/00-authCode.sql
diff --git a/db/changes/231401/00-authCode.sql b/db/changes/231401/00-authCode.sql
new file mode 100644
index 000000000..8d1b48f12
--- /dev/null
+++ b/db/changes/231401/00-authCode.sql
@@ -0,0 +1,13 @@
+create table `salix`.`authCode`
+(
+ userFk int UNSIGNED not null,
+ code int not null,
+ constraint authCode_pk
+ primary key (userFk),
+ constraint authCode_unique
+ unique (code),
+ constraint authCode_user_id_fk
+ foreign key (userFk) references account.user (id)
+ on update cascade on delete cascade
+);
+
diff --git a/front/core/services/auth.js b/front/core/services/auth.js
index c15a34d94..5755f8f34 100644
--- a/front/core/services/auth.js
+++ b/front/core/services/auth.js
@@ -24,7 +24,7 @@ export default class Auth {
initialize() {
let criteria = {
to: state => {
- const outLayout = ['login', 'recover-password', 'reset-password'];
+ const outLayout = ['login', 'recover-password', 'reset-password', 'validate-email'];
return !outLayout.some(ol => ol == state.name);
}
};
From 2e0325e567ef5a9a83a4fa29aba6f6fe2e48212f Mon Sep 17 00:00:00 2001
From: joan
Date: Thu, 6 Apr 2023 14:59:25 +0200
Subject: [PATCH 003/143] Validate code
---
back/methods/account/login.js | 30 +++++++-
back/methods/account/validate-auth.js | 73 +++++++++++++++++++
back/model-config.json | 6 ++
back/models/account.js | 1 +
back/models/account.json | 10 +++
back/models/auth-code.json | 31 ++++++++
back/models/user-access.json | 36 +++++++++
db/changes/231401/00-authCode.sql | 14 ++++
db/changes/231401/00-user.sql | 2 +-
front/core/services/auth.js | 17 +++++
front/salix/components/login/index.js | 26 +++++--
.../components/validate-email/index.html | 19 ++---
.../salix/components/validate-email/index.js | 47 ++++++------
loopback/locale/es.json | 8 +-
loopback/util/forbiddenError.js | 9 +++
.../email/auth-code/assets/css/import.js | 13 ++++
.../email/auth-code/assets/css/style.css | 5 ++
.../templates/email/auth-code/auth-code.html | 17 +++++
print/templates/email/auth-code/auth-code.js | 15 ++++
print/templates/email/auth-code/locale/es.yml | 5 ++
20 files changed, 331 insertions(+), 53 deletions(-)
create mode 100644 back/methods/account/validate-auth.js
create mode 100644 back/models/auth-code.json
create mode 100644 back/models/user-access.json
create mode 100644 loopback/util/forbiddenError.js
create mode 100644 print/templates/email/auth-code/assets/css/import.js
create mode 100644 print/templates/email/auth-code/assets/css/style.css
create mode 100644 print/templates/email/auth-code/auth-code.html
create mode 100755 print/templates/email/auth-code/auth-code.js
create mode 100644 print/templates/email/auth-code/locale/es.yml
diff --git a/back/methods/account/login.js b/back/methods/account/login.js
index 7393e8374..47d4d629a 100644
--- a/back/methods/account/login.js
+++ b/back/methods/account/login.js
@@ -1,8 +1,9 @@
const md5 = require('md5');
const UserError = require('vn-loopback/util/user-error');
+const ForbiddenError = require('vn-loopback/util/forbiddenError');
module.exports = Self => {
- Self.remoteMethod('login', {
+ Self.remoteMethodCtx('login', {
description: 'Login a user with username/email and password',
accepts: [
{
@@ -26,7 +27,7 @@ module.exports = Self => {
}
});
- Self.login = async function(user, password) {
+ Self.login = async function(ctx, user, password) {
let $ = Self.app.models;
let token;
let usesEmail = user.indexOf('@') !== -1;
@@ -43,7 +44,7 @@ module.exports = Self => {
? {email: user}
: {name: user};
let account = await Self.findOne({
- fields: ['active', 'password'],
+ fields: ['id', 'active', 'password', 'twoFactor'],
where
});
@@ -63,6 +64,29 @@ module.exports = Self => {
}
}
+ if (account.twoFactor === 'email') {
+ const authAccess = await $.UserAccess.findOne({
+ where: {
+ userFk: account.id,
+ ip: ctx.req.connection.remoteAddress
+ }
+ });
+ if (!authAccess) {
+ const code = String(Math.floor(Math.random() * 999999));
+ const maxTTL = ((60 * 1000) * 5); // 5 min
+ await $.AuthCode.upsertWithWhere({userFk: account.id}, {
+ userFk: account.id,
+ code: code,
+ expires: Date.now() + maxTTL
+ });
+
+ ctx.args.code = code;
+ await Self.sendTemplate(ctx, 'auth-code');
+
+ throw new ForbiddenError();
+ }
+ }
+
let loginInfo = Object.assign({password}, userInfo);
token = await $.User.login(loginInfo, 'user');
return {token: token.id};
diff --git a/back/methods/account/validate-auth.js b/back/methods/account/validate-auth.js
new file mode 100644
index 000000000..ba1c6a3bb
--- /dev/null
+++ b/back/methods/account/validate-auth.js
@@ -0,0 +1,73 @@
+const UserError = require('vn-loopback/util/user-error');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('validateAuth', {
+ description: 'Login a user with username/email and password',
+ accepts: [
+ {
+ arg: 'user',
+ type: 'String',
+ description: 'The user name or email',
+ required: true
+ },
+ {
+ arg: 'password',
+ type: 'String',
+ description: 'The password'
+ },
+ {
+ arg: 'code',
+ type: 'String',
+ description: 'The auth code'
+ }
+ ],
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/validate-auth`,
+ verb: 'POST'
+ }
+ });
+
+ Self.validateAuth = async function(ctx, username, password, code) {
+ const {AuthCode, UserAccess} = Self.app.models;
+
+ const authCode = await AuthCode.findOne({
+ where: {
+ code: code
+ }
+ });
+
+ const expired = Date.now() > authCode.expires;
+ if (!authCode || expired)
+ throw new UserError('Invalid or expired verification code');
+
+ const user = await Self.findById(authCode.userFk, {
+ fields: ['name', 'twoFactor']
+ });
+
+ if (user.name !== username)
+ throw new UserError('Authentication failed');
+
+ const headers = ctx.req.headers;
+ let platform = headers['sec-ch-ua-platform'];
+ let browser = headers['sec-ch-ua'];
+
+ if (platform) platform = platform.replace(/['"]+/g, '');
+ if (browser) browser = browser.split(';')[0].replace(/['"]+/g, '');
+
+ await UserAccess.upsertWithWhere({userFk: authCode.userFk}, {
+ userFk: authCode.userFk,
+ ip: ctx.req.connection.remoteAddress,
+ agent: headers['user-agent'],
+ platform: platform,
+ browser: browser
+ });
+
+ await authCode.destroy();
+
+ return Self.login(ctx, username, password);
+ };
+};
diff --git a/back/model-config.json b/back/model-config.json
index 29676e979..91061eb32 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -5,6 +5,9 @@
"AccountingType": {
"dataSource": "vn"
},
+ "AuthCode": {
+ "dataSource": "vn"
+ },
"Bank": {
"dataSource": "vn"
},
@@ -116,6 +119,9 @@
"Town": {
"dataSource": "vn"
},
+ "UserAccess": {
+ "dataSource": "vn"
+ },
"Url": {
"dataSource": "vn"
},
diff --git a/back/models/account.js b/back/models/account.js
index 6d71a4e52..fb9c95005 100644
--- a/back/models/account.js
+++ b/back/models/account.js
@@ -11,6 +11,7 @@ module.exports = Self => {
require('../methods/account/set-password')(Self);
require('../methods/account/recover-password')(Self);
require('../methods/account/validate-token')(Self);
+ require('../methods/account/validate-auth')(Self);
require('../methods/account/privileges')(Self);
// Validations
diff --git a/back/models/account.json b/back/models/account.json
index 5e35c711a..3b3e2cca5 100644
--- a/back/models/account.json
+++ b/back/models/account.json
@@ -54,6 +54,9 @@
},
"hasGrant": {
"type": "boolean"
+ },
+ "twoFactor": {
+ "type": "string"
}
},
"relations": {
@@ -113,6 +116,13 @@
"principalId": "$authenticated",
"permission": "ALLOW"
},
+ {
+ "property": "validateAuth",
+ "accessType": "EXECUTE",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ },
{
"property": "privileges",
"accessType": "*",
diff --git a/back/models/auth-code.json b/back/models/auth-code.json
new file mode 100644
index 000000000..b6a89115f
--- /dev/null
+++ b/back/models/auth-code.json
@@ -0,0 +1,31 @@
+{
+ "name": "AuthCode",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "salix.authCode"
+ }
+ },
+ "properties": {
+ "userFk": {
+ "type": "number",
+ "required": true,
+ "id": true
+ },
+ "code": {
+ "type": "string",
+ "required": true
+ },
+ "expires": {
+ "type": "number",
+ "required": true
+ }
+ },
+ "relations": {
+ "user": {
+ "type": "belongsTo",
+ "model": "Account",
+ "foreignKey": "userFk"
+ }
+ }
+}
diff --git a/back/models/user-access.json b/back/models/user-access.json
new file mode 100644
index 000000000..f60d70251
--- /dev/null
+++ b/back/models/user-access.json
@@ -0,0 +1,36 @@
+{
+ "name": "UserAccess",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "salix.userAccess"
+ }
+ },
+ "properties": {
+ "userFk": {
+ "type": "number",
+ "required": true,
+ "id": true
+ },
+ "ip": {
+ "type": "string",
+ "required": true
+ },
+ "agent": {
+ "type": "string"
+ },
+ "platform": {
+ "type": "string"
+ },
+ "browser": {
+ "type": "string"
+ }
+ },
+ "relations": {
+ "user": {
+ "type": "belongsTo",
+ "model": "Account",
+ "foreignKey": "userFk"
+ }
+ }
+}
diff --git a/db/changes/231401/00-authCode.sql b/db/changes/231401/00-authCode.sql
index 8d1b48f12..7f742d4af 100644
--- a/db/changes/231401/00-authCode.sql
+++ b/db/changes/231401/00-authCode.sql
@@ -2,6 +2,7 @@ create table `salix`.`authCode`
(
userFk int UNSIGNED not null,
code int not null,
+ expires TIMESTAMP not null,
constraint authCode_pk
primary key (userFk),
constraint authCode_unique
@@ -11,3 +12,16 @@ create table `salix`.`authCode`
on update cascade on delete cascade
);
+create table `salix`.`userAccess`
+(
+ userFk int UNSIGNED not null,
+ ip VARCHAR(25) not null,
+ agent text null,
+ platform VARCHAR(25) null,
+ browser VARCHAR(25) null,
+ constraint userAccess_pk
+ primary key (userFk),
+ constraint userAccess_user_null_fk
+ foreign key (userFk) references account.user (id)
+)
+ auto_increment = 0;
\ No newline at end of file
diff --git a/db/changes/231401/00-user.sql b/db/changes/231401/00-user.sql
index 2c457c14e..1427d0460 100644
--- a/db/changes/231401/00-user.sql
+++ b/db/changes/231401/00-user.sql
@@ -1,3 +1,3 @@
alter table `account`.`user`
- add `2FA` ENUM ('email') null comment 'Two factor auth type';
+ add `twoFactor` ENUM ('email') null comment 'Two factor auth type';
diff --git a/front/core/services/auth.js b/front/core/services/auth.js
index 5755f8f34..479696931 100644
--- a/front/core/services/auth.js
+++ b/front/core/services/auth.js
@@ -63,6 +63,23 @@ export default class Auth {
json => this.onLoginOk(json, remember));
}
+ validateCode(user, password, code, remember) {
+ if (!user) {
+ let err = new UserError('Please enter your username');
+ err.code = 'EmptyLogin';
+ return this.$q.reject(err);
+ }
+
+ let params = {
+ user: user,
+ password: password || undefined,
+ code: code
+ };
+
+ return this.$http.post('Accounts/validate-auth', params).then(
+ json => this.onLoginOk(json, remember));
+ }
+
onLoginOk(json, remember) {
this.vnToken.set(json.data.token, remember);
diff --git a/front/salix/components/login/index.js b/front/salix/components/login/index.js
index 150e896a1..78632aa99 100644
--- a/front/salix/components/login/index.js
+++ b/front/salix/components/login/index.js
@@ -5,13 +5,14 @@ import './style.scss';
* A simple login form.
*/
export default class Controller {
- constructor($, $element, vnAuth) {
+ constructor($, $element, vnAuth, $state) {
Object.assign(this, {
$,
$element,
vnAuth,
user: localStorage.getItem('lastUser'),
- remember: true
+ remember: true,
+ $state
});
}
@@ -22,11 +23,21 @@ export default class Controller {
localStorage.setItem('lastUser', this.user);
this.loading = false;
})
- .catch(err => {
+ .catch(error => {
+ if (error.message === 'Forbidden') {
+ this.outLayout.login = {
+ user: this.user,
+ password: this.password,
+ remember: this.remember
+ };
+ this.$state.go('validate-email');
+ return;
+ }
+
this.loading = false;
this.password = '';
this.focusUser();
- throw err;
+ throw error;
});
}
@@ -35,9 +46,12 @@ export default class Controller {
this.$.userField.focus();
}
}
-Controller.$inject = ['$scope', '$element', 'vnAuth'];
+Controller.$inject = ['$scope', '$element', 'vnAuth', '$state'];
ngModule.vnComponent('vnLogin', {
template: require('./index.html'),
- controller: Controller
+ controller: Controller,
+ require: {
+ outLayout: '^vnOutLayout'
+ }
});
diff --git a/front/salix/components/validate-email/index.html b/front/salix/components/validate-email/index.html
index bdbdc113e..e03cb9dcb 100644
--- a/front/salix/components/validate-email/index.html
+++ b/front/salix/components/validate-email/index.html
@@ -1,19 +1,10 @@
-Reset password
-
-
-
+Enter verification code
+Please enter the verification code that we have sent to your email address within 5 minutes.
+
+
\ No newline at end of file
diff --git a/front/salix/components/validate-email/index.js b/front/salix/components/validate-email/index.js
index c10e1b2b0..f337ab8af 100644
--- a/front/salix/components/validate-email/index.js
+++ b/front/salix/components/validate-email/index.js
@@ -2,47 +2,42 @@ import ngModule from '../../module';
import './style.scss';
export default class Controller {
- constructor($scope, $element, $http, vnApp, $translate, $state, $location) {
+ constructor($scope, $element, vnAuth, $state) {
Object.assign(this, {
$scope,
$element,
- $http,
- vnApp,
- $translate,
- $state,
- $location
+ vnAuth,
+ user: localStorage.getItem('lastUser'),
+ remember: true,
+ $state
});
}
$onInit() {
- this.$http.get('UserPasswords/findOne')
- .then(res => {
- this.passRequirements = res.data;
- });
+ this.loginData = this.outLayout.login;
+ if (!this.loginData)
+ this.$state.go('login');
}
submit() {
- if (!this.newPassword)
- throw new UserError(`You must enter a new password`);
- if (this.newPassword != this.repeatPassword)
- throw new UserError(`Passwords don't match`);
-
- const headers = {
- Authorization: this.$location.$$search.access_token
- };
-
- const newPassword = this.newPassword;
-
- this.$http.post('users/reset-password', {newPassword}, {headers})
+ this.loading = true;
+ this.vnAuth.validateCode(this.loginData.user, this.loginData.password, this.code, this.loginData.remember)
.then(() => {
- this.vnApp.showSuccess(this.$translate.instant('Password changed!'));
- this.$state.go('login');
+ localStorage.setItem('lastUser', this.user);
+ this.loading = false;
+ })
+ .catch(error => {
+ this.loading = false;
+ throw error;
});
}
}
-Controller.$inject = ['$scope', '$element', '$http', 'vnApp', '$translate', '$state', '$location'];
+Controller.$inject = ['$scope', '$element', 'vnAuth', '$state'];
ngModule.vnComponent('vnValidateEmail', {
template: require('./index.html'),
- controller: Controller
+ controller: Controller,
+ require: {
+ outLayout: '^vnOutLayout'
+ }
});
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 42276efe7..70ba15098 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -273,6 +273,8 @@
"Not exist this branch": "La rama no existe",
"This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado",
"Insert a date range": "Inserte un rango de fechas",
- "Added observation": "{{user}} añadió esta observacion: {{text}}",
- "Comment added to client": "Observación añadida al cliente {{clientFk}}"
-}
+ "Added observation": "{{user}} añadió esta observacion: {{text}}",
+ "Comment added to client": "Observación añadida al cliente {{clientFk}}",
+ "Invalid auth code": "Invalid auth code",
+ "Invalid or expired verification code": "Invalid or expired verification code"
+}
\ No newline at end of file
diff --git a/loopback/util/forbiddenError.js b/loopback/util/forbiddenError.js
new file mode 100644
index 000000000..998cb4593
--- /dev/null
+++ b/loopback/util/forbiddenError.js
@@ -0,0 +1,9 @@
+module.exports = class ForbiddenError extends Error {
+ constructor(message, code, ...translateArgs) {
+ super(message);
+ this.name = 'ForbiddenError';
+ this.statusCode = 403;
+ this.code = code;
+ this.translateArgs = translateArgs;
+ }
+};
diff --git a/print/templates/email/auth-code/assets/css/import.js b/print/templates/email/auth-code/assets/css/import.js
new file mode 100644
index 000000000..7360587f7
--- /dev/null
+++ b/print/templates/email/auth-code/assets/css/import.js
@@ -0,0 +1,13 @@
+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`,
+ `${__dirname}/style.css`])
+ .mergeStyles();
+
diff --git a/print/templates/email/auth-code/assets/css/style.css b/print/templates/email/auth-code/assets/css/style.css
new file mode 100644
index 000000000..d3bfa2aea
--- /dev/null
+++ b/print/templates/email/auth-code/assets/css/style.css
@@ -0,0 +1,5 @@
+.code {
+ border: 2px dashed #8dba25;
+ border-radius: 3px;
+ text-align: center
+}
\ No newline at end of file
diff --git a/print/templates/email/auth-code/auth-code.html b/print/templates/email/auth-code/auth-code.html
new file mode 100644
index 000000000..ea87e6c66
--- /dev/null
+++ b/print/templates/email/auth-code/auth-code.html
@@ -0,0 +1,17 @@
+
+
+
+
+
{{$t('Enter the following code to continue to your account')}}
+
+ {{ code }}
+
+
{{$t('It expires in 5 minutes.')}}
+
+
+
\ No newline at end of file
diff --git a/print/templates/email/auth-code/auth-code.js b/print/templates/email/auth-code/auth-code.js
new file mode 100755
index 000000000..7ddd1c2db
--- /dev/null
+++ b/print/templates/email/auth-code/auth-code.js
@@ -0,0 +1,15 @@
+const Component = require(`vn-print/core/component`);
+const emailBody = new Component('email-body');
+
+module.exports = {
+ name: 'auth-code',
+ components: {
+ 'email-body': emailBody.build(),
+ },
+ props: {
+ code: {
+ type: String,
+ required: true
+ }
+ }
+};
diff --git a/print/templates/email/auth-code/locale/es.yml b/print/templates/email/auth-code/locale/es.yml
new file mode 100644
index 000000000..b77937468
--- /dev/null
+++ b/print/templates/email/auth-code/locale/es.yml
@@ -0,0 +1,5 @@
+subject: Código de verificación
+title: Código de verificación
+description: Alguien ha solicitado un código de verificación para poder iniciar sesión. Si no lo has solicitado tu, ignora este email.
+Enter the following code to continue to your account: Introduce el siguiente código para poder continuar con tu cuenta
+It expires in 5 minutes.: Expira en 5 minutos
From b9e48f2102e3e4214f910e9f402bf977d0e04c77 Mon Sep 17 00:00:00 2001
From: joan
Date: Tue, 11 Apr 2023 07:39:43 +0200
Subject: [PATCH 004/143] Added translations & enable through departments
---
db/changes/231401/00-authCode.sql | 4 ++--
db/changes/231401/00-department.sql | 24 +++++++++++++++++++
db/changes/231401/00-user.sql | 3 +--
.../components/validate-email/index.html | 2 +-
.../components/validate-email/locale/en.yml | 4 ----
.../components/validate-email/locale/es.yml | 12 ++++------
.../components/validate-email/style.scss | 2 +-
print/templates/email/auth-code/locale/fr.yml | 5 ++++
print/templates/email/auth-code/locale/pt.yml | 5 ++++
9 files changed, 43 insertions(+), 18 deletions(-)
create mode 100644 db/changes/231401/00-department.sql
delete mode 100644 front/salix/components/validate-email/locale/en.yml
create mode 100644 print/templates/email/auth-code/locale/fr.yml
create mode 100644 print/templates/email/auth-code/locale/pt.yml
diff --git a/db/changes/231401/00-authCode.sql b/db/changes/231401/00-authCode.sql
index 7f742d4af..0415c90f0 100644
--- a/db/changes/231401/00-authCode.sql
+++ b/db/changes/231401/00-authCode.sql
@@ -8,7 +8,7 @@ create table `salix`.`authCode`
constraint authCode_unique
unique (code),
constraint authCode_user_id_fk
- foreign key (userFk) references account.user (id)
+ foreign key (userFk) references `account`.`user` (id)
on update cascade on delete cascade
);
@@ -22,6 +22,6 @@ create table `salix`.`userAccess`
constraint userAccess_pk
primary key (userFk),
constraint userAccess_user_null_fk
- foreign key (userFk) references account.user (id)
+ foreign key (userFk) references `account`.`user` (id)
)
auto_increment = 0;
\ No newline at end of file
diff --git a/db/changes/231401/00-department.sql b/db/changes/231401/00-department.sql
new file mode 100644
index 000000000..ffc3a1622
--- /dev/null
+++ b/db/changes/231401/00-department.sql
@@ -0,0 +1,24 @@
+alter table `vn`.`department`
+ add `twoFactor` ENUM ('email') null comment 'Default user tow-factor auth type';
+
+drop trigger `vn`.`department_afterUpdate`;
+
+DELIMITER $$
+$$
+create definer = root@localhost trigger department_afterUpdate
+ after update
+ on department
+ for each row
+BEGIN
+ IF !(OLD.parentFk <=> NEW.parentFk) THEN
+ UPDATE vn.department_recalc SET isChanged = TRUE;
+ END IF;
+
+ IF !(OLD.twoFactor <=> NEW.twoFactor) THEN
+ UPDATE account.user u
+ JOIN vn.workerDepartment wd ON wd.workerFk = u.id
+ SET u.twoFactor = NEW.twoFactor
+ WHERE wd.departmentFk = NEW.id;
+ END IF;
+END;$$
+DELIMITER ;
diff --git a/db/changes/231401/00-user.sql b/db/changes/231401/00-user.sql
index 1427d0460..2a2a522c5 100644
--- a/db/changes/231401/00-user.sql
+++ b/db/changes/231401/00-user.sql
@@ -1,3 +1,2 @@
alter table `account`.`user`
- add `twoFactor` ENUM ('email') null comment 'Two factor auth type';
-
+ add `twoFactor` ENUM ('email') null comment 'Two-factor auth type';
\ No newline at end of file
diff --git a/front/salix/components/validate-email/index.html b/front/salix/components/validate-email/index.html
index e03cb9dcb..3607e1a76 100644
--- a/front/salix/components/validate-email/index.html
+++ b/front/salix/components/validate-email/index.html
@@ -1,5 +1,5 @@
Enter verification code
-Please enter the verification code that we have sent to your email address within 5 minutes.
+Please enter the verification code that we have sent to your email address within 5 minutes
\ No newline at end of file
diff --git a/print/templates/email/auth-code/locale/en.yml b/print/templates/email/auth-code/locale/en.yml
new file mode 100644
index 000000000..5f63d280f
--- /dev/null
+++ b/print/templates/email/auth-code/locale/en.yml
@@ -0,0 +1,5 @@
+subject: Verification code
+title: Verification code
+description: Somebody did request a verification code for login. If you didn't request it, please ignore this email.
+Enter the following code to continue to your account: Enter the following code to continue to your account
+It expires in 5 minutes: It expires in 5 minutes
diff --git a/print/templates/email/auth-code/locale/es.yml b/print/templates/email/auth-code/locale/es.yml
index b77937468..31952891b 100644
--- a/print/templates/email/auth-code/locale/es.yml
+++ b/print/templates/email/auth-code/locale/es.yml
@@ -2,4 +2,4 @@ subject: Código de verificación
title: Código de verificación
description: Alguien ha solicitado un código de verificación para poder iniciar sesión. Si no lo has solicitado tu, ignora este email.
Enter the following code to continue to your account: Introduce el siguiente código para poder continuar con tu cuenta
-It expires in 5 minutes.: Expira en 5 minutos
+It expires in 5 minutes: Expira en 5 minutos
diff --git a/print/templates/email/auth-code/locale/fr.yml b/print/templates/email/auth-code/locale/fr.yml
index 34fee9d1e..e435a2487 100644
--- a/print/templates/email/auth-code/locale/fr.yml
+++ b/print/templates/email/auth-code/locale/fr.yml
@@ -2,4 +2,4 @@ subject: Code de vérification
title: Code de vérification
description: Quelqu'un a demandé un code de vérification pour se connecter. Si ce n'était pas toi, ignore cet email.
Enter the following code to continue to your account: Entrez le code suivant pour continuer avec votre compte
-It expires in 5 minutes.: Il expire dans 5 minutes.
+It expires in 5 minutes: Il expire dans 5 minutes.
diff --git a/print/templates/email/auth-code/locale/pt.yml b/print/templates/email/auth-code/locale/pt.yml
index 9ffa1b2f6..940b03c4d 100644
--- a/print/templates/email/auth-code/locale/pt.yml
+++ b/print/templates/email/auth-code/locale/pt.yml
@@ -2,4 +2,4 @@ subject: Código de verificação
title: Código de verificação
description: Alguém solicitou um código de verificação para entrar. Se você não fez essa solicitação, ignore este e-mail.
Enter the following code to continue to your account: Insira o seguinte código para continuar com sua conta.
-It expires in 5 minutes.: Expira em 5 minutos.
+It expires in 5 minutes: Expira em 5 minutos.
From 4807fcb394327905ff82ca36aa8151e52dfe6a83 Mon Sep 17 00:00:00 2001
From: joan
Date: Tue, 11 Apr 2023 09:01:59 +0200
Subject: [PATCH 007/143] Removed focus
---
back/methods/account/specs/login.spec.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/back/methods/account/specs/login.spec.js b/back/methods/account/specs/login.spec.js
index 9f6c0c17d..074d74789 100644
--- a/back/methods/account/specs/login.spec.js
+++ b/back/methods/account/specs/login.spec.js
@@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server');
-fdescribe('account login()', () => {
+describe('account login()', () => {
const employeeId = 1;
const unauthCtx = {
req: {
From b5f2cf3711ffcca96603273aec2fdd29595531b3 Mon Sep 17 00:00:00 2001
From: joan
Date: Thu, 13 Apr 2023 11:54:56 +0200
Subject: [PATCH 008/143] Added unit test & translation fixes
---
.../account/specs/validate-auth.spec.js | 41 +++++++++++++++++++
back/methods/account/validate-auth.js | 2 +-
db/changes/231401/00-department.sql | 2 +-
loopback/locale/es.json | 2 +-
4 files changed, 44 insertions(+), 3 deletions(-)
create mode 100644 back/methods/account/specs/validate-auth.spec.js
diff --git a/back/methods/account/specs/validate-auth.spec.js b/back/methods/account/specs/validate-auth.spec.js
new file mode 100644
index 000000000..44ea96320
--- /dev/null
+++ b/back/methods/account/specs/validate-auth.spec.js
@@ -0,0 +1,41 @@
+const {models} = require('vn-loopback/server/server');
+
+fdescribe('account validateAuth()', () => {
+ const developerId = 9;
+
+ it('should throw an error for a non existent code', async() => {
+ const ctx = {req: {accessToken: {userId: developerId}}};
+
+ let error;
+ try {
+ await models.Account.validateAuth(ctx, 'developer', 'nightmare', '123456');
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error).toBeDefined();
+ expect(error.statusCode).toBe(400);
+ expect(error.message).toEqual('Invalid or expired verification code');
+ });
+
+ it('should throw an error when a code doesn`t match the login username', async() => {
+ const ctx = {req: {accessToken: {userId: developerId}}};
+
+ let error;
+ try {
+ const authCode = await models.AuthCode.create({
+ userFk: 1,
+ code: '555555',
+ expires: Date.vnNow() + (60 * 1000)
+ });
+ await models.Account.validateAuth(ctx, 'developer', 'nightmare', '555555');
+ await authCode.destroy();
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error).toBeDefined();
+ expect(error.statusCode).toBe(400);
+ expect(error.message).toEqual('Authentication failed');
+ });
+});
diff --git a/back/methods/account/validate-auth.js b/back/methods/account/validate-auth.js
index ba1c6a3bb..6745b8838 100644
--- a/back/methods/account/validate-auth.js
+++ b/back/methods/account/validate-auth.js
@@ -40,7 +40,7 @@ module.exports = Self => {
}
});
- const expired = Date.now() > authCode.expires;
+ const expired = authCode && Date.vnNow() > authCode.expires;
if (!authCode || expired)
throw new UserError('Invalid or expired verification code');
diff --git a/db/changes/231401/00-department.sql b/db/changes/231401/00-department.sql
index ffc3a1622..d9a91ee30 100644
--- a/db/changes/231401/00-department.sql
+++ b/db/changes/231401/00-department.sql
@@ -1,5 +1,5 @@
alter table `vn`.`department`
- add `twoFactor` ENUM ('email') null comment 'Default user tow-factor auth type';
+ add `twoFactor` ENUM ('email') null comment 'Default user two-factor auth type';
drop trigger `vn`.`department_afterUpdate`;
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 70ba15098..be9b0036a 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -275,6 +275,6 @@
"Insert a date range": "Inserte un rango de fechas",
"Added observation": "{{user}} añadió esta observacion: {{text}}",
"Comment added to client": "Observación añadida al cliente {{clientFk}}",
- "Invalid auth code": "Invalid auth code",
+ "Invalid auth code": "Código de verificación incorrecto",
"Invalid or expired verification code": "Invalid or expired verification code"
}
\ No newline at end of file
From 9aaea7e8ed75499d285ac3e0754d1271dbc4cb50 Mon Sep 17 00:00:00 2001
From: joan
Date: Thu, 13 Apr 2023 12:01:51 +0200
Subject: [PATCH 009/143] Changed to new SQL version
---
back/methods/account/specs/validate-auth.spec.js | 2 +-
db/changes/{231401 => 231601}/00-authCode.sql | 0
db/changes/{231401 => 231601}/00-department.sql | 0
db/changes/{231401 => 231601}/00-user.sql | 0
4 files changed, 1 insertion(+), 1 deletion(-)
rename db/changes/{231401 => 231601}/00-authCode.sql (100%)
rename db/changes/{231401 => 231601}/00-department.sql (100%)
rename db/changes/{231401 => 231601}/00-user.sql (100%)
diff --git a/back/methods/account/specs/validate-auth.spec.js b/back/methods/account/specs/validate-auth.spec.js
index 44ea96320..cc2eea092 100644
--- a/back/methods/account/specs/validate-auth.spec.js
+++ b/back/methods/account/specs/validate-auth.spec.js
@@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server');
-fdescribe('account validateAuth()', () => {
+describe('account validateAuth()', () => {
const developerId = 9;
it('should throw an error for a non existent code', async() => {
diff --git a/db/changes/231401/00-authCode.sql b/db/changes/231601/00-authCode.sql
similarity index 100%
rename from db/changes/231401/00-authCode.sql
rename to db/changes/231601/00-authCode.sql
diff --git a/db/changes/231401/00-department.sql b/db/changes/231601/00-department.sql
similarity index 100%
rename from db/changes/231401/00-department.sql
rename to db/changes/231601/00-department.sql
diff --git a/db/changes/231401/00-user.sql b/db/changes/231601/00-user.sql
similarity index 100%
rename from db/changes/231401/00-user.sql
rename to db/changes/231601/00-user.sql
From ef87dcc0f5e0f58cb05bb8679f625c016ff2140b Mon Sep 17 00:00:00 2001
From: joan
Date: Tue, 18 Apr 2023 07:38:40 +0200
Subject: [PATCH 010/143] require authentication on every login
---
back/methods/account/login.js | 37 +++-------------
back/methods/account/sign-in.js | 63 +++++++++++++++++++++++++++
back/methods/account/validate-auth.js | 2 +-
back/models/account.js | 1 +
back/models/account.json | 2 +-
front/core/services/auth.js | 2 +-
6 files changed, 72 insertions(+), 35 deletions(-)
create mode 100644 back/methods/account/sign-in.js
diff --git a/back/methods/account/login.js b/back/methods/account/login.js
index 2eeb5a1c4..116836068 100644
--- a/back/methods/account/login.js
+++ b/back/methods/account/login.js
@@ -1,9 +1,8 @@
const md5 = require('md5');
const UserError = require('vn-loopback/util/user-error');
-const ForbiddenError = require('vn-loopback/util/forbiddenError');
module.exports = Self => {
- Self.remoteMethodCtx('login', {
+ Self.remoteMethod('login', {
description: 'Login a user with username/email and password',
accepts: [
{
@@ -27,11 +26,13 @@ module.exports = Self => {
}
});
- Self.login = async function(ctx, user, password) {
+ Self.login = async function(user, password) {
let $ = Self.app.models;
let token;
let usesEmail = user.indexOf('@') !== -1;
+ console.log(user, password);
+
let userInfo = usesEmail
? {email: user}
: {username: user};
@@ -44,7 +45,7 @@ module.exports = Self => {
? {email: user}
: {name: user};
let account = await Self.findOne({
- fields: ['id', 'active', 'email', 'password', 'twoFactor'],
+ fields: ['id', 'active', 'password'],
where
});
@@ -64,34 +65,6 @@ module.exports = Self => {
}
}
- if (account && account.twoFactor === 'email') {
- const authAccess = await $.UserAccess.findOne({
- where: {
- userFk: account.id,
- ip: ctx.req.connection.remoteAddress
- }
- });
- if (!authAccess) {
- const code = String(Math.floor(Math.random() * 999999));
- const maxTTL = ((60 * 1000) * 5); // 5 min
- await $.AuthCode.upsertWithWhere({userFk: account.id}, {
- userFk: account.id,
- code: code,
- expires: Date.now() + maxTTL
- });
-
- const params = {
- recipientId: account.id,
- recipient: account.email,
- code: code
- };
- ctx.args = {...ctx.args, ...params};
- await Self.sendTemplate(ctx, 'auth-code');
-
- throw new ForbiddenError('REQUIRES_2FA');
- }
- }
-
let loginInfo = Object.assign({password}, userInfo);
token = await $.User.login(loginInfo, 'user');
return {token: token.id};
diff --git a/back/methods/account/sign-in.js b/back/methods/account/sign-in.js
new file mode 100644
index 000000000..9a4f30cd4
--- /dev/null
+++ b/back/methods/account/sign-in.js
@@ -0,0 +1,63 @@
+const ForbiddenError = require('vn-loopback/util/forbiddenError');
+
+module.exports = Self => {
+ Self.remoteMethodCtx('signin', {
+ description: 'Login a user with username/email and password',
+ accepts: [
+ {
+ arg: 'user',
+ type: 'String',
+ description: 'The user name or email',
+ required: true
+ }, {
+ arg: 'password',
+ type: 'String',
+ description: 'The password'
+ }
+ ],
+ returns: {
+ type: 'object',
+ root: true
+ },
+ http: {
+ path: `/signin`,
+ verb: 'POST'
+ }
+ });
+
+ Self.signin = async function(ctx, user, password) {
+ const $ = Self.app.models;
+ const usesEmail = user.indexOf('@') !== -1;
+
+ const where = usesEmail
+ ? {email: user}
+ : {name: user};
+
+ const account = await Self.findOne({
+ fields: ['id', 'active', 'email', 'password', 'twoFactor'],
+ where
+ });
+
+ if (account && account.twoFactor === 'email') {
+ const code = String(Math.floor(Math.random() * 999999));
+ const maxTTL = ((60 * 1000) * 5); // 5 min
+ await $.AuthCode.upsertWithWhere({userFk: account.id}, {
+ userFk: account.id,
+ code: code,
+ expires: Date.now() + maxTTL
+ });
+
+ const params = {
+ recipientId: account.id,
+ recipient: account.email,
+ code: code
+ };
+ ctx.args = {...ctx.args, ...params};
+ await Self.sendTemplate(ctx, 'auth-code');
+
+ throw new ForbiddenError('REQUIRES_2FA');
+ }
+
+ return $.models.login(user, password);
+ };
+};
diff --git a/back/methods/account/validate-auth.js b/back/methods/account/validate-auth.js
index 6745b8838..1f906f4a6 100644
--- a/back/methods/account/validate-auth.js
+++ b/back/methods/account/validate-auth.js
@@ -68,6 +68,6 @@ module.exports = Self => {
await authCode.destroy();
- return Self.login(ctx, username, password);
+ return Self.login(username, password);
};
};
diff --git a/back/models/account.js b/back/models/account.js
index fb9c95005..28f7c467f 100644
--- a/back/models/account.js
+++ b/back/models/account.js
@@ -4,6 +4,7 @@ const LoopBackContext = require('loopback-context');
const {Email} = require('vn-print');
module.exports = Self => {
+ require('../methods/account/sign-in')(Self);
require('../methods/account/login')(Self);
require('../methods/account/logout')(Self);
require('../methods/account/acl')(Self);
diff --git a/back/models/account.json b/back/models/account.json
index 3b3e2cca5..30f8acab1 100644
--- a/back/models/account.json
+++ b/back/models/account.json
@@ -89,7 +89,7 @@
},
"acls": [
{
- "property": "login",
+ "property": "signin",
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
diff --git a/front/core/services/auth.js b/front/core/services/auth.js
index 479696931..b90b52112 100644
--- a/front/core/services/auth.js
+++ b/front/core/services/auth.js
@@ -59,7 +59,7 @@ export default class Auth {
password: password || undefined
};
- return this.$http.post('Accounts/login', params).then(
+ return this.$http.post('Accounts/signin', params).then(
json => this.onLoginOk(json, remember));
}
From c2af40edb5309f37b2c46a6e4a260e40b9ac75de Mon Sep 17 00:00:00 2001
From: joan
Date: Tue, 18 Apr 2023 13:15:04 +0200
Subject: [PATCH 011/143] changes
---
back/methods/vn-user/sign-in.js | 14 +++---
back/methods/vn-user/signIn.js | 68 ---------------------------
back/methods/vn-user/specs/signIn.js | 2 +-
back/methods/vn-user/specs/signOut.js | 4 +-
back/methods/vn-user/validate-auth.js | 2 +-
back/models/vn-user.js | 44 ++++++++++++++++-
db/changes/231601/00-userAcl.sql | 3 +-
7 files changed, 55 insertions(+), 82 deletions(-)
delete mode 100644 back/methods/vn-user/signIn.js
diff --git a/back/methods/vn-user/sign-in.js b/back/methods/vn-user/sign-in.js
index 9a4f30cd4..0a0133b82 100644
--- a/back/methods/vn-user/sign-in.js
+++ b/back/methods/vn-user/sign-in.js
@@ -33,23 +33,23 @@ module.exports = Self => {
? {email: user}
: {name: user};
- const account = await Self.findOne({
+ const vnUser = await Self.findOne({
fields: ['id', 'active', 'email', 'password', 'twoFactor'],
where
});
- if (account && account.twoFactor === 'email') {
+ if (vnUser && vnUser.twoFactor === 'email') {
const code = String(Math.floor(Math.random() * 999999));
const maxTTL = ((60 * 1000) * 5); // 5 min
- await $.AuthCode.upsertWithWhere({userFk: account.id}, {
- userFk: account.id,
+ await $.AuthCode.upsertWithWhere({userFk: vnUser.id}, {
+ userFk: vnUser.id,
code: code,
expires: Date.now() + maxTTL
});
const params = {
- recipientId: account.id,
- recipient: account.email,
+ recipientId: vnUser.id,
+ recipient: vnUser.email,
code: code
};
ctx.args = {...ctx.args, ...params};
@@ -58,6 +58,6 @@ module.exports = Self => {
throw new ForbiddenError('REQUIRES_2FA');
}
- return $.models.login(user, password);
+ return Self.validateLogin(user, password);
};
};
diff --git a/back/methods/vn-user/signIn.js b/back/methods/vn-user/signIn.js
deleted file mode 100644
index 5f6c7f699..000000000
--- a/back/methods/vn-user/signIn.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const UserError = require('vn-loopback/util/user-error');
-
-module.exports = Self => {
- Self.remoteMethod('signIn', {
- description: 'Login a user with username/email and password',
- accepts: [
- {
- arg: 'user',
- type: 'String',
- description: 'The user name or email',
- http: {source: 'form'},
- required: true
- }, {
- arg: 'password',
- type: 'String',
- description: 'The password'
- }
- ],
- returns: {
- type: 'object',
- root: true
- },
- http: {
- path: `/signIn`,
- verb: 'POST'
- }
- });
-
- Self.signIn = async function(user, password) {
- let models = Self.app.models;
- let token;
- let usesEmail = user.indexOf('@') !== -1;
-
- let userInfo = usesEmail
- ? {email: user}
- : {username: user};
- let instance = await Self.findOne({
- fields: ['username', 'password'],
- where: userInfo
- });
-
- let where = usesEmail
- ? {email: user}
- : {name: user};
- const vnUser = await Self.findOne({
- fields: ['active'],
- where
- });
-
- let validCredentials = instance
- && await instance.hasPassword(password);
-
- if (validCredentials) {
- if (!vnUser.active)
- throw new UserError('User disabled');
-
- try {
- await models.Account.sync(instance.username, password);
- } catch (err) {
- console.warn(err);
- }
- }
-
- let loginInfo = Object.assign({password}, userInfo);
- token = await Self.login(loginInfo, 'user');
- return {token: token.id};
- };
-};
diff --git a/back/methods/vn-user/specs/signIn.js b/back/methods/vn-user/specs/signIn.js
index 64e4d55f5..b4d619ced 100644
--- a/back/methods/vn-user/specs/signIn.js
+++ b/back/methods/vn-user/specs/signIn.js
@@ -1,6 +1,6 @@
const {models} = require('vn-loopback/server/server');
-fdescribe('account login()', () => {
+describe('account login()', () => {
const employeeId = 1;
const unauthCtx = {
req: {
diff --git a/back/methods/vn-user/specs/signOut.js b/back/methods/vn-user/specs/signOut.js
index 3f224b2ff..e6ca1f156 100644
--- a/back/methods/vn-user/specs/signOut.js
+++ b/back/methods/vn-user/specs/signOut.js
@@ -1,12 +1,12 @@
const {models} = require('vn-loopback/server/server');
-describe('VnUser signOut()', () => {
+fdescribe('VnUser signOut()', () => {
it('should logout and remove token after valid login', async() => {
let loginResponse = await app.models.VnUser.validateLogin('buyer', 'nightmare');
let accessToken = await app.models.AccessToken.findById(loginResponse.token);
let ctx = {req: {accessToken: accessToken}};
- let logoutResponse = await models.VnUser.signOut(ctx);
+ let logoutResponse = await models.VnUser.logout(ctx);
let tokenAfterLogout = await models.AccessToken.findById(loginResponse.token);
expect(logoutResponse).toBeTrue();
diff --git a/back/methods/vn-user/validate-auth.js b/back/methods/vn-user/validate-auth.js
index 1f906f4a6..312f1347a 100644
--- a/back/methods/vn-user/validate-auth.js
+++ b/back/methods/vn-user/validate-auth.js
@@ -68,6 +68,6 @@ module.exports = Self => {
await authCode.destroy();
- return Self.login(username, password);
+ return Self.validateLogin(username, password);
};
};
diff --git a/back/models/vn-user.js b/back/models/vn-user.js
index 84ba11794..e59c99fd1 100644
--- a/back/models/vn-user.js
+++ b/back/models/vn-user.js
@@ -5,11 +5,12 @@ const {Email} = require('vn-print');
module.exports = function(Self) {
vnModel(Self);
- require('../methods/vn-user/signIn')(Self);
+ require('../methods/vn-user/sign-in')(Self);
require('../methods/vn-user/acl')(Self);
require('../methods/vn-user/recover-password')(Self);
require('../methods/vn-user/validate-token')(Self);
require('../methods/vn-user/privileges')(Self);
+ require('../methods/vn-user/validate-auth')(Self);
// Validations
@@ -107,4 +108,45 @@ module.exports = function(Self) {
return email.send();
});
+
+ Self.validateLogin = async function(user, password) {
+ let $ = Self.app.models;
+ let token;
+ let usesEmail = user.indexOf('@') !== -1;
+
+ let userInfo = usesEmail
+ ? {email: user}
+ : {username: user};
+ let instance = await $.VnUser.findOne({
+ fields: ['username', 'password'],
+ where: userInfo
+ });
+
+ let where = usesEmail
+ ? {email: user}
+ : {name: user};
+ let vnUser = await $.VnUser.findOne({
+ fields: ['active'],
+ where
+ });
+
+ let validCredentials = instance && (
+ await instance.hasPassword(password)
+ );
+
+ if (validCredentials) {
+ if (!vnUser.active)
+ throw new UserError('User disabled');
+
+ try {
+ await $.Account.sync(instance.username, password);
+ } catch (err) {
+ console.warn(err);
+ }
+ }
+
+ let loginInfo = Object.assign({password}, userInfo);
+ token = await $.VnUser.login(loginInfo, 'user');
+ return {token: token.id};
+ };
};
diff --git a/db/changes/231601/00-userAcl.sql b/db/changes/231601/00-userAcl.sql
index 64803bf18..b75a22315 100644
--- a/db/changes/231601/00-userAcl.sql
+++ b/db/changes/231601/00-userAcl.sql
@@ -3,8 +3,7 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('VnUser', '*', '*', 'ALLOW', 'ROLE', 'employee'),
('VnUser','acl','READ','ALLOW','ROLE','account'),
('VnUser','getCurrentUserData','READ','ALLOW','ROLE','account'),
- ('VnUser','changePassword', 'WRITE', 'ALLOW', 'ROLE', 'account'),
- ('Account','exists','READ','ALLOW','ROLE','account');
+ ('VnUser','changePassword', 'WRITE', 'ALLOW', 'ROLE', 'account');
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES
From c3443ecc7cef98304bb894244a51d5e838c417f6 Mon Sep 17 00:00:00 2001
From: joan
Date: Tue, 18 Apr 2023 14:37:20 +0200
Subject: [PATCH 012/143] Updated e2e
---
back/methods/vn-user/specs/signOut.js | 42 -------------------
.../vn-user/specs/validate-auth.spec.js | 4 +-
..._smartTable_searchBar_integrations.spec.js | 5 ++-
front/core/services/auth.js | 2 +-
modules/account/back/methods/account/login.js | 2 +-
5 files changed, 7 insertions(+), 48 deletions(-)
delete mode 100644 back/methods/vn-user/specs/signOut.js
diff --git a/back/methods/vn-user/specs/signOut.js b/back/methods/vn-user/specs/signOut.js
deleted file mode 100644
index e6ca1f156..000000000
--- a/back/methods/vn-user/specs/signOut.js
+++ /dev/null
@@ -1,42 +0,0 @@
-const {models} = require('vn-loopback/server/server');
-
-fdescribe('VnUser signOut()', () => {
- it('should logout and remove token after valid login', async() => {
- let loginResponse = await app.models.VnUser.validateLogin('buyer', 'nightmare');
- let accessToken = await app.models.AccessToken.findById(loginResponse.token);
- let ctx = {req: {accessToken: accessToken}};
-
- let logoutResponse = await models.VnUser.logout(ctx);
- let tokenAfterLogout = await models.AccessToken.findById(loginResponse.token);
-
- expect(logoutResponse).toBeTrue();
- expect(tokenAfterLogout).toBeNull();
- });
-
- it('should throw a 401 error when token is invalid', async() => {
- let error;
- let ctx = {req: {accessToken: {id: 'invalidToken'}}};
-
- try {
- response = await models.VnUser.signOut(ctx);
- } catch (e) {
- error = e;
- }
-
- expect(error).toBeDefined();
- expect(error.statusCode).toBe(401);
- });
-
- it('should throw an error when no token is passed', async() => {
- let error;
- let ctx = {req: {accessToken: null}};
-
- try {
- response = await models.VnUser.signOut(ctx);
- } catch (e) {
- error = e;
- }
-
- expect(error).toBeDefined();
- });
-});
diff --git a/back/methods/vn-user/specs/validate-auth.spec.js b/back/methods/vn-user/specs/validate-auth.spec.js
index cc2eea092..958770b4b 100644
--- a/back/methods/vn-user/specs/validate-auth.spec.js
+++ b/back/methods/vn-user/specs/validate-auth.spec.js
@@ -8,7 +8,7 @@ describe('account validateAuth()', () => {
let error;
try {
- await models.Account.validateAuth(ctx, 'developer', 'nightmare', '123456');
+ await models.VnUser.validateAuth(ctx, 'developer', 'nightmare', '123456');
} catch (e) {
error = e;
}
@@ -28,7 +28,7 @@ describe('account validateAuth()', () => {
code: '555555',
expires: Date.vnNow() + (60 * 1000)
});
- await models.Account.validateAuth(ctx, 'developer', 'nightmare', '555555');
+ await models.VnUser.validateAuth(ctx, 'developer', 'nightmare', '555555');
await authCode.destroy();
} catch (e) {
error = e;
diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js
index a3d747f1c..b2c2291c6 100644
--- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js
+++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js
@@ -75,11 +75,12 @@ describe('SmartTable SearchBar integration', () => {
});
});
- describe('as orders', () => {
+ // #5573 - The amount of rows differs when loading from side menu
+ // https://redmine.verdnatura.es/issues/5573
+ xdescribe('as orders', () => {
it('should order by first id', async() => {
await page.loginAndModule('developer', 'item');
await page.accessToSection('item.fixedPrice');
- await page.doSearch();
const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value');
diff --git a/front/core/services/auth.js b/front/core/services/auth.js
index 2ab2caa62..c1242209e 100644
--- a/front/core/services/auth.js
+++ b/front/core/services/auth.js
@@ -59,7 +59,7 @@ export default class Auth {
password: password || undefined
};
- return this.$http.post('VnUsers/signin', params).then(
+ return this.$http.post('Accounts/login', params).then(
json => this.onLoginOk(json, remember));
}
diff --git a/modules/account/back/methods/account/login.js b/modules/account/back/methods/account/login.js
index c3218172c..a512b5330 100644
--- a/modules/account/back/methods/account/login.js
+++ b/modules/account/back/methods/account/login.js
@@ -23,5 +23,5 @@ module.exports = Self => {
}
});
- Self.login = async(user, password) => Self.app.models.VnUser.signIn(user, password);
+ Self.login = async(user, password) => Self.app.models.VnUser.validateLogin(user, password);
};
From c1ea1acc8c5147fbbc161cb6726b730e4607b4a0 Mon Sep 17 00:00:00 2001
From: alexm
Date: Wed, 26 Apr 2023 13:49:08 +0200
Subject: [PATCH 013/143] refs #4614 fear(ticket): add 'set weight'
funcionality
---
db/changes/231601/00-ticketWeight.sql | 7 ++
db/dump/fixtures.sql | 66 +++++++++----------
modules/ticket/back/models/ticket.json | 3 +
.../ticket/front/descriptor-menu/index.html | 23 +++++++
modules/ticket/front/descriptor-menu/index.js | 9 +++
modules/ticket/front/summary/index.html | 5 ++
.../invoice-incoterms/sql/incoterms.sql | 53 +++++++--------
7 files changed, 104 insertions(+), 62 deletions(-)
create mode 100644 db/changes/231601/00-ticketWeight.sql
diff --git a/db/changes/231601/00-ticketWeight.sql b/db/changes/231601/00-ticketWeight.sql
new file mode 100644
index 000000000..188804348
--- /dev/null
+++ b/db/changes/231601/00-ticketWeight.sql
@@ -0,0 +1,7 @@
+UPDATE vn.ticket t
+ JOIN vn.ticketObservation o ON o.ticketFk = t.id
+ SET t.weight = cast(REPLACE(o.description, ',', '.') as decimal(10,2))
+ WHERE o.observationTypeFk = 6;
+
+DELETE FROM vn.ticketObservation WHERE observationTypeFk = 6;
+DELETE FROM vn.observationType WHERE id = 6;
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 15ccece35..dc109e4c4 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -688,40 +688,40 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen
(6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3),
(7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5);
-INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`)
+INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`)
VALUES
- (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T2222222', 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T3333333', 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
- (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T4444444', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
- (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE()),
- (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()),
- (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, util.VN_CURDATE()),
- (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE()),
- (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
- (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE()),
- (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE()),
- (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()),
- (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE());
+ (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1),
+ (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2),
+ (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T2222222', 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL),
+ (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T3333333', 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL),
+ (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T4444444', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL),
+ (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL),
+ (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL),
+ (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL),
+ (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, util.VN_CURDATE(), NULL),
+ (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL),
+ (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
+ (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
+ (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL),
+ (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
+ (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL),
+ (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL),
+ (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL);
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json
index b2e87362f..ec4193bed 100644
--- a/modules/ticket/back/models/ticket.json
+++ b/modules/ticket/back/models/ticket.json
@@ -60,6 +60,9 @@
},
"totalWithoutVat": {
"type": "number"
+ },
+ "weight": {
+ "type": "number"
}
},
"relations": {
diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html
index c2ebc3e3a..64204feb7 100644
--- a/modules/ticket/front/descriptor-menu/index.html
+++ b/modules/ticket/front/descriptor-menu/index.html
@@ -148,6 +148,12 @@
translate>
Refund all
+
+ Set ticket weight
+
@@ -341,3 +347,20 @@
question="Are you sure you want to replace this delivery note?"
message="Already exist signed delivery note">
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js
index 1a88b00d5..c9cad9bd2 100644
--- a/modules/ticket/front/descriptor-menu/index.js
+++ b/modules/ticket/front/descriptor-menu/index.js
@@ -335,6 +335,15 @@ class Controller extends Section {
this.vnApp.showSuccess(this.$t('PDF sent!'));
});
}
+
+ setTicketWeight(weight) {
+ return this.$http.patch(`Tickets/${this.ticket.id}`, {weight})
+ .then(() => {
+ this.$.setTicketWeight.hide();
+ this.vnApp.showSuccess(this.$t('Data saved!'));
+ this.reload();
+ });
+ }
}
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html
index 97055208b..dd0e94f42 100644
--- a/modules/ticket/front/summary/index.html
+++ b/modules/ticket/front/summary/index.html
@@ -65,6 +65,11 @@
{{$ctrl.summary.refFk | dashIfEmpty}}
+
+
+ {{$ctrl.summary.weight | dashIfEmpty}}
+
+
Date: Tue, 9 May 2023 07:11:21 +0200
Subject: [PATCH 014/143] correct folder
---
db/changes/232001/00-authCode.sql | 27 +++++++++++++++++++++++
db/changes/232001/00-department.sql | 24 ++++++++++++++++++++
db/changes/{231801 => 232001}/00-user.sql | 0
3 files changed, 51 insertions(+)
create mode 100644 db/changes/232001/00-authCode.sql
create mode 100644 db/changes/232001/00-department.sql
rename db/changes/{231801 => 232001}/00-user.sql (100%)
diff --git a/db/changes/232001/00-authCode.sql b/db/changes/232001/00-authCode.sql
new file mode 100644
index 000000000..0415c90f0
--- /dev/null
+++ b/db/changes/232001/00-authCode.sql
@@ -0,0 +1,27 @@
+create table `salix`.`authCode`
+(
+ userFk int UNSIGNED not null,
+ code int not null,
+ expires TIMESTAMP not null,
+ constraint authCode_pk
+ primary key (userFk),
+ constraint authCode_unique
+ unique (code),
+ constraint authCode_user_id_fk
+ foreign key (userFk) references `account`.`user` (id)
+ on update cascade on delete cascade
+);
+
+create table `salix`.`userAccess`
+(
+ userFk int UNSIGNED not null,
+ ip VARCHAR(25) not null,
+ agent text null,
+ platform VARCHAR(25) null,
+ browser VARCHAR(25) null,
+ constraint userAccess_pk
+ primary key (userFk),
+ constraint userAccess_user_null_fk
+ foreign key (userFk) references `account`.`user` (id)
+)
+ auto_increment = 0;
\ No newline at end of file
diff --git a/db/changes/232001/00-department.sql b/db/changes/232001/00-department.sql
new file mode 100644
index 000000000..d9a91ee30
--- /dev/null
+++ b/db/changes/232001/00-department.sql
@@ -0,0 +1,24 @@
+alter table `vn`.`department`
+ add `twoFactor` ENUM ('email') null comment 'Default user two-factor auth type';
+
+drop trigger `vn`.`department_afterUpdate`;
+
+DELIMITER $$
+$$
+create definer = root@localhost trigger department_afterUpdate
+ after update
+ on department
+ for each row
+BEGIN
+ IF !(OLD.parentFk <=> NEW.parentFk) THEN
+ UPDATE vn.department_recalc SET isChanged = TRUE;
+ END IF;
+
+ IF !(OLD.twoFactor <=> NEW.twoFactor) THEN
+ UPDATE account.user u
+ JOIN vn.workerDepartment wd ON wd.workerFk = u.id
+ SET u.twoFactor = NEW.twoFactor
+ WHERE wd.departmentFk = NEW.id;
+ END IF;
+END;$$
+DELIMITER ;
diff --git a/db/changes/231801/00-user.sql b/db/changes/232001/00-user.sql
similarity index 100%
rename from db/changes/231801/00-user.sql
rename to db/changes/232001/00-user.sql
From 87e1caa4eb53ac07840755ae1057b5966e5861e6 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Mon, 15 May 2023 10:43:06 +0200
Subject: [PATCH 015/143] refs #5334 department seccion
---
.../front/department/basic-data/index.html | 101 +++++++++++++++++
.../front/department/basic-data/index.js | 27 +++++
.../front/department/basic-data/locale/es.yml | 9 ++
.../front/department/{ => index}/index.html | 3 +-
.../front/department/{ => index}/index.js | 2 +-
modules/worker/front/department/routes.json | 103 ++++++++++++++++++
.../front/department/summary/index.html | 73 +++++++++++++
.../worker/front/department/summary/index.js | 74 +++++++++++++
.../front/department/summary/locale/es.yml | 4 +
modules/worker/front/index.js | 2 +-
modules/worker/front/routes.json | 2 +-
11 files changed, 396 insertions(+), 4 deletions(-)
create mode 100644 modules/worker/front/department/basic-data/index.html
create mode 100644 modules/worker/front/department/basic-data/index.js
create mode 100644 modules/worker/front/department/basic-data/locale/es.yml
rename modules/worker/front/department/{ => index}/index.html (93%)
rename modules/worker/front/department/{ => index}/index.js (98%)
create mode 100644 modules/worker/front/department/routes.json
create mode 100644 modules/worker/front/department/summary/index.html
create mode 100644 modules/worker/front/department/summary/index.js
create mode 100644 modules/worker/front/department/summary/locale/es.yml
diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html
new file mode 100644
index 000000000..d89d88f2e
--- /dev/null
+++ b/modules/worker/front/department/basic-data/index.html
@@ -0,0 +1,101 @@
+
+
+
+
diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js
new file mode 100644
index 000000000..ea75d7b97
--- /dev/null
+++ b/modules/worker/front/department/basic-data/index.js
@@ -0,0 +1,27 @@
+import ngModule from '../module';
+import Section from 'salix/components/section';
+
+class Controller extends Section {
+ constructor($element, $) {
+ super($element, $);
+ this.maritalStatus = [
+ {code: 'M', name: this.$t('Married')},
+ {code: 'S', name: this.$t('Single')}
+ ];
+ }
+ onSubmit() {
+ return this.$.watcher.submit()
+ .then(() => this.card.reload());
+ }
+}
+
+ngModule.vnComponent('vnWorkerBasicData', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ worker: '<'
+ },
+ require: {
+ card: '^vnWorkerCard'
+ }
+});
diff --git a/modules/worker/front/department/basic-data/locale/es.yml b/modules/worker/front/department/basic-data/locale/es.yml
new file mode 100644
index 000000000..edf08de90
--- /dev/null
+++ b/modules/worker/front/department/basic-data/locale/es.yml
@@ -0,0 +1,9 @@
+Marital status: Estado civil
+Origin country: País origen
+Education level: Nivel educación
+SSN: NSS
+Married: Casado/a
+Single: Soltero/a
+Business phone: Teléfono de empresa
+Mobile extension: Extensión móvil
+Locker: Taquilla
diff --git a/modules/worker/front/department/index.html b/modules/worker/front/department/index/index.html
similarity index 93%
rename from modules/worker/front/department/index.html
rename to modules/worker/front/department/index/index.html
index df8630104..9afa90e13 100644
--- a/modules/worker/front/department/index.html
+++ b/modules/worker/front/department/index/index.html
@@ -12,7 +12,8 @@
sort-func="$ctrl.onSort($a, $b)"
on-drop="$ctrl.onDrop($dropped, $dragged)"
on-drag-start="$ctrl.onDragStart(item)"
- on-drag-end="$ctrl.onDragEnd(item)">
+ on-drag-end="$ctrl.onDragEnd(item)"
+ ui-sref="department.card.summary(item)">
{{::item.name}}
diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index/index.js
similarity index 98%
rename from modules/worker/front/department/index.js
rename to modules/worker/front/department/index/index.js
index 15904a963..178299362 100644
--- a/modules/worker/front/department/index.js
+++ b/modules/worker/front/department/index/index.js
@@ -1,4 +1,4 @@
-import ngModule from '../module';
+import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller extends Section {
diff --git a/modules/worker/front/department/routes.json b/modules/worker/front/department/routes.json
new file mode 100644
index 000000000..f6fd46367
--- /dev/null
+++ b/modules/worker/front/department/routes.json
@@ -0,0 +1,103 @@
+{
+ "module": "deparment",
+ "name": "Departments",
+ "icon" : "work",
+ "validations" : true,
+ "dependencies": ["account"],
+ "menus": {
+ "main": [
+ {"state": "deparment.index", "icon": "icon-worker"}
+ ],
+ "card": [
+ {"state": "department.card.basicData", "icon": "settings"},
+ {
+ "icon": "icon-wiki",
+ "external":true,
+ "url": "http://wiki.verdnatura.es",
+ "description": "Wikipedia"
+ },
+ {"state": "worker.card.workerLog", "icon": "history"}
+ ]
+ },
+ "routes": [
+ {
+ "url": "/worker",
+ "state": "worker",
+ "abstract": true,
+ "component": "vn-worker",
+ "description": "Workers"
+ }, {
+ "url": "/index?q",
+ "state": "worker.index",
+ "component": "vn-worker-index",
+ "description": "Workers"
+ }, {
+ "url" : "/summary",
+ "state": "worker.card.summary",
+ "component": "vn-worker-summary",
+ "description": "Summary",
+ "params": {
+ "worker": "$ctrl.worker"
+ }
+ }, {
+ "url": "/:id",
+ "state": "worker.card",
+ "component": "vn-worker-card",
+ "abstract": true,
+ "description": "Detail"
+ }, {
+ "url": "/basic-data",
+ "state": "worker.card.basicData",
+ "component": "vn-worker-basic-data",
+ "description": "Basic data",
+ "params": {
+ "worker": "$ctrl.worker"
+ },
+ "acl": ["hr"]
+ }, {
+ "url" : "/log",
+ "state": "worker.card.workerLog",
+ "component": "vn-worker-log",
+ "description": "Log",
+ "acl": ["salesAssistant"]
+ }, {
+ "url": "/index",
+ "state": "worker.card.note.index",
+ "component": "vn-worker-note",
+ "description": "Notes",
+ "params": {
+ "worker": "$ctrl.worker"
+ },
+ "acl": ["hr"]
+ }, {
+ "url": "/create",
+ "state": "worker.card.note.create",
+ "component": "vn-note-worker-create",
+ "description": "New note"
+ },
+ {
+ "url": "/index",
+ "state": "worker.card.dms.index",
+ "component": "vn-worker-dms-index",
+ "description": "My documentation",
+ "acl": ["employee"]
+ },
+ {
+ "url": "/create",
+ "state": "worker.card.dms.create",
+ "component": "vn-worker-dms-create",
+ "description": "Upload file",
+ "params": {
+ "worker": "$ctrl.worker"
+ },
+ "acl": ["hr"]
+ },
+ {
+ "url": "/create",
+ "state": "worker.create",
+ "component": "vn-worker-create",
+ "description": "New worker",
+ "acl": ["hr"]
+ }
+ ]
+}
diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html
new file mode 100644
index 000000000..de8710a6d
--- /dev/null
+++ b/modules/worker/front/department/summary/index.html
@@ -0,0 +1,73 @@
+
+
+
+
+
+ {{worker.firstName}} {{worker.lastName}}
+
+
+
+
+
+ Basic data
+
+
+
+
+
+
+
+
+
+ {{::worker.boss.nickname}}
+
+
+
+
+
+
+
+
+
+
+
+
+ User data
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
new file mode 100644
index 000000000..c2ad107d5
--- /dev/null
+++ b/modules/worker/front/department/summary/index.js
@@ -0,0 +1,74 @@
+import ngModule from '../module';
+import Summary from 'salix/components/summary';
+
+class Controller extends Summary {
+ get worker() {
+ return this._worker;
+ }
+
+ set worker(value) {
+ this._worker = value;
+ this.$.worker = null;
+ if (!value) return;
+
+ const query = `Workers/${value.id}`;
+ const filter = {
+ include: [
+ {
+ relation: 'user',
+ scope: {
+ fields: ['name', 'roleFk'],
+ include: [{
+ relation: 'role',
+ scope: {
+ fields: ['name']
+ }
+ },
+ {
+ relation: 'emailUser',
+ scope: {
+ fields: ['email']
+ }
+ }]
+ }
+ },
+ {
+ relation: 'client',
+ scope: {fields: ['fi', 'phone']}
+ },
+ {
+ relation: 'boss',
+ scope: {fields: ['id', 'nickname']}
+ },
+ {
+ relation: 'sip',
+ scope: {fields: ['extension']}
+ },
+ {
+ relation: 'department',
+ scope: {
+ include: {
+ relation: 'department'
+ }
+ }
+ }
+ ]
+ };
+
+ this.$http.get(query, {params: {filter}}).then(res => {
+ this.$.worker = res.data;
+ });
+ }
+
+ get isHr() {
+ return this.aclService.hasAny(['hr']);
+ }
+}
+
+ngModule.vnComponent('vnWorkerSummary', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ worker: '<'
+ }
+});
diff --git a/modules/worker/front/department/summary/locale/es.yml b/modules/worker/front/department/summary/locale/es.yml
new file mode 100644
index 000000000..fb9d2e2ca
--- /dev/null
+++ b/modules/worker/front/department/summary/locale/es.yml
@@ -0,0 +1,4 @@
+Business phone: Teléfono de empresa
+Personal phone: Teléfono personal
+Mobile extension: Extensión móvil
+Locker: Taquilla
diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js
index 8fad2c0df..605ec9dde 100644
--- a/modules/worker/front/index.js
+++ b/modules/worker/front/index.js
@@ -11,7 +11,7 @@ import './search-panel';
import './basic-data';
import './pbx';
import './pda';
-import './department';
+import './department/index';
import './calendar';
import './time-control';
import './log';
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 25a0ffbcf..6817d0cef 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -118,7 +118,7 @@
"worker": "$ctrl.worker"
}
}, {
- "url" : "/department",
+ "url" : "/department/department",
"state": "worker.department",
"component": "vn-worker-department",
"description": "Departments",
From 598067f75724482cf10962afb513c18235f13444 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Mon, 15 May 2023 13:15:33 +0200
Subject: [PATCH 016/143] refs #5334 routes
---
front/salix/components/left-menu/left-menu.js | 2 +-
modules/worker/back/models/department.json | 12 ++
.../worker/front/department/card/index.html | 5 +
modules/worker/front/department/card/index.js | 29 +++++
.../front/department/descriptor/index.html | 90 +++++++++++++++
.../front/department/descriptor/index.js | 104 ++++++++++++++++++
.../front/department/descriptor/index.spec.js | 26 +++++
.../worker/front/department/index/index.html | 2 +-
.../worker/front/department/index/index.js | 2 +-
.../worker/front/department/main/index.html | 18 +++
modules/worker/front/department/main/index.js | 9 ++
modules/worker/front/department/routes.json | 103 -----------------
.../front/department/summary/index.html | 44 ++++----
.../worker/front/department/summary/index.js | 52 ++-------
modules/worker/front/routes.json | 28 ++++-
15 files changed, 351 insertions(+), 175 deletions(-)
create mode 100644 modules/worker/front/department/card/index.html
create mode 100644 modules/worker/front/department/card/index.js
create mode 100644 modules/worker/front/department/descriptor/index.html
create mode 100644 modules/worker/front/department/descriptor/index.js
create mode 100644 modules/worker/front/department/descriptor/index.spec.js
create mode 100644 modules/worker/front/department/main/index.html
create mode 100644 modules/worker/front/department/main/index.js
delete mode 100644 modules/worker/front/department/routes.json
diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js
index da545b291..6bec61775 100644
--- a/front/salix/components/left-menu/left-menu.js
+++ b/front/salix/components/left-menu/left-menu.js
@@ -45,7 +45,7 @@ export default class LeftMenu {
if (acl && !this.aclService.hasAny(acl))
continue;
}
-
+ console.log(state, item);
let myItem = {
icon: item.icon,
description: item.description || state.description,
diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json
index c3f627e93..7d8d61d73 100644
--- a/modules/worker/back/models/department.json
+++ b/modules/worker/back/models/department.json
@@ -38,5 +38,17 @@
"hasToMistake": {
"type": "number"
}
+ },
+ "relations": {
+ "client": {
+ "type": "belongsTo",
+ "model": "Client",
+ "foreignKey": "clientFk"
+ },
+ "worker": {
+ "type": "belongsTo",
+ "model": "Worker",
+ "foreignKey": "workerFk"
+ }
}
}
diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html
new file mode 100644
index 000000000..cc1ad59e4
--- /dev/null
+++ b/modules/worker/front/department/card/index.html
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js
new file mode 100644
index 000000000..288c1a8c3
--- /dev/null
+++ b/modules/worker/front/department/card/index.js
@@ -0,0 +1,29 @@
+import ngModule from '../module';
+import ModuleCard from 'salix/components/module-card';
+
+class Controller extends ModuleCard {
+ reload() {
+ const filter = {
+ fields: ['chatName', 'notificationEmail'],
+ include: [
+ {
+ relation: 'client',
+ scope: {fields: ['name']}
+ },
+ {
+ relation: 'worker',
+ scope: {fields: ['name']}
+ }
+
+ ]
+ };
+
+ this.$http.get(`Departments/${this.$params.id}`, {filter})
+ .then(res => this.department = res.data);
+ }
+}
+
+ngModule.vnComponent('vnWorkerDepartmentCard', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html
new file mode 100644
index 000000000..564c2d4da
--- /dev/null
+++ b/modules/worker/front/department/descriptor/index.html
@@ -0,0 +1,90 @@
+
+
\ No newline at end of file
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js
new file mode 100644
index 000000000..af57643b7
--- /dev/null
+++ b/modules/worker/front/department/descriptor/index.js
@@ -0,0 +1,104 @@
+import ngModule from '../module';
+import Descriptor from 'salix/components/descriptor';
+
+class Controller extends Descriptor {
+ constructor($element, $, $rootScope) {
+ super($element, $);
+ this.$rootScope = $rootScope;
+ }
+
+ // get worker() {
+ // return this.entity;
+ // }
+
+ // set worker(value) {
+ // this.entity = value;
+
+ // if (value)
+ // this.getIsExcluded();
+ // }
+
+ // get excluded() {
+ // return this.entity.excluded;
+ // }
+
+ // set excluded(value) {
+ // this.entity.excluded = value;
+ // }
+
+ // getIsExcluded() {
+ // this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
+ // this.excluded = data.data.exists;
+ // });
+ // }
+
+ // handleExcluded() {
+ // if (this.excluded) {
+ // this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
+ // this.excluded = false;
+ // } else {
+ // this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
+ // this.excluded = true;
+ // }
+ // }
+
+ // loadData() {
+ // const filter = {
+ // include: [
+ // {
+ // relation: 'user',
+ // scope: {
+ // fields: ['name'],
+ // include: {
+ // relation: 'emailUser',
+ // scope: {
+ // fields: ['email']
+ // }
+ // }
+ // }
+ // }, {
+ // relation: 'client',
+ // scope: {
+ // fields: ['fi']
+ // }
+ // }, {
+ // relation: 'sip',
+ // scope: {
+ // fields: ['extension']
+ // }
+ // }, {
+ // relation: 'department',
+ // scope: {
+ // include: {
+ // relation: 'department'
+ // }
+ // }
+ // }
+ // ]
+ // };
+
+ // return this.getData(`Workers/${this.id}`, {filter})
+ // .then(res => this.entity = res.data);
+ // }
+
+ // onUploadResponse() {
+ // const timestamp = Date.vnNew().getTime();
+ // const src = this.$rootScope.imagePath('user', '520x520', this.worker.id);
+ // const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id);
+ // const newSrc = `${src}&t=${timestamp}`;
+ // const newZoomSrc = `${zoomSrc}&t=${timestamp}`;
+
+ // this.$.photo.setAttribute('src', newSrc);
+ // this.$.photo.setAttribute('zoom-image', newZoomSrc);
+ // }
+}
+
+Controller.$inject = ['$element', '$scope', '$rootScope'];
+
+ngModule.vnComponent('vnWorkerDepartmentDescriptor', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ worker: '<'
+ }
+});
diff --git a/modules/worker/front/department/descriptor/index.spec.js b/modules/worker/front/department/descriptor/index.spec.js
new file mode 100644
index 000000000..dfb800415
--- /dev/null
+++ b/modules/worker/front/department/descriptor/index.spec.js
@@ -0,0 +1,26 @@
+import './index.js';
+
+describe('vnWorkerDescriptor', () => {
+ let controller;
+ let $httpBackend;
+
+ beforeEach(ngModule('worker'));
+
+ beforeEach(inject(($componentController, _$httpBackend_) => {
+ $httpBackend = _$httpBackend_;
+ controller = $componentController('vnWorkerDescriptor', {$element: null});
+ }));
+
+ describe('loadData()', () => {
+ it(`should perform a get query to store the worker data into the controller`, () => {
+ const id = 1;
+ const response = 'foo';
+
+ $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response);
+ controller.id = id;
+ $httpBackend.flush();
+
+ expect(controller.worker).toEqual(response);
+ });
+ });
+});
diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html
index 9afa90e13..894583213 100644
--- a/modules/worker/front/department/index/index.html
+++ b/modules/worker/front/department/index/index.html
@@ -13,7 +13,7 @@
on-drop="$ctrl.onDrop($dropped, $dragged)"
on-drag-start="$ctrl.onDragStart(item)"
on-drag-end="$ctrl.onDragEnd(item)"
- ui-sref="department.card.summary(item)">
+ ng-click="department.card.summary($item)">
{{::item.name}}
diff --git a/modules/worker/front/department/index/index.js b/modules/worker/front/department/index/index.js
index 178299362..6b7ab18da 100644
--- a/modules/worker/front/department/index/index.js
+++ b/modules/worker/front/department/index/index.js
@@ -77,7 +77,7 @@ class Controller extends Section {
}
}
-ngModule.vnComponent('vnWorkerDepartment', {
+ngModule.vnComponent('vnWorkerDepartmentIndex', {
template: require('./index.html'),
controller: Controller
});
diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html
new file mode 100644
index 000000000..3ab993e83
--- /dev/null
+++ b/modules/worker/front/department/main/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js
new file mode 100644
index 000000000..75110f749
--- /dev/null
+++ b/modules/worker/front/department/main/index.js
@@ -0,0 +1,9 @@
+import ngModule from '../module';
+import ModuleMain from 'salix/components/module-main';
+
+export default class Worker extends ModuleMain {}
+
+ngModule.vnComponent('vnWorkerDepartment', {
+ controller: Worker,
+ template: require('./index.html')
+});
diff --git a/modules/worker/front/department/routes.json b/modules/worker/front/department/routes.json
deleted file mode 100644
index f6fd46367..000000000
--- a/modules/worker/front/department/routes.json
+++ /dev/null
@@ -1,103 +0,0 @@
-{
- "module": "deparment",
- "name": "Departments",
- "icon" : "work",
- "validations" : true,
- "dependencies": ["account"],
- "menus": {
- "main": [
- {"state": "deparment.index", "icon": "icon-worker"}
- ],
- "card": [
- {"state": "department.card.basicData", "icon": "settings"},
- {
- "icon": "icon-wiki",
- "external":true,
- "url": "http://wiki.verdnatura.es",
- "description": "Wikipedia"
- },
- {"state": "worker.card.workerLog", "icon": "history"}
- ]
- },
- "routes": [
- {
- "url": "/worker",
- "state": "worker",
- "abstract": true,
- "component": "vn-worker",
- "description": "Workers"
- }, {
- "url": "/index?q",
- "state": "worker.index",
- "component": "vn-worker-index",
- "description": "Workers"
- }, {
- "url" : "/summary",
- "state": "worker.card.summary",
- "component": "vn-worker-summary",
- "description": "Summary",
- "params": {
- "worker": "$ctrl.worker"
- }
- }, {
- "url": "/:id",
- "state": "worker.card",
- "component": "vn-worker-card",
- "abstract": true,
- "description": "Detail"
- }, {
- "url": "/basic-data",
- "state": "worker.card.basicData",
- "component": "vn-worker-basic-data",
- "description": "Basic data",
- "params": {
- "worker": "$ctrl.worker"
- },
- "acl": ["hr"]
- }, {
- "url" : "/log",
- "state": "worker.card.workerLog",
- "component": "vn-worker-log",
- "description": "Log",
- "acl": ["salesAssistant"]
- }, {
- "url": "/index",
- "state": "worker.card.note.index",
- "component": "vn-worker-note",
- "description": "Notes",
- "params": {
- "worker": "$ctrl.worker"
- },
- "acl": ["hr"]
- }, {
- "url": "/create",
- "state": "worker.card.note.create",
- "component": "vn-note-worker-create",
- "description": "New note"
- },
- {
- "url": "/index",
- "state": "worker.card.dms.index",
- "component": "vn-worker-dms-index",
- "description": "My documentation",
- "acl": ["employee"]
- },
- {
- "url": "/create",
- "state": "worker.card.dms.create",
- "component": "vn-worker-dms-create",
- "description": "Upload file",
- "params": {
- "worker": "$ctrl.worker"
- },
- "acl": ["hr"]
- },
- {
- "url": "/create",
- "state": "worker.create",
- "component": "vn-worker-create",
- "description": "New worker",
- "acl": ["hr"]
- }
- ]
-}
diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html
index de8710a6d..3cffe2f71 100644
--- a/modules/worker/front/department/summary/index.html
+++ b/modules/worker/front/department/summary/index.html
@@ -1,18 +1,18 @@
-
- {{worker.firstName}} {{worker.lastName}}
+ {{department.name}}
@@ -21,34 +21,28 @@
ng-show="!$ctrl.isHr">
Basic data
-
+
-
+
-
+
+ label="Boss:">
{{::worker.boss.nickname}}
-
+
-
-
-
-
-
+
@@ -68,6 +62,6 @@
-
-
+
+
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
index c2ad107d5..ede559d18 100644
--- a/modules/worker/front/department/summary/index.js
+++ b/modules/worker/front/department/summary/index.js
@@ -2,56 +2,28 @@ import ngModule from '../module';
import Summary from 'salix/components/summary';
class Controller extends Summary {
- get worker() {
- return this._worker;
+ get department() {
+ return this._department;
}
- set worker(value) {
- this._worker = value;
- this.$.worker = null;
+ set department(value) {
+ this._department = value;
+ this.$.department = null;
if (!value) return;
- const query = `Workers/${value.id}`;
+ const query = `Departments/${value.id}`;
const filter = {
+ fields: ['chatName', 'notificationEmail'],
include: [
- {
- relation: 'user',
- scope: {
- fields: ['name', 'roleFk'],
- include: [{
- relation: 'role',
- scope: {
- fields: ['name']
- }
- },
- {
- relation: 'emailUser',
- scope: {
- fields: ['email']
- }
- }]
- }
- },
{
relation: 'client',
- scope: {fields: ['fi', 'phone']}
+ scope: {fields: ['name']}
},
{
- relation: 'boss',
- scope: {fields: ['id', 'nickname']}
- },
- {
- relation: 'sip',
- scope: {fields: ['extension']}
- },
- {
- relation: 'department',
- scope: {
- include: {
- relation: 'department'
- }
- }
+ relation: 'worker',
+ scope: {fields: ['name']}
}
+
]
};
@@ -65,7 +37,7 @@ class Controller extends Summary {
}
}
-ngModule.vnComponent('vnWorkerSummary', {
+ngModule.vnComponent('vnDepartmentSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 6817d0cef..34a8a14e3 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -7,7 +7,7 @@
"menus": {
"main": [
{"state": "worker.index", "icon": "icon-worker"},
- {"state": "worker.department", "icon": "work"}
+ {"state": "worker.department.index", "icon": "work"}
],
"card": [
{"state": "worker.card.basicData", "icon": "settings"},
@@ -118,11 +118,31 @@
"worker": "$ctrl.worker"
}
}, {
- "url" : "/department/department",
+ "url": "/department",
"state": "worker.department",
- "component": "vn-worker-department",
- "description": "Departments",
+ "abstract": true,
+ "description":"Departments",
+ "component": "ui-view"
+ }, {
+ "url": "/:id",
+ "state": "worker.department.card",
+ "component": "vn-worker-department-card",
+ "abstract": true,
+ "description": "Detail"
+ }, {
+ "url" : "/index",
+ "state": "worker.department.index",
+ "component": "vn-worker-department-index",
+ "description": "Department",
"acl": ["hr"]
+ }, {
+ "url" : "/summary",
+ "state": "worker.department.card.summary",
+ "component": "vn-worker-department-summary",
+ "description": "Summary",
+ "params": {
+ "department": "$ctrl.department"
+ }
}, {
"url": "/dms",
"state": "worker.card.dms",
From 071849065a41af6d26a25111009ed31b4acdc8e1 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Mon, 15 May 2023 13:55:35 +0200
Subject: [PATCH 017/143] refs #5334 fix main
---
modules/worker/front/department/index.js | 8 ++++++++
modules/worker/front/department/main/index.js | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 modules/worker/front/department/index.js
diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index.js
new file mode 100644
index 000000000..5dcbe4097
--- /dev/null
+++ b/modules/worker/front/department/index.js
@@ -0,0 +1,8 @@
+import './main';
+import './index/';
+import './summary';
+import './card';
+import './descriptor';
+import './create';
+import './basic-data';
+import './search-panel';
diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js
index 75110f749..246f8fe49 100644
--- a/modules/worker/front/department/main/index.js
+++ b/modules/worker/front/department/main/index.js
@@ -1,9 +1,9 @@
import ngModule from '../module';
import ModuleMain from 'salix/components/module-main';
-export default class Worker extends ModuleMain {}
+export default class Department extends ModuleMain {}
ngModule.vnComponent('vnWorkerDepartment', {
- controller: Worker,
+ controller: Department,
template: require('./index.html')
});
From 443821b5c20a0c2b51879d62ec1230144bb9969f Mon Sep 17 00:00:00 2001
From: carlossa
Date: Mon, 15 May 2023 13:59:54 +0200
Subject: [PATCH 018/143] refs #5334 ?q
---
modules/worker/front/routes.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 34a8a14e3..50245b571 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -118,7 +118,7 @@
"worker": "$ctrl.worker"
}
}, {
- "url": "/department",
+ "url": "/department?q",
"state": "worker.department",
"abstract": true,
"description":"Departments",
From fd4d04756a218a8a2f3bfe7e93c6b9b7592ea219 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 16 May 2023 08:54:54 +0200
Subject: [PATCH 019/143] refs #5334 routes index fix
---
front/salix/components/left-menu/left-menu.js | 1 -
modules/worker/front/department/basic-data/index.js | 2 +-
modules/worker/front/department/card/index.js | 2 +-
modules/worker/front/department/descriptor/index.js | 2 +-
modules/worker/front/department/index.js | 4 ++--
modules/worker/front/department/main/index.js | 2 +-
modules/worker/front/department/summary/index.js | 2 +-
modules/worker/front/index.js | 2 +-
modules/worker/front/routes.json | 6 ------
9 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js
index 6bec61775..a0392ccce 100644
--- a/front/salix/components/left-menu/left-menu.js
+++ b/front/salix/components/left-menu/left-menu.js
@@ -45,7 +45,6 @@ export default class LeftMenu {
if (acl && !this.aclService.hasAny(acl))
continue;
}
- console.log(state, item);
let myItem = {
icon: item.icon,
description: item.description || state.description,
diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js
index ea75d7b97..1f2dd848c 100644
--- a/modules/worker/front/department/basic-data/index.js
+++ b/modules/worker/front/department/basic-data/index.js
@@ -1,4 +1,4 @@
-import ngModule from '../module';
+import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller extends Section {
diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js
index 288c1a8c3..c7bf32569 100644
--- a/modules/worker/front/department/card/index.js
+++ b/modules/worker/front/department/card/index.js
@@ -1,4 +1,4 @@
-import ngModule from '../module';
+import ngModule from '../../module';
import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js
index af57643b7..12ec396a6 100644
--- a/modules/worker/front/department/descriptor/index.js
+++ b/modules/worker/front/department/descriptor/index.js
@@ -1,4 +1,4 @@
-import ngModule from '../module';
+import ngModule from '../../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index.js
index 5dcbe4097..3e4db6106 100644
--- a/modules/worker/front/department/index.js
+++ b/modules/worker/front/department/index.js
@@ -3,6 +3,6 @@ import './index/';
import './summary';
import './card';
import './descriptor';
-import './create';
+// import './create';
import './basic-data';
-import './search-panel';
+// import './search-panel';
diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js
index 246f8fe49..3fda47246 100644
--- a/modules/worker/front/department/main/index.js
+++ b/modules/worker/front/department/main/index.js
@@ -1,4 +1,4 @@
-import ngModule from '../module';
+import ngModule from '../../module';
import ModuleMain from 'salix/components/module-main';
export default class Department extends ModuleMain {}
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
index ede559d18..cef13c479 100644
--- a/modules/worker/front/department/summary/index.js
+++ b/modules/worker/front/department/summary/index.js
@@ -1,4 +1,4 @@
-import ngModule from '../module';
+import ngModule from '../../module';
import Summary from 'salix/components/summary';
class Controller extends Summary {
diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js
index 605ec9dde..8fad2c0df 100644
--- a/modules/worker/front/index.js
+++ b/modules/worker/front/index.js
@@ -11,7 +11,7 @@ import './search-panel';
import './basic-data';
import './pbx';
import './pda';
-import './department/index';
+import './department';
import './calendar';
import './time-control';
import './log';
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 50245b571..3f4f1977d 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -129,12 +129,6 @@
"component": "vn-worker-department-card",
"abstract": true,
"description": "Detail"
- }, {
- "url" : "/index",
- "state": "worker.department.index",
- "component": "vn-worker-department-index",
- "description": "Department",
- "acl": ["hr"]
}, {
"url" : "/summary",
"state": "worker.department.card.summary",
From 612d0a2dfbd25173a1f471f4735c49f1abd1b063 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 16 May 2023 09:52:48 +0200
Subject: [PATCH 020/143] refs #5334 fix index
---
modules/worker/front/routes.json | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 3f4f1977d..50245b571 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -129,6 +129,12 @@
"component": "vn-worker-department-card",
"abstract": true,
"description": "Detail"
+ }, {
+ "url" : "/index",
+ "state": "worker.department.index",
+ "component": "vn-worker-department-index",
+ "description": "Department",
+ "acl": ["hr"]
}, {
"url" : "/summary",
"state": "worker.department.card.summary",
From 3dcdbe022361f09e234ed534f04fabe034194f77 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 16 May 2023 11:41:42 +0200
Subject: [PATCH 021/143] refs #5334 summary basic data
---
.../front/department/basic-data/index.html | 88 ++++++++-----------
.../front/department/basic-data/locale/es.yml | 22 +++--
.../worker/front/department/index/index.html | 2 +-
.../front/department/summary/index.html | 36 ++++++--
.../front/department/summary/locale/es.yml | 15 +++-
5 files changed, 89 insertions(+), 74 deletions(-)
diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html
index d89d88f2e..0b381b2f1 100644
--- a/modules/worker/front/department/basic-data/index.html
+++ b/modules/worker/front/department/basic-data/index.html
@@ -1,7 +1,7 @@
-
+
@@ -12,78 +12,62 @@
-
-
-
-
-
-
-
-
-
-
-
-
+ label="Boss department"
+ ng-model="$ctrl.department.workerFk">
+
+
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/worker/front/department/basic-data/locale/es.yml b/modules/worker/front/department/basic-data/locale/es.yml
index edf08de90..ea80cfed1 100644
--- a/modules/worker/front/department/basic-data/locale/es.yml
+++ b/modules/worker/front/department/basic-data/locale/es.yml
@@ -1,9 +1,13 @@
-Marital status: Estado civil
-Origin country: País origen
-Education level: Nivel educación
-SSN: NSS
-Married: Casado/a
-Single: Soltero/a
-Business phone: Teléfono de empresa
-Mobile extension: Extensión móvil
-Locker: Taquilla
+Name: Nombre
+Code: Código
+Chat: Chat
+Email: Email
+Boss department: Jefe del departamento
+Self-consumption customer: Cliente autoconsumo
+Telecommutes: Teletrabaja
+Notificate errors: Notificar errores
+Is on production: Pertenece a producción
+Fill in days without physical check-ins: Rellenar fichadas
+Send check-ins by email: Enviar fichadas por email
+Save: Guardar
+Undo changes: Deshacer cambios
diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html
index 894583213..ad802542c 100644
--- a/modules/worker/front/department/index/index.html
+++ b/modules/worker/front/department/index/index.html
@@ -13,7 +13,7 @@
on-drop="$ctrl.onDrop($dropped, $dragged)"
on-drag-start="$ctrl.onDragStart(item)"
on-drag-end="$ctrl.onDragEnd(item)"
- ng-click="department.card.summary($item)">
+ ng-click="worker.department.card.summary($item)">
{{::item.name}}
diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html
index 3cffe2f71..3ed5a310e 100644
--- a/modules/worker/front/department/summary/index.html
+++ b/modules/worker/front/department/summary/index.html
@@ -2,7 +2,7 @@
@@ -21,17 +21,17 @@
ng-show="!$ctrl.isHr">
Basic data
-
-
-
+ label="Boss department">
@@ -41,11 +41,31 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
Date: Tue, 16 May 2023 12:12:25 +0200
Subject: [PATCH 022/143] refs #5334 fix summary route
---
.../front/department/descriptor/index.html | 20 ++++---------------
.../worker/front/department/main/index.html | 4 +++-
modules/worker/front/routes.json | 13 +++---------
3 files changed, 10 insertions(+), 27 deletions(-)
diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html
index 564c2d4da..05230bd09 100644
--- a/modules/worker/front/department/descriptor/index.html
+++ b/modules/worker/front/department/descriptor/index.html
@@ -1,19 +1,7 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html
index 3ab993e83..2aebd0f4d 100644
--- a/modules/worker/front/department/main/index.html
+++ b/modules/worker/front/department/main/index.html
@@ -15,4 +15,6 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 50245b571..89cafc6e2 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -7,7 +7,7 @@
"menus": {
"main": [
{"state": "worker.index", "icon": "icon-worker"},
- {"state": "worker.department.index", "icon": "work"}
+ {"state": "worker.department", "icon": "work"}
],
"card": [
{"state": "worker.card.basicData", "icon": "settings"},
@@ -120,22 +120,15 @@
}, {
"url": "/department?q",
"state": "worker.department",
- "abstract": true,
"description":"Departments",
- "component": "ui-view"
+ "component": "vn-worker-department"
}, {
"url": "/:id",
"state": "worker.department.card",
"component": "vn-worker-department-card",
"abstract": true,
"description": "Detail"
- }, {
- "url" : "/index",
- "state": "worker.department.index",
- "component": "vn-worker-department-index",
- "description": "Department",
- "acl": ["hr"]
- }, {
+ }, {
"url" : "/summary",
"state": "worker.department.card.summary",
"component": "vn-worker-department-summary",
From 9f9963af5679edcae918134b20031dad4e54035c Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 16 May 2023 13:10:26 +0200
Subject: [PATCH 023/143] refs #5334 descriptor
---
.../front/department/descriptor/index.html | 53 ++------
.../front/department/descriptor/index.js | 125 ++++++------------
2 files changed, 53 insertions(+), 125 deletions(-)
diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html
index 05230bd09..0fa80da50 100644
--- a/modules/worker/front/department/descriptor/index.html
+++ b/modules/worker/front/department/descriptor/index.html
@@ -7,63 +7,30 @@
ng-click="$ctrl.handleExcluded()"
translate
ng-if="!$ctrl.excluded">
- Click to exclude the user from getting disabled
-
-
- Click to allow the user to be disabled
+ Delete
+ {{worker.department.name}}
+ {{worker.department.id}}
+ label="Chat"
+ value="{{$ctrl.worker.department.chatName}}">
+ value="{{$ctrl.worker.department.emailNotification}}">
+ label="Self-consumption customer"
+ value="{{$ctrl.worker.department.clientFK}}">
-
-
+ label="Boss department"
+ value="{{$ctrl.worker.department.workerFk}}">
-
-
-
-
-
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js
index 12ec396a6..937f4c351 100644
--- a/modules/worker/front/department/descriptor/index.js
+++ b/modules/worker/front/department/descriptor/index.js
@@ -7,90 +7,51 @@ class Controller extends Descriptor {
this.$rootScope = $rootScope;
}
- // get worker() {
- // return this.entity;
- // }
+ get department() {
+ return this.entity;
+ }
- // set worker(value) {
- // this.entity = value;
+ set department(value) {
+ this.entity = value;
+ }
+ loadData() {
+ const filter = {
+ include: [
+ {
+ relation: 'user',
+ scope: {
+ fields: ['name'],
+ include: {
+ relation: 'emailUser',
+ scope: {
+ fields: ['email']
+ }
+ }
+ }
+ }, {
+ relation: 'client',
+ scope: {
+ fields: ['fi']
+ }
+ }, {
+ relation: 'sip',
+ scope: {
+ fields: ['extension']
+ }
+ }, {
+ relation: 'department',
+ scope: {
+ include: {
+ relation: 'department'
+ }
+ }
+ }
+ ]
+ };
- // if (value)
- // this.getIsExcluded();
- // }
-
- // get excluded() {
- // return this.entity.excluded;
- // }
-
- // set excluded(value) {
- // this.entity.excluded = value;
- // }
-
- // getIsExcluded() {
- // this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
- // this.excluded = data.data.exists;
- // });
- // }
-
- // handleExcluded() {
- // if (this.excluded) {
- // this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
- // this.excluded = false;
- // } else {
- // this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
- // this.excluded = true;
- // }
- // }
-
- // loadData() {
- // const filter = {
- // include: [
- // {
- // relation: 'user',
- // scope: {
- // fields: ['name'],
- // include: {
- // relation: 'emailUser',
- // scope: {
- // fields: ['email']
- // }
- // }
- // }
- // }, {
- // relation: 'client',
- // scope: {
- // fields: ['fi']
- // }
- // }, {
- // relation: 'sip',
- // scope: {
- // fields: ['extension']
- // }
- // }, {
- // relation: 'department',
- // scope: {
- // include: {
- // relation: 'department'
- // }
- // }
- // }
- // ]
- // };
-
- // return this.getData(`Workers/${this.id}`, {filter})
- // .then(res => this.entity = res.data);
- // }
-
- // onUploadResponse() {
- // const timestamp = Date.vnNew().getTime();
- // const src = this.$rootScope.imagePath('user', '520x520', this.worker.id);
- // const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id);
- // const newSrc = `${src}&t=${timestamp}`;
- // const newZoomSrc = `${zoomSrc}&t=${timestamp}`;
-
- // this.$.photo.setAttribute('src', newSrc);
- // this.$.photo.setAttribute('zoom-image', newZoomSrc);
- // }
+ return this.getData(`Workers/${this.id}`, {filter})
+ .then(res => this.entity = res.data);
+ }
}
Controller.$inject = ['$element', '$scope', '$rootScope'];
From 5c9ee21cfce621f02cb01a4c84bc3cf2a9e2d236 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 16 May 2023 14:00:05 +0200
Subject: [PATCH 024/143] refs #5334 department.card
---
modules/worker/front/department/card/index.html | 2 +-
modules/worker/front/routes.json | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html
index cc1ad59e4..b9ae1a87b 100644
--- a/modules/worker/front/department/card/index.html
+++ b/modules/worker/front/department/card/index.html
@@ -1,5 +1,5 @@
-
+
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 89cafc6e2..4314a6401 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -24,6 +24,8 @@
"description": "Wikipedia"
},
{"state": "worker.card.workerLog", "icon": "history"}
+ ], "department": [
+ {"state": "worker.deparment.card.basicData", "icon": "settings"}
]
},
"keybindings": [
@@ -136,6 +138,14 @@
"params": {
"department": "$ctrl.department"
}
+ }, {
+ "url": "/basic-data",
+ "state": "worker.deparment.card.basicData",
+ "component": "vn-worker-department-basic-data",
+ "description": "Basic data",
+ "params": {
+ "department": "$ctrl.department"
+ }
}, {
"url": "/dms",
"state": "worker.card.dms",
From f63dd0f9a383f10a838e5cd31badf6f4127bf014 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Wed, 17 May 2023 09:05:28 +0200
Subject: [PATCH 025/143] refs #5334 datos
---
modules/worker/front/department/card/index.html | 2 +-
modules/worker/front/department/card/index.js | 3 ++-
modules/worker/front/routes.json | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html
index b9ae1a87b..032939600 100644
--- a/modules/worker/front/department/card/index.html
+++ b/modules/worker/front/department/card/index.html
@@ -1,5 +1,5 @@
-
+
diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js
index c7bf32569..9b1ccf08d 100644
--- a/modules/worker/front/department/card/index.js
+++ b/modules/worker/front/department/card/index.js
@@ -4,7 +4,8 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
const filter = {
- fields: ['chatName', 'notificationEmail'],
+ fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
+ 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'],
include: [
{
relation: 'client',
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index 4314a6401..a24cf9722 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -25,7 +25,7 @@
},
{"state": "worker.card.workerLog", "icon": "history"}
], "department": [
- {"state": "worker.deparment.card.basicData", "icon": "settings"}
+ {"state": "worker.department.card.basicData", "icon": "settings"}
]
},
"keybindings": [
From adafd7444b3363ea752a6808fcae843a47fcca51 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Wed, 17 May 2023 10:04:44 +0200
Subject: [PATCH 026/143] refs #5334 worker-department
---
modules/worker/front/department/card/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html
index 032939600..b9ae1a87b 100644
--- a/modules/worker/front/department/card/index.html
+++ b/modules/worker/front/department/card/index.html
@@ -1,5 +1,5 @@
-
+
From 10e085ca1b1952651814f93b0b68641891372b6b Mon Sep 17 00:00:00 2001
From: carlossa
Date: Fri, 26 May 2023 11:43:51 +0200
Subject: [PATCH 027/143] refs #5334 link department
---
modules/worker/front/department/index/index.html | 9 ++++++---
modules/worker/front/department/summary/index.js | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html
index ad802542c..259f4b8f0 100644
--- a/modules/worker/front/department/index/index.html
+++ b/modules/worker/front/department/index/index.html
@@ -12,9 +12,12 @@
sort-func="$ctrl.onSort($a, $b)"
on-drop="$ctrl.onDrop($dropped, $dragged)"
on-drag-start="$ctrl.onDragStart(item)"
- on-drag-end="$ctrl.onDragEnd(item)"
- ng-click="worker.department.card.summary($item)">
- {{::item.name}}
+ on-drag-end="$ctrl.onDragEnd(item)">
+
+ {{::item.name}}
+
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
index cef13c479..51d5aa969 100644
--- a/modules/worker/front/department/summary/index.js
+++ b/modules/worker/front/department/summary/index.js
@@ -37,7 +37,7 @@ class Controller extends Summary {
}
}
-ngModule.vnComponent('vnDepartmentSummary', {
+ngModule.vnComponent('vnWorkerDepartmentSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
From 2b06c628766ecb95aab894857636fb6b3a0e1c59 Mon Sep 17 00:00:00 2001
From: alexm
Date: Fri, 26 May 2023 12:21:15 +0200
Subject: [PATCH 028/143] refs #5334 left-menu
---
front/salix/components/left-menu/left-menu.js | 3 +++
modules/worker/front/department/basic-data/index.js | 5 +----
modules/worker/front/department/main/index.html | 5 +----
modules/worker/front/routes.json | 4 ++--
4 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js
index a0392ccce..4a9bcc8e3 100644
--- a/front/salix/components/left-menu/left-menu.js
+++ b/front/salix/components/left-menu/left-menu.js
@@ -45,6 +45,9 @@ export default class LeftMenu {
if (acl && !this.aclService.hasAny(acl))
continue;
}
+ console.log('MyItem:', item);
+ console.log('MyState:', state);
+ console.log(item.description, state.description);
let myItem = {
icon: item.icon,
description: item.description || state.description,
diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js
index 1f2dd848c..d9b60c683 100644
--- a/modules/worker/front/department/basic-data/index.js
+++ b/modules/worker/front/department/basic-data/index.js
@@ -15,13 +15,10 @@ class Controller extends Section {
}
}
-ngModule.vnComponent('vnWorkerBasicData', {
+ngModule.vnComponent('vnWorkerDepartmentBasicData', {
template: require('./index.html'),
controller: Controller,
bindings: {
worker: '<'
- },
- require: {
- card: '^vnWorkerCard'
}
});
diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html
index 2aebd0f4d..ee260b516 100644
--- a/modules/worker/front/department/main/index.html
+++ b/modules/worker/front/department/main/index.html
@@ -12,9 +12,6 @@
model="model">
-
-
-
-
\ No newline at end of file
+
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index a24cf9722..41d09ba4f 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -122,8 +122,8 @@
}, {
"url": "/department?q",
"state": "worker.department",
- "description":"Departments",
- "component": "vn-worker-department"
+ "component": "vn-worker-department",
+ "description":"Departments"
}, {
"url": "/:id",
"state": "worker.department.card",
From 07898043521091c33445e35b96064bbdb4985aa2 Mon Sep 17 00:00:00 2001
From: alexm
Date: Fri, 26 May 2023 12:58:03 +0200
Subject: [PATCH 029/143] refs #5334 fix basic-data
---
front/salix/components/left-menu/left-menu.js | 4 +---
.../front/department/descriptor/index.html | 18 +++++++++---------
modules/worker/front/department/index.js | 2 +-
.../worker/front/department/main/index.html | 3 ++-
modules/worker/front/routes.json | 16 ++++++++++------
5 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js
index 4a9bcc8e3..da545b291 100644
--- a/front/salix/components/left-menu/left-menu.js
+++ b/front/salix/components/left-menu/left-menu.js
@@ -45,9 +45,7 @@ export default class LeftMenu {
if (acl && !this.aclService.hasAny(acl))
continue;
}
- console.log('MyItem:', item);
- console.log('MyState:', state);
- console.log(item.description, state.description);
+
let myItem = {
icon: item.icon,
description: item.description || state.description,
diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html
index 0fa80da50..28433e612 100644
--- a/modules/worker/front/department/descriptor/index.html
+++ b/modules/worker/front/department/descriptor/index.html
@@ -1,7 +1,7 @@
+ base-state="worker.department">
{{worker.department.id}}
@@ -39,7 +39,7 @@
-
+
Date: Fri, 26 May 2023 13:25:49 +0200
Subject: [PATCH 031/143] refs #5334 fix checks basic-data
---
modules/worker/front/department/basic-data/index.html | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html
index 0b381b2f1..2406080bf 100644
--- a/modules/worker/front/department/basic-data/index.html
+++ b/modules/worker/front/department/basic-data/index.html
@@ -48,6 +48,7 @@
ng-model="$ctrl.department.clientFk">
+
@@ -60,14 +61,19 @@
label="Is on production"
ng-model="$ctrl.department.isProduction">
+
+
+
+
+
From ceaaece0071108b1096d16eb190be039d781e2b8 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Fri, 26 May 2023 14:08:37 +0200
Subject: [PATCH 032/143] refs #5334 label-value
---
.../front/department/basic-data/index.js | 4 ---
.../front/department/descriptor/index.js | 32 +++++--------------
.../front/department/summary/index.html | 18 ++++-------
.../worker/front/department/summary/index.js | 7 ++--
4 files changed, 20 insertions(+), 41 deletions(-)
diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js
index d9b60c683..d5f988141 100644
--- a/modules/worker/front/department/basic-data/index.js
+++ b/modules/worker/front/department/basic-data/index.js
@@ -4,10 +4,6 @@ import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
- this.maritalStatus = [
- {code: 'M', name: this.$t('Married')},
- {code: 'S', name: this.$t('Single')}
- ];
}
onSubmit() {
return this.$.watcher.submit()
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js
index 937f4c351..eb6489826 100644
--- a/modules/worker/front/department/descriptor/index.js
+++ b/modules/worker/front/department/descriptor/index.js
@@ -16,35 +16,19 @@ class Controller extends Descriptor {
}
loadData() {
const filter = {
+ fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
+ 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'],
include: [
{
- relation: 'user',
- scope: {
- fields: ['name'],
- include: {
- relation: 'emailUser',
- scope: {
- fields: ['email']
- }
- }
- }
- }, {
relation: 'client',
- scope: {
- fields: ['fi']
- }
- }, {
- relation: 'sip',
- scope: {
- fields: ['extension']
- }
+ scope: {fields: ['name']}
+ },
+ {
+ relation: 'worker',
+ scope: {fields: ['name']}
}, {
relation: 'department',
- scope: {
- include: {
- relation: 'department'
- }
- }
+ scope: {fields: ['name']}
}
]
};
diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html
index 6b7ded649..979f01dc0 100644
--- a/modules/worker/front/department/summary/index.html
+++ b/modules/worker/front/department/summary/index.html
@@ -2,9 +2,9 @@
-
+
{{department.name}}
@@ -12,7 +12,7 @@
@@ -24,21 +24,17 @@
-
-
- {{::worker.boss.nickname}}
-
+ label="Boss department"
+ value="{{$ctrl.worker.department.workerFk}}">
-
Date: Fri, 26 May 2023 14:23:34 +0200
Subject: [PATCH 033/143] refs #5334 fix hasToSendMail
---
modules/worker/front/department/card/index.js | 2 +-
modules/worker/front/department/descriptor/index.js | 2 +-
modules/worker/front/department/summary/index.js | 9 +++++----
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js
index 9b1ccf08d..72b0876a0 100644
--- a/modules/worker/front/department/card/index.js
+++ b/modules/worker/front/department/card/index.js
@@ -5,7 +5,7 @@ class Controller extends ModuleCard {
reload() {
const filter = {
fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
- 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'],
+ 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'],
include: [
{
relation: 'client',
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js
index eb6489826..31a37e338 100644
--- a/modules/worker/front/department/descriptor/index.js
+++ b/modules/worker/front/department/descriptor/index.js
@@ -17,7 +17,7 @@ class Controller extends Descriptor {
loadData() {
const filter = {
fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
- 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'],
+ 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'],
include: [
{
relation: 'client',
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
index f40214be5..3c78e329f 100644
--- a/modules/worker/front/department/summary/index.js
+++ b/modules/worker/front/department/summary/index.js
@@ -14,7 +14,7 @@ class Controller extends Summary {
const query = `Departments/${value.id}`;
const filter = {
fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
- 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'],
+ 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'],
include: [
{
relation: 'client',
@@ -30,9 +30,10 @@ class Controller extends Summary {
]
};
- this.$http.get(query, {params: {filter}}).then(res => {
- this.$.worker = res.data;
- });
+ this.$http.get(query, {params: {filter}})
+ .then(res => {
+ this.$.department = res.data;
+ });
}
get isHr() {
From 2a78a912eb9d1cf3d1a95761c8155043371976c2 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Fri, 26 May 2023 14:35:12 +0200
Subject: [PATCH 034/143] refs #5334 worker.department
---
modules/worker/front/department/summary/index.html | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html
index 979f01dc0..850b1e9f4 100644
--- a/modules/worker/front/department/summary/index.html
+++ b/modules/worker/front/department/summary/index.html
@@ -22,23 +22,23 @@
Basic data
+ value="{{worker.department.department.name}}">
+ value="{{worker.department.department.code}}">
+ value="{{worker.department.department.chat}}">
+ value="{{$ctrl.worker.department.department.workerFk}}">
+ value="{{worker.department.department.notificationEmail}}">
+ value="{{worker.department.department.workerFk}}">
From f4e877dadad25ce9e07a6da01de34b7c62495032 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Mon, 29 May 2023 14:46:39 +0200
Subject: [PATCH 035/143] refs #5334 refactor summary
---
.../front/department/basic-data/index.js | 12 +-----
.../worker/front/department/summary/index.js | 40 ++++++-------------
2 files changed, 15 insertions(+), 37 deletions(-)
diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js
index d5f988141..31f50ee85 100644
--- a/modules/worker/front/department/basic-data/index.js
+++ b/modules/worker/front/department/basic-data/index.js
@@ -1,20 +1,12 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
-class Controller extends Section {
- constructor($element, $) {
- super($element, $);
- }
- onSubmit() {
- return this.$.watcher.submit()
- .then(() => this.card.reload());
- }
-}
+export default class Controller extends Section {}
ngModule.vnComponent('vnWorkerDepartmentBasicData', {
template: require('./index.html'),
controller: Controller,
bindings: {
- worker: '<'
+ department: '<'
}
});
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
index 3c78e329f..4897c27a2 100644
--- a/modules/worker/front/department/summary/index.js
+++ b/modules/worker/front/department/summary/index.js
@@ -1,39 +1,25 @@
import ngModule from '../../module';
-import Summary from 'salix/components/summary';
-
-class Controller extends Summary {
- get department() {
- return this._department;
- }
+import Component from 'core/lib/component';
+class Controller extends Component {
set department(value) {
this._department = value;
- this.$.department = null;
+ this.$.summary = null;
if (!value) return;
- const query = `Departments/${value.id}`;
const filter = {
- fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
- 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'],
include: [
- {
- relation: 'client',
- scope: {fields: ['name']}
- },
- {
- relation: 'worker',
- scope: {fields: ['name']}
- }, {
- relation: 'department',
- scope: {fields: ['name']}
- }
+ {relation: 'client'},
+ {relation: 'worker'},
+ {relation: 'department'}
]
};
- this.$http.get(query, {params: {filter}})
- .then(res => {
- this.$.department = res.data;
- });
+ this.$http.get(`Departments/${value.id}`, {filter})
+ .then(res => this.$.summary = res.data);
+ }
+ get department() {
+ return this._department;
}
get isHr() {
@@ -41,10 +27,10 @@ class Controller extends Summary {
}
}
-ngModule.vnComponent('vnWorkerDepartmentSummary', {
+ngModule.component('vnWorkerDepartmentSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
- worker: '<'
+ department: '<'
}
});
From 2d6f0bb2ce10e5847c42145a93f5846e9395a011 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Mon, 29 May 2023 15:27:50 +0200
Subject: [PATCH 036/143] refs #5334 front fix
---
modules/worker/back/models/department.json | 3 +-
.../front/department/summary/index.html | 33 ++++++++-----------
2 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json
index 7d8d61d73..855124620 100644
--- a/modules/worker/back/models/department.json
+++ b/modules/worker/back/models/department.json
@@ -9,7 +9,8 @@
"properties": {
"id": {
"id": true,
- "type": "number"
+ "type": "number",
+ "description": "Identifier"
},
"code": {
"type": "string"
diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html
index 850b1e9f4..6950ea7c1 100644
--- a/modules/worker/front/department/summary/index.html
+++ b/modules/worker/front/department/summary/index.html
@@ -1,18 +1,11 @@
-
-
-
-
- {{department.name}}
+ {{summary.name}}
@@ -22,45 +15,45 @@
Basic data
+ value="{{summary.name}}">
+ value="{{summary.code}}">
+ value="{{summary.chat}}">
+ value="{{$summary.workerFk}}">
+ value="{{summary.notificationEmail}}">
+ value="{{summary.workerFk}}">
+ ng-model="$ctrl.summary.isTeleworking">
+ ng-model="$ctrl.summary.hasToMistake">
+ ng-model="$ctrl.summary.isProduction">
+ ng-model="$ctrl.summary.hasToRefill">
+ ng-model="$ctrl.summary.hasToSendMail">
From d9a64211de6f1f46ebdbe5f63b6ba453ddf60a32 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 30 May 2023 09:16:02 +0200
Subject: [PATCH 037/143] refs #5334 fix descriptor, basic-data, summary
---
modules/worker/back/models/department.json | 5 ++++-
.../front/department/basic-data/index.html | 3 +--
.../front/department/descriptor/index.html | 12 ++++++------
.../front/department/descriptor/index.js | 7 ++-----
.../worker/front/department/summary/index.html | 18 ++++++++++++------
.../worker/front/department/summary/index.js | 3 +--
modules/worker/front/routes.json | 5 ++---
7 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json
index 855124620..37ec3a3a1 100644
--- a/modules/worker/back/models/department.json
+++ b/modules/worker/back/models/department.json
@@ -8,8 +8,8 @@
},
"properties": {
"id": {
- "id": true,
"type": "number",
+ "id": true,
"description": "Identifier"
},
"code": {
@@ -38,6 +38,9 @@
},
"hasToMistake": {
"type": "number"
+ },
+ "isTeleworking": {
+ "type": "boolean"
}
},
"relations": {
diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html
index 2406080bf..9b82f4ec6 100644
--- a/modules/worker/front/department/basic-data/index.html
+++ b/modules/worker/front/department/basic-data/index.html
@@ -1,9 +1,8 @@
-
+ url="Departments">
diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js
index 4897c27a2..6fbffc852 100644
--- a/modules/worker/front/department/summary/index.js
+++ b/modules/worker/front/department/summary/index.js
@@ -10,8 +10,7 @@ class Controller extends Component {
const filter = {
include: [
{relation: 'client'},
- {relation: 'worker'},
- {relation: 'department'}
+ {relation: 'worker'}
]
};
diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json
index ccba0551a..7ac692391 100644
--- a/modules/worker/front/routes.json
+++ b/modules/worker/front/routes.json
@@ -146,9 +146,8 @@
"component": "vn-worker-department-basic-data",
"description": "Basic data",
"params": {
- "item-type": "$ctrl.itemType"
- },
- "acl": ["buyer"]
+ "department": "$ctrl.department"
+ }
},
{
"url": "/dms",
From 107d8d1edd808f2873ddadd502374ee9382d1fe3 Mon Sep 17 00:00:00 2001
From: carlossa
Date: Tue, 30 May 2023 10:13:49 +0200
Subject: [PATCH 038/143] refs #5334 model y vista
---
modules/worker/back/models/department.json | 9 +++++++++
modules/worker/front/department/basic-data/index.html | 2 +-
modules/worker/front/department/summary/index.html | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json
index 37ec3a3a1..edeba74f7 100644
--- a/modules/worker/back/models/department.json
+++ b/modules/worker/back/models/department.json
@@ -41,6 +41,15 @@
},
"isTeleworking": {
"type": "boolean"
+ },
+ "hasToRefill": {
+ "type": "boolean"
+ },
+ "hasToSendMail": {
+ "type": "boolean"
+ },
+ "isProduction": {
+ "type": "boolean"
}
},
"relations": {
diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html
index 9b82f4ec6..ef5760be2 100644
--- a/modules/worker/front/department/basic-data/index.html
+++ b/modules/worker/front/department/basic-data/index.html
@@ -4,7 +4,7 @@
form="form"
url="Departments">
-