-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLAN-1908: Create treatment dialog #2066
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e7c3b20
PLAN-1908: Create treatment dialog
LALuis a72804d
PLAN-1908: Create treatment dialog
LALuis fd714b1
Merge branch 'main' into lucho-plan-1908-treatment-plan-name-popup
LALuis a9b5694
PLAN-1908: Copy change from Jordan
LALuis 7311f9d
Merge branch 'lucho-plan-1908-treatment-plan-name-popup' of github.co…
LALuis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
.../app/plan/create-scenarios/create-treatment-dialog/create-treatment-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<h3 mat-dialog-title class="title">Name Your Treatment Plan</h3> | ||
<form [formGroup]="treatmentForm" (ngSubmit)="submit()"> | ||
<mat-dialog-content> | ||
<mat-form-field class="name-field"> | ||
<mat-label>Name</mat-label> | ||
<input matInput formControlName="treatmentName" /> | ||
</mat-form-field> | ||
<mat-error | ||
*ngIf=" | ||
treatmentForm.get('treatmentName')?.touched && | ||
treatmentForm.get('treatmentName')?.invalid | ||
"> | ||
Treatment name is required. | ||
</mat-error> | ||
</mat-dialog-content> | ||
<mat-dialog-actions align="end"> | ||
<button | ||
mat-button | ||
color="primary" | ||
type="button" | ||
(click)="cancel()" | ||
[disabled]="submitting"> | ||
CANCEL | ||
</button> | ||
<button | ||
mat-button | ||
type="submit" | ||
color="primary" | ||
data-id="save" | ||
[disabled]="submitting || treatmentForm.get('treatmentName')?.invalid"> | ||
<mat-spinner *ngIf="submitting" diameter="24"></mat-spinner> | ||
<span *ngIf="!submitting">SAVE</span> | ||
</button> | ||
</mat-dialog-actions> | ||
</form> |
19 changes: 19 additions & 0 deletions
19
.../app/plan/create-scenarios/create-treatment-dialog/create-treatment-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
:host { | ||
display: block; | ||
} | ||
|
||
mat-form-field { | ||
min-width: 480px; | ||
} | ||
|
||
.name-field { | ||
margin-top: 32px; | ||
} | ||
|
||
.title { | ||
margin: 24px 24px 0; | ||
} | ||
|
||
mat-dialog-actions { | ||
padding: 0 24px 16px; | ||
} |
35 changes: 35 additions & 0 deletions
35
...p/plan/create-scenarios/create-treatment-dialog/create-treatment-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { CreateTreatmentDialogComponent } from './create-treatment-dialog.component'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { MatDialogRef } from '@angular/material/dialog'; | ||
import { LegacyMaterialModule } from 'src/app/material/legacy-material.module'; | ||
import { MockProvider } from 'ng-mocks'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
describe('CreateTreatmentDialogComponent', () => { | ||
let component: CreateTreatmentDialogComponent; | ||
let fixture: ComponentFixture<CreateTreatmentDialogComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
CreateTreatmentDialogComponent, | ||
CommonModule, | ||
ReactiveFormsModule, | ||
LegacyMaterialModule, | ||
BrowserAnimationsModule, | ||
], | ||
providers: [MockProvider(MatDialogRef)], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(CreateTreatmentDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
...rc/app/plan/create-scenarios/create-treatment-dialog/create-treatment-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { | ||
FormControl, | ||
FormGroup, | ||
ReactiveFormsModule, | ||
Validators, | ||
} from '@angular/forms'; | ||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; | ||
import { LegacyMaterialModule } from 'src/app/material/legacy-material.module'; | ||
|
||
@Component({ | ||
selector: 'app-create-treatment-dialog', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
ReactiveFormsModule, | ||
MatDialogModule, | ||
LegacyMaterialModule, | ||
], | ||
templateUrl: './create-treatment-dialog.component.html', | ||
styleUrl: './create-treatment-dialog.component.scss', | ||
}) | ||
export class CreateTreatmentDialogComponent { | ||
submitting: boolean = false; | ||
treatmentForm = new FormGroup({ | ||
treatmentName: new FormControl('', [Validators.required]), | ||
}); | ||
|
||
constructor( | ||
private dialogRef: MatDialogRef<CreateTreatmentDialogComponent> | ||
) {} | ||
|
||
async submit() { | ||
if (this.treatmentForm.valid) { | ||
this.submitting = true; | ||
const treatmentName = | ||
this.treatmentForm.get('treatmentName')?.value || ''; | ||
this.dialogRef.close(treatmentName); | ||
this.submitting = false; | ||
} | ||
} | ||
|
||
cancel(): void { | ||
this.submitting = false; | ||
this.dialogRef.close(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to comment this from the screenshot :) That should be Name your Treatment PLAN :D