diff --git a/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.html b/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.html index 85421dea1..8b8e6b42a 100644 --- a/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.html +++ b/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.html @@ -1,6 +1,7 @@
{{warningText}}
+ Practice @@ -186,7 +187,7 @@
diff --git a/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.scss b/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.scss index 986f2bed8..90bdd2add 100644 --- a/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.scss +++ b/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.scss @@ -1,78 +1,90 @@ - .mat-stepper-horizontal { - margin-top: 8px; - } - - .mat-mdc-form-field { - margin-top: 16px; + margin-top: 8px; +} + +.mat-mdc-form-field { + margin-top: 16px; +} + +.warningText { + text-align: center; + color: red; + font-size: 12px; +} + + +.dialog-content { + .saveButtonPosition { + position: absolute; + left: 20px; + top: 20px } - .warningText{ - text-align: center; - color: red; - font-size: 12px; + .StepTitle { + display: flex; + justify-content: center; + font-size: medium; + font-weight: bold; } - .dialog-content{ - - .StepTitle{ - display: flex; - justify-content: center; - font-size: medium; - font-weight: bold; - } - .StepContainer{ - display: flex; - flex-direction: column; - align-items: flex-start; - width: 50%; - gap: .4rem; - - .StepContent{ + .StepContainer { + display: flex; + flex-direction: column; + align-items: flex-start; + width: 50%; + gap: .4rem; + + .StepContent { display: flex; align-items: center; justify-content: center; flex-direction: column; + .form-group { // width: 500px; - padding-top: 10px; - padding-bottom: 20px; + padding-top: 10px; + padding-bottom: 20px; } + label { font-size: 14px; font-weight: 400; margin-right: 10px; } + input.form-control { font-size: 16px; outline-color: #8a2644; padding: 10px; width: 90%; } - .ButtonSection{ + + .ButtonSection { width: 15rem; } } - } - .genderDiv{ - display: flex; - align-items: center; - gap: 5px; - margin-top: 1rem; - margin-bottom: 1rem; - flex-direction: row; - } - .genderType{ - width: 5rem; - height: 5rem; - font-weight: 700; - display: flex; - border-radius: 5px; - margin: 2px; - align-items: center; - justify-content: center; - text-align: center; - } - } + + .genderDiv { + display: flex; + align-items: center; + gap: 5px; + margin-top: 1rem; + margin-bottom: 1rem; + flex-direction: row; + } + + .genderType { + width: 5rem; + height: 5rem; + font-weight: 700; + display: flex; + border-radius: 5px; + margin: 2px; + align-items: center; + justify-content: center; + text-align: center; + } + +} \ No newline at end of file diff --git a/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.ts b/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.ts index 9e9c22146..271b740a6 100644 --- a/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.ts +++ b/apps/picsa-tools/option-tool/src/app/components/editor/editor.component.ts @@ -1,6 +1,15 @@ import {Component,EventEmitter, OnInit, Output ,ViewChild} from '@angular/core'; import { MatStepper } from '@angular/material/stepper' +export interface IOptionData { + practice: string; + gender: string []; + benefits: {benefit:string, beneficiary:string[]} []; + performance:{lowRf:string, midRf:string, highRf:string}; + investment: {money:string, time:string}; + time: string; + risk: string; +} @Component({ selector: 'option-editor', templateUrl: './editor.component.html', @@ -19,6 +28,8 @@ export class EditorComponent implements OnInit { benefitsStartTime: string; risk:string; isLinear = false; + editMode= false + editIndex:number; @ViewChild(MatStepper) stepper: MatStepper; @@ -40,7 +51,9 @@ export class EditorComponent implements OnInit { this.perfomanceValues= {lowRf:"", midRf:"", highRf:""}; this.investmentValues={money:"", time:""}; this.benefitsStartTime =""; - this.risk="" + this.risk=""; + this.editIndex = -1; + } handleGender(gender:string){ @@ -68,6 +81,7 @@ export class EditorComponent implements OnInit { beneficiary:[] }) } + onlyNumbers(event): boolean { const charCode = (event.which) ? event.which : event.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { @@ -76,13 +90,14 @@ export class EditorComponent implements OnInit { return true; } - async finishProcess (){ + async submitForm (){ //compile collected data if(this.practiceEntry && this.gender.length > 0 && this.benefitsStartTime && this.risk){ const finalObject = { + data:{ practice:this.practiceEntry, gender: this.gender, benefits:this.benefits, @@ -90,8 +105,10 @@ export class EditorComponent implements OnInit { investment:this.investmentValues, time:this.benefitsStartTime, risk:this.risk - } - this.dataTransfer.emit(finalObject); + }, + index:this.editIndex + } + this.dataTransfer.emit(finalObject); this.resetVariables() this.resetStepper() }else{ @@ -115,16 +132,26 @@ export class EditorComponent implements OnInit { this.investmentValues={money:"", time:""}; this.benefitsStartTime =""; this.risk="" + this.editIndex=-1 + this.editMode=false + } + //incase of edits + presetVariables(rowData:IOptionData,index:number){ + //remove all warinings + this.warningText=''; + //editor + this.editMode =true; + this.editIndex =index; + + this.benefits= rowData.benefits + this.perfomanceValues = rowData.performance + this.investmentValues = rowData.investment + this.practiceEntry=rowData.practice + this.gender= rowData.gender; + this.benefitsStartTime =rowData.time + this.risk=rowData.risk } resetStepper(): void { this.stepper.reset(); } - submitForm() { - console.log('Form submitted!'); - } - // ngOnDestroy() { - // // Reset variables when the component is destroyed. - - // } - } diff --git a/apps/picsa-tools/option-tool/src/app/pages/home/home.component.html b/apps/picsa-tools/option-tool/src/app/pages/home/home.component.html index 5f68c14d5..3ef3416f0 100644 --- a/apps/picsa-tools/option-tool/src/app/pages/home/home.component.html +++ b/apps/picsa-tools/option-tool/src/app/pages/home/home.component.html @@ -76,15 +76,15 @@ - + -
- +
diff --git a/apps/picsa-tools/option-tool/src/app/pages/home/home.component.ts b/apps/picsa-tools/option-tool/src/app/pages/home/home.component.ts index 019163465..5b167e4e7 100644 --- a/apps/picsa-tools/option-tool/src/app/pages/home/home.component.ts +++ b/apps/picsa-tools/option-tool/src/app/pages/home/home.component.ts @@ -1,4 +1,5 @@ -import { Component } from '@angular/core'; +import { Component,ViewChild } from '@angular/core'; +import { EditorComponent } from '../../components/editor/editor.component'; export interface IOptionData { practice: string; @@ -20,6 +21,9 @@ export class HomeComponent { public dataSource: IOptionData[] = []; public displayedColumns: string[] = ['practice', 'gender', 'benefits', 'performance','investment','time','risk' ]; + + @ViewChild(EditorComponent) editorComponent: EditorComponent; + matStepperOpen = false; @@ -29,11 +33,30 @@ export class HomeComponent { public closeDialog(){ this.matStepperOpen = false } - onDataTransfer(data: IOptionData) { + onDataTransfer(data:{data:IOptionData,index:number}) { console.log('Received data from editor:', data); // close the child component - this.dataSource = [...this.dataSource, data]; + if(data.index > -1){ + this.dataSource[data.index]=data.data + //invoke change detaction + this.dataSource=[...this.dataSource] + }else{ + this.dataSource = [...this.dataSource, data.data]; + } + //detect change for the case of editing a raw this.matStepperOpen = false; } + openNewDialog(){ + this.editorComponent.resetVariables(); + this.openDialog() + } + onRowClicked(row: IOptionData, index: number) { + // console.log('Row clicked', row); + // console.log('Index of the Row', index) + // open stepper with this data + // since it is already running with the current home page + this.editorComponent.presetVariables(row,index); + this.openDialog() + } }