Skip to content

Commit

Permalink
add missed translation to client module
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar-Nabil authored and alberto-art3ch committed Aug 5, 2024
1 parent 656537a commit 559e013
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { UntypedFormControl } from '@angular/forms';

/** Custom Services */
import { CentersService } from 'app/centers/centers.service';
Expand All @@ -12,9 +12,10 @@ import { SettingsService } from 'app/settings/settings.service';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';

/** Custom Models */
import { TranslateService } from '@ngx-translate/core';
import { Dates } from 'app/core/utils/dates';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
import { Dates } from 'app/core/utils/dates';

/**
* Center Attendance component.
Expand Down Expand Up @@ -59,7 +60,8 @@ export class CenterAttendanceComponent implements OnInit {
private router: Router,
private centersService: CentersService,
private settingsService: SettingsService,
public dialog: MatDialog) {
public dialog: MatDialog,
private translateService: TranslateService) {
this.route.data.subscribe(( data: { centersActionData: any }) => {
this.centerData = data.centersActionData;
this.membersData = data.centersActionData.clients;
Expand Down Expand Up @@ -97,14 +99,14 @@ export class CenterAttendanceComponent implements OnInit {
const formfields: FormfieldBase[] = [
new SelectBase({
controlName: 'attendanceType',
label: 'Attendance',
label: this.translateService.instant('labels.buttons.Attendance'),
value: member.attendanceType,
options: { label: 'value', value: 'id', data: this.attendanceTypeOptions },
required: false
}),
];
const data = {
title: 'Assign Member Attendance',
title: this.translateService.instant('labels.buttons.Assign Member') + ' ' + this.translateService.instant('labels.buttons.Attendance'),
layout: { addButtonText: 'Confirm' },
formfields: formfields
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h3>{{"labels.heading.Notes" | translate}}</h3>
<form #formRef="ngForm" [formGroup]="noteForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
(ngSubmit)="submit()">
<mat-form-field fxFlex="calc(90%-20px)">
<textarea formControlName="note" matInput placeholder="Write a note ...."></textarea>
<textarea formControlName="note" matInput placeholder="{{'labels.text.Write a note' | translate}} ...."></textarea>
</mat-form-field>
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid" *mifosxHasPermission="'CREATE_GROUPNOTE'">
<fa-icon icon="plus" class="m-r-10"></fa-icon> {{"labels.buttons.Add" | translate}}
Expand Down
18 changes: 10 additions & 8 deletions src/app/centers/centers-view/notes-tab/notes-tab.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { UntypedFormGroup, UntypedFormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';

/** Custom Components */
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';

/** Custom Services */
import { CentersService } from '../../centers.service';
import { TranslateService } from '@ngx-translate/core';
import { AuthenticationService } from '../../../core/authentication/authentication.service';
import { CentersService } from '../../centers.service';

@Component({
selector: 'mifosx-notes-tab',
Expand All @@ -28,7 +29,8 @@ export class NotesTabComponent implements OnInit {
private formBuilder: UntypedFormBuilder,
private centersService: CentersService,
private authenticationService: AuthenticationService,
private dialog: MatDialog) {
private dialog: MatDialog,
private translateService: TranslateService) {
const savedCredentials = this.authenticationService.getCredentials();
this.username = savedCredentials.username;
this.centerId = this.route.parent.snapshot.params['centerId'];
Expand Down Expand Up @@ -66,13 +68,13 @@ export class NotesTabComponent implements OnInit {
required: true,
value: noteContent,
controlType: 'input',
label: 'Note'
label: this.translateService.instant('labels.inputs.Note')
}],
layout: {
columns: 1,
addButtonText: 'Confirm'
},
title: 'Edit Note'
title: this.translateService.instant('labels.heading.Edit Note')
}
});
editNoteDialogRef.afterClosed().subscribe((response: any) => {
Expand All @@ -86,7 +88,7 @@ export class NotesTabComponent implements OnInit {

deleteNote(noteId: string, index: number) {
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `Note id:${noteId}` }
data: { deleteContext: `${this.translateService.instant('labels.inputs.Note')} ${this.translateService.instant('labels.inputs.Id')}:${noteId}` }
});
deleteNoteDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ClientAddressStepComponent {
*/
editAddress(address: any, index: number) {
const data = {
title: 'Edit Client Address',
title: this.translateService.instant('labels.buttons.Edit') + ' ' + this.translateService.instant('labels.catalogs.Client') + ' ' + this.translateService.instant('labels.heading.Address'),
formfields: this.getAddressFormFields(address),
layout: { addButtonText: 'Edit' }
};
Expand All @@ -94,7 +94,7 @@ export class ClientAddressStepComponent {
*/
deleteAddress(address: any, index: number) {
const deleteAddressDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `address type : ${address.addressType} ${index}` }
data: { deleteContext: `${this.translateService.instant('labels.heading.Address')} ${this.translateService.instant('labels.inputs.Type')} : ${address.addressType} ${index}` }
});
deleteAddressDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
Expand Down
38 changes: 23 additions & 15 deletions src/app/clients/clients-view/address-tab/address-tab.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Angular Imports */
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute } from '@angular/router';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
Expand All @@ -10,6 +10,7 @@ import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';

/** Custom Services */
import { TranslateService } from '@ngx-translate/core';
import { ClientsService } from '../../clients.service';

/**
Expand All @@ -35,10 +36,12 @@ export class AddressTabComponent {
* @param {ActivatedRoute} route Activated Route
* @param {ClientsService} clientService Clients Service
* @param {MatDialog} dialog Mat Dialog
* @param {TranslateService} translateService Translate Service.
*/
constructor(private route: ActivatedRoute,
private clientService: ClientsService,
private dialog: MatDialog) {
private dialog: MatDialog,
private translateService: TranslateService) {
this.route.data.subscribe((data: {
clientAddressData: any,
clientAddressFieldConfig: any,
Expand All @@ -56,7 +59,7 @@ export class AddressTabComponent {
*/
addAddress() {
const data = {
title: 'Add Client 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 });
Expand All @@ -81,7 +84,7 @@ export class AddressTabComponent {
*/
editAddress(address: any, index: number) {
const data = {
title: 'Edit Client 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' }
};
Expand Down Expand Up @@ -138,82 +141,87 @@ export class AddressTabComponent {
*/
getAddressFormFields(formType?: string, address?: any) {
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}`)
}

if (formType === 'add') {
formfields.push(this.isFieldEnabled('addressType') ? new SelectBase({
controlName: 'addressType',
label: 'Address Type',
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: '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: 'Address Line 1',
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: 'Address Line 2',
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: 'Address Line 3',
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: 'Town / Village',
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: '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: 'State / Province',
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: 'Country District',
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: 'Country',
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: 'Postal Code',
label: this.translateService.instant('labels.inputs.Postal Code'),
value: address ? address.postalCode : '',
type: 'text',
order: 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<mat-label>{{"labels.inputs.Relationship" | translate}}</mat-label>
<mat-select formControlName="relationshipId" required>
<mat-option *ngFor="let relation of addFamilyMemberTemplate.relationshipIdOptions" [value]="relation.id">
{{ relation.name }}
{{ relation.name | translateKey:'catalogs' }}
</mat-option>
</mat-select>
<mat-error *ngIf="addFamilyMemberForm.controls.relationshipId.hasError('required')">
Expand All @@ -57,7 +57,7 @@
<mat-label>{{"labels.inputs.Gender" | translate}}</mat-label>
<mat-select formControlName="genderId" required>
<mat-option *ngFor="let gender of addFamilyMemberTemplate.genderIdOptions" [value]="gender.id">
{{ gender.name }}
{{ gender.name | translateKey:'catalogs' }}
</mat-option>
</mat-select>
<mat-error *ngIf="addFamilyMemberForm.controls.genderId.hasError('required')">
Expand All @@ -69,7 +69,7 @@
<mat-label>{{"labels.inputs.Profession" | translate}}</mat-label>
<mat-select formControlName="professionId">
<mat-option *ngFor="let profession of addFamilyMemberTemplate.professionIdOptions" [value]="profession.id">
{{ profession.name }}
{{ profession.name | translateKey:'catalogs' }}
</mat-option>
</mat-select>
</mat-form-field>
Expand All @@ -79,7 +79,7 @@
<mat-select formControlName="maritalStatusId">
<mat-option *ngFor="let maritalStatus of addFamilyMemberTemplate.maritalStatusIdOptions"
[value]="maritalStatus.id">
{{ maritalStatus.name }}
{{ maritalStatus.name | translateKey:'catalogs'}}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<mat-label>{{"labels.inputs.Relationship" | translate}}</mat-label>
<mat-select formControlName="relationshipId" required>
<mat-option *ngFor="let relation of addFamilyMemberTemplate.relationshipIdOptions" [value]="relation.id">
{{ relation.name }}
{{ relation.name | translateKey:'catalogs'}}
</mat-option>
</mat-select>
<mat-error *ngIf="editFamilyMemberForm.controls.relationshipId.hasError('required')">
Expand All @@ -57,7 +57,7 @@
<mat-label>{{"labels.inputs.Gender" | translate}}</mat-label>
<mat-select formControlName="genderId" required>
<mat-option *ngFor="let gender of addFamilyMemberTemplate.genderIdOptions" [value]="gender.id">
{{ gender.name }}
{{ gender.name | translateKey:'catalogs'}}
</mat-option>
</mat-select>
<mat-error *ngIf="editFamilyMemberForm.controls.genderId.hasError('required')">
Expand All @@ -69,7 +69,7 @@
<mat-label>{{"labels.inputs.Profession" | translate}}</mat-label>
<mat-select formControlName="professionId">
<mat-option *ngFor="let profession of addFamilyMemberTemplate.professionIdOptions" [value]="profession.id">
{{ profession.name }}
{{ profession.name | translateKey:'catalogs'}}
</mat-option>
</mat-select>
</mat-form-field>
Expand All @@ -79,7 +79,7 @@
<mat-select formControlName="maritalStatusId">
<mat-option *ngFor="let maritalStatus of addFamilyMemberTemplate.maritalStatusIdOptions"
[value]="maritalStatus.id">
{{ maritalStatus.name }}
{{ maritalStatus.name | translateKey:'catalogs'}}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/** Angular Imports */
import { Component, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatTable } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog';
import { MatTable } from '@angular/material/table';
import { ActivatedRoute } from '@angular/router';

/** Custom Models */
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';

/** Custom Components */
import { UploadDocumentDialogComponent } from '../custom-dialogs/upload-document-dialog/upload-document-dialog.component';
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
import { UploadDocumentDialogComponent } from '../custom-dialogs/upload-document-dialog/upload-document-dialog.component';

/** Custom Services */
import { ClientsService } from '../../clients.service';
import { TranslateService } from '@ngx-translate/core';
import { ClientsService } from '../../clients.service';

/**
* Identities Tab Component
Expand Down Expand Up @@ -72,6 +72,9 @@ export class IdentitiesTabComponent {
* Add Client Identifier
*/
addIdentifier() {
for (let index = 0; index < this.clientIdentifierTemplate.allowedDocumentTypes.length; index++) {
this.clientIdentifierTemplate.allowedDocumentTypes[index].name = this.translateService.instant(`labels.catalogs.${this.clientIdentifierTemplate.allowedDocumentTypes[index].name}`)
}
const formfields: FormfieldBase[] = [
new SelectBase({
controlName: 'documentTypeId',
Expand Down Expand Up @@ -139,7 +142,7 @@ export class IdentitiesTabComponent {
*/
deleteIdentifier(clientId: string, identifierId: string, index: number) {
const deleteIdentifierDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `identifier id:${identifierId}` }
data: { deleteContext: `${this.translateService.instant('labels.heading.identifier id')} : ${identifierId}` }
});
deleteIdentifierDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
Expand Down
Loading

0 comments on commit 559e013

Please sign in to comment.