7187-redirect #2476
|
@ -1,41 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Worker pda path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('hr', 'worker');
|
|
||||||
await page.accessToSearchResult('employeeNick');
|
|
||||||
await page.accessToSection('worker.card.pda');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check if worker has already a PDA allocated', async() => {
|
|
||||||
expect(await page.waitToGetProperty(selectors.workerPda.currentPDA, 'value')).toContain('serialNumber1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should deallocate the PDA', async() => {
|
|
||||||
await page.waitToClick(selectors.workerPda.delete);
|
|
||||||
let message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('PDA deallocated');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should allocate a new PDA', async() => {
|
|
||||||
await page.autocompleteSearch(selectors.workerPda.newPDA, 'serialNumber2');
|
|
||||||
await page.waitToClick(selectors.workerPda.submit);
|
|
||||||
let message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('PDA allocated');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check if a new PDA has been allocated', async() => {
|
|
||||||
expect(await page.waitToGetProperty(selectors.workerPda.currentPDA, 'value')).toContain('serialNumber2');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,50 +0,0 @@
|
||||||
<div class="vn-w-md" ng-show="$ctrl.currentPDA">
|
|
||||||
<vn-card class="vn-pa-lg">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield
|
|
||||||
label="Current PDA"
|
|
||||||
ng-model="$ctrl.currentPDA.description"
|
|
||||||
disabled="true">
|
|
||||||
<append>
|
|
||||||
<vn-icon-button
|
|
||||||
icon="delete"
|
|
||||||
vn-tooltip="Deallocate PDA"
|
|
||||||
ng-click="$ctrl.deallocatePDA()"
|
|
||||||
vn-acl="hr, productionAssi">
|
|
||||||
</vn-icon-button>
|
|
||||||
</append>
|
|
||||||
</vn-textfield>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
</div>
|
|
||||||
<form name="form" ng-show="!$ctrl.currentPDA" ng-submit="$ctrl.allocatePDA()" class="vn-w-md">
|
|
||||||
<vn-card class="vn-pa-lg">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-acl="hr, productionAssi"
|
|
||||||
ng-model="$ctrl.newPDA"
|
|
||||||
url="DeviceProductions"
|
|
||||||
fields="['id', 'modelFk', 'serialNumber']"
|
|
||||||
where="{'stateFk': 'idle'}"
|
|
||||||
label="New PDA"
|
|
||||||
order="id"
|
|
||||||
value-field="id"
|
|
||||||
show-field="serialNumber">
|
|
||||||
<tpl-item>
|
|
||||||
<div>
|
|
||||||
ID: {{id}}
|
|
||||||
</div>
|
|
||||||
<div class="text-caption text-grey">
|
|
||||||
{{modelFk}}, {{serialNumber}}
|
|
||||||
</div>
|
|
||||||
</tpl-item>
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
<vn-button-bar>
|
|
||||||
<vn-submit
|
|
||||||
disabled="!$ctrl.newPDA"
|
|
||||||
label="Assign">
|
|
||||||
</vn-submit>
|
|
||||||
</vn-button-bar>
|
|
||||||
</form>
|
|
|
@ -1,53 +1,18 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
const filter = {
|
|
||||||
where: {userFk: this.$params.id},
|
|
||||||
include: {relation: 'deviceProduction'}
|
|
||||||
};
|
|
||||||
this.$http.get('DeviceProductionUsers', {filter}).
|
|
||||||
then(res => {
|
|
||||||
if (res.data && res.data.length > 0)
|
|
||||||
this.setCurrentPDA(res.data[0]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deallocatePDA() {
|
async $onInit() {
|
||||||
this.$http.post(`Workers/${this.$params.id}/deallocatePDA`, {pda: this.currentPDA.deviceProductionFk})
|
const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`);
|
||||||
pablone marked this conversation as resolved
|
|||||||
.then(() => {
|
this.$state.go('worker.card.summary', {id: this.$params.id});
|
||||||
this.vnApp.showSuccess(this.$t('PDA deallocated'));
|
window.location.href = url;
|
||||||
delete this.currentPDA;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
allocatePDA() {
|
|
||||||
this.$http.post(`Workers/${this.$params.id}/allocatePDA`, {pda: this.newPDA})
|
|
||||||
.then(res => {
|
|
||||||
if (res.data)
|
|
||||||
this.setCurrentPDA(res.data);
|
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$t('PDA allocated'));
|
|
||||||
delete this.newPDA;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setCurrentPDA(data) {
|
|
||||||
this.currentPDA = data;
|
|
||||||
this.currentPDA.description = [];
|
|
||||||
this.currentPDA.description.push(`ID: ${this.currentPDA.deviceProductionFk}`);
|
|
||||||
this.currentPDA.description.push(`${this.$t('Model')}: ${this.currentPDA.deviceProduction.modelFk}`);
|
|
||||||
this.currentPDA.description.push(`${this.$t('Serial Number')}: ${this.currentPDA.deviceProduction.serialNumber}`);
|
|
||||||
this.currentPDA.description = this.currentPDA.description.join(' ');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope'];
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnWorkerPda', {
|
ngModule.vnComponent('vnWorkerPda', {
|
||||||
template: require('./index.html'),
|
controller: Controller
|
||||||
controller: Controller,
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Worker', () => {
|
|
||||||
describe('Component vnWorkerPda', () => {
|
|
||||||
let $httpBackend;
|
|
||||||
let $scope;
|
|
||||||
let $element;
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(ngModule('worker'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
$element = angular.element('<vn-worker-pda></vn-worker-pda>');
|
|
||||||
controller = $componentController('vnWorkerPda', {$element, $scope});
|
|
||||||
$httpBackend.expectGET(`DeviceProductionUsers`).respond();
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('deallocatePDA()', () => {
|
|
||||||
it('should make an HTTP Post query to deallocatePDA', () => {
|
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
||||||
controller.currentPDA = {deviceProductionFk: 1};
|
|
||||||
controller.$params.id = 1;
|
|
||||||
|
|
||||||
$httpBackend
|
|
||||||
.expectPOST(`Workers/${controller.$params.id}/deallocatePDA`,
|
|
||||||
{pda: controller.currentPDA.deviceProductionFk})
|
|
||||||
.respond();
|
|
||||||
controller.deallocatePDA();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
||||||
expect(controller.currentPDA).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('allocatePDA()', () => {
|
|
||||||
it('should make an HTTP Post query to allocatePDA', () => {
|
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
||||||
controller.newPDA = 4;
|
|
||||||
controller.$params.id = 1;
|
|
||||||
|
|
||||||
$httpBackend
|
|
||||||
.expectPOST(`Workers/${controller.$params.id}/allocatePDA`,
|
|
||||||
{pda: controller.newPDA})
|
|
||||||
.respond();
|
|
||||||
controller.allocatePDA();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
||||||
expect(controller.newPDA).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('setCurrentPDA()', () => {
|
|
||||||
it('should set CurrentPDA', () => {
|
|
||||||
const data = {
|
|
||||||
deviceProductionFk: 1,
|
|
||||||
deviceProduction: {
|
|
||||||
modelFk: 1,
|
|
||||||
serialNumber: 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
controller.setCurrentPDA(data);
|
|
||||||
|
|
||||||
expect(controller.currentPDA).toBeDefined();
|
|
||||||
expect(controller.currentPDA.description).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,6 +0,0 @@
|
||||||
@import "./variables";
|
|
||||||
|
|
||||||
.text-grey {
|
|
||||||
color: $color-font-light;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Fer
this.$state.go('worker.card.summary', {id: this.$params.id});
Si no si tiras atrás en el navegador, entras en bucle