5334-editDepartment #1521

Merged
carlossa merged 84 commits from 5334-editDepartment into dev 2023-07-06 07:09:06 +00:00
33 changed files with 728 additions and 106 deletions

View File

@ -894,6 +894,18 @@ export default {
extension: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(5) > section > span',
},
department: {
firstDepartment: 'vn-worker-department-index vn-card > vn-treeview vn-treeview-childs vn-treeview-childs vn-treeview-childs a'
},
departmentSummary: {
header: 'vn-worker-department-summary h5',
name: 'vn-worker-department-summary vn-horizontal > vn-one > vn-vertical > vn-label-value:nth-child(1) > section > span',
code: 'vn-worker-department-summary vn-horizontal > vn-one > vn-vertical > vn-label-value:nth-child(2) > section > span',
chat: 'vn-worker-department-summary vn-horizontal > vn-one > vn-vertical > vn-label-value:nth-child(3) > section > span',
bossDepartment: 'vn-worker-department-summary vn-horizontal > vn-one > vn-vertical > vn-label-value:nth-child(4) > section > span',
email: 'vn-worker-department-summary vn-horizontal > vn-one > vn-vertical > vn-label-value:nth-child(5) > section > span',
clientFk: 'vn-worker-department-summary vn-horizontal > vn-one > vn-vertical > vn-label-value:nth-child(6) > section > span',
},
workerBasicData: {
name: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.firstName"]',
surname: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.lastName"]',
@ -901,6 +913,13 @@ export default {
locker: 'vn-worker-basic-data vn-input-number[ng-model="$ctrl.worker.locker"]',
saveButton: 'vn-worker-basic-data button[type=submit]'
},
departmentBasicData: {
Name: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.name"]',
Code: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.code"]',
Chat: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.chat"]',
Email: 'vn-worker-department-basic-data vn-textfield[ng-model="$ctrl.department.notificationEmail"]',
saveButton: 'vn-worker-department-basic-data button[type=submit]'
},
workerNotes: {
addNoteFloatButton: 'vn-worker-note vn-icon[icon="add"]',
note: 'vn-note-worker-create vn-textarea[ng-model="$ctrl.note.text"]',

View File

@ -0,0 +1,29 @@
import selectors from '../../../helpers/selectors.js';
import getBrowser from '../../../helpers/puppeteer';
describe('department summary path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('hr', 'worker');
await page.accessToSection('worker.department');
await page.doSearch('INFORMATICA');
await page.click(selectors.department.firstDepartment);
});
afterAll(async() => {
await browser.close();
});
it('should reach the employee summary section and check all properties', async() => {
expect(await page.waitToGetProperty(selectors.departmentSummary.header, 'innerText')).toEqual('INFORMATICA');
expect(await page.getProperty(selectors.departmentSummary.name, 'innerText')).toEqual('INFORMATICA');
expect(await page.getProperty(selectors.departmentSummary.code, 'innerText')).toEqual('it');
expect(await page.getProperty(selectors.departmentSummary.chat, 'innerText')).toEqual('informatica-cau');
expect(await page.getProperty(selectors.departmentSummary.bossDepartment, 'innerText')).toEqual('');
expect(await page.getProperty(selectors.departmentSummary.email, 'innerText')).toEqual('-');
expect(await page.getProperty(selectors.departmentSummary.clientFk, 'innerText')).toEqual('-');
});
});

View File

@ -0,0 +1,43 @@
import getBrowser from '../../../helpers/puppeteer';
import selectors from '../../../helpers/selectors.js';
const $ = {
form: 'vn-worker-department-basic-data form',
};
describe('department summary path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('hr', 'worker');
await page.accessToSection('worker.department');
await page.doSearch('INFORMATICA');
await page.click(selectors.department.firstDepartment);
});
beforeEach(async() => {
await page.accessToSection('worker.department.card.basicData');
});
afterAll(async() => {
await browser.close();
});
it(`should edit the department basic data and confirm the department data was edited`, async() => {
const values = {
Name: 'Informatica',
Code: 'IT',
Chat: 'informatica-cau',
Email: 'it@verdnatura.es',
};
await page.fillForm($.form, values);
const formValues = await page.fetchForm($.form, Object.keys(values));
const message = await page.sendForm($.form, values);
expect(message.isSuccess).toBeTrue();
expect(formValues).toEqual(values);
});
});

