#460 expedition
This commit is contained in:
parent
eea42ec958
commit
dda12c4b62
|
@ -22,6 +22,7 @@ Worker: Trabajador
|
|||
Send: Enviar
|
||||
Sample: Plantilla
|
||||
Credit: Crédito
|
||||
Are you sure you want to delete this expedition?: Está seguro de borrar esta expedición?
|
||||
|
||||
# Sections
|
||||
Clients: Clientes
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/ticket/api/Expeditions"
|
||||
filter="::$ctrl.filter"
|
||||
url="/ticket/api/Expeditions/filter"
|
||||
link="{ticketFk: $ctrl.$stateParams.id}"
|
||||
limit="20"
|
||||
data="expeditions">
|
||||
|
@ -33,17 +32,17 @@
|
|||
vn-tooltip="Delete expedition"
|
||||
ng-click="$ctrl.deleteExpedition(expedition)">delete</i>
|
||||
</vn-td>
|
||||
<vn-td pointer number
|
||||
ng-click="$ctrl.showDescriptor($event, expedition.item.id)"
|
||||
class="link">
|
||||
{{("000000"+expedition.itemFk).slice(-6)}}
|
||||
<vn-td number
|
||||
ng-class="{'link pointer':expedition.itemFk}"
|
||||
ng-click="$ctrl.showDescriptor($event, expedition.itemFk)">
|
||||
{{expedition.itemFk}}
|
||||
</vn-td>
|
||||
<vn-td>{{::expedition.item.name}}</vn-td>
|
||||
<vn-td>{{::expedition.box.name}}</vn-td>
|
||||
<vn-td>{{::expedition.namePackage}}</vn-td>
|
||||
<vn-td>{{::expedition.nameBox}}</vn-td>
|
||||
<vn-td number>{{::expedition.counter}}</vn-td>
|
||||
<vn-td number>{{::expedition.checked}}</vn-td>
|
||||
<vn-td>{{::expedition.worker.firstName}} {{::expedition.worker.name}}</vn-td>
|
||||
<vn-td>{{::expedition.created | date:'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td>{{::expedition.firstName}} {{::expedition.nameWorker}}</vn-td>
|
||||
<vn-td>{{::expedition.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
<vn-empty-rows ng-if="model.data.length === 0" translate>
|
||||
|
@ -58,3 +57,9 @@
|
|||
</vn-card>
|
||||
</vn-vertical>
|
||||
<vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover>
|
||||
<vn-confirm
|
||||
vn-id="delete-expedition"
|
||||
on-response="$ctrl.returnDialog(response)"
|
||||
question="Delete expedition"
|
||||
message="Are you sure you want to delete this expedition?">
|
||||
</vn-confirm>
|
|
@ -5,33 +5,23 @@ class Controller {
|
|||
this.$scope = $scope;
|
||||
this.$stateParams = $stateParams;
|
||||
this.$http = $http;
|
||||
this.filter = {
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'box',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {fields: ['firstName', 'name']}
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
deleteExpedition(expedition) {
|
||||
this.$http.delete(`/ticket/api/Expeditions/${expedition.id}`, this.params).then(
|
||||
() => this.$scope.model.refresh()
|
||||
);
|
||||
this.expeditionId = expedition.id;
|
||||
this.$scope.deleteExpedition.show();
|
||||
}
|
||||
|
||||
returnDialog(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
this.$http.delete(`/ticket/api/Expeditions/${this.expeditionId}`).then(
|
||||
() => this.$scope.model.refresh()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
showDescriptor(event, itemFk) {
|
||||
if (!itemFk) return;
|
||||
this.$scope.descriptor.itemFk = itemFk;
|
||||
this.$scope.descriptor.parent = event.target;
|
||||
this.$scope.descriptor.show();
|
||||
|
|
|
@ -24,15 +24,16 @@ describe('Ticket', () => {
|
|||
controller = $componentController('vnTicketExpedition', {$state: $state}, {$scope: $scope});
|
||||
}));
|
||||
|
||||
describe('deleteExpedition()', () => {
|
||||
describe('returnDialog()', () => {
|
||||
it('should perform a DELETE query', () => {
|
||||
spyOn($scope.model, 'refresh');
|
||||
|
||||
let expedition = {id: 1};
|
||||
let response = 'ACCEPT';
|
||||
controller.expeditionId = 1;
|
||||
|
||||
$httpBackend.when('DELETE', `/ticket/api/Expeditions/1`).respond(200);
|
||||
$httpBackend.expect('DELETE', `/ticket/api/Expeditions/1`);
|
||||
controller.deleteExpedition(expedition);
|
||||
controller.returnDialog(response);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($scope.model.refresh).toHaveBeenCalledWith();
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('filter', {
|
||||
description: 'Find all instances of the model matched by filter from the data source.',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['Object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/filter`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.filter = async filter => {
|
||||
let stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
e.ticketFk,
|
||||
e.isBox,
|
||||
i1.name namePackage,
|
||||
e.counter,
|
||||
e.checked,
|
||||
i2.name nameBox,
|
||||
e.itemFk,
|
||||
w.name nameWorker,
|
||||
w.firstName,
|
||||
e.created
|
||||
FROM
|
||||
vn.expedition e
|
||||
LEFT JOIN vn.item i2 ON i2.id = e.itemFk
|
||||
INNER JOIN vn.item i1 ON i1.id = e.isBox
|
||||
LEFT JOIN vn.worker w ON w.id = e.workerFk
|
||||
`);
|
||||
stmt.merge(Self.buildSuffix(filter, 'e'));
|
||||
|
||||
return await Self.rawStmt(stmt);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/expedition/filter')(Self);
|
||||
};
|
Loading…
Reference in New Issue