fixed worker descriptor not showing the correct worker
gitea/salix/dev This commit looks good Details

This commit is contained in:
Gerard 2019-02-19 15:09:50 +01:00
parent 2121b87895
commit b7db5f969b
11 changed files with 45 additions and 25 deletions

View File

@ -76,7 +76,7 @@
<vn-client-descriptor-popover vn-id="clientDescriptor"></vn-client-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>
<vn-dialog class="dialog-summary"
vn-id="dialog-summary-claim">

View File

@ -149,5 +149,5 @@
</vn-item-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>

View File

@ -119,5 +119,5 @@
</vn-item-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>

View File

@ -81,7 +81,7 @@
</vn-client-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>
<vn-dialog
vn-id="summary"

View File

@ -64,7 +64,7 @@
</vn-item-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>
<vn-confirm
vn-id="delete-expedition"

View File

@ -120,5 +120,5 @@
</vn-client-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>

View File

@ -86,7 +86,7 @@
</vn-item-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>
<a ui-sref="ticket.card.request.create"
vn-tooltip="New request"

View File

@ -61,5 +61,5 @@
</vn-item-descriptor-popover>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>

View File

@ -41,5 +41,5 @@
</a>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
worker-fk="$ctrl.selectedWorker">
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>

View File

@ -11,16 +11,16 @@ class Controller extends Component {
this.worker = null;
}
set workerFk(id) {
if (id == this._workerFk) return;
set userId(id) {
if (id == this._userId) return;
this._workerFk = id;
this._userId = id;
this.worker = null;
this.loadData();
}
get workerFk() {
return this._workerFk;
get userId() {
return this._userId;
}
set quicklinks(value = {}) {
@ -37,8 +37,11 @@ class Controller extends Component {
}
loadData() {
let query = `api/Workers/${this._workerFk}`;
let query = `api/Workers/findOne`;
let filter = {
where: {
userFk: this._userId
},
include: [
{
relation: 'user',
@ -49,6 +52,13 @@ class Controller extends Component {
}, {
relation: 'sip',
scope: {fields: ['extension']}
}, {
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
}
]
};
@ -67,7 +77,7 @@ ngModule.component('vnWorkerDescriptorPopover', {
template: require('./index.html'),
controller: Controller,
bindings: {
workerFk: '<',
userId: '<',
quicklinks: '<'
}
});

View File

@ -21,23 +21,23 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
describe('workerFk()', () => {
it(`should not apply any changes if the received id is the same stored in _workerFk`, () => {
controller.worker = 'I exist!';
controller._workerFk = 1;
controller._userId = 1;
spyOn(controller, 'loadData');
controller.workerFk = 1;
controller.userId = 1;
expect(controller.worker).toEqual('I exist!');
expect(controller._workerFk).toEqual(1);
expect(controller._userId).toEqual(1);
expect(controller.loadData).not.toHaveBeenCalled();
});
it(`should set the received id into _workerFk, set the worker to null and then call loadData()`, () => {
controller.worker = `Please don't`;
controller._workerFk = 1;
controller._userId = 1;
spyOn(controller, 'loadData');
controller.workerFk = 999;
controller.userId = 999;
expect(controller.worker).toBeNull();
expect(controller._workerFk).toEqual(999);
expect(controller._userId).toEqual(999);
expect(controller.loadData).toHaveBeenCalledWith();
});
});
@ -53,12 +53,15 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
describe('loadData()', () => {
it(`should perform a get query to store the worker data into the controller`, () => {
controller.workerFk = 1;
controller.userId = 1;
controller.canceler = null;
let response = {};
let config = {
filter: {
where: {
userFk: controller.userId
},
include: [
{
relation: 'user',
@ -69,6 +72,13 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
}, {
relation: 'sip',
scope: {fields: ['extension']}
}, {
relation: 'department',
scope: {
include: {
relation: 'department'
}
}
}
]
}
@ -76,8 +86,8 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
let json = $httpParamSerializer(config);
$httpBackend.whenGET(`api/Workers/${controller._workerFk}?${json}`).respond(response);
$httpBackend.expectGET(`api/Workers/${controller._workerFk}?${json}`);
$httpBackend.whenGET(`api/Workers/findOne?${json}`).respond(response);
$httpBackend.expectGET(`api/Workers/findOne?${json}`);
controller.loadData();
$httpBackend.flush();