This commit is contained in:
Bernat 2019-01-11 12:26:06 +01:00
commit f7244cc22b
8 changed files with 102 additions and 32 deletions

View File

@ -0,0 +1,35 @@
import './index.js';
describe('Component vnTable', () => {
let $scope;
let $element;
let controller;
beforeEach(ngModule('vnCore'));
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$element = angular.element(`
<vn-table model="model">
<vn-thead class="ng-scope">
<vn-tr>
<vn-th field="id"></vn-th>
<vn-th field="salesPerson" class="active"></vn-th>
<vn-th field="shipped" class="active"></vn-th>
</vn-tr>
</vn-thead>
</vn-table>`);
controller = $componentController('vnTable', {$scope, $element, $transclude: () => {}});
}));
describe('setActiveArrow()', () => {
it(`should remove the active class from all table headers and then add it to the one in field`, () => {
controller.field = 'id';
controller.setActiveArrow();
expect($element[0].getElementsByClassName('active')[0].getAttribute('field')).toEqual('id');
expect($element[0].getElementsByClassName('active').length).toEqual(1);
});
});
});

View File

@ -0,0 +1,27 @@
module.exports = Self => {
Self.remoteMethod('getAgenciesWithWarehouse', {
description: 'Returns a list of agencies that can land a shipment on a day for an address and a warehouse',
accessType: '',
accepts: [{
arg: 'filter',
type: 'object',
required: true,
description: 'addressFk'
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getAgenciesWithWarehouse`,
verb: 'get'
}
});
Self.getAgenciesWithWarehouse = async filter => {
let query = `CALL vn.agencyHourGetWarehouse(?, ?, ?)`;
let result = await Self.rawSql(query, [filter.addressFk, filter.landed, filter.warehouseFk]);
return result;
};
};

View File

@ -1,4 +1,5 @@
module.exports = Self => {
require('../methods/agency/landsThatDay')(Self);
require('../methods/agency/getFirstShipped')(Self);
require('../methods/agency/getAgenciesWithWarehouse')(Self);
};

View File

@ -16,7 +16,8 @@
url="/client/api/Clients"
show-field="name"
value-field="id"
label="Client">
label="Client"
order="id">
</vn-autocomplete>
<vn-autocomplete
vn-one

View File

@ -16,7 +16,8 @@
search-function="{or: [{id: {regexp: $search}}, {name: {regexp: $search}}]}"
show-field="name"
value-field="id"
field="$ctrl.order.clientFk">
field="$ctrl.order.clientFk"
order="id">
<tpl-item>{{id}}: {{name}}</tpl-item>
</vn-autocomplete>
<vn-autocomplete

View File

@ -7,7 +7,8 @@
search-function="{or: [{id: {regexp: $search}}, {name: {regexp: $search}}]}"
show-field="name"
value-field="id"
field="$ctrl.clientFk">
field="$ctrl.clientFk"
order="id">
<tpl-item>{{id}}: {{name}}</tpl-item>
</vn-autocomplete>
<vn-autocomplete

View File

@ -1,38 +1,41 @@
{
"name": "TicketPackaging",
"base": "VnModel",
"base": "Loggable",
"log": {
"model": "TicketLog",
"relation": "ticket"
},
"options": {
"mysql": {
"table": "ticketPackaging"
"table": "ticketPackaging"
}
},
"properties": {
"id": {
"id": true,
"type": "Number",
"description": "Identifier"
},
"quantity": {
"type": "Number"
},
"created": {
"type": "Date"
},
"pvp": {
"type": "Number"
}
"id": {
"id": true,
"type": "Number",
"description": "Identifier"
},
"quantity": {
"type": "Number"
},
"created": {
"type": "Date"
},
"pvp": {
"type": "Number"
}
},
"relations": {
"ticket": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "ticketFk"
},
"packaging": {
"type": "belongsTo",
"model": "Packaging",
"foreignKey": "packagingFk"
}
"ticket": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "ticketFk"
},
"packaging": {
"type": "belongsTo",
"model": "Packaging",
"foreignKey": "packagingFk"
}
}
}
}

View File

@ -9,7 +9,8 @@
show-field="name"
value-field="id"
field="$ctrl.clientFk"
initial-data="$ctrl.clientFk">
initial-data="$ctrl.clientFk"
order="id">
</vn-autocomplete>
<vn-autocomplete vn-one
data="$ctrl.addresses"