This commit is contained in:
parent
2c012b084a
commit
69434caa52
|
@ -1,3 +1,4 @@
|
|||
|
||||
{
|
||||
"name": "Dms",
|
||||
"description": "Documental Managment system",
|
||||
|
@ -22,6 +23,12 @@
|
|||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"hardCopyNumber": {
|
||||
"type": "Number"
|
||||
},
|
||||
"hasFile": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"created": {
|
||||
"type": "Date"
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
"path": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"code": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` ( `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ( 'ClientDms', 'remove', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` ( `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ( 'ClientDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,19 @@
|
|||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP FOREIGN KEY `clientes_gestdoc_ibfk_3`;
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`gest_doc_id`);
|
||||
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP INDEX `fk_clientes_gestdoc_1_idx` ;
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD INDEX `fk_clientes_gestdoc_1_idx` (`Id_Cliente` ASC);
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD CONSTRAINT `fk_clientes_gestdoc_3`
|
||||
FOREIGN KEY (`Id_Cliente`)
|
||||
REFERENCES `vn2008`.`Clientes` (`id_cliente`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -0,0 +1,9 @@
|
|||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD INDEX `fk_clientes_gestdoc_1_idx` (`Id_Cliente` ASC);
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD CONSTRAINT `fk_clientes_gestdoc_3`
|
||||
FOREIGN KEY (`Id_Cliente`)
|
||||
REFERENCES `vn2008`.`Clientes` (`id_cliente`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -1458,7 +1458,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `c
|
|||
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
||||
VALUES
|
||||
(1, 14, '1.pdf', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', CURDATE()),
|
||||
(2, 5, '2.pdf', 5, 1, 442, 1, TRUE, 'Client:101', 'Client:101 dms for the client', CURDATE());
|
||||
(2, 5, '2.pdf', 5, 1, 442, 1, TRUE, 'Client:101', 'Client:101 dms for the client', CURDATE()),
|
||||
(3, 5, '3.pdf', 5, 1, 442, NULL, TRUE, 'Client: 101', 'Client:101 readme', CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`ticketDms`(`ticketFk`, `dmsFk`)
|
||||
VALUES
|
||||
|
@ -1466,4 +1467,5 @@ INSERT INTO `vn`.`ticketDms`(`ticketFk`, `dmsFk`)
|
|||
|
||||
INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
|
||||
VALUES
|
||||
(101, 2);
|
||||
(101, 2),
|
||||
(101, 3);
|
|
@ -0,0 +1,35 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('removes', {
|
||||
description: 'Delete an client dms',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
arg: 'dmsId',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'dms identifier',
|
||||
},
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/removes`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.removes = async dmsId => {
|
||||
if (!dmsId)
|
||||
throw new UserError('There is nothing to delete');
|
||||
|
||||
let targetClientDms = await Self.app.models.ClientDms.findOne({where: {dmsFk: dmsId}});
|
||||
let targetDms = await Self.app.models.Dms.findById(dmsId);
|
||||
let trashDmsType = await Self.app.models.DmsType.findOne({where: {code: 'trash'}});
|
||||
|
||||
await targetClientDms.destroy();
|
||||
await targetDms.updateAttribute('dmsTypeFk', trashDmsType.id);
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Client dms stuff', () => {
|
||||
let dmsToRestore;
|
||||
let dmsTypeToRestore;
|
||||
afterAll(async done => {
|
||||
await app.models.ClientDms.create(dmsToRestore);
|
||||
await dmsTypeToRestore.save();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
it('should delete a dms from a client and update the dmsType to trash', async() => {
|
||||
const dmsId = 2;
|
||||
|
||||
dmsToRestore = await app.models.ClientDms.findOne({where: {dmsFk: dmsId}});
|
||||
dmsTypeToRestore = await app.models.Dms.findById(dmsToRestore.dmsFk);
|
||||
|
||||
await app.models.ClientDms.removes(dmsId);
|
||||
|
||||
let destroyedDms = await app.models.ClientDms.findOne({where: {dmsFk: dmsId}});
|
||||
|
||||
let alteredDmsType = await app.models.Dms.findById(dmsId);
|
||||
|
||||
expect(destroyedDms).toBeNull();
|
||||
expect(alteredDmsType.dmsTypeFk).toEqual(13);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/dms/removes')(Self);
|
||||
};
|
|
@ -3,7 +3,7 @@
|
|||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"ClientLog",
|
||||
"relation": "ticket",
|
||||
"relation": "client",
|
||||
"showField": "dmsFk"
|
||||
},
|
||||
"options": {
|
||||
|
@ -12,14 +12,13 @@
|
|||
}
|
||||
},
|
||||
"properties": {
|
||||
"clientFk": {
|
||||
"dmsFk": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"required": true
|
||||
},
|
||||
"dmsFk": {
|
||||
"clientFk": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
|
@ -36,3 +35,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/client/api/ClientDms"
|
||||
link="{clientFk: $ctrl.$stateParams.id}"
|
||||
filter="::$ctrl.filter"
|
||||
limit="20"
|
||||
data="$ctrl.clientDms">
|
||||
</vn-crud-model>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="dmsFk" default-order="DESC" number>File</vn-th>
|
||||
<vn-th>Description</vn-th>
|
||||
<vn-th>Reference</vn-th>
|
||||
<vn-th number>Hard copy</vn-th>
|
||||
<vn-th>Worker</vn-th>
|
||||
<vn-th>Created</vn-th>
|
||||
<vn-th></vn-th>
|
||||
<vn-th></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="document in $ctrl.clientDms">
|
||||
<vn-td number>{{::document.dmsFk}}</vn-td>
|
||||
<vn-td title = "{{::document.dms.description}}">
|
||||
{{::document.dms.description}}</vn-td>
|
||||
</vn-td>
|
||||
<vn-td>{{::document.dms.reference}}</vn-td>
|
||||
<vn-td number>{{::document.dms.hardCopyNumber | dashIfEmpty}}</vn-td>
|
||||
<vn-td>
|
||||
<span class="link"
|
||||
ng-click="$ctrl.showWorkerDescriptor($event, document.dms.workerFk)">
|
||||
{{::document.dms.worker.user.nickname | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::document.dms.created | dateTime:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
<vn-td center>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove file"
|
||||
icon="delete"
|
||||
ng-click="$ctrl.showDeleteConfirm(document.dmsFk)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
<vn-td center>
|
||||
<a
|
||||
target="_blank"
|
||||
href="api/dms/{{::document.dmsFk}}/download?access_token={{::$ctrl.accessToken}}">
|
||||
<vn-icon-button
|
||||
icon="cloud_download"
|
||||
title="{{'Download file' | translate}}">
|
||||
</vn-icon-button>
|
||||
</a>
|
||||
</vn-td>
|
||||
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-vertical>
|
||||
<vn-pagination model="model"></vn-pagination>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-confirm
|
||||
vn-id="confirm"
|
||||
message="This file will be deleted"
|
||||
question="Are you sure?"
|
||||
on-response="$ctrl.deleteDms(response)">
|
||||
</vn-confirm>
|
|
@ -0,0 +1,71 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams, $scope, vnToken, $http, vnApp, $translate) {
|
||||
this.$stateParams = $stateParams;
|
||||
this.$ = $scope;
|
||||
this.accessToken = vnToken.token;
|
||||
this.$http = $http;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.filter = {
|
||||
include: {
|
||||
relation: 'dms',
|
||||
scope: {
|
||||
fields: ['dmsTypeFk', 'workerFk', 'file', 'created', 'description', 'reference', 'hardCopyNumber'],
|
||||
include: [{
|
||||
relation: 'dmsType',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
}
|
||||
},
|
||||
}
|
||||
}]
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
showWorkerDescriptor(event, workerFk) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
this.$.workerDescriptor.parent = event.target;
|
||||
this.$.workerDescriptor.workerFk = workerFk;
|
||||
this.$.workerDescriptor.show();
|
||||
}
|
||||
|
||||
showDeleteConfirm(dmsId) {
|
||||
this.selectedDms = dmsId;
|
||||
this.$.confirm.show();
|
||||
}
|
||||
|
||||
deleteDms(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
let dmsId = this.selectedDms;
|
||||
let query = `/client/api/ClientDms/removes`;
|
||||
|
||||
this.$http.post(query, {dmsId}).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$stateParams', '$scope', 'vnToken', '$http', 'vnApp', '$translate'];
|
||||
|
||||
ngModule.component('vnClientDms', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
});
|
|
@ -0,0 +1,9 @@
|
|||
Type: Tipo
|
||||
File management: Gestión documental
|
||||
File: Fichero
|
||||
Hard copy: Copia
|
||||
This file will be deleted: Este fichero va a ser borrado
|
||||
Are you sure?: Estas seguro?
|
||||
File deleted: Fichero eliminado
|
||||
Remove file: Eliminar fichero
|
||||
Download file: Descargar fichero
|
|
@ -0,0 +1,6 @@
|
|||
vn-client-risk-index {
|
||||
.totalBox {
|
||||
display: table;
|
||||
float: right;
|
||||
}
|
||||
}
|
|
@ -35,4 +35,5 @@ import './sample/create';
|
|||
import './web-payment';
|
||||
import './log';
|
||||
import './sms';
|
||||
import './dms';
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
{"state": "client.card.creditInsurance.index", "icon": "icon-solunion"},
|
||||
{"state": "client.card.contact", "icon": "contact_phone"},
|
||||
{"state": "client.card.sample.index", "icon": "mail"},
|
||||
{"state": "client.card.webPayment", "icon": "icon-onlinepayment"}
|
||||
{"state": "client.card.webPayment", "icon": "icon-onlinepayment"},
|
||||
{"state": "client.card.dms", "icon": "cloud_download"}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -314,6 +315,12 @@
|
|||
"state": "client.card.log",
|
||||
"component": "vn-client-log",
|
||||
"description": "Log"
|
||||
},
|
||||
{
|
||||
"url": "/dms",
|
||||
"state": "client.card.dms",
|
||||
"component": "vn-client-dms",
|
||||
"description": "File management"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
},
|
||||
"componentTypeRate": {
|
||||
"type": "Number"
|
||||
},
|
||||
"code": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
Loading…
Reference in New Issue