refs #2051 feat: getAllowedContentTypes approach
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2023-12-12 15:03:00 +01:00
parent 6334431d2b
commit d206c93305
13 changed files with 142 additions and 206 deletions

View File

@ -15,6 +15,7 @@ import './module-card';
import './module-main'; import './module-main';
import './side-menu/side-menu'; import './side-menu/side-menu';
import './section'; import './section';
import './section-dms';
import './summary'; import './summary';
import './topbar/topbar'; import './topbar/topbar';
import './user-popover'; import './user-popover';

View File

@ -0,0 +1,24 @@
import ngModule from '../../module';
import Component from 'core/lib/component';
import './style.scss';
export default class SectionDms extends Component {
getAllowedContentTypes() {
return this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
return contentTypes;
});
}
getDms(dmsId) {
return this.$http.get(`Dms/${dmsId}`).then(res => res);
}
getDmsTypes(params) {
return this.$http.get('DmsTypes/findOne', params).then(res => res);
}
}
ngModule.vnComponent('vnSectionDms', {
controller: SectionDms
});

View File

@ -1,8 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
import './style.scss'; import './style.scss';
class Controller extends Section { class Controller extends SectionDms {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.dms = { this.dms = {
@ -20,46 +20,36 @@ class Controller extends Section {
this._client = value; this._client = value;
if (value) { if (value) {
this.setDefaultParams(); const params = {filter: {
this.getAllowedContentTypes(); where: {code: 'paymentsLaw'}
}};
this.getDmsTypes(params).then(res => this.handleDefaultParams(res));
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes
}); });
} }
setDefaultParams() { handleDefaultParams({data: dmsType}) {
const params = {filter: { const companyId = this.vnConfig.companyFk;
where: {code: 'paymentsLaw'} const warehouseId = this.vnConfig.warehouseFk;
}}; const defaultParams = {
this.$http.get('DmsTypes/findOne', {params}).then(res => { reference: this.client.id,
const dmsType = res.data && res.data; warehouseId: warehouseId,
const companyId = this.vnConfig.companyFk; companyId: companyId,
const warehouseId = this.vnConfig.warehouseFk; dmsTypeId: dmsType.id,
const defaultParams = { description: this.$t('ClientFileDescription', {
reference: this.client.id, dmsTypeName: dmsType.name,
warehouseId: warehouseId, clientId: this.client.id,
companyId: companyId, clientName: this.client.name
dmsTypeId: dmsType.id, }).toUpperCase()
description: this.$t('ClientFileDescription', { };
dmsTypeName: dmsType.name,
clientId: this.client.id,
clientName: this.client.name
}).toUpperCase()
};
this.dms = Object.assign(this.dms, defaultParams); this.dms = Object.assign(this.dms, defaultParams);
});
} }
onSubmit() { onSubmit() {

View File

@ -1,8 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
import './style.scss'; import './style.scss';
class Controller extends Section { class Controller extends SectionDms {
get client() { get client() {
return this._client; return this._client;
} }
@ -11,39 +11,28 @@ class Controller extends Section {
this._client = value; this._client = value;
if (value) { if (value) {
this.setDefaultParams(); this.getDms(this.$params.dmsId).then(handleDefaultParams);
this.getAllowedContentTypes(); this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes
}); });
} }
setDefaultParams() { handleDefaultParams({data: dms}) {
const path = `Dms/${this.$params.dmsId}`; this.dms = {
this.$http.get(path).then(res => { reference: dms.reference,
const dms = res.data && res.data; warehouseId: dms.warehouseFk,
this.dms = { companyId: dms.companyFk,
reference: dms.reference, dmsTypeId: dms.dmsTypeFk,
warehouseId: dms.warehouseFk, description: dms.description,
companyId: dms.companyFk, hasFile: dms.hasFile,
dmsTypeId: dms.dmsTypeFk, hasFileAttached: false,
description: dms.description, files: []
hasFile: dms.hasFile, };
hasFileAttached: false,
files: []
};
});
} }
onSubmit() { onSubmit() {

View File

@ -1,8 +1,8 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
import UserError from 'core/lib/user-error'; import UserError from 'core/lib/user-error';
class Controller extends Section { class Controller extends SectionDms {
constructor($element, $, vnFile) { constructor($element, $, vnFile) {
super($element, $, vnFile); super($element, $, vnFile);
this.dms = { this.dms = {
@ -11,7 +11,7 @@ class Controller extends Section {
hasFileAttached: false hasFileAttached: false
}; };
this.vnFile = vnFile; this.vnFile = vnFile;
this.getAllowedContentTypes(); this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this._editDownloadDisabled = false; this._editDownloadDisabled = false;
} }
@ -53,15 +53,6 @@ class Controller extends Section {
}); });
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
if (res.data.length > 0) {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
}
});
}
openEditDialog(dmsId) { openEditDialog(dmsId) {
this.getFile(dmsId).then(() => this.$.dmsEditDialog.show()); this.getFile(dmsId).then(() => this.$.dmsEditDialog.show());
} }

View File

@ -1,9 +1,9 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
import './style.scss'; import './style.scss';
import UserError from 'core/lib/user-error'; import UserError from 'core/lib/user-error';
class Controller extends Section { class Controller extends SectionDms {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.dms = { this.dms = {
@ -19,9 +19,11 @@ class Controller extends Section {
set route(value) { set route(value) {
this._route = value; this._route = value;
const params = {filter: {
this.setDefaultParams(); where: {code: 'invoiceIn'}
this.getAllowedContentTypes(); }};
this.getDmsTypes(params).then(res => this.handleDefaultParams(res));
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
} }
$onChanges() { $onChanges() {
@ -29,36 +31,23 @@ class Controller extends Section {
this.params = JSON.parse(this.$params.q); this.params = JSON.parse(this.$params.q);
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes
}); });
} }
setDefaultParams() { handleDefaultParams({data: dmsType}) {
const params = {filter: { const companyId = this.vnConfig.companyFk;
where: {code: 'invoiceIn'} const warehouseId = this.vnConfig.warehouseFk;
}}; const defaultParams = {
this.$http.get('DmsTypes/findOne', {params}).then(res => { warehouseId: warehouseId,
const dmsType = res.data && res.data; companyId: companyId,
const companyId = this.vnConfig.companyFk; dmsTypeId: dmsType.id,
const warehouseId = this.vnConfig.warehouseFk; description: this.params.supplierName
const defaultParams = { };
warehouseId: warehouseId,
companyId: companyId,
dmsTypeId: dmsType.id,
description: this.params.supplierName
};
this.dms = Object.assign(this.dms, defaultParams); this.dms = Object.assign(this.dms, defaultParams);
});
} }
onSubmit() { onSubmit() {

View File

@ -1,7 +1,7 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
class Controller extends Section { class Controller extends SectionDms {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.dms = { this.dms = {
@ -19,45 +19,36 @@ class Controller extends Section {
this._ticket = value; this._ticket = value;
if (value) { if (value) {
this.setDefaultParams(); const params = {filter: {
this.getAllowedContentTypes(); where: {code: 'ticket'}
}};
this.getDmsTypes(params).then(res => this.handleDefaultParams(res));
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes
}); });
} }
setDefaultParams() { handleDefaultParams(data) {
const params = {filter: { const dmsTypeId = res?.data?.id;
where: {code: 'ticket'} const warehouseId = this.vnConfig.warehouseFk;
}}; const defaultParams = {
this.$http.get('DmsTypes/findOne', {params}).then(res => { reference: this.ticket.id,
const dmsTypeId = res.data && res.data.id; warehouseId: warehouseId,
const warehouseId = this.vnConfig.warehouseFk; companyId: this.ticket.companyFk,
const defaultParams = { dmsTypeId: dmsTypeId,
reference: this.ticket.id, description: this.$t('FileDescription', {
warehouseId: warehouseId, ticketId: this.ticket.id,
companyId: this.ticket.companyFk, clientId: this.ticket.client.id,
dmsTypeId: dmsTypeId, clientName: this.ticket.client.name
description: this.$t('FileDescription', { }).toUpperCase()
ticketId: this.ticket.id, };
clientId: this.ticket.client.id,
clientName: this.ticket.client.name
}).toUpperCase()
};
this.dms = Object.assign(this.dms, defaultParams); this.dms = Object.assign(this.dms, defaultParams);
});
} }
onSubmit() { onSubmit() {

View File

@ -1,7 +1,7 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
class Controller extends Section { class Controller extends SectionDms {
get ticket() { get ticket() {
return this._ticket; return this._ticket;
} }
@ -10,39 +10,28 @@ class Controller extends Section {
this._ticket = value; this._ticket = value;
if (value) { if (value) {
this.setDefaultParams(); this.getDms(this.$params.dmsId).then(handleDefaultParams);
this.getAllowedContentTypes(); this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes
}); });
} }
setDefaultParams() { handleDefaultParams({data: dms}) {
const path = `Dms/${this.$params.dmsId}`; this.dms = {
this.$http.get(path).then(res => { reference: dms.reference,
const dms = res.data && res.data; warehouseId: dms.warehouseFk,
this.dms = { companyId: dms.companyFk,
reference: dms.reference, dmsTypeId: dms.dmsTypeFk,
warehouseId: dms.warehouseFk, description: dms.description,
companyId: dms.companyFk, hasFile: dms.hasFile,
dmsTypeId: dms.dmsTypeFk, hasFileAttached: false,
description: dms.description, files: []
hasFile: dms.hasFile, };
hasFileAttached: false,
files: []
};
});
} }
onSubmit() { onSubmit() {

View File

@ -17,16 +17,10 @@ class Controller extends Section {
if (value) { if (value) {
this.setDefaultParams(); this.setDefaultParams();
this.getAllowedContentTypes(); this.allowedContentTypes = this.getAllowedContentTypes();
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {

View File

@ -1,8 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
import './style.scss'; import './style.scss';
class Controller extends Section { class Controller extends SectionDms {
get travel() { get travel() {
return this._travel; return this._travel;
} }
@ -12,17 +12,10 @@ class Controller extends Section {
if (value) { if (value) {
this.setDefaultParams(); this.setDefaultParams();
this.getAllowedContentTypes(); this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes

View File

@ -21,17 +21,12 @@ class Controller extends Section {
if (value) { if (value) {
this.setDefaultParams(); this.setDefaultParams();
this.getAllowedContentTypes(); this.getAllowedContentTypes().then(data => {
this.allowedContentTypes = data;
});
} }
} }
getAllowedContentTypes() {
this.$http.get('DmsContainers/allowedContentTypes').then(res => {
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
}
get contentTypesInfo() { get contentTypesInfo() {
return this.$t('ContentTypesInfo', { return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes

View File

@ -1,8 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section'; import SectionDms from 'salix/components/section-dms';
import './style.scss'; import './style.scss';
class Controller extends Section { class Controller extends SectionDms {
get worker() { get worker() {
return this._worker; return this._worker;
} }
@ -11,16 +11,10 @@ class Controller extends Section {
this._worker = value; this._worker = value;
if (value) { if (value) {
this.setDefaultParams(); this.getDms(this.$params.dmsId).then(handleDefaultParams);
this.getAllowedContentTypes();
}
}
getAllowedContentTypes() { this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this.$http.get('DmsContainers/allowedContentTypes').then(res => { }
const contentTypes = res.data.join(', ');
this.allowedContentTypes = contentTypes;
});
} }
get contentTypesInfo() { get contentTypesInfo() {
@ -29,21 +23,17 @@ class Controller extends Section {
}); });
} }
setDefaultParams() { handleDefaultParams({data: dms}) {
const path = `Dms/${this.$params.dmsId}`; this.dms = {
this.$http.get(path).then(res => { reference: dms.reference,
const dms = res.data && res.data; warehouseId: dms.warehouseFk,
this.dms = { companyId: dms.companyFk,
reference: dms.reference, dmsTypeId: dms.dmsTypeFk,
warehouseId: dms.warehouseFk, description: dms.description,
companyId: dms.companyFk, hasFile: dms.hasFile,
dmsTypeId: dms.dmsTypeFk, hasFileAttached: false,
description: dms.description, files: []
hasFile: dms.hasFile, };
hasFileAttached: false,
files: []
};
});
} }
onSubmit() { onSubmit() {