entry index refactor
gitea/salix/2122-entry_index This commit looks good
Details
gitea/salix/2122-entry_index This commit looks good
Details
This commit is contained in:
parent
61b3ce184c
commit
3f978bd32b
|
@ -1129,17 +1129,19 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
|
||||||
(4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500, 'fourth travel', 0),
|
(4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500, 'fourth travel', 0),
|
||||||
(5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500, 'fifth travel', 1),
|
(5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500, 'fifth travel', 1),
|
||||||
(6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500, 'sixth travel', 1),
|
(6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500, 'sixth travel', 1),
|
||||||
(7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1);
|
(7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1),
|
||||||
|
(8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'eight travel', 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`, `notes`, `evaNotes`)
|
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`,`isInventory`, `isRaid`, `notes`, `evaNotes`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 'this is the note one', 'observation one'),
|
(1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 0, 0, '', ''),
|
||||||
(2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 'this is the note two', 'observation two'),
|
(2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'),
|
||||||
(3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 'this is the note three', 'observation three'),
|
(3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'),
|
||||||
(4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 'this is the note four', 'observation four'),
|
(4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'),
|
||||||
(5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 'this is the note five', 'observation five'),
|
(5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'),
|
||||||
(6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 'this is the note six', 'observation six'),
|
(6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'),
|
||||||
(7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 'this is the note seven', 'observation seven');
|
(7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'),
|
||||||
|
(8, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 8', 1, 1, '', '');
|
||||||
|
|
||||||
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
|
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -127,6 +127,7 @@ module.exports = Self => {
|
||||||
e.companyFk,
|
e.companyFk,
|
||||||
e.gestDocFk,
|
e.gestDocFk,
|
||||||
e.invoiceInFk,
|
e.invoiceInFk,
|
||||||
|
t.landed,
|
||||||
s.name AS supplierName,
|
s.name AS supplierName,
|
||||||
co.code AS companyCode,
|
co.code AS companyCode,
|
||||||
cu.code AS currencyCode
|
cu.code AS currencyCode
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe('Entry filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.Entry.filter(ctx);
|
let result = await app.models.Entry.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(7);
|
expect(result.length).toEqual(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the entry matching the supplier', async() => {
|
it('should return the entry matching the supplier', async() => {
|
||||||
|
@ -35,7 +35,7 @@ describe('Entry filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.Entry.filter(ctx);
|
let result = await app.models.Entry.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(5);
|
expect(result.length).toEqual(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the entry matching the company', async() => {
|
it('should return the entry matching the company', async() => {
|
||||||
|
@ -47,7 +47,7 @@ describe('Entry filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.Entry.filter(ctx);
|
let result = await app.models.Entry.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(6);
|
expect(result.length).toEqual(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the entries matching isBooked', async() => {
|
it('should return the entries matching isBooked', async() => {
|
||||||
|
|
|
@ -16,45 +16,68 @@
|
||||||
<vn-table model="model">
|
<vn-table model="model">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
|
<vn-th></vn-th>
|
||||||
<vn-th field="id" number>Id</vn-th>
|
<vn-th field="id" number>Id</vn-th>
|
||||||
<vn-th field="created" center>Created</vn-th>
|
<vn-th field="landed" center>Landed</vn-th>
|
||||||
<vn-th field="travelFk">Travel</vn-th>
|
|
||||||
<vn-th>Notes</vn-th>
|
|
||||||
<vn-th>Reference</vn-th>
|
<vn-th>Reference</vn-th>
|
||||||
<vn-th field="isBooked" center>Booked</vn-th>
|
|
||||||
<vn-th field="isInventory" center>Is inventory</vn-th>
|
|
||||||
<vn-th field="isConfirmed" center>Confirmed</vn-th>
|
|
||||||
<vn-th field="isOrdered" center>Ordered</vn-th>
|
|
||||||
<vn-th field="isRaid" center>Is raid</vn-th>
|
|
||||||
<vn-th center>Commission</vn-th>
|
|
||||||
<vn-th field="supplierFk">Supplier</vn-th>
|
<vn-th field="supplierFk">Supplier</vn-th>
|
||||||
<vn-th field="currencyFk" center>Currency</vn-th>
|
<vn-th field="currencyFk" center>Currency</vn-th>
|
||||||
<vn-th field="companyFk" center>Company</vn-th>
|
<vn-th field="companyFk" center>Company</vn-th>
|
||||||
|
<vn-th field="isBooked" center>Booked</vn-th>
|
||||||
|
<vn-th field="isConfirmed" center>Confirmed</vn-th>
|
||||||
|
<vn-th field="isOrdered" center>Ordered</vn-th>
|
||||||
|
<vn-th>Notes</vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<a ng-repeat="entry in entries"
|
<a ng-repeat="entry in entries"
|
||||||
class="clickable vn-tr search-result"
|
class="clickable vn-tr search-result"
|
||||||
ui-sref="entry.card.summary({id: {{::entry.id}}})">
|
ui-sref="entry.card.summary({id: {{::entry.id}}})">
|
||||||
|
<vn-td>
|
||||||
|
<vn-icon
|
||||||
|
ng-show="entry.isInventory"
|
||||||
|
class="bright"
|
||||||
|
vn-tooltip="Inventory entry"
|
||||||
|
icon="icon-unavailable">
|
||||||
|
</vn-icon>
|
||||||
|
<vn-icon
|
||||||
|
ng-show="entry.isRaid"
|
||||||
|
class="bright"
|
||||||
|
vn-tooltip="Virtual entry"
|
||||||
|
icon="icon-100">
|
||||||
|
</vn-icon>
|
||||||
|
</vn-td>
|
||||||
<vn-td number>{{::entry.id}}</vn-td>
|
<vn-td number>{{::entry.id}}</vn-td>
|
||||||
<vn-td center>{{::entry.created | date:'dd/MM/yyyy'}}</vn-td>
|
<vn-td center>
|
||||||
<vn-td center expand>{{::entry.travelFk}}</vn-td>
|
<span
|
||||||
<vn-td expand>{{::entry.notes}}</vn-td>
|
class="link"
|
||||||
|
ng-click="$ctrl.showTravelDescriptor($event, entry.travelFk)">
|
||||||
|
{{::entry.landed | date:'dd/MM/yyyy'}}
|
||||||
|
</span>
|
||||||
|
</vn-td>
|
||||||
<vn-td expand>{{::entry.ref}}</vn-td>
|
<vn-td expand>{{::entry.ref}}</vn-td>
|
||||||
<vn-td center><vn-check ng-model="entry.isBooked" disabled="true"></vn-check></vn-td>
|
|
||||||
<vn-td center><vn-check ng-model="entry.isInventory" disabled="true"></vn-check></vn-td>
|
|
||||||
<vn-td center><vn-check ng-model="entry.isConfirmed" disabled="true"></vn-check></vn-td>
|
|
||||||
<vn-td center><vn-check ng-model="entry.isOrdered" disabled="true"></vn-check></vn-td>
|
|
||||||
<vn-td center><vn-check ng-model="entry.isRaid" disabled="true"></vn-check></vn-td>
|
|
||||||
<vn-td center expand>{{::entry.commission}}</vn-td>
|
|
||||||
<vn-td expand>{{::entry.supplierName}}</vn-td>
|
<vn-td expand>{{::entry.supplierName}}</vn-td>
|
||||||
<vn-td center expand>{{::entry.currencyCode}}</vn-td>
|
<vn-td center expand>{{::entry.currencyCode}}</vn-td>
|
||||||
<vn-td center expand>{{::entry.companyCode}}</vn-td>
|
<vn-td center expand>{{::entry.companyCode}}</vn-td>
|
||||||
|
<vn-td center><vn-check ng-model="entry.isBooked" disabled="true"></vn-check></vn-td>
|
||||||
|
<vn-td center><vn-check ng-model="entry.isConfirmed" disabled="true"></vn-check></vn-td>
|
||||||
|
<vn-td center><vn-check ng-model="entry.isOrdered" disabled="true"></vn-check></vn-td>
|
||||||
|
<vn-td shrink>
|
||||||
|
<vn-icon
|
||||||
|
ng-if="entry.notes.length"
|
||||||
|
vn-tooltip="{{::entry.notes}}"
|
||||||
|
icon="insert_drive_file">
|
||||||
|
</vn-icon>
|
||||||
|
</vn-td>
|
||||||
</a>
|
</a>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
<vn-travel-descriptor-popover
|
||||||
|
vn-id="travelDescriptor"
|
||||||
|
travel-fk="$ctrl.selectedTravel">
|
||||||
|
</vn-travel-descriptor-popover>
|
||||||
<vn-popup vn-id="summary">
|
<vn-popup vn-id="summary">
|
||||||
<vn-entry-summary
|
<vn-entry-summary
|
||||||
entry="$ctrl.entrySelected">
|
entry="$ctrl.entrySelected">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
export default class Controller {
|
export default class Controller {
|
||||||
constructor($scope) {
|
constructor($scope) {
|
||||||
this.$ = $scope;
|
this.$ = $scope;
|
||||||
|
@ -11,6 +11,16 @@ export default class Controller {
|
||||||
else
|
else
|
||||||
this.$.model.clear();
|
this.$.model.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showTravelDescriptor(event, travelFk) {
|
||||||
|
if (event.defaultPrevented) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
this.selectedTravel = travelFk;
|
||||||
|
this.$.travelDescriptor.parent = event.target;
|
||||||
|
this.$.travelDescriptor.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$scope'];
|
Controller.$inject = ['$scope'];
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
Inventory entry: Es inventario
|
||||||
|
Virtual entry: Es una redada
|
||||||
|
Supplier: Proveedor
|
||||||
|
Currency: Moneda
|
||||||
|
Company: Empresa
|
||||||
|
Confirmed: Confirmada
|
||||||
|
Ordered: Pedida
|
||||||
|
Is raid: Redada
|
||||||
|
Commission: Comisión
|
||||||
|
Landed: F. entrega
|
||||||
|
Reference: Referencia
|
||||||
|
Created: Creado
|
||||||
|
Booked: Facturado
|
||||||
|
Is inventory: Inventario
|
||||||
|
Notes: Notas
|
|
@ -0,0 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
|
vn-icon[icon=insert_drive_file]{
|
||||||
|
color: $color-font-secondary;
|
||||||
|
}
|
|
@ -1,15 +1,3 @@
|
||||||
#Ordenar alfabeticamente
|
#Ordenar alfabeticamente
|
||||||
Reference: Referencia
|
|
||||||
Created: Creado
|
|
||||||
Booked: Facturado
|
|
||||||
Is inventory: Inventario
|
|
||||||
Notes: Notas
|
|
||||||
Travel: Envío
|
|
||||||
Supplier: Proveedor
|
|
||||||
Currency: Moneda
|
|
||||||
Company: Empresa
|
|
||||||
Confirmed: Confirmada
|
|
||||||
Ordered: Pedida
|
|
||||||
Is raid: Redada
|
|
||||||
Commission: Comisión
|
|
||||||
# Sections
|
# Sections
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"module": "entry",
|
"module": "entry",
|
||||||
"name": "Entries",
|
"name": "Entries",
|
||||||
"icon": "icon-entry",
|
"icon": "icon-entry",
|
||||||
|
"dependencies": ["travel"],
|
||||||
"validations": true,
|
"validations": true,
|
||||||
"menus": {
|
"menus": {
|
||||||
"main": [
|
"main": [
|
||||||
|
|
|
@ -22,6 +22,7 @@ module.exports = Self => {
|
||||||
let where = filter.where;
|
let where = filter.where;
|
||||||
let query = `CALL vn.itemLastEntries(?, ?)`;
|
let query = `CALL vn.itemLastEntries(?, ?)`;
|
||||||
let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]);
|
let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]);
|
||||||
|
|
||||||
return lastEntries;
|
return lastEntries;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe('Travel filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.Travel.filter(ctx);
|
let result = await app.models.Travel.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(7);
|
expect(result.length).toEqual(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the travel matching "total entries"', async() => {
|
it('should return the travel matching "total entries"', async() => {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<vn-popover vn-id="popover">
|
||||||
|
<vn-spinner
|
||||||
|
ng-if="$ctrl.travel == null"
|
||||||
|
style="padding: 1em;"
|
||||||
|
enable="true">
|
||||||
|
</vn-spinner>
|
||||||
|
<vn-travel-descriptor
|
||||||
|
ng-if="$ctrl.travel"
|
||||||
|
travel="$ctrl.travel"
|
||||||
|
quicklinks="$ctrl.quicklinks">
|
||||||
|
</vn-travel-descriptor>
|
||||||
|
</vn-popover>
|
|
@ -0,0 +1,88 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Component from 'core/lib/component';
|
||||||
|
|
||||||
|
class Controller extends Component {
|
||||||
|
constructor($element, $scope, $http, $timeout, $q) {
|
||||||
|
super($element, $scope);
|
||||||
|
this.$timeout = $timeout;
|
||||||
|
this.$http = $http;
|
||||||
|
this.$q = $q;
|
||||||
|
this.travel = null;
|
||||||
|
this._quicklinks = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
set travelFk(travelFk) {
|
||||||
|
if (travelFk == this._travelFk) return;
|
||||||
|
|
||||||
|
this._travelFk = travelFk;
|
||||||
|
this.travel = null;
|
||||||
|
this.loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
get travelFk() {
|
||||||
|
return this._travelFk;
|
||||||
|
}
|
||||||
|
|
||||||
|
get quicklinks() {
|
||||||
|
return this._quicklinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
set quicklinks(value = {}) {
|
||||||
|
Object.keys(value).forEach(key => {
|
||||||
|
this._quicklinks[key] = value[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
this.$.popover.parent = this.parent;
|
||||||
|
this.$.popover.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadData() {
|
||||||
|
let query = `Travels/findOne`;
|
||||||
|
let filter = {
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'ref',
|
||||||
|
'shipped',
|
||||||
|
'landed',
|
||||||
|
'totalEntries',
|
||||||
|
'warehouseInFk',
|
||||||
|
'warehouseOutFk'
|
||||||
|
],
|
||||||
|
where: {
|
||||||
|
id: this._travelFk
|
||||||
|
},
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'warehouseIn',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
relation: 'warehouseOut',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$http.get(query, {params: {filter}}).then(res => {
|
||||||
|
this.travel = res.data;
|
||||||
|
this.$.$applyAsync(() => {
|
||||||
|
this.$.popover.relocate();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
|
||||||
|
|
||||||
|
ngModule.component('vnTravelDescriptorPopover', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
travelFk: '<',
|
||||||
|
quicklinks: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,100 @@
|
||||||
|
import './index.js';
|
||||||
|
|
||||||
|
describe('travel Component vnTravelDescriptorPopover', () => {
|
||||||
|
let $httpBackend;
|
||||||
|
let $httpParamSerializer;
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
let $element;
|
||||||
|
|
||||||
|
beforeEach(ngModule('travel'));
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
|
$element = angular.element(`<div></div>`);
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.popover = {relocate: () => {}, show: () => {}};
|
||||||
|
controller = $componentController('vnTravelDescriptorPopover', {$scope, $element});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('travelFk()', () => {
|
||||||
|
it(`should not apply any changes if the received id is the same stored in _travelFk`, () => {
|
||||||
|
controller.travel = 'I exist!';
|
||||||
|
controller._travelFk = 1;
|
||||||
|
spyOn(controller, 'loadData');
|
||||||
|
controller.travelFk = 1;
|
||||||
|
|
||||||
|
expect(controller.travel).toEqual('I exist!');
|
||||||
|
expect(controller._travelFk).toEqual(1);
|
||||||
|
expect(controller.loadData).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should set the received id into _travelFk, set the travel to null and then call loadData()`, () => {
|
||||||
|
controller.travel = `Please don't`;
|
||||||
|
controller._travelFk = 1;
|
||||||
|
spyOn(controller, 'loadData');
|
||||||
|
controller.travelFk = 999;
|
||||||
|
|
||||||
|
expect(controller.travel).toBeNull();
|
||||||
|
expect(controller._travelFk).toEqual(999);
|
||||||
|
expect(controller.loadData).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('show()', () => {
|
||||||
|
it(`should call the show()`, () => {
|
||||||
|
spyOn(controller.$.popover, 'show');
|
||||||
|
controller.show();
|
||||||
|
|
||||||
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('loadData()', () => {
|
||||||
|
it(`should perform a get query to store the worker data into the controller`, () => {
|
||||||
|
controller.travelFk = 1;
|
||||||
|
controller.canceler = null;
|
||||||
|
let response = {};
|
||||||
|
|
||||||
|
let config = {
|
||||||
|
filter: {
|
||||||
|
fields: [
|
||||||
|
'id',
|
||||||
|
'ref',
|
||||||
|
'shipped',
|
||||||
|
'landed',
|
||||||
|
'totalEntries',
|
||||||
|
'warehouseInFk',
|
||||||
|
'warehouseOutFk'
|
||||||
|
],
|
||||||
|
where: {
|
||||||
|
id: controller.travelFk
|
||||||
|
},
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'warehouseIn',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
relation: 'warehouseOut',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let json = $httpParamSerializer(config);
|
||||||
|
|
||||||
|
$httpBackend.whenGET(`Travels/findOne?${json}`).respond(response);
|
||||||
|
$httpBackend.expectGET(`Travels/findOne?${json}`);
|
||||||
|
controller.loadData();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.travel).toEqual(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -11,4 +11,4 @@ import './log';
|
||||||
import './create';
|
import './create';
|
||||||
import './thermograph/index/';
|
import './thermograph/index/';
|
||||||
import './thermograph/create/';
|
import './thermograph/create/';
|
||||||
|
import './descriptor-popover';
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Component from 'core/lib/component';
|
import Component from 'core/lib/component';
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
class Controller extends Component {
|
class Controller extends Component {
|
||||||
constructor($element, $scope, $http, $timeout, $q) {
|
constructor($element, $scope, $http, $timeout, $q) {
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
vn-ticket-descriptor-popover {
|
|
||||||
vn-ticket-descriptor {
|
|
||||||
display: block;
|
|
||||||
width: 16em;
|
|
||||||
max-height: 28em;
|
|
||||||
|
|
||||||
& > vn-card {
|
|
||||||
margin: 0!important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue