change Fk to Id
gitea/salix/2122-entry_index This commit looks good Details

This commit is contained in:
Bernat Exposito Domenech 2020-02-18 11:07:55 +01:00
parent 3f978bd32b
commit 6540ef9598
3 changed files with 19 additions and 19 deletions

View File

@ -76,7 +76,7 @@
</vn-card> </vn-card>
<vn-travel-descriptor-popover <vn-travel-descriptor-popover
vn-id="travelDescriptor" vn-id="travelDescriptor"
travel-fk="$ctrl.selectedTravel"> travel-id="$ctrl.selectedTravel">
</vn-travel-descriptor-popover> </vn-travel-descriptor-popover>
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
<vn-entry-summary <vn-entry-summary

View File

@ -11,16 +11,16 @@ class Controller extends Component {
this._quicklinks = {}; this._quicklinks = {};
} }
set travelFk(travelFk) { set travelId(travelId) {
if (travelFk == this._travelFk) return; if (travelId == this._travelId) return;
this._travelFk = travelFk; this._travelId = travelId;
this.travel = null; this.travel = null;
this.loadData(); this.loadData();
} }
get travelFk() { get travelId() {
return this._travelFk; return this._travelId;
} }
get quicklinks() { get quicklinks() {
@ -51,7 +51,7 @@ class Controller extends Component {
'warehouseOutFk' 'warehouseOutFk'
], ],
where: { where: {
id: this._travelFk id: this._travelId
}, },
include: [ include: [
{ {
@ -82,7 +82,7 @@ ngModule.component('vnTravelDescriptorPopover', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,
bindings: { bindings: {
travelFk: '<', travelId: '<',
quicklinks: '<' quicklinks: '<'
} }
}); });

View File

@ -18,26 +18,26 @@ describe('travel Component vnTravelDescriptorPopover', () => {
controller = $componentController('vnTravelDescriptorPopover', {$scope, $element}); controller = $componentController('vnTravelDescriptorPopover', {$scope, $element});
})); }));
describe('travelFk()', () => { describe('travelId()', () => {
it(`should not apply any changes if the received id is the same stored in _travelFk`, () => { it(`should not apply any changes if the received id is the same stored in _travelId`, () => {
controller.travel = 'I exist!'; controller.travel = 'I exist!';
controller._travelFk = 1; controller._travelId = 1;
spyOn(controller, 'loadData'); spyOn(controller, 'loadData');
controller.travelFk = 1; controller.travelId = 1;
expect(controller.travel).toEqual('I exist!'); expect(controller.travel).toEqual('I exist!');
expect(controller._travelFk).toEqual(1); expect(controller._travelId).toEqual(1);
expect(controller.loadData).not.toHaveBeenCalled(); expect(controller.loadData).not.toHaveBeenCalled();
}); });
it(`should set the received id into _travelFk, set the travel to null and then call loadData()`, () => { it(`should set the received id into _travelId, set the travel to null and then call loadData()`, () => {
controller.travel = `Please don't`; controller.travel = `Please don't`;
controller._travelFk = 1; controller._travelId = 1;
spyOn(controller, 'loadData'); spyOn(controller, 'loadData');
controller.travelFk = 999; controller.travelId = 999;
expect(controller.travel).toBeNull(); expect(controller.travel).toBeNull();
expect(controller._travelFk).toEqual(999); expect(controller._travelId).toEqual(999);
expect(controller.loadData).toHaveBeenCalledWith(); expect(controller.loadData).toHaveBeenCalledWith();
}); });
}); });
@ -53,7 +53,7 @@ describe('travel Component vnTravelDescriptorPopover', () => {
describe('loadData()', () => { describe('loadData()', () => {
it(`should perform a get query to store the worker data into the controller`, () => { it(`should perform a get query to store the worker data into the controller`, () => {
controller.travelFk = 1; controller.travelId = 1;
controller.canceler = null; controller.canceler = null;
let response = {}; let response = {};
@ -69,7 +69,7 @@ describe('travel Component vnTravelDescriptorPopover', () => {
'warehouseOutFk' 'warehouseOutFk'
], ],
where: { where: {
id: controller.travelFk id: controller.travelId
}, },
include: [ include: [
{ {