-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/46 implement room create functionality #95
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
Merged
PIPetkova19
merged 16 commits into
main
from
feature/46-implement-room-create-functionality
Jul 22, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
137f877
Add create form for room
PIPetkova19 0ff2c22
Use extracted api url for service
PIPetkova19 2966cfd
Add takeUntilDestroyed to subscriptions
PIPetkova19 24741f1
Add i18n to alert
PIPetkova19 c696e70
Fix tests for room component
PIPetkova19 b08129e
Resolve double submit issue
PIPetkova19 c2ddf08
Replace alert with snack bar
PIPetkova19 7a3aa43
Merge branch 'main' into feature/46-implement-room-create-functionality
PIPetkova19 fa1374d
Fix button position
PIPetkova19 2292189
Optimized imports
PIPetkova19 57b253d
Add typed formGroup definitions
PIPetkova19 bb93a15
Add snackbar displaying error message
PIPetkova19 97e2e2f
Merge branch 'main' into feature/46-implement-room-create-functionality
PIPetkova19 0b1b3a8
Add return types to functions
PIPetkova19 5de4a10
Add return types to functions
PIPetkova19 c1dc63f
Remove unused imports from tests
PIPetkova19 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
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export interface CourseElm { | ||
| id: string; | ||
| majorId: string; | ||
| courseYear: number; | ||
| locaticourseTypeon: string; | ||
| courseSubtype: string; | ||
| } |
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
19 changes: 19 additions & 0 deletions
19
uniplanWeb/src/app/features/room/room-add-form/room-add-form.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,19 @@ | ||
| <app-add-form [title]="'major.add.title' | translate" (saveClicked)="save()"> | ||
| <form [formGroup]="addForm"> | ||
| <mat-form-field appearance="fill"> | ||
| <mat-label>{{ 'room.room-number' | translate }}</mat-label> | ||
| <input matInput id="room-number" type="text" formControlName="roomNumber" /> | ||
| </mat-form-field> | ||
|
|
||
| <mat-form-field appearance="fill"> | ||
| <mat-label>{{ 'features.faculty-label' | translate }}</mat-label> | ||
| <mat-select formControlName="facultyId"> | ||
| @for (faculty of faculties; track faculty.id) { | ||
| <mat-option [value]="faculty.id"> | ||
| {{ faculty.facultyName }} | ||
| </mat-option> | ||
| } | ||
| </mat-select> | ||
| </mat-form-field> | ||
| </form> | ||
| </app-add-form> |
14 changes: 14 additions & 0 deletions
14
uniplanWeb/src/app/features/room/room-add-form/room-add-form.scss
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,14 @@ | ||
| mat-form-field { | ||
| width: 100%; | ||
| } | ||
|
|
||
| mat-dialog-title { | ||
| font-size: 20px; | ||
| font-weight: bold; | ||
| color: #3f51b5; | ||
| } | ||
|
|
||
| input { | ||
| border-radius: 10px; | ||
| width: 100%; | ||
| } |
28 changes: 28 additions & 0 deletions
28
uniplanWeb/src/app/features/room/room-add-form/room-add-form.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,28 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { RoomAddForm } from './room-add-form'; | ||
| import { translateTestingProviders } from '@testing/translate-testing'; | ||
| import { MatDialogRef } from '@angular/material/dialog'; | ||
|
|
||
| describe('RoomAddForm', () => { | ||
| let component: RoomAddForm; | ||
| let fixture: ComponentFixture<RoomAddForm>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [RoomAddForm], | ||
| providers: [ | ||
| ...translateTestingProviders, | ||
| { provide: MatDialogRef, useValue: {} }, | ||
| ] | ||
| }) | ||
| .compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(RoomAddForm); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
103 changes: 103 additions & 0 deletions
103
uniplanWeb/src/app/features/room/room-add-form/room-add-form.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,103 @@ | ||
| import { Component, OnInit, ChangeDetectionStrategy, inject, DestroyRef } from '@angular/core'; | ||
| import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
| import { Validators, FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
| import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; | ||
| import { MatFormField, MatLabel } from '@angular/material/form-field'; | ||
| import { MatInputModule } from '@angular/material/input'; | ||
| import { MatSelectModule } from '@angular/material/select'; | ||
| import { MatOptionModule } from '@angular/material/core'; | ||
| import { MatSnackBar } from '@angular/material/snack-bar'; | ||
| import { TranslatePipe, TranslateService } from '@ngx-translate/core'; | ||
| import { finalize } from 'rxjs'; | ||
| import { AddForm } from '../../../core/shared/add-form/add-form'; | ||
| import { FacultyService } from '../../faculty/faculty-service'; | ||
| import { FacultyElm } from '../../../core/interfaces/faculty-elm'; | ||
| import { RoomService } from '../room-service'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-room-add-form', | ||
| templateUrl: './room-add-form.html', | ||
| styleUrl: './room-add-form.scss', | ||
| changeDetection: ChangeDetectionStrategy.Eager, | ||
| imports: [ | ||
| MatDialogModule, | ||
| MatFormField, | ||
| MatLabel, | ||
| MatInputModule, | ||
| MatSelectModule, | ||
| MatOptionModule, | ||
| AddForm, | ||
| TranslatePipe, | ||
| ReactiveFormsModule | ||
| ], | ||
| }) | ||
|
|
||
| export class RoomAddForm implements OnInit { | ||
| private dialogRef = inject(MatDialogRef<AddForm>); | ||
| private facultyService = inject(FacultyService); | ||
| private roomService = inject(RoomService) | ||
| faculties: FacultyElm[] = []; | ||
| private destroyRef = inject(DestroyRef); | ||
| private translate = inject(TranslateService); | ||
| private isSubmitting = false; | ||
| private _snackBar = inject(MatSnackBar); | ||
|
|
||
| addForm = new FormGroup({ | ||
|
PIPetkova19 marked this conversation as resolved.
|
||
| roomNumber: new FormControl<string | null>('', Validators.required), | ||
| facultyId: new FormControl<string | null>('', Validators.required), | ||
| }); | ||
|
|
||
| ngOnInit(): void { | ||
| this.facultyService.getFaculties() | ||
| .pipe(takeUntilDestroyed(this.destroyRef)) | ||
| .subscribe({ | ||
| next: (data) => { | ||
| this.faculties = data; | ||
| }, | ||
| error: (err) => { | ||
| console.error('Failed to load faculties', err); | ||
|
PIPetkova19 marked this conversation as resolved.
|
||
| this.openSnackBar( | ||
| this.translate.instant('faculty.load.failed'), | ||
| this.translate.instant('shared.close-btn') | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| openSnackBar(message: string, action: string): void { | ||
| this._snackBar.open(message, action); | ||
| } | ||
|
|
||
| save(): void { | ||
| if (this.addForm.invalid || this.isSubmitting) { | ||
| return; | ||
| } | ||
|
|
||
| this.isSubmitting = true; | ||
| this.addForm.disable(); | ||
|
|
||
| const newRoom = { | ||
| roomNumber: this.addForm.value.roomNumber ?? '', | ||
| facultyId: this.addForm.value.facultyId ?? '', | ||
| }; | ||
|
|
||
| this.roomService.createRoom(newRoom) | ||
| .pipe(takeUntilDestroyed(this.destroyRef), | ||
| finalize(() => { | ||
| this.isSubmitting = false; | ||
| this.addForm.enable(); | ||
| })) | ||
| .subscribe({ | ||
| next: (response) => { | ||
| this.dialogRef.close(response); | ||
| }, | ||
| error: (err) => { | ||
| console.error('Failed to add room', err); | ||
| this.openSnackBar( | ||
| this.translate.instant('room.add.failed'), | ||
| this.translate.instant('shared.close-btn') | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
uniplanWeb/src/app/features/room/room-options/room-options.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 @@ | ||
| <app-add-button (addClicked)="openAddForm()" class="add-button"></app-add-button> |
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.