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 './side-menu/side-menu';
import './section';
import './section-dms';
import './summary';
import './topbar/topbar';
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 SectionDms from 'salix/components/section-dms';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends SectionDms {
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.dms = {
@ -20,36 +20,46 @@ class Controller extends SectionDms {
this._client = value;
if (value) {
const params = {filter: {
where: {code: 'paymentsLaw'}
}};
this.getDmsTypes(params).then(res => this.handleDefaultParams(res));
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this.setDefaultParams();
this.getAllowedContentTypes();
}
}
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
});
}
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()
};
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()
};
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 SectionDms from 'salix/components/section-dms';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends SectionDms {
class Controller extends Section {
get client() {
return this._client;
}
@ -11,28 +11,39 @@ class Controller extends SectionDms {
this._client = value;
if (value) {
this.getDms(this.$params.dmsId).then(handleDefaultParams);
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this.setDefaultParams();
this.getAllowedContentTypes();
}
}
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
});
}
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: []
};
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: []
};
});
}
onSubmit() {

View File

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

View File

@ -1,9 +1,9 @@
import ngModule from '../../module';
import SectionDms from 'salix/components/section-dms';
import Section from 'salix/components/section';
import './style.scss';
import UserError from 'core/lib/user-error';
class Controller extends SectionDms {
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.dms = {
@ -19,11 +19,9 @@ class Controller extends SectionDms {
set route(value) {
this._route = value;
const params = {filter: {
where: {code: 'invoiceIn'}
}};
this.getDmsTypes(params).then(res => this.handleDefaultParams(res));
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this.setDefaultParams();
this.getAllowedContentTypes();
}
$onChanges() {
@ -31,23 +29,36 @@ class Controller extends SectionDms {
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
});
}
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
};
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
};
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 SectionDms from 'salix/components/section-dms';
import Section from 'salix/components/section';
class Controller extends SectionDms {
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.dms = {
@ -19,36 +19,45 @@ class Controller extends SectionDms {
this._ticket = value;
if (value) {
const params = {filter: {
where: {code: 'ticket'}
}};
this.getDmsTypes(params).then(res => this.handleDefaultParams(res));
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this.setDefaultParams();
this.getAllowedContentTypes();
}
}
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
});
}
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()
};
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()
};
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 SectionDms from 'salix/components/section-dms';
import Section from 'salix/components/section';
class Controller extends SectionDms {
class Controller extends Section {
get ticket() {
return this._ticket;
}
@ -10,28 +10,39 @@ class Controller extends SectionDms {
this._ticket = value;
if (value) {
this.getDms(this.$params.dmsId).then(handleDefaultParams);
this.getAllowedContentTypes().then(data => this.allowedContentTypes = data);
this.setDefaultParams();
this.getAllowedContentTypes();
}
}
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
});
}
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: []
};
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: []
};
});
}
onSubmit() {

View File

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

View File

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

View File

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

View File

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