diff --git a/db/changes/10071-coffee/00-dmsType.sql b/db/changes/10071-coffee/00-dmsType.sql
deleted file mode 100644
index b8fc3b37b4..0000000000
--- a/db/changes/10071-coffee/00-dmsType.sql
+++ /dev/null
@@ -1 +0,0 @@
-INSERT INTO `vn2008`.`gesttip` (`tipo`, `path`, `writeRoleFk`, `readRoleFk`, `code`) VALUES ('Reclamación', '', '18', '1', 'claim');
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index be383e7357..cddff81231 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -1837,7 +1837,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `c
(16, 'Logistica', 'logistica', NULL, NULL, 'logistics'),
(17, 'cmr', 'cmr', NULL, NULL, 'cmr'),
(18, 'dua', 'dua', NULL, NULL, 'dua'),
- (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets');
+ (19, 'inmovilizado', 'inmovilizado', NULL, NULL, 'fixedAssets'),
+ (20, 'Reclamación', 'reclamacion', NULL, NULL, 'claim');
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
diff --git a/front/core/components/input-file/index.html b/front/core/components/input-file/index.html
index 59cfcff7dc..4e9c486316 100644
--- a/front/core/components/input-file/index.html
+++ b/front/core/components/input-file/index.html
@@ -18,7 +18,10 @@
ng-blur="$ctrl.hasFocus = false"
tabindex="{{$ctrl.input.tabindex}}"
accept="{{$ctrl.accept}}"/>
-
+
diff --git a/front/core/components/input-file/index.js b/front/core/components/input-file/index.js
index b54d5af2c0..24c0cb44ae 100644
--- a/front/core/components/input-file/index.js
+++ b/front/core/components/input-file/index.js
@@ -122,6 +122,7 @@ ngModule.component('vnInputFile', {
name: '@?',
disabled: '',
multiple: '',
+ required: '@?',
accept: '@?',
rule: '@?',
files: '=model',
diff --git a/front/core/components/textfield/textfield.html b/front/core/components/textfield/textfield.html
index 22756497f1..066ecfa569 100644
--- a/front/core/components/textfield/textfield.html
+++ b/front/core/components/textfield/textfield.html
@@ -16,7 +16,7 @@
tabindex="{{$ctrl.input.tabindex}}"/>
diff --git a/modules/claim/back/methods/claim-dms/allowedContentTypes.js b/modules/claim/back/methods/claim-dms/allowedContentTypes.js
new file mode 100644
index 0000000000..2f5183f926
--- /dev/null
+++ b/modules/claim/back/methods/claim-dms/allowedContentTypes.js
@@ -0,0 +1,23 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('allowedContentTypes', {
+ description: 'Returns a list of allowed contentTypes',
+ accessType: 'READ',
+ returns: {
+ type: ['Object'],
+ root: true
+ },
+ http: {
+ path: `/allowedContentTypes`,
+ verb: 'GET'
+ }
+ });
+
+ Self.allowedContentTypes = async() => {
+ const storageConnector = Self.app.dataSources.storage.connector;
+ const allowedContentTypes = storageConnector.allowedContentTypes;
+ const modelAllowedContentTypes = Self.definition.settings.allowedContentTypes;
+
+ return modelAllowedContentTypes || allowedContentTypes;
+ };
+};
+
diff --git a/modules/claim/back/models/claim-dms.js b/modules/claim/back/models/claim-dms.js
index 58cb1c8837..ab7beaaf54 100644
--- a/modules/claim/back/models/claim-dms.js
+++ b/modules/claim/back/models/claim-dms.js
@@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/claim-dms/removeFile')(Self);
+ require('../methods/claim-dms/allowedContentTypes')(Self);
};
diff --git a/modules/claim/back/models/claim-dms.json b/modules/claim/back/models/claim-dms.json
index 76e9e7997c..9ef9648864 100644
--- a/modules/claim/back/models/claim-dms.json
+++ b/modules/claim/back/models/claim-dms.json
@@ -10,6 +10,11 @@
"table": "claimDms"
}
},
+ "allowedContentTypes": [
+ "image/png",
+ "image/jpeg",
+ "image/jpg"
+ ],
"properties": {
"dmsFk": {
"type": "Number",
diff --git a/modules/claim/front/dms/create/index.html b/modules/claim/front/dms/create/index.html
index 58617c780b..0aba5a46ae 100644
--- a/modules/claim/front/dms/create/index.html
+++ b/modules/claim/front/dms/create/index.html
@@ -45,8 +45,15 @@
label="File"
model="$ctrl.dms.files"
on-change="$ctrl.onFileChange(files)"
- accept=".png, .jpg, .jpeg"
+ accept="{{$ctrl.allowedContentTypes}}"
multiple="true">
+
+
+
+
diff --git a/modules/claim/front/dms/create/index.js b/modules/claim/front/dms/create/index.js
index 15a0dbcbc2..2560d6c249 100644
--- a/modules/claim/front/dms/create/index.js
+++ b/modules/claim/front/dms/create/index.js
@@ -22,8 +22,23 @@ class Controller {
set claim(value) {
this._claim = value;
- if (value)
+ if (value) {
this.setDefaultParams();
+ this.getAllowedContentTypes();
+ }
+ }
+
+ getAllowedContentTypes() {
+ this.$http.get('/api/claimDms/allowedContentTypes').then(res => {
+ const contentTypes = res.data.join(', ');
+ this.allowedContentTypes = contentTypes;
+ });
+ }
+
+ get contentTypesInfo() {
+ return this.$translate.instant('ContentTypesInfo', {
+ allowedContentTypes: this.allowedContentTypes
+ });
}
setDefaultParams() {
diff --git a/modules/claim/front/dms/create/index.spec.js b/modules/claim/front/dms/create/index.spec.js
index 0031b0d382..335f691b97 100644
--- a/modules/claim/front/dms/create/index.spec.js
+++ b/modules/claim/front/dms/create/index.spec.js
@@ -22,8 +22,9 @@ describe('Claim', () => {
}));
describe('claim() setter', () => {
- it('should set the claim data and then call setDefaultParams()', () => {
+ it('should set the claim data and then call setDefaultParams() and getAllowedContentTypes()', () => {
spyOn(controller, 'setDefaultParams');
+ spyOn(controller, 'getAllowedContentTypes');
controller._claim = undefined;
controller.claim = {
id: 15,
@@ -33,6 +34,7 @@ describe('Claim', () => {
expect(controller.claim).toBeDefined();
expect(controller.setDefaultParams).toHaveBeenCalledWith();
+ expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
});
});
@@ -62,5 +64,18 @@ describe('Claim', () => {
expect(controller.dms.hasFileAttached).toBeTruthy();
});
});
+
+ describe('getAllowedContentTypes()', () => {
+ it('should make an HTTP GET request to get the allowed content types', () => {
+ const expectedResponse = ['image/png', 'image/jpg'];
+ $httpBackend.when('GET', `/api/claimDms/allowedContentTypes`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/claimDms/allowedContentTypes`);
+ controller.getAllowedContentTypes();
+ $httpBackend.flush();
+
+ expect(controller.allowedContentTypes).toBeDefined();
+ expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
+ });
+ });
});
});
diff --git a/modules/claim/front/dms/create/locale/en.yml b/modules/claim/front/dms/create/locale/en.yml
deleted file mode 100644
index 9f4c026a44..0000000000
--- a/modules/claim/front/dms/create/locale/en.yml
+++ /dev/null
@@ -1 +0,0 @@
-FileDescription: Ticket id {{ticketId}} from client {{clientName}} id {{clientId}}
\ No newline at end of file
diff --git a/modules/claim/front/dms/edit/index.html b/modules/claim/front/dms/edit/index.html
index 66df4658e7..9a74807bc9 100644
--- a/modules/claim/front/dms/edit/index.html
+++ b/modules/claim/front/dms/edit/index.html
@@ -45,7 +45,15 @@
label="File"
model="$ctrl.dms.files"
on-change="$ctrl.onFileChange(files)"
- accept=".pdf, .png, .jpg, .jpeg, application/zip, application/rar, application/x-7z-compressed">
+ accept="{{$ctrl.allowedContentTypes}}"
+ multiple="true">
+
+
+
+
diff --git a/modules/claim/front/dms/edit/index.js b/modules/claim/front/dms/edit/index.js
index 2ad609bb5d..02b1fd54bd 100644
--- a/modules/claim/front/dms/edit/index.js
+++ b/modules/claim/front/dms/edit/index.js
@@ -18,8 +18,23 @@ class Controller {
set claim(value) {
this._claim = value;
- if (value)
+ if (value) {
this.setDefaultParams();
+ this.getAllowedContentTypes();
+ }
+ }
+
+ getAllowedContentTypes() {
+ this.$http.get('/api/claimDms/allowedContentTypes').then(res => {
+ const contentTypes = res.data.join(', ');
+ this.allowedContentTypes = contentTypes;
+ });
+ }
+
+ get contentTypesInfo() {
+ return this.$translate.instant('ContentTypesInfo', {
+ allowedContentTypes: this.allowedContentTypes
+ });
}
setDefaultParams() {
diff --git a/modules/claim/front/dms/edit/index.spec.js b/modules/claim/front/dms/edit/index.spec.js
index 51940090bf..03add5ab13 100644
--- a/modules/claim/front/dms/edit/index.spec.js
+++ b/modules/claim/front/dms/edit/index.spec.js
@@ -18,8 +18,9 @@ describe('Claim', () => {
}));
describe('claim() setter', () => {
- it('should set the claim data and then call setDefaultParams()', () => {
+ it('should set the claim data and then call setDefaultParams() and getAllowedContentTypes()', () => {
spyOn(controller, 'setDefaultParams');
+ spyOn(controller, 'getAllowedContentTypes');
controller._claim = undefined;
controller.claim = {
id: 15,
@@ -28,6 +29,7 @@ describe('Claim', () => {
expect(controller.setDefaultParams).toHaveBeenCalledWith();
expect(controller.claim).toBeDefined();
+ expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
});
});
@@ -38,7 +40,7 @@ describe('Claim', () => {
reference: 101,
warehouseFk: 1,
companyFk: 442,
- dmsTypeFk: 12,
+ dmsTypeFk: 20,
description: 'Test',
hasFile: false,
hasFileAttached: false
@@ -51,7 +53,7 @@ describe('Claim', () => {
expect(controller.dms).toBeDefined();
expect(controller.dms.reference).toEqual(101);
- expect(controller.dms.dmsTypeId).toEqual(12);
+ expect(controller.dms.dmsTypeId).toEqual(20);
});
});
@@ -65,5 +67,18 @@ describe('Claim', () => {
expect(controller.dms.hasFileAttached).toBeTruthy();
});
});
+
+ describe('getAllowedContentTypes()', () => {
+ it('should make an HTTP GET request to get the allowed content types', () => {
+ const expectedResponse = ['image/png', 'image/jpg'];
+ $httpBackend.when('GET', `/api/claimDms/allowedContentTypes`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/claimDms/allowedContentTypes`);
+ controller.getAllowedContentTypes();
+ $httpBackend.flush();
+
+ expect(controller.allowedContentTypes).toBeDefined();
+ expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
+ });
+ });
});
});
diff --git a/modules/claim/front/dms/edit/locale/es.yml b/modules/claim/front/dms/edit/locale/es.yml
deleted file mode 100644
index 9d97564ba6..0000000000
--- a/modules/claim/front/dms/edit/locale/es.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-Edit file: Editar fichero
-File: Fichero
-Generate identifier for original file: Generar identificador para archivo original
\ No newline at end of file
diff --git a/modules/claim/front/dms/index/locale/es.yml b/modules/claim/front/dms/index/locale/es.yml
deleted file mode 100644
index f355af6653..0000000000
--- a/modules/claim/front/dms/index/locale/es.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-Type: Tipo
-Are you sure you want to continue?: ¿Seguro que quieres continuar?
\ No newline at end of file
diff --git a/modules/claim/front/dms/locale/en.yml b/modules/claim/front/dms/locale/en.yml
new file mode 100644
index 0000000000..a202e8bf27
--- /dev/null
+++ b/modules/claim/front/dms/locale/en.yml
@@ -0,0 +1,2 @@
+FileDescription: Ticket id {{ticketId}} from client {{clientName}} id {{clientId}}
+ContentTypesInfo: Allowed file types {{allowedContentTypes}}
\ No newline at end of file
diff --git a/modules/claim/front/dms/create/locale/es.yml b/modules/claim/front/dms/locale/es.yml
similarity index 53%
rename from modules/claim/front/dms/create/locale/es.yml
rename to modules/claim/front/dms/locale/es.yml
index d63487f04d..8a8674c5a0 100644
--- a/modules/claim/front/dms/create/locale/es.yml
+++ b/modules/claim/front/dms/locale/es.yml
@@ -1,5 +1,8 @@
Upload file: Subir fichero
+Edit file: Editar fichero
Upload: Subir
File: Fichero
FileDescription: Reclamación id {{claimId}} del cliente "{{clientName}}" id {{clientId}}
-Generate identifier for original file: Generar identificador para archivo original
\ No newline at end of file
+Generate identifier for original file: Generar identificador para archivo original
+ContentTypesInfo: "Tipos de archivo permitidos: {{allowedContentTypes}}"
+Are you sure you want to continue?: ¿Seguro que quieres continuar?
\ No newline at end of file
diff --git a/modules/client/back/methods/client-dms/allowedContentTypes.js b/modules/client/back/methods/client-dms/allowedContentTypes.js
new file mode 100644
index 0000000000..2f5183f926
--- /dev/null
+++ b/modules/client/back/methods/client-dms/allowedContentTypes.js
@@ -0,0 +1,23 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('allowedContentTypes', {
+ description: 'Returns a list of allowed contentTypes',
+ accessType: 'READ',
+ returns: {
+ type: ['Object'],
+ root: true
+ },
+ http: {
+ path: `/allowedContentTypes`,
+ verb: 'GET'
+ }
+ });
+
+ Self.allowedContentTypes = async() => {
+ const storageConnector = Self.app.dataSources.storage.connector;
+ const allowedContentTypes = storageConnector.allowedContentTypes;
+ const modelAllowedContentTypes = Self.definition.settings.allowedContentTypes;
+
+ return modelAllowedContentTypes || allowedContentTypes;
+ };
+};
+
diff --git a/modules/client/back/models/client-dms.js b/modules/client/back/models/client-dms.js
index 9e5da9132e..0cffb042c1 100644
--- a/modules/client/back/models/client-dms.js
+++ b/modules/client/back/models/client-dms.js
@@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/client-dms/removeFile')(Self);
+ require('../methods/client-dms/allowedContentTypes')(Self);
};
diff --git a/modules/client/back/models/client-dms.json b/modules/client/back/models/client-dms.json
index c919c22233..28ad219175 100644
--- a/modules/client/back/models/client-dms.json
+++ b/modules/client/back/models/client-dms.json
@@ -5,7 +5,7 @@
"model":"ClientLog",
"relation": "client",
"showField": "dmsFk"
- },
+ },
"options": {
"mysql": {
"table": "clientDms"
diff --git a/modules/client/front/dms/create/index.html b/modules/client/front/dms/create/index.html
index 6010fb4a9b..4096265788 100644
--- a/modules/client/front/dms/create/index.html
+++ b/modules/client/front/dms/create/index.html
@@ -46,7 +46,16 @@
label="File"
model="$ctrl.dms.files"
on-change="$ctrl.onFileChange(files)"
- accept=".pdf, .png, .jpg, .jpeg, application/zip, application/rar, application/x-7z-compressed">
+ accept="{{$ctrl.allowedContentTypes}}"
+ required="true"
+ multiple="true">
+
+
+
+
diff --git a/modules/client/front/dms/create/index.js b/modules/client/front/dms/create/index.js
index 924e5fb263..7f14ca1873 100644
--- a/modules/client/front/dms/create/index.js
+++ b/modules/client/front/dms/create/index.js
@@ -22,8 +22,23 @@ class Controller {
set client(value) {
this._client = value;
- if (value)
+ if (value) {
this.setDefaultParams();
+ this.getAllowedContentTypes();
+ }
+ }
+
+ getAllowedContentTypes() {
+ this.$http.get('/api/clientDms/allowedContentTypes').then(res => {
+ const contentTypes = res.data.join(', ');
+ this.allowedContentTypes = contentTypes;
+ });
+ }
+
+ get contentTypesInfo() {
+ return this.$translate.instant('ContentTypesInfo', {
+ allowedContentTypes: this.allowedContentTypes
+ });
}
setDefaultParams() {
diff --git a/modules/client/front/dms/create/index.spec.js b/modules/client/front/dms/create/index.spec.js
index 5ef4d28f3f..3cba70a00f 100644
--- a/modules/client/front/dms/create/index.spec.js
+++ b/modules/client/front/dms/create/index.spec.js
@@ -18,8 +18,9 @@ describe('Client', () => {
}));
describe('client() setter', () => {
- it('should set the client data and then call setDefaultParams()', () => {
+ it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
spyOn(controller, 'setDefaultParams');
+ spyOn(controller, 'getAllowedContentTypes');
controller.client = {
id: 15,
name: 'Bruce wayne'
@@ -27,6 +28,7 @@ describe('Client', () => {
expect(controller.client).toBeDefined();
expect(controller.setDefaultParams).toHaveBeenCalledWith();
+ expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
});
});
@@ -56,5 +58,18 @@ describe('Client', () => {
expect(controller.dms.hasFileAttached).toBeTruthy();
});
});
+
+ describe('getAllowedContentTypes()', () => {
+ it('should make an HTTP GET request to get the allowed content types', () => {
+ const expectedResponse = ['image/png', 'image/jpg'];
+ $httpBackend.when('GET', `/api/clientDms/allowedContentTypes`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/clientDms/allowedContentTypes`);
+ controller.getAllowedContentTypes();
+ $httpBackend.flush();
+
+ expect(controller.allowedContentTypes).toBeDefined();
+ expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
+ });
+ });
});
});
diff --git a/modules/client/front/dms/create/locale/en.yml b/modules/client/front/dms/create/locale/en.yml
deleted file mode 100644
index 56f6a658bb..0000000000
--- a/modules/client/front/dms/create/locale/en.yml
+++ /dev/null
@@ -1 +0,0 @@
-ClientFileDescription: "{{dmsTypeName}} from client {{clientName}} id {{clientId}}"
\ No newline at end of file
diff --git a/modules/client/front/dms/create/locale/es.yml b/modules/client/front/dms/create/locale/es.yml
deleted file mode 100644
index 2ea3b31d86..0000000000
--- a/modules/client/front/dms/create/locale/es.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-Upload file: Subir fichero
-Upload: Subir
-File: Fichero
-ClientFileDescription: "{{dmsTypeName}} del cliente {{clientName}} id {{clientId}}"
-Generate identifier for original file: Generar identificador para archivo original
\ No newline at end of file
diff --git a/modules/client/front/dms/edit/index.js b/modules/client/front/dms/edit/index.js
index be83964673..45490263b2 100644
--- a/modules/client/front/dms/edit/index.js
+++ b/modules/client/front/dms/edit/index.js
@@ -18,8 +18,23 @@ class Controller {
set client(value) {
this._client = value;
- if (value)
+ if (value) {
this.setDefaultParams();
+ this.getAllowedContentTypes();
+ }
+ }
+
+ getAllowedContentTypes() {
+ this.$http.get('/api/clientDms/allowedContentTypes').then(res => {
+ const contentTypes = res.data.join(', ');
+ this.allowedContentTypes = contentTypes;
+ });
+ }
+
+ get contentTypesInfo() {
+ return this.$translate.instant('ContentTypesInfo', {
+ allowedContentTypes: this.allowedContentTypes
+ });
}
setDefaultParams() {
diff --git a/modules/client/front/dms/edit/index.spec.js b/modules/client/front/dms/edit/index.spec.js
index 5ef4d28f3f..7faf629afc 100644
--- a/modules/client/front/dms/edit/index.spec.js
+++ b/modules/client/front/dms/edit/index.spec.js
@@ -1,43 +1,52 @@
import './index';
describe('Client', () => {
- describe('Component vnClientDmsCreate', () => {
+ describe('Component vnClientDmsEdit', () => {
let controller;
let $scope;
let $httpBackend;
- let $httpParamSerializer;
+ let $state;
beforeEach(ngModule('client'));
- beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
+ beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
- $httpParamSerializer = _$httpParamSerializer_;
- controller = $componentController('vnClientDmsCreate', {$scope});
- controller._client = {id: 101, name: 'Bruce wayne'};
+ $state = {params: {dmsId: 1}};
+ controller = $componentController('vnClientDmsEdit', {$scope, $state});
+ controller._client = {id: 1};
}));
describe('client() setter', () => {
- it('should set the client data and then call setDefaultParams()', () => {
+ it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
spyOn(controller, 'setDefaultParams');
+ spyOn(controller, 'getAllowedContentTypes');
+ controller._client = undefined;
controller.client = {
- id: 15,
- name: 'Bruce wayne'
+ id: 15
};
- expect(controller.client).toBeDefined();
expect(controller.setDefaultParams).toHaveBeenCalledWith();
+ expect(controller.client).toBeDefined();
+ expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
});
});
describe('setDefaultParams()', () => {
it('should perform a GET query and define the dms property on controller', () => {
- const params = {filter: {
- where: {code: 'paymentsLaw'}
- }};
- let serializedParams = $httpParamSerializer(params);
- $httpBackend.when('GET', `/api/DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'});
- $httpBackend.expect('GET', `/api/DmsTypes/findOne?${serializedParams}`);
+ const dmsId = 1;
+ const expectedResponse = {
+ reference: 101,
+ warehouseFk: 1,
+ companyFk: 442,
+ dmsTypeFk: 12,
+ description: 'Test',
+ hasFile: false,
+ hasFileAttached: false
+ };
+
+ $httpBackend.when('GET', `/api/Dms/${dmsId}`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/Dms/${dmsId}`).respond(expectedResponse);
controller.setDefaultParams();
$httpBackend.flush();
@@ -50,11 +59,25 @@ describe('Client', () => {
describe('onFileChange()', () => {
it('should set dms hasFileAttached property to true if has any files', () => {
const files = [{id: 1, name: 'MyFile'}];
+ controller.dms = {hasFileAttached: false};
controller.onFileChange(files);
$scope.$apply();
expect(controller.dms.hasFileAttached).toBeTruthy();
});
});
+
+ describe('getAllowedContentTypes()', () => {
+ it('should make an HTTP GET request to get the allowed content types', () => {
+ const expectedResponse = ['image/png', 'image/jpg'];
+ $httpBackend.when('GET', `/api/clientDms/allowedContentTypes`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/clientDms/allowedContentTypes`);
+ controller.getAllowedContentTypes();
+ $httpBackend.flush();
+
+ expect(controller.allowedContentTypes).toBeDefined();
+ expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
+ });
+ });
});
});
diff --git a/modules/client/front/dms/edit/locale/es.yml b/modules/client/front/dms/edit/locale/es.yml
deleted file mode 100644
index 9d97564ba6..0000000000
--- a/modules/client/front/dms/edit/locale/es.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-Edit file: Editar fichero
-File: Fichero
-Generate identifier for original file: Generar identificador para archivo original
\ No newline at end of file
diff --git a/modules/client/front/dms/locale/en.yml b/modules/client/front/dms/locale/en.yml
new file mode 100644
index 0000000000..766853fca7
--- /dev/null
+++ b/modules/client/front/dms/locale/en.yml
@@ -0,0 +1,2 @@
+ClientFileDescription: "{{dmsTypeName}} from client {{clientName}} id {{clientId}}"
+ContentTypesInfo: Allowed file types {{allowedContentTypes}}
\ No newline at end of file
diff --git a/modules/client/front/dms/locale/es.yml b/modules/client/front/dms/locale/es.yml
new file mode 100644
index 0000000000..4185098f30
--- /dev/null
+++ b/modules/client/front/dms/locale/es.yml
@@ -0,0 +1,14 @@
+Upload file: Subir fichero
+Edit file: Editar fichero
+Upload: Subir
+File: Fichero
+ClientFileDescription: "{{dmsTypeName}} del cliente {{clientName}} id {{clientId}}"
+ContentTypesInfo: "Tipos de archivo permitidos: {{allowedContentTypes}}"
+Generate identifier for original file: Generar identificador para archivo original
+File management: Gestión documental
+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
\ No newline at end of file
diff --git a/modules/order/front/filter/index.spec.js b/modules/order/front/filter/index.spec.js
index fe7f3e9ed8..89a2c68b74 100644
--- a/modules/order/front/filter/index.spec.js
+++ b/modules/order/front/filter/index.spec.js
@@ -1,7 +1,7 @@
import './index.js';
import crudModel from 'core/mocks/crud-model';
-fdescribe('Order', () => {
+describe('Order', () => {
describe('Component vnCatalogFilter', () => {
let $scope;
let $state;
diff --git a/modules/ticket/back/methods/ticket-dms/allowedContentTypes.js b/modules/ticket/back/methods/ticket-dms/allowedContentTypes.js
new file mode 100644
index 0000000000..2f5183f926
--- /dev/null
+++ b/modules/ticket/back/methods/ticket-dms/allowedContentTypes.js
@@ -0,0 +1,23 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('allowedContentTypes', {
+ description: 'Returns a list of allowed contentTypes',
+ accessType: 'READ',
+ returns: {
+ type: ['Object'],
+ root: true
+ },
+ http: {
+ path: `/allowedContentTypes`,
+ verb: 'GET'
+ }
+ });
+
+ Self.allowedContentTypes = async() => {
+ const storageConnector = Self.app.dataSources.storage.connector;
+ const allowedContentTypes = storageConnector.allowedContentTypes;
+ const modelAllowedContentTypes = Self.definition.settings.allowedContentTypes;
+
+ return modelAllowedContentTypes || allowedContentTypes;
+ };
+};
+
diff --git a/modules/ticket/back/models/ticket-dms.js b/modules/ticket/back/models/ticket-dms.js
index ddb338632e..8a6d034340 100644
--- a/modules/ticket/back/models/ticket-dms.js
+++ b/modules/ticket/back/models/ticket-dms.js
@@ -1,3 +1,4 @@
module.exports = Self => {
require('../methods/ticket-dms/removeFile')(Self);
+ require('../methods/ticket-dms/allowedContentTypes')(Self);
};
diff --git a/modules/ticket/front/dms/create/index.html b/modules/ticket/front/dms/create/index.html
index 7c8ae6ad2d..2ab817c759 100644
--- a/modules/ticket/front/dms/create/index.html
+++ b/modules/ticket/front/dms/create/index.html
@@ -45,7 +45,15 @@
label="File"
model="$ctrl.dms.files"
on-change="$ctrl.onFileChange(files)"
- accept=".pdf, .png, .jpg, .jpeg, application/zip, application/rar, application/x-7z-compressed">
+ accept="{{$ctrl.allowedContentTypes}}"
+ multiple="true">
+
+
+
+
diff --git a/modules/ticket/front/dms/create/index.js b/modules/ticket/front/dms/create/index.js
index 630c1149f8..2869c831a1 100644
--- a/modules/ticket/front/dms/create/index.js
+++ b/modules/ticket/front/dms/create/index.js
@@ -22,8 +22,23 @@ class Controller {
set ticket(value) {
this._ticket = value;
- if (value)
+ if (value) {
this.setDefaultParams();
+ this.getAllowedContentTypes();
+ }
+ }
+
+ getAllowedContentTypes() {
+ this.$http.get('/api/ticketDms/allowedContentTypes').then(res => {
+ const contentTypes = res.data.join(', ');
+ this.allowedContentTypes = contentTypes;
+ });
+ }
+
+ get contentTypesInfo() {
+ return this.$translate.instant('ContentTypesInfo', {
+ allowedContentTypes: this.allowedContentTypes
+ });
}
setDefaultParams() {
diff --git a/modules/ticket/front/dms/create/index.spec.js b/modules/ticket/front/dms/create/index.spec.js
index 0014c010da..d4f6ad63b8 100644
--- a/modules/ticket/front/dms/create/index.spec.js
+++ b/modules/ticket/front/dms/create/index.spec.js
@@ -23,8 +23,9 @@ describe('Ticket', () => {
}));
describe('client() setter', () => {
- it('should set the ticket data and then call setDefaultParams()', () => {
+ it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
spyOn(controller, 'setDefaultParams');
+ spyOn(controller, 'getAllowedContentTypes');
controller.ticket = {
id: 15,
name: 'Bruce wayne'
@@ -32,6 +33,7 @@ describe('Ticket', () => {
expect(controller.ticket).toBeDefined();
expect(controller.setDefaultParams).toHaveBeenCalledWith();
+ expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
});
});
@@ -61,5 +63,18 @@ describe('Ticket', () => {
expect(controller.dms.hasFileAttached).toBeTruthy();
});
});
+
+ describe('getAllowedContentTypes()', () => {
+ it('should make an HTTP GET request to get the allowed content types', () => {
+ const expectedResponse = ['image/png', 'image/jpg'];
+ $httpBackend.when('GET', `/api/ticketDms/allowedContentTypes`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/ticketDms/allowedContentTypes`);
+ controller.getAllowedContentTypes();
+ $httpBackend.flush();
+
+ expect(controller.allowedContentTypes).toBeDefined();
+ expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
+ });
+ });
});
});
diff --git a/modules/ticket/front/dms/create/locale/en.yml b/modules/ticket/front/dms/create/locale/en.yml
deleted file mode 100644
index 9f4c026a44..0000000000
--- a/modules/ticket/front/dms/create/locale/en.yml
+++ /dev/null
@@ -1 +0,0 @@
-FileDescription: Ticket id {{ticketId}} from client {{clientName}} id {{clientId}}
\ No newline at end of file
diff --git a/modules/ticket/front/dms/create/locale/es.yml b/modules/ticket/front/dms/create/locale/es.yml
deleted file mode 100644
index 999826352b..0000000000
--- a/modules/ticket/front/dms/create/locale/es.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-Upload file: Subir fichero
-Upload: Subir
-File: Fichero
-FileDescription: Ticket id {{ticketId}} del cliente {{clientName}} id {{clientId}}
-Generate identifier for original file: Generar identificador para archivo original
\ No newline at end of file
diff --git a/modules/ticket/front/dms/edit/index.html b/modules/ticket/front/dms/edit/index.html
index 7614a7783b..44075615dc 100644
--- a/modules/ticket/front/dms/edit/index.html
+++ b/modules/ticket/front/dms/edit/index.html
@@ -45,7 +45,15 @@
label="File"
model="$ctrl.dms.files"
on-change="$ctrl.onFileChange(files)"
- accept=".pdf, .png, .jpg, .jpeg, application/zip, application/rar, application/x-7z-compressed">
+ accept="{{$ctrl.allowedContentTypes}}"
+ multiple="true">
+
+
+
+
diff --git a/modules/ticket/front/dms/edit/index.js b/modules/ticket/front/dms/edit/index.js
index 486d377918..800e78b978 100644
--- a/modules/ticket/front/dms/edit/index.js
+++ b/modules/ticket/front/dms/edit/index.js
@@ -18,8 +18,23 @@ class Controller {
set ticket(value) {
this._ticket = value;
- if (value)
+ if (value) {
this.setDefaultParams();
+ this.getAllowedContentTypes();
+ }
+ }
+
+ getAllowedContentTypes() {
+ this.$http.get('/api/ticketDms/allowedContentTypes').then(res => {
+ const contentTypes = res.data.join(', ');
+ this.allowedContentTypes = contentTypes;
+ });
+ }
+
+ get contentTypesInfo() {
+ return this.$translate.instant('ContentTypesInfo', {
+ allowedContentTypes: this.allowedContentTypes
+ });
}
setDefaultParams() {
diff --git a/modules/ticket/front/dms/edit/index.spec.js b/modules/ticket/front/dms/edit/index.spec.js
index 5ef4d28f3f..7639a4ae90 100644
--- a/modules/ticket/front/dms/edit/index.spec.js
+++ b/modules/ticket/front/dms/edit/index.spec.js
@@ -1,60 +1,83 @@
import './index';
-describe('Client', () => {
- describe('Component vnClientDmsCreate', () => {
+describe('Ticket', () => {
+ describe('Component vnTicketDmsEdit', () => {
let controller;
let $scope;
let $httpBackend;
- let $httpParamSerializer;
+ let $state;
- beforeEach(ngModule('client'));
+ beforeEach(ngModule('ticket'));
- beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
+ beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
- $httpParamSerializer = _$httpParamSerializer_;
- controller = $componentController('vnClientDmsCreate', {$scope});
- controller._client = {id: 101, name: 'Bruce wayne'};
+ $state = {params: {dmsId: 1}};
+ controller = $componentController('vnTicketDmsEdit', {$scope, $state});
+ controller._ticket = {id: 1, ticketFk: 16};
}));
- describe('client() setter', () => {
- it('should set the client data and then call setDefaultParams()', () => {
+ describe('ticket() setter', () => {
+ it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
spyOn(controller, 'setDefaultParams');
- controller.client = {
- id: 15,
- name: 'Bruce wayne'
+ spyOn(controller, 'getAllowedContentTypes');
+ controller._ticket = undefined;
+ controller.ticket = {
+ id: 15
};
- expect(controller.client).toBeDefined();
expect(controller.setDefaultParams).toHaveBeenCalledWith();
+ expect(controller.ticket).toBeDefined();
+ expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
});
});
describe('setDefaultParams()', () => {
it('should perform a GET query and define the dms property on controller', () => {
- const params = {filter: {
- where: {code: 'paymentsLaw'}
- }};
- let serializedParams = $httpParamSerializer(params);
- $httpBackend.when('GET', `/api/DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'});
- $httpBackend.expect('GET', `/api/DmsTypes/findOne?${serializedParams}`);
+ const dmsId = 1;
+ const expectedResponse = {
+ reference: 101,
+ warehouseFk: 1,
+ companyFk: 442,
+ dmsTypeFk: 14,
+ description: 'Test',
+ hasFile: false,
+ hasFileAttached: false
+ };
+
+ $httpBackend.when('GET', `/api/Dms/${dmsId}`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/Dms/${dmsId}`).respond(expectedResponse);
controller.setDefaultParams();
$httpBackend.flush();
expect(controller.dms).toBeDefined();
expect(controller.dms.reference).toEqual(101);
- expect(controller.dms.dmsTypeId).toEqual(12);
+ expect(controller.dms.dmsTypeId).toEqual(14);
});
});
describe('onFileChange()', () => {
it('should set dms hasFileAttached property to true if has any files', () => {
const files = [{id: 1, name: 'MyFile'}];
+ controller.dms = {hasFileAttached: false};
controller.onFileChange(files);
$scope.$apply();
expect(controller.dms.hasFileAttached).toBeTruthy();
});
});
+
+ describe('getAllowedContentTypes()', () => {
+ it('should make an HTTP GET request to get the allowed content types', () => {
+ const expectedResponse = ['image/png', 'image/jpg'];
+ $httpBackend.when('GET', `/api/ticketDms/allowedContentTypes`).respond(expectedResponse);
+ $httpBackend.expect('GET', `/api/ticketDms/allowedContentTypes`);
+ controller.getAllowedContentTypes();
+ $httpBackend.flush();
+
+ expect(controller.allowedContentTypes).toBeDefined();
+ expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
+ });
+ });
});
});
diff --git a/modules/ticket/front/dms/edit/locale/es.yml b/modules/ticket/front/dms/edit/locale/es.yml
deleted file mode 100644
index 9d97564ba6..0000000000
--- a/modules/ticket/front/dms/edit/locale/es.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-Edit file: Editar fichero
-File: Fichero
-Generate identifier for original file: Generar identificador para archivo original
\ No newline at end of file
diff --git a/modules/ticket/front/dms/index/locale/es.yml b/modules/ticket/front/dms/index/locale/es.yml
deleted file mode 100644
index c6742ef3cc..0000000000
--- a/modules/ticket/front/dms/index/locale/es.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-Type: Tipo
-File management: Gestión documental
-Are you sure you want to continue?: ¿Seguro que quieres continuar?
\ No newline at end of file
diff --git a/modules/ticket/front/dms/locale/en.yml b/modules/ticket/front/dms/locale/en.yml
new file mode 100644
index 0000000000..a202e8bf27
--- /dev/null
+++ b/modules/ticket/front/dms/locale/en.yml
@@ -0,0 +1,2 @@
+FileDescription: Ticket id {{ticketId}} from client {{clientName}} id {{clientId}}
+ContentTypesInfo: Allowed file types {{allowedContentTypes}}
\ No newline at end of file
diff --git a/modules/ticket/front/dms/locale/es.yml b/modules/ticket/front/dms/locale/es.yml
new file mode 100644
index 0000000000..998960a8ea
--- /dev/null
+++ b/modules/ticket/front/dms/locale/es.yml
@@ -0,0 +1,9 @@
+Upload file: Subir fichero
+Edit file: Editar fichero
+Upload: Subir
+File: Fichero
+FileDescription: Ticket id {{ticketId}} del cliente {{clientName}} id {{clientId}}
+Generate identifier for original file: Generar identificador para archivo original
+ContentTypesInfo: 'Tipos de archivo permitidos: {{allowedContentTypes}}'
+Are you sure you want to continue?: ¿Seguro que quieres continuar?
+File management: Gestión documental
\ No newline at end of file