View File

@ -147,14 +147,12 @@
"Receipt's bank was not found": "Receipt's bank was not found",
"This receipt was not compensated": "This receipt was not compensated",
"Client's email was not found": "Client's email was not found",
"Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº {{id}}",
"Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d",
"It is not possible to modify tracked sales": "It is not possible to modify tracked sales",
"It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo",
"It is not possible to modify cloned sales": "It is not possible to modify cloned sales",
"Valid priorities: 1,2,3": "Valid priorities: 1,2,3",
"Warehouse inventory not set": "Almacén inventario no está establecido",
"Component cost not set": "Componente coste no está estabecido",
"Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2",
"Description cannot be blank": "Description cannot be blank",
"company": "Company",
"country": "Country",
@ -177,5 +175,6 @@
"Invalid quantity": "Invalid quantity",
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address",
"The renew period has not been exceeded": "The renew period has not been exceeded"
"The renew period has not been exceeded": "The renew period has not been exceeded",
"Valid priorities": "Valid priorities: %d"
}

View File

@ -268,7 +268,7 @@
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
"Warehouse inventory not set": "El almacén inventario no está establecido",
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
"Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº {{id}}",
"Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d",
"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",
"Collection does not exist": "La colección no existe",
@ -298,5 +298,6 @@
"Error while generating PDF": "Error al generar PDF",
"Error when sending mail to client": "Error al enviar el correo al cliente",
"Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado"
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado",
"Valid priorities": "Prioridades válidas: %d"
}

es extrany una traduccio amb un numero, a més, quan son tan llargues, la de l'ingles es posa curta tipo "can't delete n3" i ja després es mostra tot.

es extrany una traduccio amb un numero, a més, quan son tan llargues, la de l'ingles es posa curta tipo "can't delete n3" i ja després es mostra tot.

Es una traducció que ve desde DEV que genera a fer els test e2e

Es una traducció que ve desde DEV que genera a fer els test e2e

View File

@ -1,4 +1,4 @@
let UserError = require('vn-loopback/util/user-error');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('new', {
@ -49,7 +49,7 @@ module.exports = Self => {
try {
const itemConfig = await models.ItemConfig.findOne({fields: ['validPriorities']}, myOptions);
if (!itemConfig.validPriorities.includes(params.priority))
throw new UserError(`Valid priorities: ${[...itemConfig.validPriorities]}`);
throw new UserError('Valid priorities', 'VALID_PRIORITIES', [...itemConfig.validPriorities]);
const provisionalName = params.provisionalName;
delete params.provisionalName;

View File

@ -50,7 +50,7 @@ module.exports = Self => {
fields: ['id']}
, myOptions);
if (ticketRefunds.length > 0)
throw new UserError($t('Tickets with associated refunds', {id: ticketRefunds[0].id}));
throw new UserError('Tickets with associated refunds', 'TICKET_REFUND', ticketRefunds[0].id);
// Check if has sales with shelving
const canDeleteTicketWithPartPrepared =

View File

@ -33,7 +33,6 @@ module.exports = Self => {
map.set(node.parentFk, []);
map.get(node.parentFk).push(node);
}
function setLeaves(nodes) {
if (!nodes) return;
for (let node of nodes) {
@ -43,6 +42,7 @@ module.exports = Self => {
}
let leaves = map.get(parentId);
setLeaves(leaves);
return leaves || [];

View File

@ -0,0 +1,10 @@
const models = require('vn-loopback/server/server').models;
describe('department getLeaves()', () => {
const ctx = {req: {accessToken: {userId: 9}}};
it('should return the department and the childs containing the search value', async() => {
let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA');
expect(result.length).toEqual(1);
});
});

View File

@ -8,8 +8,9 @@
},
"properties": {
"id": {
"type": "number",
"id": true,
"type": "number"
"description": "Identifier"
},
"code": {
"type": "string"
@ -37,6 +38,30 @@
},
"hasToMistake": {
"type": "number"
},
"isTeleworking": {
"type": "boolean"
},
"hasToRefill": {
"type": "boolean"
},
"hasToSendMail": {
"type": "boolean"
},
"isProduction": {
"type": "boolean"
}
},
"relations": {
"client": {
"type": "belongsTo",
"model": "Client",
"foreignKey": "clientFk"
},
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
}
}
}

View File

@ -60,7 +60,7 @@
"user": {
"type": "belongsTo",
"model": "VnUser",
"foreignKey": "userFk"
"foreignKey": "id"
},
"boss": {
"type": "belongsTo",

View File

@ -0,0 +1,102 @@
<vn-watcher
vn-id="watcher"
data="$ctrl.department"
form="form"
url="Departments">
</vn-watcher>
<vn-portal slot="topbar">
<vn-searchbar
vn-focus
info="Search departments by id, name or code"
on-search="$ctrl.onSearch($params)"
base-state="worker.department">
</vn-searchbar>
</vn-portal>
<form name="form" ng-submit="watcher.submit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-vertical>
<vn-horizontal>
<vn-textfield
vn-one
label="Name"
ng-model="$ctrl.department.name"
vn-name="Name">
</vn-textfield>
<vn-textfield
vn-one
label="Code"
ng-model="$ctrl.department.code"
vn-name="Code">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Chat"
ng-model="$ctrl.department.chatName"
vn-name="Chat">
</vn-textfield>
<vn-textfield type="Email"
carlossa marked this conversation as resolved Outdated
Outdated
Review

Deberia ser Autocomplete

Deberia ser Autocomplete
vn-one
label="Email"
ng-model="$ctrl.department.notificationEmail"
vn-name="Email">
</vn-textfield>
Outdated
Review

Deberia ser Autocomplete

Deberia ser Autocomplete
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
ng-model="$ctrl.department.workerFk"
url="Workers/activeWithInheritedRole"
show-field="nickname"
search-function="{firstName: $search}"
label="Boss department">
</vn-autocomplete>
<vn-autocomplete
ng-model="$ctrl.department.clientFk"
url="Clients/"
show-field="name"
search-function="{firstName: $search}"
label="Self-consumption customer">
</vn-autocomplete>
carlossa marked this conversation as resolved Outdated

jo posaria teleworking es mes intuitiu per a la gent

No, the term "teleworking" is not incorrect. In fact, "teleworking" and "telecommuting" are often used interchangeably to refer to the practice of working remotely. Both terms describe the same concept of performing work duties from a location outside of a traditional office environment.

While "telecommuting" is more commonly used in North America, "teleworking" is a term that is more prevalent in Europe and other parts of the world. The choice between the two terms may vary depending on regional preferences and cultural norms.

jo posaria teleworking es mes intuitiu per a la gent No, the term "teleworking" is not incorrect. In fact, "teleworking" and "telecommuting" are often used interchangeably to refer to the practice of working remotely. Both terms describe the same concept of performing work duties from a location outside of a traditional office environment. While "telecommuting" is more commonly used in North America, "teleworking" is a term that is more prevalent in Europe and other parts of the world. The choice between the two terms may vary depending on regional preferences and cultural norms.

Consistencia en la terminología: Asegúrate de que estás utilizando terminología consistente en todas tus etiquetas. Por ejemplo, en una etiqueta usas "Teleworking" y en otra "check-ins". Sería más consistente si usas "Telework" y "Check-ins" o "Teleworking" y "Checking in", según corresponda.

agafem telework

Consistencia en la terminología: Asegúrate de que estás utilizando terminología consistente en todas tus etiquetas. Por ejemplo, en una etiqueta usas "Teleworking" y en otra "check-ins". Sería más consistente si usas "Telework" y "Check-ins" o "Teleworking" y "Checking in", según corresponda. agafem telework
</vn-horizontal>
<vn-horizontal>
<vn-check
label="Telework"
ng-model="$ctrl.department.isTeleworking">
</vn-check>
<vn-check
label="Notify on errors"
carlossa marked this conversation as resolved Outdated

chatgpt
dime en ingles una variable para indicar que alguien trabaja en produccion
ChatGPT
La variable para indicar que alguien trabaja en producción podría denominarse worksInProduction.

chatgpt dime en ingles una variable para indicar que alguien trabaja en produccion ChatGPT La variable para indicar que alguien trabaja en producción podría denominarse worksInProduction.
ng-model="$ctrl.department.hasToMistake">
</vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-check
label="worksInProduction"
ng-model="$ctrl.department.isProduction">
</vn-check>
<vn-check
label="Fill in days without physical check-ins"
ng-model="$ctrl.department.hasToRefill">
</vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-check
label="Send check-ins by email"
ng-model="$ctrl.department.hasToSendMail">
</vn-check>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
label="Save">
</vn-submit>
<vn-button
class="cancel"
label="Undo changes"
disabled="!watcher.dataChanged()"
ng-click="watcher.loadOriginalData()">
</vn-button>
</vn-button-bar>
</form>

View File

@ -0,0 +1,10 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
ngModule.vnComponent('vnWorkerDepartmentBasicData', {
carlossa marked this conversation as resolved Outdated
Outdated
Review

Me sona que si no gastes el Controller pots borrar esta linea y...

Me sona que si no gastes el Controller pots borrar esta linea y...
template: require('./index.html'),
controller: Section,
bindings: {
department: '<'
carlossa marked this conversation as resolved Outdated
Outdated
Review

... Aci posar Section (No estic segur)

... Aci posar Section (No estic segur)
}
});

View File

@ -0,0 +1,13 @@
Name: Nombre
Code: Código
Chat: Chat
Email: Email
Boss department: Jefe del departamento
Self-consumption customer: Cliente autoconsumo
Telecommutes: Teletrabaja
Notify on errors: Notificar errores
worksInProduction: Pertenece a producción
Fill in days without physical check-ins: Completar días sin registros físicos
Send check-ins by email: Enviar fichadas por email
Save: Guardar
Undo changes: Deshacer cambios

View File

@ -0,0 +1,5 @@
<vn-portal slot="menu">
<vn-worker-department-descriptor department="$ctrl.department"></vn-worker-department-descriptor>
<vn-left-menu source="department"></vn-left-menu>
</vn-portal>
<ui-view></ui-view>

View File

@ -0,0 +1,39 @@
import ngModule from '../../module';
import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
const filter = {
fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'],
include: [
{
Outdated
Review

Esta mal anidat

Esta mal anidat

A mi si que me apareix bé

A mi si que me apareix bé
relation: 'client',
scope: {
fields: ['id', 'name']
}
}, {
relation: 'worker',
scope: {
fields: ['id', 'firstName', 'lastName'],
include: {
relation: 'user',
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
});

View File

@ -0,0 +1,4 @@
<slot-descriptor>
<vn-worker-department-descriptor>
</vn-worker-department-descriptor>
</slot-descriptor>

View File

@ -0,0 +1,9 @@
import ngModule from '../../module';
import DescriptorPopover from 'salix/components/descriptor-popover';
class Controller extends DescriptorPopover {}
carlossa marked this conversation as resolved
Review

Aci lo mateix de antes (si te dixa en el cas de antes aci tambe deuria)

Aci lo mateix de antes (si te dixa en el cas de antes aci tambe deuria)
ngModule.vnComponent('vnWorkerDepartmentDescriptorPopover', {
slotTemplate: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,49 @@
<vn-descriptor-content
module="worker"
description="$ctrl.department.name"
base-state="worker.department">
<slot-menu>
<vn-item
ng-click="deleteConfirmation.show()"
name="deleteDepartment"
translate>
Delete
</vn-item>
</slot-menu>
<slot-body>
<div class="attributes">
<vn-label-value
label="Chat"
value="{{$ctrl.department.chatName}}">
</vn-label-value>
<vn-label-value
label="Email"
value="{{$ctrl.department.emailNotification}}">
</vn-label-value>
<vn-label-value
label="Self-consumption customer"
value="{{$ctrl.department.client.name}}">
</vn-label-value>
<vn-label-value
label="Boss department"
value="{{$ctrl.department.worker.firstName}}">
</vn-label-value>
</div>
<div class="quicklinks">
<div ng-transclude="btnOne">
<vn-quick-link vn-anchor="{state: 'worker.index', params: {q: {departmentFk: $ctrl.$params.id} } }"
vn-tooltip="Department workers"
alexm marked this conversation as resolved Outdated
Outdated
Review

Si pots una indentacio cap a dins

Si pots una indentacio cap a dins

A mi me apareix bé ja que ho tinc tot en la mateixa linea

A mi me apareix bé ja que ho tinc tot en la mateixa linea
icon="icon-worker">
</vn-quick-link>
</div>
</div>
</slot-body>
</vn-descriptor-content>
<vn-popup vn-id="summary">
<vn-worker-summary worker="$ctrl.worker"></vn-worker-summary>
</vn-popup>
<vn-confirm
vn-id="deleteConfirmation"
on-accept="$ctrl.deleteDepartment()"
question="Are you sure you want to delete this department?">
carlossa marked this conversation as resolved Outdated


Este es el que hi havia en el projecte es sol gastar Are you sure,
posal així per tindreu tot igual

<vn-confirm vn-id="deleteNode" on-accept="$ctrl.onRemoveResponse()" question="Delete department" message="Are you sure you want to delete it?"> </vn-confirm> Este es el que hi havia en el projecte es sol gastar Are you sure, posal així per tindreu tot igual
</vn-confirm>
carlossa marked this conversation as resolved Outdated
Outdated
Review

Este codi si no vas a gastarlo, borral

Este codi si no vas a gastarlo, borral

View File

@ -0,0 +1,45 @@
import ngModule from '../../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
constructor($element, $, $rootScope) {
super($element, $);
this.$rootScope = $rootScope;
}
get department() {
return this.entity;
}
set department(value) {
this.entity = value;
}
filterDepartments(department, event) {
if (event.defaultPrevented) return;
event.preventDefault();
event.stopPropagation();
this.$state.go(`worker.index`,
{q: JSON.stringify({departmentFk: department.id})});
}
deleteDepartment() {
return this.$http.delete(`Departments/${this.id}`)
.then(() => {
this.$state.go('worker.department');
this.vnApp.showSuccess(this.$t('Department deleted.'));
});
}
}
carlossa marked this conversation as resolved Outdated
Outdated
Review

Jo crec que en $ctrl.department ja tens les dades que vols carregades no fa falta que les tornes a demanar

Jo crec que en $ctrl.department ja tens les dades que vols carregades no fa falta que les tornes a demanar
Controller.$inject = ['$element', '$scope', '$rootScope'];
ngModule.vnComponent('vnWorkerDepartmentDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
department: '<'
}
});

View File

@ -1,83 +1,7 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
$postLink() {
this.$.treeview.fetch();
}
onFetch(item) {
const params = item ? {parentId: item.id} : null;
return this.$.model.applyFilter({}, params).then(() => {
return this.$.model.data;
});
}
onSort(a, b) {
return a.name.localeCompare(b.name);
}
onDrop(dropped, dragged) {
const params = dropped ? {parentId: dropped.id} : null;
const query = `departments/${dragged.id}/moveChild`;
this.$http.post(query, params).then(() => {
this.$.treeview.move(dragged, dropped);
});
}
onCreate(parent) {
this.newChild = {
parent: parent,
name: ''
};
this.$.createNode.show();
}
onCreateDialogOpen() {
this.newChild.name = '';
}
onCreateResponse() {
try {
if (!this.newChild.name)
throw new Error(`Name can't be empty`);
const params = {name: this.newChild.name};
const parent = this.newChild.parent;
if (parent && parent.id)
params.parentId = parent.id;
const query = `departments/createChild`;
this.$http.post(query, params).then(res => {
const item = res.data;
item.parent = parent;
this.$.treeview.create(item);
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
return false;
}
return true;
}
onRemove(item) {
this.removedChild = item;
this.$.deleteNode.show();
}
onRemoveResponse() {
const childId = this.removedChild.id;
const path = `departments/${childId}/removeChild`;
this.$http.post(path).then(() => {
this.$.treeview.remove(this.removedChild);
});
}
}
ngModule.vnComponent('vnWorkerDepartment', {
template: require('./index.html'),
controller: Controller
});
import './main';
import './index/';
import './summary';
import './card';
import './descriptor';
import './basic-data';
import './descriptor-popover';

View File

@ -3,6 +3,14 @@
url="departments/getLeaves"
auto-load="false">
</vn-crud-model>
<vn-portal slot="topbar">
<vn-searchbar
vn-focus
info="Search departments by id, name or code"
on-search="$ctrl.onSearch($params)"
base-state="worker.department">
</vn-searchbar>
</vn-portal>
<form name="form" class="vn-w-md">
<vn-card class="vn-pa-md">
<vn-treeview vn-id="treeview" root-label="Departments" read-only="false"
@ -13,7 +21,12 @@
on-drop="$ctrl.onDrop($dropped, $dragged)"
on-drag-start="$ctrl.onDragStart(item)"
on-drag-end="$ctrl.onDragEnd(item)">
<a
style="display: block; color: inherit;"
ui-sref="worker.department.card.summary({id: item.id})"
translate>
{{::item.name}}
</a>
</vn-treeview>
</vn-card>
</form>

View File

@ -0,0 +1,94 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller extends Section {
$postLink() {
this.$.treeview.fetch();
if (this.$params.q) {
const search = JSON.parse(this.$params.q);
this.onSearch(search);
}
}
onSearch(params) {
this.$.model.applyFilter({}, params).then(() => {
const data = this.$.model.data;
this.$.treeview.data = data;
});
}
onFetch(item) {
const params = item ? {parentId: item.id} : null;
return this.$.model.applyFilter({}, params).then(() => {
return this.$.model.data;
});
}
onSort(a, b) {
return a.name.localeCompare(b.name);
}
onDrop(dropped, dragged) {
const params = dropped ? {parentId: dropped.id} : null;
const query = `departments/${dragged.id}/moveChild`;
this.$http.post(query, params).then(() => {
this.$.treeview.move(dragged, dropped);
});
}
onCreate(parent) {
this.newChild = {
parent: parent,
name: ''
};
this.$.createNode.show();
}
onCreateDialogOpen() {
this.newChild.name = '';
}
onCreateResponse() {
try {
if (!this.newChild.name)
throw new Error(`Name can't be empty`);
const params = {name: this.newChild.name};
const parent = this.newChild.parent;
if (parent && parent.id)
params.parentId = parent.id;
const query = `departments/createChild`;
this.$http.post(query, params).then(res => {
const item = res.data;
item.parent = parent;
this.$.treeview.create(item);
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
return false;
}
return true;
}
onRemove(item) {
this.removedChild = item;
this.$.deleteNode.show();
}
onRemoveResponse() {
const childId = this.removedChild.id;
const path = `departments/${childId}/removeChild`;
this.$http.post(path).then(() => {
this.$.treeview.remove(this.removedChild);
});
}
}
ngModule.vnComponent('vnWorkerDepartmentIndex', {
template: require('./index.html'),
controller: Controller
});

View File

@ -2,3 +2,4 @@ New department: Nuevo departamento
Delete department: Eliminar departamento
Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo?
Name can't be empty: El nombre esta vacio
Department workers: Trabajadores del departamento

View File

@ -0,0 +1,9 @@
<vn-crud-model
vn-id="model"
url="Departments/filter"
limit="20"
order="id">
</vn-crud-model>
<ui-view>
<vn-worker-department-index></vn-worker-department-index>
</ui-view>

View File

@ -0,0 +1,7 @@
import ngModule from '../../module';
import ModuleMain from 'salix/components/module-main';
ngModule.vnComponent('vnWorkerDepartment', {
Outdated
Review

Aci lo mateix de antes, si te funciona sense esta linea millor

Aci lo mateix de antes, si te funciona sense esta linea millor
controller: ModuleMain,
template: require('./index.html')
});

View File

@ -0,0 +1,91 @@
<vn-portal slot="topbar">
<vn-searchbar
vn-focus
info="Search departments by id, name or code"
on-search="$ctrl.onSearch($params)"
base-state="worker.department">
</vn-searchbar>
</vn-portal>
<vn-card class="summary">
<h5>
<span>{{summary.name}}</span>
</h5>
<vn-horizontal class="vn-pa-md">
<vn-one class="expand">
<h4 ng-show="$ctrl.isHr">
<a
ui-sref="worker.department.card.basicData({id:summary.id})">
<span translate vn-tooltip="Go to">Basic data</span>
</a>
</h4>
<h4
translates
ng-show="!$ctrl.isHr">
Basic data
</h4>
</vn-one>
<vn-one>
<vn-vertical>
<vn-label-value label="Nombre"
value="{{summary.name}}">
</vn-label-value>
<vn-label-value label="Code"
value="{{summary.code}}">
</vn-label-value>
<vn-label-value label="Chat"
value="{{summary.chatName}}">
</vn-label-value>
<vn-label-value
label="Boss department">
<span
carlossa marked this conversation as resolved Outdated

teleworking

teleworking
ng-click="workerDescriptor.show($event, summary.worker.id)"
class="link">
{{summary.worker.user.name}}
</span>
</vn-label-value>
carlossa marked this conversation as resolved Outdated

Notify on errors

Notify on errors
<vn-label-value
label="Email"
value="{{summary.notificationEmail}}">
</vn-label-value>
<vn-label-value label="Self-consumption customer"
value="{{summary.client.name}}">
</vn-label-value>
</vn-vertical>
</vn-one>
<vn-one>
<vn-vertical>
<vn-check
label="Telework"
ng-model="summary.isTeleworking"
disabled="true">
</vn-check>
<vn-check
label="Notify on errors"
ng-model="summary.hasToMistake"
disabled="true">
</vn-check>
<vn-check
label="worksInProduction"
ng-model="summary.isProduction"
disabled="true">
</vn-check>
<vn-check
label="Fill in days without physical check-ins"
ng-model="summary.hasToRefill"
disabled="true">
</vn-check>
<vn-check
label="Send check-ins by email"
ng-model="summary.hasToSendMail"
disabled="true">
</vn-check>
</vn-vertical>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
<vn-worker-department-descriptor-popover
vn-id="workerDepartmentDescriptor">
</vn-worker-department-descriptor-popover>

View File

@ -0,0 +1,27 @@
import ngModule from '../../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
set department(value) {
this._department = value;
this.$.summary = null;
if (!value) return;
this.$.summary = this.department;
Outdated
Review

Revisa que no tingues ja les dades en this.department

Revisa que no tingues ja les dades en this.department
}
get department() {
return this._department;
}
get isHr() {
return this.aclService.hasAny(['hr']);
}
}
ngModule.component('vnWorkerDepartmentSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
department: '<'
}
});

View File

@ -0,0 +1,12 @@
Name: Nombre
Code: Código
Chat: Chat
Boss department: Jefe de departamento
Email: Email
Self-consumption customer: Cliente autoconsumo
Telework: Teletrabaja
Notify on errors: Notificar errores
worksInProduction: Pertenece a producción
Fill in days without physical check-ins: Completar días sin registros físicos
carlossa marked this conversation as resolved Outdated

Completar días sin registros físicos

Completar días sin registros físicos
Send check-ins by email: Enviar fichadas por mail
Are you sure you want to delete this department?: ¿Estás seguro de que quieres eliminar este departamento?

View File

@ -0,0 +1,8 @@
@import "./variables";
vn-worker-department-summary {
.expand {
min-width: 100%;
}
}

View File

@ -24,6 +24,9 @@
"description": "Wikipedia"
},
{"state": "worker.card.workerLog", "icon": "history"}
],
"department": [
{"state": "worker.department.card.basicData", "icon": "settings"}
]
},
"keybindings": [
@ -118,12 +121,35 @@
"worker": "$ctrl.worker"
}
}, {
"url" : "/department",
"url": "/department?q",
"state": "worker.department",
"component": "vn-worker-department",
"description": "Departments",
"acl": ["hr"]
Outdated
Review

El ACL es deuria mantindre

El ACL es deuria mantindre
"description":"Departments"
}, {
Outdated
Review

Aci "acl" employee. Revisa que les modificacions estiguen ben possats els acls per a hr

Aci "acl" employee. Revisa que les modificacions estiguen ben possats els acls per a hr
"url": "/:id",
carlossa marked this conversation as resolved
Review

Department deuria tindre ACLs en les seues seccions? @jgallego

Department deuria tindre ACLs en les seues seccions? @jgallego
Review

Si, editar rrhh, visualizar employee.

Si, editar rrhh, visualizar employee.
"state": "worker.department.card",
"component": "vn-worker-department-card",
"abstract": true,
"description": "Detail"
}, {
"url" : "/summary",
"state": "worker.department.card.summary",
"component": "vn-worker-department-summary",
"description": "Summary",
"params": {
"department": "$ctrl.department"
}
},
{
"url": "/basic-data",
"state": "worker.department.card.basicData",
"component": "vn-worker-department-basic-data",
"description": "Basic data",
"params": {
"department": "$ctrl.department"
}
},
{
"url": "/dms",
"state": "worker.card.dms",
"abstract": true,

View File

@ -27,15 +27,19 @@
<vn-label-value label="Email" no-ellipsize
value="{{worker.user.emailUser.email}}">
</vn-label-value>
<vn-label-value label="Department"
value="{{worker.department.department.name}}">
<vn-label-value label="Department">
<span
ng-click="workerDepartmentDescriptor.show($event, worker.department.department.id)"
class="link">
{{worker.department.department.name}}
</span>
</vn-label-value>
<vn-label-value
label="Boss">
<span
ng-click="workerDescriptor.show($event, worker.boss.id)"
class="link">
{{::worker.boss.nickname}}
{{::worker.boss.name}}
</span>
</vn-label-value>
<vn-label-value label="Mobile extension"
@ -71,3 +75,6 @@
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
<vn-worker-department-descriptor-popover
vn-id="workerDepartmentDescriptor">
</vn-worker-department-descriptor-popover>

View File

@ -38,7 +38,7 @@ class Controller extends Summary {
},
{
relation: 'boss',
scope: {fields: ['id', 'nickname']}
scope: {fields: ['id', 'name']}
},
{
relation: 'sip',
@ -48,7 +48,8 @@ class Controller extends Summary {
relation: 'department',
scope: {
include: {
relation: 'department'
relation: 'department',
scope: {fields: ['id', 'code', 'name']}
}
}
}