forked from doubtfire-lms/doubtfire-web
-
Notifications
You must be signed in to change notification settings - Fork 137
Feature: Grant Extension Form #285
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
20b07c0
feat: add Grant Extension form component
JoeMacl 7c338a6
feat: updated grant extension form with validation and styling
JoeMacl 570433a
feat: update progress on grant extension form
JoeMacl b3b5f97
style: improve modal responsiveness and log form submission
JoeMacl 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -165,4 +165,4 @@ | |
| "@nx/nx-linux-x64-gnu": "^18.0", | ||
| "@nx/nx-win32-x64-msvc": "^18.0" | ||
| } | ||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
src/app/admin/modals/grant-extension-form/grant-extension-dialog.component.ts
This file contains hidden or 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,27 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { MatDialogRef } from '@angular/material/dialog'; | ||
| import { GrantExtensionFormComponent } from './grant-extension-form.component'; | ||
| import { MatDialogModule } from '@angular/material/dialog'; | ||
| import { CommonModule } from '@angular/common'; | ||
|
|
||
| @Component({ | ||
| selector: 'f-grant-extension-dialog', | ||
| standalone: true, | ||
| imports: [MatDialogModule, CommonModule, GrantExtensionFormComponent], | ||
| template: ` | ||
| <h2 mat-dialog-title>Grant Extension</h2> | ||
| <mat-dialog-content> | ||
| <f-grant-extension-form></f-grant-extension-form> | ||
| </mat-dialog-content> | ||
| <mat-dialog-actions align="end"> | ||
| <button mat-button (click)="close()">Close</button> | ||
| </mat-dialog-actions> | ||
| ` | ||
| }) | ||
| export class GrantExtensionDialogComponent { | ||
| constructor(private dialogRef: MatDialogRef<GrantExtensionDialogComponent>) {} | ||
|
|
||
| close(): void { | ||
| this.dialogRef.close(); | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
src/app/admin/modals/grant-extension-form/grant-extension-form.component.html
This file contains hidden or 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,65 @@ | ||
| <h2 mat-dialog-title>Grant Extension</h2> | ||
|
|
||
| <mat-dialog-content [formGroup]="grantExtensionForm"> | ||
| <!-- Student Selection --> | ||
| <mat-form-field appearance="fill" class="w-full mb-4"> | ||
| <mat-label>Student</mat-label> | ||
| <mat-select formControlName="student" required> | ||
| <mat-option value="" disabled>Select a student</mat-option> | ||
| <mat-option *ngFor="let student of students" [value]="student.id"> | ||
| {{ student.name }} | ||
| </mat-option> | ||
| </mat-select> | ||
| <mat-error *ngIf="grantExtensionForm.get('student')?.touched && grantExtensionForm.get('student')?.invalid"> | ||
| Please select a student. | ||
| </mat-error> | ||
| </mat-form-field> | ||
|
|
||
| <!-- Extension Duration --> | ||
| <div class="mb-4"> | ||
| <label for="extension" class="block text-xl font-semibold text-gray-900"> | ||
| Extension Duration: <strong>{{ grantExtensionForm.get('extension')?.value }}</strong> day(s) | ||
| </label> | ||
|
|
||
| <mat-slider | ||
| min="1" | ||
| max="30" | ||
| step="1" | ||
| tickInterval="5" | ||
| thumbLabel | ||
| class="w-full" | ||
| style="width: 100%; max-width: 600px; min-width: 300px;" | ||
| > | ||
| <input matSliderThumb formControlName="extension" /> | ||
| </mat-slider> | ||
| </div> | ||
|
|
||
|
|
||
|
|
||
| <!-- Reason Field --> | ||
| <mat-form-field appearance="fill" class="w-full mb-4"> | ||
| <mat-label>Reason</mat-label> | ||
| <textarea | ||
| matInput | ||
| formControlName="reason" | ||
| rows="4" | ||
| required | ||
| ></textarea> | ||
| <mat-error *ngIf="grantExtensionForm.get('reason')?.touched && grantExtensionForm.get('reason')?.invalid"> | ||
| Please provide a reason for the extension. | ||
| </mat-error> | ||
| </mat-form-field> | ||
|
|
||
| <!-- Notes Field --> | ||
| <mat-form-field appearance="fill" class="w-full mb-4"> | ||
| <mat-label>Additional Notes (optional)</mat-label> | ||
| <textarea matInput formControlName="notes" rows="3"></textarea> | ||
| </mat-form-field> | ||
| </mat-dialog-content> | ||
|
|
||
| <mat-dialog-actions align="end"> | ||
| <button mat-button (click)="close()" [disabled]="isSubmitting">Cancel</button> | ||
| <button mat-flat-button color="primary" type="submit" (click)="onSubmit()" [disabled]="isSubmitting"> | ||
| Grant Extension | ||
| </button> | ||
| </mat-dialog-actions> | ||
Empty file.
22 changes: 22 additions & 0 deletions
22
src/app/admin/modals/grant-extension-form/grant-extension-form.component.spec.ts
This file contains hidden or 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,22 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { GrantExtensionFormComponent } from './grant-extension-form.component'; | ||
|
|
||
| describe('GrantExtensionFormComponent', () => { | ||
| let component: GrantExtensionFormComponent; | ||
| let fixture: ComponentFixture<GrantExtensionFormComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [GrantExtensionFormComponent] | ||
| }) | ||
| .compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(GrantExtensionFormComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
JoeMacl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); | ||
85 changes: 85 additions & 0 deletions
85
src/app/admin/modals/grant-extension-form/grant-extension-form.component.ts
This file contains hidden or 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,85 @@ | ||
| import { Component, OnInit, Inject } from '@angular/core'; | ||
| import { FormGroup, FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; | ||
| import { CommonModule } from '@angular/common'; | ||
| import { MatFormFieldModule } from '@angular/material/form-field'; | ||
| import { MatSelectModule } from '@angular/material/select'; | ||
| import { MatInputModule } from '@angular/material/input'; | ||
| import { MatSliderModule } from '@angular/material/slider'; | ||
| import { MatButtonModule } from '@angular/material/button'; | ||
| import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
|
|
||
JoeMacl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Component({ | ||
| selector: 'f-grant-extension-form', | ||
| standalone: true, | ||
| imports: [ | ||
| ReactiveFormsModule, | ||
| CommonModule, | ||
| MatFormFieldModule, | ||
| MatSelectModule, | ||
| MatInputModule, | ||
| MatSliderModule, | ||
| MatButtonModule, | ||
| MatDialogModule | ||
| ], | ||
| templateUrl: './grant-extension-form.component.html', | ||
| styleUrls: ['./grant-extension-form.component.scss'] | ||
| }) | ||
| export class GrantExtensionFormComponent implements OnInit { | ||
| grantExtensionForm!: FormGroup; | ||
| isSubmitting = false; | ||
|
|
||
| students = [ | ||
| { id: 1, name: 'Joe M' }, | ||
| { id: 2, name: 'Sahiru W' }, | ||
| { id: 3, name: 'Samindi M' } | ||
| ]; | ||
|
|
||
| constructor( | ||
| private fb: FormBuilder, | ||
| private dialogRef: MatDialogRef<GrantExtensionFormComponent>, | ||
| @Inject(MAT_DIALOG_DATA) public data: { unitId: number; taskDefinitionId: number } | ||
| ) {} | ||
|
|
||
| ngOnInit(): void { | ||
| this.grantExtensionForm = this.fb.group({ | ||
| student: ['', Validators.required], | ||
| extension: [1, [Validators.required, Validators.min(1)]], | ||
| reason: ['', Validators.required], | ||
| notes: [''], | ||
| }); | ||
| console.log('Received dialog data:', this.data); | ||
| } | ||
|
|
||
| onSubmit(): void { | ||
| if (this.grantExtensionForm.invalid) { | ||
| this.grantExtensionForm.markAllAsTouched(); | ||
| return; | ||
| } | ||
|
|
||
| this.isSubmitting = true; | ||
|
|
||
| setTimeout(() => { | ||
| console.log('Form submitted:', { | ||
| ...this.grantExtensionForm.value, | ||
| unitId: this.data.unitId, | ||
| taskDefinitionId: this.data.taskDefinitionId | ||
| }); | ||
|
|
||
| this.grantExtensionForm.reset({ | ||
| student: '', | ||
| extension: 1, | ||
| reason: '', | ||
| notes: '' | ||
| }); | ||
|
|
||
| this.isSubmitting = false; | ||
| this.dialogRef.close(); | ||
| }, 1000); | ||
| console.log('Submitting with data:', this.data); | ||
|
|
||
|
|
||
| } | ||
| close(): void { | ||
| this.dialogRef.close(); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
58 changes: 27 additions & 31 deletions
58
...ard/directives/task-dashboard/directives/task-status-card/task-status-card.component.html
This file contains hidden or 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 |
|---|---|---|
| @@ -1,44 +1,40 @@ | ||
| <mat-card appearance="outlined"> | ||
| @if (triggers?.length > 0) { | ||
| <mat-form-field class="px-4 pt-4" appearance="outline"> | ||
| <mat-select [value]="task?.status" (selectionChange)="triggerTransition($event.value)"> | ||
| <mat-select-trigger> | ||
| <span style="display: inline-flex"> | ||
| <status-icon [status]="task?.status" style="margin-right: 10px"></status-icon> | ||
| <h2 class="mb-0">{{ task?.statusLabel() }}</h2> | ||
| </span> | ||
| </mat-select-trigger> | ||
| @for (trigger of triggers; track trigger) { | ||
| <mat-option [value]="trigger.status"> | ||
| <status-icon [status]="trigger.status" [showTooltip]="false"></status-icon> | ||
| <span style="display: inline-flex; margin-left: 10px" | ||
| ><h5>{{ trigger.label }}</h5></span | ||
| > | ||
| </mat-option> | ||
| } | ||
| </mat-select> | ||
| </mat-form-field> | ||
| } @if (triggers?.length < 0) { | ||
| <mat-card-title> | ||
| <span style="display: inline-flex"> | ||
| <status-icon [status]="task?.status" style="margin-right: 10px"></status-icon> | ||
| <h5>{{ task?.statusLabel() }}</h5> | ||
| </span> | ||
| </mat-card-title> | ||
| <mat-form-field class="px-4 pt-4" appearance="outline"> | ||
| <mat-select [value]="task?.status" (selectionChange)="triggerTransition($event.value)"> | ||
| <mat-select-trigger> | ||
| <span style="display: inline-flex"> | ||
| <status-icon [status]="task?.status" style="margin-right: 10px"></status-icon> | ||
| <h2 class="mb-0">{{ task?.statusLabel() }}</h2> | ||
| </span> | ||
| </mat-select-trigger> | ||
| @for (trigger of triggers; track trigger) { | ||
| <mat-option [value]="trigger.status"> | ||
| <status-icon [status]="trigger.status" [showTooltip]="false"></status-icon> | ||
| <span style="display: inline-flex; margin-left: 10px"> | ||
| <h5>{{ trigger.label }}</h5> | ||
| </span> | ||
| </mat-option> | ||
| } | ||
| </mat-select> | ||
| </mat-form-field> | ||
| } | ||
|
|
||
| <mat-card-content> | ||
| <p>{{ task?.statusHelp().reason }} {{ task?.statusHelp().action }}</p> | ||
| </mat-card-content> | ||
|
|
||
| @if ( task?.unit.currentUserIsStaff || task?.canApplyForExtension() || (task?.inSubmittedState() && | ||
| task?.requiresFileUpload()) ) { | ||
| <mat-card-actions class="space-x-2"> | ||
| @if (task?.canApplyForExtension()) { | ||
| <button mat-stroked-button (click)="applyForExtension()">Request extension</button> | ||
| } @if (task?.inSubmittedState() && task?.requiresFileUpload()) { | ||
| <button mat-stroked-button (click)="updateFilesInSubmission()">Upload new files</button> | ||
| <button mat-stroked-button (click)="applyForExtension()">Request extension</button> | ||
| } | ||
| @if (task?.inSubmittedState() && task?.requiresFileUpload()) { | ||
| <button mat-stroked-button (click)="updateFilesInSubmission()">Upload new files</button> | ||
| } | ||
|
|
||
| <!-- Always show for testing --> | ||
| <button mat-stroked-button color="primary" (click)="openGrantExtensionDialog()"> | ||
| Grant Extension | ||
| </button> | ||
| </mat-card-actions> | ||
| } | ||
| </mat-card> |
This file contains hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.