refs #2051 feat: remove front methods refactor

This commit is contained in:
Javier Segarra 2023-12-13 13:47:30 +01:00
parent d206c93305
commit a5ecec9603
13 changed files with 182 additions and 134 deletions

View File

@ -15,7 +15,6 @@ 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

@ -1,24 +0,0 @@
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 SectionDms from 'salix/components/section-dms'; import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller extends SectionDms { class Controller extends Section {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.dms = { this.dms = {
@ -20,36 +20,46 @@ class Controller extends SectionDms {
this._client = value; this._client = value;
if (value) { if (value) {
const params = {filter: { this.setDefaultParams();
where: {code: 'paymentsLaw'} this.getAllowedContentTypes();
}};
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
}); });
} }
handleDefaultParams({data: dmsType}) { setDefaultParams() {
const companyId = this.vnConfig.companyFk; const params = {filter: {
const warehouseId = this.vnConfig.warehouseFk; where: {code: 'paymentsLaw'}
const defaultParams = { }};
reference: this.client.id, 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.$t('ClientFileDescription', { const defaultParams = {
dmsTypeName: dmsType.name, reference: this.client.id,
clientId: this.client.id, warehouseId: warehouseId,
clientName: this.client.name companyId: companyId,
}).toUpperCase() 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() { onSubmit() {

View File

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

View File

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

View File

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

View File

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

View File

@ -7,15 +7,9 @@ class Controller extends Section {
this.filter = { this.filter = {
include: [ include: [
{ {
relation: 'worker', relation: 'user',
scope: { scope: {
fields: ['id'], fields: ['name']
include: {
relation: 'user',
scope: {
fields: ['name']
}
}
} }
}, { }, {
relation: 'state', relation: 'state',

View File

@ -17,10 +17,16 @@ class Controller extends Section {
if (value) { if (value) {
this.setDefaultParams(); this.setDefaultParams();
this.allowedContentTypes = this.getAllowedContentTypes(); 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 SectionDms from 'salix/components/section-dms'; import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller extends SectionDms { class Controller extends Section {
get travel() { get travel() {
return this._travel; return this._travel;
} }
@ -12,10 +12,17 @@ class Controller extends SectionDms {
if (value) { if (value) {
this.setDefaultParams(); this.setDefaultParams();
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data); 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', {
allowedContentTypes: this.allowedContentTypes allowedContentTypes: this.allowedContentTypes

View File

@ -21,12 +21,17 @@ class Controller extends Section {
if (value) { if (value) {
this.setDefaultParams(); this.setDefaultParams();
this.getAllowedContentTypes().then(data => { this.getAllowedContentTypes();
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