build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -22,7 +22,6 @@ import { ClientsService } from '../../clients.service';
|
||||
styleUrls: ['./address-tab.component.scss']
|
||||
})
|
||||
export class AddressTabComponent {
|
||||
|
||||
/** Client Address Data */
|
||||
clientAddressData: any;
|
||||
/** Client Address Field Config */
|
||||
@@ -38,20 +37,20 @@ export class AddressTabComponent {
|
||||
* @param {MatDialog} dialog Mat Dialog
|
||||
* @param {TranslateService} translateService Translate Service.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private clientService: ClientsService,
|
||||
private dialog: MatDialog,
|
||||
private translateService: TranslateService) {
|
||||
this.route.data.subscribe((data: {
|
||||
clientAddressData: any,
|
||||
clientAddressFieldConfig: any,
|
||||
clientAddressTemplateData: any
|
||||
}) => {
|
||||
this.clientAddressData = data.clientAddressData;
|
||||
this.clientAddressFieldConfig = data.clientAddressFieldConfig;
|
||||
this.clientAddressTemplate = data.clientAddressTemplateData;
|
||||
this.clientId = this.route.parent.snapshot.paramMap.get('clientId');
|
||||
});
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private clientService: ClientsService,
|
||||
private dialog: MatDialog,
|
||||
private translateService: TranslateService
|
||||
) {
|
||||
this.route.data.subscribe(
|
||||
(data: { clientAddressData: any; clientAddressFieldConfig: any; clientAddressTemplateData: any }) => {
|
||||
this.clientAddressData = data.clientAddressData;
|
||||
this.clientAddressFieldConfig = data.clientAddressFieldConfig;
|
||||
this.clientAddressTemplate = data.clientAddressTemplateData;
|
||||
this.clientId = this.route.parent.snapshot.paramMap.get('clientId');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,20 +58,26 @@ export class AddressTabComponent {
|
||||
*/
|
||||
addAddress() {
|
||||
const data = {
|
||||
title: this.translateService.instant('labels.buttons.Add') + ' ' + this.translateService.instant('labels.catalogs.Client') + ' ' + this.translateService.instant('labels.heading.Address'),
|
||||
title:
|
||||
this.translateService.instant('labels.buttons.Add') +
|
||||
' ' +
|
||||
this.translateService.instant('labels.catalogs.Client') +
|
||||
' ' +
|
||||
this.translateService.instant('labels.heading.Address'),
|
||||
formfields: this.getAddressFormFields('add')
|
||||
};
|
||||
const addAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||
addAddressDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
this.clientService.createClientAddress(this.clientId, response.data.value.addressType, response.data.value).subscribe((res: any) => {
|
||||
const addressData = response.data.value;
|
||||
addressData.addressId = res.resourceId;
|
||||
addressData.addressType = this.getSelectedValue('addressTypeIdOptions', addressData.addressType).name;
|
||||
addressData.isActive = false;
|
||||
this.clientAddressData.push(addressData);
|
||||
});
|
||||
|
||||
this.clientService
|
||||
.createClientAddress(this.clientId, response.data.value.addressType, response.data.value)
|
||||
.subscribe((res: any) => {
|
||||
const addressData = response.data.value;
|
||||
addressData.addressId = res.resourceId;
|
||||
addressData.addressType = this.getSelectedValue('addressTypeIdOptions', addressData.addressType).name;
|
||||
addressData.isActive = false;
|
||||
this.clientAddressData.push(addressData);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -84,7 +89,12 @@ export class AddressTabComponent {
|
||||
*/
|
||||
editAddress(address: any, index: number) {
|
||||
const data = {
|
||||
title: this.translateService.instant('labels.buttons.Edit') + ' ' + this.translateService.instant('labels.catalogs.Client') + ' ' + this.translateService.instant('labels.heading.Address'),
|
||||
title:
|
||||
this.translateService.instant('labels.buttons.Edit') +
|
||||
' ' +
|
||||
this.translateService.instant('labels.catalogs.Client') +
|
||||
' ' +
|
||||
this.translateService.instant('labels.heading.Address'),
|
||||
formfields: this.getAddressFormFields('edit', address),
|
||||
layout: { addButtonText: 'Edit' }
|
||||
};
|
||||
@@ -94,11 +104,13 @@ export class AddressTabComponent {
|
||||
const addressData = response.data.value;
|
||||
addressData.addressId = address.addressId;
|
||||
addressData.isActive = address.isActive;
|
||||
this.clientService.editClientAddress(this.clientId, address.addressTypeId, addressData).subscribe((res: any) => {
|
||||
addressData.addressTypeId = address.addressTypeId;
|
||||
addressData.addressType = address.addressType;
|
||||
this.clientAddressData[index] = addressData;
|
||||
});
|
||||
this.clientService
|
||||
.editClientAddress(this.clientId, address.addressTypeId, addressData)
|
||||
.subscribe((res: any) => {
|
||||
addressData.addressTypeId = address.addressTypeId;
|
||||
addressData.addressType = address.addressType;
|
||||
this.clientAddressData[index] = addressData;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,8 +121,8 @@ export class AddressTabComponent {
|
||||
*/
|
||||
toggleAddress(address: any) {
|
||||
const addressData = {
|
||||
'addressId': address.addressId,
|
||||
'isActive': address.isActive ? false : true
|
||||
addressId: address.addressId,
|
||||
isActive: address.isActive ? false : true
|
||||
};
|
||||
this.clientService.editClientAddress(this.clientId, address.addressTypeId, addressData).subscribe(() => {
|
||||
address.isActive = address.isActive ? false : true;
|
||||
@@ -122,7 +134,7 @@ export class AddressTabComponent {
|
||||
* @param {any} fieldName Field Name
|
||||
*/
|
||||
isFieldEnabled(fieldName: any) {
|
||||
return (this.clientAddressFieldConfig.find((fieldObj: any) => fieldObj.field === fieldName))?.isEnabled;
|
||||
return this.clientAddressFieldConfig.find((fieldObj: any) => fieldObj.field === fieldName)?.isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +143,7 @@ export class AddressTabComponent {
|
||||
* @param {any} fieldId Field Id
|
||||
*/
|
||||
getSelectedValue(fieldName: any, fieldId: any) {
|
||||
return (this.clientAddressTemplate[fieldName].find((fieldObj: any) => fieldObj.id === fieldId));
|
||||
return this.clientAddressTemplate[fieldName].find((fieldObj: any) => fieldObj.id === fieldId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,91 +155,136 @@ export class AddressTabComponent {
|
||||
let formfields: FormfieldBase[] = [];
|
||||
|
||||
for (let index = 0; index < this.clientAddressTemplate.addressTypeIdOptions.length; index++) {
|
||||
this.clientAddressTemplate.addressTypeIdOptions[index].name = this.translateService.instant(`labels.catalogs.${this.clientAddressTemplate.addressTypeIdOptions[index].name}`);
|
||||
this.clientAddressTemplate.addressTypeIdOptions[index].name = this.translateService.instant(
|
||||
`labels.catalogs.${this.clientAddressTemplate.addressTypeIdOptions[index].name}`
|
||||
);
|
||||
}
|
||||
|
||||
if (formType === 'add') {
|
||||
formfields.push(this.isFieldEnabled('addressType') ? new SelectBase({
|
||||
controlName: 'addressType',
|
||||
label: this.translateService.instant('labels.inputs.Address Type'),
|
||||
value: address ? address.addressType : '',
|
||||
options: { label: 'name', value: 'id', data: this.clientAddressTemplate.addressTypeIdOptions },
|
||||
order: 1
|
||||
}) : null);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('addressType')
|
||||
? new SelectBase({
|
||||
controlName: 'addressType',
|
||||
label: this.translateService.instant('labels.inputs.Address Type'),
|
||||
value: address ? address.addressType : '',
|
||||
options: { label: 'name', value: 'id', data: this.clientAddressTemplate.addressTypeIdOptions },
|
||||
order: 1
|
||||
})
|
||||
: null
|
||||
);
|
||||
}
|
||||
formfields.push(this.isFieldEnabled('street') ? new InputBase({
|
||||
controlName: 'street',
|
||||
label: this.translateService.instant('labels.inputs.Street'),
|
||||
value: address ? address.street : '',
|
||||
type: 'text',
|
||||
required: false,
|
||||
order: 2
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('addressLine1') ? new InputBase({
|
||||
controlName: 'addressLine1',
|
||||
label: this.translateService.instant('labels.inputs.Address Line') + ' 1',
|
||||
value: address ? address.addressLine1 : '',
|
||||
type: 'text',
|
||||
order: 3
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('addressLine2') ? new InputBase({
|
||||
controlName: 'addressLine2',
|
||||
label: this.translateService.instant('labels.inputs.Address Line') + ' 2',
|
||||
value: address ? address.addressLine2 : '',
|
||||
type: 'text',
|
||||
order: 4
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('addressLine3') ? new InputBase({
|
||||
controlName: 'addressLine3',
|
||||
label: this.translateService.instant('labels.inputs.Address Line') + ' 3',
|
||||
value: address ? address.addressLine3 : '',
|
||||
type: 'text',
|
||||
order: 5
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('townVillage') ? new InputBase({
|
||||
controlName: 'townVillage',
|
||||
label: this.translateService.instant('labels.inputs.Town / Village'),
|
||||
value: address ? address.townVillage : '',
|
||||
type: 'text',
|
||||
order: 6
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('city') ? new InputBase({
|
||||
controlName: 'city',
|
||||
label: this.translateService.instant('labels.inputs.City'),
|
||||
value: address ? address.city : '',
|
||||
type: 'text',
|
||||
order: 7
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('stateProvinceId') ? new SelectBase({
|
||||
controlName: 'stateProvinceId',
|
||||
label: this.translateService.instant('labels.inputs.State / Province'),
|
||||
value: address ? address.stateProvinceId : '',
|
||||
options: { label: 'name', value: 'id', data: this.clientAddressTemplate.stateProvinceIdOptions },
|
||||
order: 8
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('countyDistrict') ? new InputBase({
|
||||
controlName: 'countryDistrict',
|
||||
label: this.translateService.instant('labels.inputs.State / Province'),
|
||||
value: address ? address.countyDistrict : '',
|
||||
type: 'text',
|
||||
order: 11
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('countryId') ? new SelectBase({
|
||||
controlName: 'countryId',
|
||||
label: this.translateService.instant('labels.inputs.Country'),
|
||||
value: address ? address.countryId : '',
|
||||
options: { label: 'name', value: 'id', data: this.clientAddressTemplate.countryIdOptions },
|
||||
order: 10
|
||||
}) : null);
|
||||
formfields.push(this.isFieldEnabled('postalCode') ? new InputBase({
|
||||
controlName: 'postalCode',
|
||||
label: this.translateService.instant('labels.inputs.Postal Code'),
|
||||
value: address ? address.postalCode : '',
|
||||
type: 'text',
|
||||
order: 11
|
||||
}) : null);
|
||||
formfields = formfields.filter(field => field !== null);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('street')
|
||||
? new InputBase({
|
||||
controlName: 'street',
|
||||
label: this.translateService.instant('labels.inputs.Street'),
|
||||
value: address ? address.street : '',
|
||||
type: 'text',
|
||||
required: false,
|
||||
order: 2
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('addressLine1')
|
||||
? new InputBase({
|
||||
controlName: 'addressLine1',
|
||||
label: this.translateService.instant('labels.inputs.Address Line') + ' 1',
|
||||
value: address ? address.addressLine1 : '',
|
||||
type: 'text',
|
||||
order: 3
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('addressLine2')
|
||||
? new InputBase({
|
||||
controlName: 'addressLine2',
|
||||
label: this.translateService.instant('labels.inputs.Address Line') + ' 2',
|
||||
value: address ? address.addressLine2 : '',
|
||||
type: 'text',
|
||||
order: 4
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('addressLine3')
|
||||
? new InputBase({
|
||||
controlName: 'addressLine3',
|
||||
label: this.translateService.instant('labels.inputs.Address Line') + ' 3',
|
||||
value: address ? address.addressLine3 : '',
|
||||
type: 'text',
|
||||
order: 5
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('townVillage')
|
||||
? new InputBase({
|
||||
controlName: 'townVillage',
|
||||
label: this.translateService.instant('labels.inputs.Town / Village'),
|
||||
value: address ? address.townVillage : '',
|
||||
type: 'text',
|
||||
order: 6
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('city')
|
||||
? new InputBase({
|
||||
controlName: 'city',
|
||||
label: this.translateService.instant('labels.inputs.City'),
|
||||
value: address ? address.city : '',
|
||||
type: 'text',
|
||||
order: 7
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('stateProvinceId')
|
||||
? new SelectBase({
|
||||
controlName: 'stateProvinceId',
|
||||
label: this.translateService.instant('labels.inputs.State / Province'),
|
||||
value: address ? address.stateProvinceId : '',
|
||||
options: { label: 'name', value: 'id', data: this.clientAddressTemplate.stateProvinceIdOptions },
|
||||
order: 8
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('countyDistrict')
|
||||
? new InputBase({
|
||||
controlName: 'countryDistrict',
|
||||
label: this.translateService.instant('labels.inputs.State / Province'),
|
||||
value: address ? address.countyDistrict : '',
|
||||
type: 'text',
|
||||
order: 11
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('countryId')
|
||||
? new SelectBase({
|
||||
controlName: 'countryId',
|
||||
label: this.translateService.instant('labels.inputs.Country'),
|
||||
value: address ? address.countryId : '',
|
||||
options: { label: 'name', value: 'id', data: this.clientAddressTemplate.countryIdOptions },
|
||||
order: 10
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields.push(
|
||||
this.isFieldEnabled('postalCode')
|
||||
? new InputBase({
|
||||
controlName: 'postalCode',
|
||||
label: this.translateService.instant('labels.inputs.Postal Code'),
|
||||
value: address ? address.postalCode : '',
|
||||
type: 'text',
|
||||
order: 11
|
||||
})
|
||||
: null
|
||||
);
|
||||
formfields = formfields.filter((field) => field !== null);
|
||||
return formfields;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user