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 './side-menu/side-menu';
import './section';
import './section-dms';
import './summary';
import './topbar/topbar';
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 Section from 'salix/components/section';
import SectionDms from 'salix/components/section-dms';
import './style.scss';
class Controller extends Section {
class Controller extends SectionDms {
constructor($element, $) {
super($element, $);
this.dms = {
@ -20,46 +20,36 @@ class Controller extends Section {
this._client = value;
if (value) {
this.setDefaultParams();
this.getAllowedContentTypes();
const params = {filter: {
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() {
return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes
});
}
setDefaultParams() {
const params = {filter: {
where: {code: 'paymentsLaw'}
}};
this.$http.get('DmsTypes/findOne', {params}).then(res => {
const dmsType = res.data && res.data;
const companyId = this.vnConfig.companyFk;
const warehouseId = this.vnConfig.warehouseFk;
const defaultParams = {
reference: this.client.id,
warehouseId: warehouseId,
companyId: companyId,
dmsTypeId: dmsType.id,
description: this.$t('ClientFileDescription', {
dmsTypeName: dmsType.name,
clientId: this.client.id,
clientName: this.client.name
}).toUpperCase()
};
handleDefaultParams({data: dmsType}) {
const companyId = this.vnConfig.companyFk;
const warehouseId = this.vnConfig.warehouseFk;
const defaultParams = {
reference: this.client.id,
warehouseId: warehouseId,
companyId: companyId,
dmsTypeId: dmsType.id,
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() {

View File

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

View File

@ -1,8 +1,8 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import SectionDms from 'salix/components/section-dms';
import UserError from 'core/lib/user-error';
class Controller extends Section {
class Controller extends SectionDms {
constructor($element, $, vnFile) {
super($element, $, vnFile);
this.dms = {
@ -11,7 +11,7 @@ class Controller extends Section {
hasFileAttached: false
};
this.vnFile = vnFile;
this.getAllowedContentTypes();
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
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) {
this.getFile(dmsId).then(() => this.$.dmsEditDialog.show());
}

View File

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

View File

@ -1,7 +1,7 @@
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, $) {
super($element, $);
this.dms = {
@ -19,45 +19,36 @@ class Controller extends Section {
this._ticket = value;
if (value) {
this.setDefaultParams();
this.getAllowedContentTypes();
const params = {filter: {
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() {
return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes
});
}
setDefaultParams() {
const params = {filter: {
where: {code: 'ticket'}
}};
this.$http.get('DmsTypes/findOne', {params}).then(res => {
const dmsTypeId = res.data && res.data.id;
const warehouseId = this.vnConfig.warehouseFk;
const defaultParams = {
reference: this.ticket.id,
warehouseId: warehouseId,
companyId: this.ticket.companyFk,
dmsTypeId: dmsTypeId,
description: this.$t('FileDescription', {
ticketId: this.ticket.id,
clientId: this.ticket.client.id,
clientName: this.ticket.client.name
}).toUpperCase()
};
handleDefaultParams(data) {
const dmsTypeId = res?.data?.id;
const warehouseId = this.vnConfig.warehouseFk;
const defaultParams = {
reference: this.ticket.id,
warehouseId: warehouseId,
companyId: this.ticket.companyFk,
dmsTypeId: dmsTypeId,
description: this.$t('FileDescription', {
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() {

View File

@ -1,7 +1,7 @@
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() {
return this._ticket;
}
@ -10,39 +10,28 @@ class Controller extends Section {
this._ticket = value;
if (value) {
this.setDefaultParams();
this.getAllowedContentTypes();
this.getDms(this.$params.dmsId).then(handleDefaultParams);
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() {
return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes
});
}
setDefaultParams() {
const path = `Dms/${this.$params.dmsId}`;
this.$http.get(path).then(res => {
const dms = res.data && res.data;
this.dms = {
reference: dms.reference,
warehouseId: dms.warehouseFk,
companyId: dms.companyFk,
dmsTypeId: dms.dmsTypeFk,
description: dms.description,
hasFile: dms.hasFile,
hasFileAttached: false,
files: []
};
});
handleDefaultParams({data: dms}) {
this.dms = {
reference: dms.reference,
warehouseId: dms.warehouseFk,
companyId: dms.companyFk,
dmsTypeId: dms.dmsTypeFk,
description: dms.description,
hasFile: dms.hasFile,
hasFileAttached: false,
files: []
};
}
onSubmit() {

View File

@ -17,16 +17,10 @@ class Controller extends Section {
if (value) {
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() {
return this.$t('ContentTypesInfo', {

View File

@ -1,8 +1,8 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
import SectionDms from 'salix/components/section-dms';
import './style.scss';
class Controller extends Section {
class Controller extends SectionDms {
get travel() {
return this._travel;
}
@ -12,17 +12,10 @@ class Controller extends Section {
if (value) {
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() {
return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes

View File

@ -21,17 +21,12 @@ class Controller extends Section {
if (value) {
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() {
return this.$t('ContentTypesInfo', {
allowedContentTypes: this.allowedContentTypes

View File

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