Tips component - Language module added

This commit is contained in:
Rene V. Vergara A. 2023-10-26 17:11:06 -04:00
parent 518dfd0ecb
commit 6a5fc45c5c
2 changed files with 45 additions and 6 deletions

View file

@ -1,17 +1,17 @@
<mat-card> <mat-card>
<mat-card-title class="scan-header"> <mat-card-title class="scan-header">
Enter tip: {{ vE.tipsEnterTip }}:
</mat-card-title> </mat-card-title>
<mat-card-content> <mat-card-content>
<br> <br>
<div align="center" class="card-contents"> <div align="center" class="card-contents">
<table cellspacing="0"> <table cellspacing="0">
<tr> <tr>
<th align="center">Subtotal</th> <th align="center"> {{ vE.tipsSubtotal }}</th>
<th align="center"></th> <th align="center"></th>
<th align="center">Tip</th> <th align="center">{{ vE.tipsTip }}</th>
<th align="center"></th> <th align="center"></th>
<th align="center">Total</th> <th align="center">{{ vE.tipsTotal }}</th>
</tr> </tr>
<tr> <tr>
<td align="center">{{orderTotal | currency}}</td> <td align="center">{{orderTotal | currency}}</td>
@ -31,10 +31,10 @@
</mat-card-content> </mat-card-content>
<mat-card-actions class="card-buttons"> <mat-card-actions class="card-buttons">
<button mat-raised-button (click)="close()"> <button mat-raised-button (click)="close()">
<mat-icon class="icon">close</mat-icon>No Tip <mat-icon class="icon">close</mat-icon>{{ vE.tipsNoTipBtn }}
</button> </button>
<button mat-raised-button color="primary" (click)="confirm()"> <button mat-raised-button color="primary" (click)="confirm()">
<mat-icon class="icon">done</mat-icon>Done <mat-icon class="icon">done</mat-icon>{{ vE.tipsDoneBtn }}
</button> </button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>

View file

@ -1,6 +1,9 @@
import { Inject, Component, OnInit } from '@angular/core'; import { Inject, Component, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({ @Component({
selector: 'app-tips', selector: 'app-tips',
templateUrl: './tips.component.html', templateUrl: './tips.component.html',
@ -12,7 +15,21 @@ export class TipsComponent implements OnInit{
value:number = 0.15; value:number = 0.15;
flag:boolean = true; flag:boolean = true;
// -------------------------------------
//
// Language Support
//
vE = {
tipsEnterTip : '',
tipsSubtotal : '',
tipsTip : '',
tipsTotal : '',
tipsNoTipBtn : '',
tipsDoneBtn : ''
}
constructor( constructor(
private languageService : LanguageService,
private dialogRef: MatDialogRef<TipsComponent>, private dialogRef: MatDialogRef<TipsComponent>,
@Inject(MAT_DIALOG_DATA) public data: {amt: number, flag: boolean}) { @Inject(MAT_DIALOG_DATA) public data: {amt: number, flag: boolean}) {
this.orderTotal = data.amt; this.orderTotal = data.amt;
@ -26,6 +43,7 @@ export class TipsComponent implements OnInit{
if(!this.flag){ if(!this.flag){
this.dialogRef.close(0); this.dialogRef.close(0);
} }
this.chgUILanguage();
} }
formatPercent(v: number) { formatPercent(v: number) {
@ -39,4 +57,25 @@ export class TipsComponent implements OnInit{
confirm() { confirm() {
this.dialogRef.close(this.orderTotal * this.value); this.dialogRef.close(this.orderTotal * this.value);
} }
chgUILanguage(){
console.log('TIPS.chgUILanguage Called ');
this.languageService.getViewElements('tips').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
this.vE.tipsEnterTip = response.data.tips_enter_tip;
this.vE.tipsSubtotal = response.data.tips_subtotal;
this.vE.tipsTip = response.data.tips_tip;
this.vE.tipsTotal = response.data.tips_total;
this.vE.tipsNoTipBtn = response.data.tips_notip_btn;
this.vE.tipsDoneBtn = response.data.tips_done_btn;
},
error => { console.log('Error >> ',error); }
);
}
} }