82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
import { Inject, Component, OnInit } from '@angular/core';
|
|
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
|
|
|
import { LanguageService } from '../language.service';
|
|
import { LanguageData } from '../language.model';
|
|
|
|
@Component({
|
|
selector: 'app-tips',
|
|
templateUrl: './tips.component.html',
|
|
styleUrls: ['./tips.component.css']
|
|
})
|
|
|
|
export class TipsComponent implements OnInit{
|
|
orderTotal:number = 0;
|
|
value:number = 0.15;
|
|
flag:boolean = true;
|
|
|
|
// -------------------------------------
|
|
//
|
|
// Language Support
|
|
//
|
|
vE = {
|
|
tipsEnterTip : '',
|
|
tipsSubtotal : '',
|
|
tipsTip : '',
|
|
tipsTotal : '',
|
|
tipsNoTipBtn : '',
|
|
tipsDoneBtn : ''
|
|
}
|
|
|
|
constructor(
|
|
private languageService : LanguageService,
|
|
private dialogRef: MatDialogRef<TipsComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: {amt: number, flag: boolean}) {
|
|
this.orderTotal = data.amt;
|
|
this.flag = data.flag;
|
|
if(!data.flag){
|
|
this.dialogRef.close(0);
|
|
}
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
if(!this.flag){
|
|
this.dialogRef.close(0);
|
|
}
|
|
this.chgUILanguage();
|
|
}
|
|
|
|
formatPercent(v: number) {
|
|
return (v * 100) + '%';
|
|
}
|
|
|
|
close() {
|
|
this.dialogRef.close(0);
|
|
}
|
|
|
|
confirm() {
|
|
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); }
|
|
);
|
|
}
|
|
|
|
}
|