2999-ticket_dms_import_from_existing + buyer to ticket.isEditable #678
|
@ -0,0 +1,4 @@
|
|||
DELETE FROM `salix`.`ACL` WHERE id = 189;
|
||||
DELETE FROM `salix`.`ACL` WHERE id = 188;
|
||||
UPDATE `salix`.`ACL` tdms SET tdms.accessType = '*'
|
||||
WHERE tdms.id = 165;
|
|
@ -1 +0,0 @@
|
|||
Delete me
|
|
@ -646,6 +646,12 @@ export default {
|
|||
saveServiceButton: 'button[type=submit]',
|
||||
saveServiceTypeButton: '.vn-dialog.shown tpl-buttons > button'
|
||||
},
|
||||
ticketDms: {
|
||||
import: 'vn-ticket-dms-index vn-button[icon="file_copy"]',
|
||||
document: 'vn-autocomplete[ng-model="$ctrl.dmsId"]',
|
||||
saveImport: 'button[response="accept"]',
|
||||
anyDocument: 'vn-ticket-dms-index > vn-data-viewer vn-tbody vn-tr'
|
||||
},
|
||||
createStateView: {
|
||||
state: 'vn-autocomplete[ng-model="$ctrl.stateFk"]',
|
||||
worker: 'vn-autocomplete[ng-model="$ctrl.workerFk"]',
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Ticket DMS path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'ticket');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('ticket.card.dms.index');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should import a document', async() => {
|
||||
await page.waitToClick(selectors.ticketDms.import);
|
||||
await page.autocompleteSearch(selectors.ticketDms.document, '1');
|
||||
await page.waitToClick(selectors.ticketDms.saveImport);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it(`should check there's a listed document now`, async() => {
|
||||
const result = await page.countElement(selectors.ticketDms.anyDocument);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
|
||||
it('should attempt to import an existing document on this ticket', async() => {
|
||||
await page.waitToClick(selectors.ticketDms.import);
|
||||
await page.autocompleteSearch(selectors.ticketDms.document, '1');
|
||||
await page.waitToClick(selectors.ticketDms.saveImport);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('This document already exists on this ticket');
|
||||
});
|
||||
|
||||
it(`should check there's still one document`, async() => {
|
||||
const result = await page.countElement(selectors.ticketDms.anyDocument);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -98,5 +98,6 @@
|
|||
"Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})",
|
||||
"None": "None",
|
||||
"error densidad = 0": "error densidad = 0",
|
||||
"nickname": "nickname"
|
||||
"nickname": "nickname",
|
||||
"This document already exists on this ticket": "This document already exists on this ticket"
|
||||
}
|
|
@ -181,5 +181,6 @@
|
|||
"This specie already exist": "Esta especie ya existe",
|
||||
"Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
|
||||
"None": "Ninguno",
|
||||
"The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada"
|
||||
"The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada",
|
||||
"This document already exists on this ticket": "Este documento ya existe en el ticket"
|
||||
}
|
|
@ -32,7 +32,9 @@ module.exports = Self => {
|
|||
|
||||
const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant', myOptions);
|
||||
const isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss', myOptions);
|
||||
const isValidRole = isSalesAssistant || isProductionBoss;
|
||||
const isBuyer = await Self.app.models.Account.hasRole(userId, 'buyer', myOptions);
|
||||
|
||||
const isValidRole = isSalesAssistant || isProductionBoss || isBuyer;
|
||||
|
||||
let alertLevel = state ? state.alertLevel : null;
|
||||
let ticket = await Self.app.models.Ticket.findById(id, {
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
require('../methods/ticket-dms/removeFile')(Self);
|
||||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError('This document already exists on this ticket');
|
||||
return err;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
},
|
||||
"properties": {
|
||||
"dmsFk": {
|
||||
"type": "Number",
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"required": true
|
||||
}
|
||||
|
|
|
@ -96,18 +96,48 @@
|
|||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<div fixed-bottom-right>
|
||||
<vn-vertical style="align-items: center;">
|
||||
<vn-button class="round sm vn-mb-sm"
|
||||
icon="file_copy"
|
||||
ng-click="$ctrl.$.dmsImportDialog.show()"
|
||||
vn-tooltip="Import from existing"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
<a ui-sref="ticket.card.dms.create" vn-bind="+">
|
||||
<vn-button class="round md vn-mb-sm"
|
||||
icon="publish"
|
||||
vn-tooltip="Upload file"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
</a>
|
||||
</vn-vertical>
|
||||
</div>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<a ui-sref="ticket.card.dms.create"
|
||||
vn-tooltip="Upload file"
|
||||
vn-bind="+"
|
||||
fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
||||
<vn-confirm
|
||||
vn-id="confirm"
|
||||
message="This file will be deleted"
|
||||
question="Are you sure you want to continue?"
|
||||
on-accept="$ctrl.deleteDms($data)">
|
||||
</vn-confirm>
|
||||
|
||||
<vn-dialog
|
||||
message="Select document id"
|
||||
vn-id="dmsImportDialog"
|
||||
on-accept="$ctrl.importDms()">
|
||||
<tpl-body>
|
||||
<vn-autocomplete
|
||||
label="Document"
|
||||
ng-model="$ctrl.dmsId"
|
||||
url="Dms"
|
||||
show-field="id"
|
||||
vn-focus>
|
||||
</vn-autocomplete>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -55,6 +55,28 @@ class Controller extends Section {
|
|||
downloadFile(dmsId) {
|
||||
this.vnFile.download(`api/dms/${dmsId}/downloadFile`);
|
||||
}
|
||||
|
||||
importDms() {
|
||||
try {
|
||||
if (!this.dmsId)
|
||||
throw new Error(`The document indentifier can't be empty`);
|
||||
|
||||
const data = {
|
||||
ticketFk: this.$params.id,
|
||||
dmsFk: this.dmsId
|
||||
};
|
||||
|
||||
this.$http.post('ticketDms', data).then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.dmsId = null;
|
||||
this.$.model.refresh();
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', 'vnFile'];
|
||||
|
|
|
@ -7,3 +7,6 @@ Generate identifier for original file: Generar identificador para archivo origin
|
|||
ContentTypesInfo: 'Tipos de archivo permitidos: {{allowedContentTypes}}'
|
||||
Are you sure you want to continue?: ¿Seguro que quieres continuar?
|
||||
File management: Gestión documental
|
||||
Select document id: Introduzca id de gestion documental
|
||||
Import from existing: Importar desde existente
|
||||
The document indentifier can't be empty: El número de documento no puede estar vacío
|
Loading…
Reference in New Issue