Merge pull request 'hotfix_workCenter2' (!1669) from hotfix_workCenter2 into master
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1669 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
06690ca71e
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('WorkerDisableExcluded', '*', 'READ', 'ALLOW', 'ROLE', 'itManagement'),
|
||||
('WorkerDisableExcluded', '*', 'WRITE', 'ALLOW', 'ROLE', 'itManagement');
|
|
@ -3,7 +3,7 @@
|
|||
data="absenceTypes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<div ng-if="$ctrl.worker.hasWorkCenter">
|
||||
<div ng-if="$ctrl.card.hasWorkCenter">
|
||||
<div class="vn-w-lg">
|
||||
<vn-card class="vn-pa-sm calendars">
|
||||
<vn-icon ng-if="::$ctrl.isSubordinate" icon="info" color-marginal
|
||||
|
@ -23,7 +23,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div
|
||||
ng-if="!$ctrl.worker.hasWorkCenter"
|
||||
ng-if="!$ctrl.card.hasWorkCenter"
|
||||
class="bg-title"
|
||||
translate>
|
||||
Autonomous worker
|
||||
|
@ -73,41 +73,39 @@
|
|||
value-field="businessFk"
|
||||
order="businessFk DESC"
|
||||
limit="5">
|
||||
<tpl-item>
|
||||
<div>#{{businessFk}}</div>
|
||||
<div class="text-caption text-secondary">
|
||||
{{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
|
||||
</div>
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</div>
|
||||
<div name="absenceTypes" class="input vn-py-md" style="overflow: hidden;">
|
||||
<vn-chip ng-repeat="absenceType in absenceTypes" ng-class="::{'selectable': $ctrl.isSubordinate}"
|
||||
ng-click="$ctrl.pick(absenceType)">
|
||||
<vn-avatar
|
||||
ng-style="{backgroundColor: absenceType.rgb}">
|
||||
<vn-icon icon="check" ng-if="absenceType.id == $ctrl.absenceType.id"></vn-icon>
|
||||
</vn-avatar>
|
||||
{{absenceType.name}}
|
||||
</vn-chip>
|
||||
</div>
|
||||
<div class="vn-py-md">
|
||||
<vn-chip>
|
||||
<vn-avatar class="festive">
|
||||
</vn-avatar>
|
||||
<span translate>Festive</span>
|
||||
</vn-chip>
|
||||
<vn-chip>
|
||||
<vn-avatar class="today">
|
||||
</vn-avatar>
|
||||
<span translate>Current day</span>
|
||||
</vn-chip>
|
||||
</div>
|
||||
<tpl-item>
|
||||
<div>#{{businessFk}}</div>
|
||||
<div class="text-caption text-secondary">
|
||||
{{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
|
||||
</div>
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</div>
|
||||
<div name="absenceTypes" class="input vn-py-md" style="overflow: hidden;">
|
||||
<vn-chip ng-repeat="absenceType in absenceTypes" ng-class="::{'selectable': $ctrl.isSubordinate}" ng-click="$ctrl.pick(absenceType)">
|
||||
<vn-avatar ng-style="{backgroundColor: absenceType.rgb}">
|
||||
<vn-icon icon="check" ng-if="absenceType.id == $ctrl.absenceType.id"></vn-icon>
|
||||
</vn-avatar>
|
||||
{{absenceType.name}}
|
||||
</vn-chip>
|
||||
</div>
|
||||
<div class="vn-py-md">
|
||||
<vn-chip>
|
||||
<vn-avatar class="festive">
|
||||
</vn-avatar>
|
||||
<span translate>Festive</span>
|
||||
</vn-chip>
|
||||
<vn-chip>
|
||||
<vn-avatar class="today">
|
||||
</vn-avatar>
|
||||
<span translate>Current day</span>
|
||||
</vn-chip>
|
||||
</div>
|
||||
</div>
|
||||
</vn-side-menu>
|
||||
|
||||
<vn-confirm
|
||||
vn-id="confirm"
|
||||
message="This item will be deleted"
|
||||
question="Are you sure you want to continue?">
|
||||
</vn-confirm>
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
set businessId(value) {
|
||||
if (!this.card.hasWorkCenter) return;
|
||||
|
||||
this._businessId = value;
|
||||
if (value) {
|
||||
this.refresh()
|
||||
|
@ -64,7 +66,7 @@ class Controller extends Section {
|
|||
|
||||
set worker(value) {
|
||||
this._worker = value;
|
||||
if (value && value.hasWorkCenter) {
|
||||
if (value) {
|
||||
this.getIsSubordinate();
|
||||
this.getActiveContract();
|
||||
}
|
||||
|
@ -293,5 +295,8 @@ ngModule.vnComponent('vnWorkerCalendar', {
|
|||
controller: Controller,
|
||||
bindings: {
|
||||
worker: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnWorkerCard'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,6 +20,9 @@ describe('Worker', () => {
|
|||
controller.absenceType = {id: 1, name: 'Holiday', code: 'holiday', rgb: 'red'};
|
||||
controller.$params.id = 1106;
|
||||
controller._worker = {id: 1106};
|
||||
controller.card = {
|
||||
hasWorkCenter: true
|
||||
};
|
||||
}));
|
||||
|
||||
describe('year() getter', () => {
|
||||
|
@ -74,7 +77,7 @@ describe('Worker', () => {
|
|||
let yesterday = new Date(today.getTime());
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
controller.worker = {id: 1107, hasWorkCenter: true};
|
||||
controller.worker = {id: 1107};
|
||||
|
||||
expect(controller.getIsSubordinate).toHaveBeenCalledWith();
|
||||
expect(controller.getActiveContract).toHaveBeenCalledWith();
|
||||
|
|
|
@ -3,7 +3,7 @@ import ModuleCard from 'salix/components/module-card';
|
|||
|
||||
class Controller extends ModuleCard {
|
||||
reload() {
|
||||
let filter = {
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'user',
|
||||
|
@ -32,13 +32,12 @@ class Controller extends ModuleCard {
|
|||
]
|
||||
};
|
||||
|
||||
this.$http.get(`Workers/${this.$params.id}`, {filter})
|
||||
.then(res => this.worker = res.data)
|
||||
.then(() =>
|
||||
this.$http.get(`Workers/${this.$params.id}/activeContract`)
|
||||
.then(res => {
|
||||
if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk;
|
||||
}));
|
||||
return Promise.all([
|
||||
this.$http.get(`Workers/${this.$params.id}`, {filter})
|
||||
.then(res => this.worker = res.data),
|
||||
this.$http.get(`Workers/${this.$params.id}/activeContract`)
|
||||
.then(res => this.hasWorkCenter = res.data.workCenterFk)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<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)}}"
|
||||
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"
|
||||
|
@ -15,39 +15,32 @@
|
|||
</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>
|
||||
<vn-item ng-click="$ctrl.handleExcluded()" translate>
|
||||
{{$ctrl.workerExcluded
|
||||
? 'Click to allow the user to be disabled'
|
||||
: 'Click to exclude the user from getting disabled'}}
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="User"
|
||||
label="User"
|
||||
value="{{$ctrl.worker.user.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Email"
|
||||
label="Email"
|
||||
value="{{$ctrl.worker.user.emailUser.email}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Department"
|
||||
label="Department"
|
||||
value="{{$ctrl.worker.department.department.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Phone"
|
||||
label="Phone"
|
||||
value="{{$ctrl.worker.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Extension"
|
||||
label="Extension"
|
||||
value="{{$ctrl.worker.sip.extension}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
|
@ -84,7 +77,7 @@
|
|||
</vn-popup>
|
||||
|
||||
<!-- Upload photo dialog -->
|
||||
<vn-upload-photo
|
||||
vn-id="uploadPhoto"
|
||||
<vn-upload-photo
|
||||
vn-id="uploadPhoto"
|
||||
on-response="$ctrl.onUploadResponse()">
|
||||
</vn-upload-photo>
|
||||
</vn-upload-photo>
|
||||
|
|
|
@ -18,28 +18,19 @@ class Controller extends Descriptor {
|
|||
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;
|
||||
this.$http.get(`WorkerDisableExcludeds/${this.entity.id}/exists`).then(data => {
|
||||
this.workerExcluded = 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;
|
||||
}
|
||||
if (this.workerExcluded)
|
||||
this.$http.delete(`WorkerDisableExcludeds/${this.entity.id}`);
|
||||
else
|
||||
this.$http.post(`WorkerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
|
||||
|
||||
this.workerExcluded = !this.workerExcluded;
|
||||
}
|
||||
|
||||
loadData() {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
filter="::$ctrl.filter"
|
||||
data="$ctrl.hours">
|
||||
</vn-crud-model>
|
||||
<div ng-if="$ctrl.worker.hasWorkCenter">
|
||||
<div ng-if="$ctrl.card.hasWorkCenter">
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<vn-table model="model" auto-load="false">
|
||||
<vn-thead>
|
||||
|
@ -107,7 +107,7 @@
|
|||
</vn-button-bar>
|
||||
</div>
|
||||
<div
|
||||
ng-if="!$ctrl.worker.hasWorkCenter"
|
||||
ng-if="!$ctrl.card.hasWorkCenter"
|
||||
class="bg-title"
|
||||
translate>
|
||||
Autonomous worker
|
||||
|
@ -136,6 +136,7 @@
|
|||
</vn-calendar>
|
||||
</div>
|
||||
</vn-side-menu>
|
||||
|
||||
<vn-dialog
|
||||
vn-id="addTimeDialog"
|
||||
on-accept="$ctrl.addTime()"
|
||||
|
|
|
@ -141,6 +141,8 @@ class Controller extends Section {
|
|||
]}
|
||||
};
|
||||
this.$.model.applyFilter(filter, params).then(() => {
|
||||
if (!this.card.hasWorkCenter) return;
|
||||
|
||||
this.getWorkedHours(this.started, this.ended);
|
||||
this.getAbsences();
|
||||
});
|
||||
|
@ -151,7 +153,6 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
getAbsences() {
|
||||
if (!this.worker.hasWorkerCenter) return;
|
||||
const fullYear = this.started.getFullYear();
|
||||
let params = {
|
||||
workerFk: this.$params.id,
|
||||
|
@ -486,5 +487,8 @@ ngModule.vnComponent('vnWorkerTimeControl', {
|
|||
controller: Controller,
|
||||
bindings: {
|
||||
worker: '<'
|
||||
},
|
||||
require: {
|
||||
card: '^vnWorkerCard'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,9 +16,8 @@ describe('Component vnWorkerTimeControl', () => {
|
|||
$scope = $rootScope.$new();
|
||||
$element = angular.element('<vn-worker-time-control></vn-worker-time-control>');
|
||||
controller = $componentController('vnWorkerTimeControl', {$element, $scope});
|
||||
controller.worker = {
|
||||
hasWorkerCenter: true
|
||||
|
||||
controller.card = {
|
||||
hasWorkCenter: true
|
||||
};
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in New Issue