This commit is contained in:
parent
87e1caa4eb
commit
598067f757
|
@ -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,
|
||||
|
|
|
@ -38,5 +38,17 @@
|
|||
"hasToMistake": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"client": {
|
||||
"type": "belongsTo",
|
||||
"model": "Client",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-worker-department-descriptor department="$ctrl.department"></vn-worker-department-descriptor>
|
||||
<vn-left-menu source="card"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -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
|
||||
});
|
|
@ -0,0 +1,90 @@
|
|||
<!-- <vn-descriptor-content
|
||||
module="worker"
|
||||
description="$ctrl.worker.firstName +' '+ $ctrl.worker.lastName"
|
||||
summary="$ctrl.$.summary">
|
||||
<slot-before>
|
||||
<div class="photo" text-center>
|
||||
<img vn-id="photo"
|
||||
ng-src="{{$root.imagePath('user', '520x520', $ctrl.worker.id)}}"
|
||||
zoom-image="{{$root.imagePath('user', '1600x1600', $ctrl.worker.id)}}"
|
||||
on-error-src/>
|
||||
<vn-float-button ng-click="uploadPhoto.show('user', $ctrl.worker.id)"
|
||||
icon="edit"
|
||||
vn-visible-by="userPhotos">
|
||||
</vn-float-button>
|
||||
</div>
|
||||
</slot-before>
|
||||
<slot-menu>
|
||||
<vn-item
|
||||
ng-click="$ctrl.handleExcluded()"
|
||||
translate
|
||||
ng-if="!$ctrl.excluded">
|
||||
Click to exclude the user from getting disabled
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="$ctrl.handleExcluded()"
|
||||
translate
|
||||
ng-if="$ctrl.excluded">
|
||||
Click to allow the user to be disabled
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="User"
|
||||
value="{{$ctrl.worker.user.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Email"
|
||||
value="{{$ctrl.worker.user.emailUser.email}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Department"
|
||||
value="{{$ctrl.worker.department.department.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Phone"
|
||||
value="{{$ctrl.worker.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Extension"
|
||||
value="{{$ctrl.worker.sip.extension}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="icons">
|
||||
<vn-icon
|
||||
vn-tooltip="This user can't be disabled"
|
||||
icon="person"
|
||||
ng-if="$ctrl.worker.excluded">
|
||||
</vn-icon>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
<div ng-transclude="btnOne">
|
||||
<vn-quick-link
|
||||
tooltip="Go to client"
|
||||
state="['client.card.summary', {id: $ctrl.id}]"
|
||||
icon="person">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
<div ng-transclude="btnTwo">
|
||||
<vn-quick-link
|
||||
vn-acl="hr"
|
||||
vn-acl-action="remove"
|
||||
tooltip="Go to user"
|
||||
state="['account.card.summary', {id: $ctrl.id}]"
|
||||
icon="face">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
<div ng-transclude="btnThree"></div>
|
||||
</div>
|
||||
</slot-body>
|
||||
</vn-descriptor-content>
|
||||
<vn-popup vn-id="summary">
|
||||
<vn-worker-summary worker="$ctrl.worker"></vn-worker-summary>
|
||||
</vn-popup>
|
||||
|
||||
<!-- Upload photo dialog -->
|
||||
<!-- <vn-upload-photo
|
||||
vn-id="uploadPhoto"
|
||||
on-response="$ctrl.onUploadResponse()">
|
||||
</vn-upload-photo> -->
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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}}
|
||||
</vn-treeview>
|
||||
</vn-card>
|
||||
|
|
|
@ -77,7 +77,7 @@ class Controller extends Section {
|
|||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnWorkerDepartment', {
|
||||
ngModule.vnComponent('vnWorkerDepartmentIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Departments/filter"
|
||||
limit="20"
|
||||
order="id">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
panel="vn-worker-search-panel"
|
||||
info="Search workers by id, firstName, lastName or user name"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
<vn-left-menu></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -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')
|
||||
});
|
|
@ -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"]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,18 +1,18 @@
|
|||
<vn-card class="summary">
|
||||
<h5>
|
||||
<a ng-if="::$ctrl.worker.id"
|
||||
vn-tooltip="Go to the worker"
|
||||
ui-sref="department.card.summary({id: {{::$ctrl.worker.id}}})"
|
||||
<a ng-if="::$ctrl.department.id"
|
||||
vn-tooltip="Go to the department"
|
||||
ui-sref="department.card.summary({id: {{::$ctrl.department.id}}})"
|
||||
name="goToSummary">
|
||||
<vn-icon-button icon="launch"></vn-icon-button>
|
||||
</a>
|
||||
<span>{{worker.firstName}} {{worker.lastName}}</span>
|
||||
<span>{{department.name}}</span>
|
||||
</h5>
|
||||
<vn-horizontal class="vn-pa-md">
|
||||
<vn-one>
|
||||
<h4 ng-show="$ctrl.isHr">
|
||||
<a
|
||||
ui-sref="worker.card.basicData({id:$ctrl.worker.id})">
|
||||
ui-sref="department.card.basicData({id:$ctrl.department.id})">
|
||||
<span translate vn-tooltip="Go to">Basic data</span>
|
||||
</a>
|
||||
</h4>
|
||||
|
@ -21,34 +21,28 @@
|
|||
ng-show="!$ctrl.isHr">
|
||||
Basic data
|
||||
</h4>
|
||||
<vn-label-value label="Id"
|
||||
value="{{worker.id}}">
|
||||
<vn-label-value label="Nombre:"
|
||||
value="{{department.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Email" no-ellipsize
|
||||
value="{{worker.user.emailUser.email}}">
|
||||
<vn-label-value label="Code:" no-ellipsize
|
||||
value="{{department.code}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Department"
|
||||
value="{{worker.department.department.name}}">
|
||||
<vn-label-value label="Chat:"
|
||||
value="{{department.chat}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Boss">
|
||||
label="Boss:">
|
||||
<span
|
||||
ng-click="workerDescriptor.show($event, worker.boss.id)"
|
||||
class="link">
|
||||
{{::worker.boss.nickname}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Mobile extension"
|
||||
value="{{worker.mobileExtension}}">
|
||||
<vn-label-value label="Email:"
|
||||
value="{{department.notificationEmail}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Business phone"
|
||||
value="{{worker.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Personal phone"
|
||||
value="{{worker.client.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Locker"
|
||||
value="{{worker.locker}}">
|
||||
<vn-label-value label="Cliente autoconsumo"
|
||||
value="{{department.workerFk}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
|
@ -68,6 +62,6 @@
|
|||
</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>
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue