Skip to content

Commit

Permalink
Merge branch 'dev' into CSCEXAM-1356
Browse files Browse the repository at this point in the history
  • Loading branch information
VirmasaloA committed Oct 23, 2024
2 parents 1700233 + 56d06a1 commit 0e2e344
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<xm-page-content [content]="content" />
<ng-template #buttons>
<div class="float-end pe-3">
<button [routerLink]="['/staff/exams']" class="btn btn-success me-3">
<button [routerLink]="['/staff/exams']" class="btn btn-success me-3 mb-3">
{{ 'i18n_toolbar_new_exam' | translate }}
</button>
<button
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/facility/facility.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<xm-page-header text="i18n_exam_rooms_administration" [appendWide]="true" [appendTemplate]="buttons" />
<xm-page-content [content]="content" />
<ng-template #buttons>
<a class="float-end bi-building btn btn-success" (click)="editMultipleRooms()">
<a class="float-end bi-building btn btn-success ms-3 mb-3" (click)="editMultipleRooms()">
<span class="ps-3">{{ 'i18n_edit_all_rooms' | translate }}</span>
</a>
<a class="float-end me-4 bi-plus-square btn btn-success" (click)="createExamRoom()">
<a class="float-end bi-plus-square btn btn-success" (click)="createExamRoom()">
<span class="ps-3">{{ 'i18n_add' | translate }}</span>
</a>
</ng-template>
Expand Down
90 changes: 43 additions & 47 deletions ui/src/app/facility/rooms/room.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,49 @@
<ng-template #content>
<div class="row">
<div class="col-md-12">
<div class="row">
<span class="col font-6">
<span class="me-2" [hidden]="!showName" onclick="document.getElementById('name_field').select();">
{{ room.name || 'i18n_no_name' | translate }}
<button
class="btn btn-link btn-lg text-body width-auto"
(click)="showName = !showName"
triggers="mouseenter:mouseleave"
popoverTitle="{{ 'i18n_instructions' | translate }}"
ngbPopover="{{ 'i18n_edit' | translate }}"
>
<i class="bi-pencil ms-2"></i>
</button>
<button
class="btn btn-link btn-lg width-auto"
(click)="disableRoom()"
triggers="mouseenter:mouseleave"
popoverTitle="{{ 'i18n_instructions' | translate }}"
ngbPopover="{{ 'i18n_inactivate_room' | translate }}"
>
<i class="text-danger bi-trash"></i>
</button>
</span>
<span [hidden]="showName">
<div class="input-group">
<input
id="name_field"
type="text"
name="name"
class="form-control input-lg"
[(ngModel)]="room.name"
required
(blur)="showName = !showName"
/>
<div class="input-group-append">
<button class="btn btn-primary" (click)="showName = !showName">
<i class="bi-check"></i>
</button>
</div>
</div>
</span>
</span>
</div>
<form
role="form"
#roomForm="ngForm"
Expand All @@ -19,53 +62,6 @@
id="roomForm"
(ngSubmit)="validateAndUpdateRoom()"
>
<div class="row">
<span class="col font-6">
<span
class="me-2"
[hidden]="!showName"
onclick="document.getElementById('name_field').select();"
>
{{ room.name || 'i18n_no_name' | translate }}
<button
class="btn btn-link btn-lg text-body width-auto"
(click)="showName = !showName"
triggers="mouseenter:mouseleave"
popoverTitle="{{ 'i18n_instructions' | translate }}"
ngbPopover="{{ 'i18n_edit' | translate }}"
>
<i class="bi-pencil ms-2"></i>
</button>
<button
class="btn btn-link btn-lg width-auto"
(click)="disableRoom()"
triggers="mouseenter:mouseleave"
popoverTitle="{{ 'i18n_instructions' | translate }}"
ngbPopover="{{ 'i18n_inactivate_room' | translate }}"
>
<i class="text-danger bi-trash"></i>
</button>
</span>
<span [hidden]="showName">
<div class="input-group">
<input
id="name_field"
type="text"
name="name"
class="form-control input-lg"
[(ngModel)]="room.name"
required
(blur)="showName = !showName"
/>
<div class="input-group-append">
<button class="btn btn-primary" (click)="showName = !showName">
<i class="bi-check"></i>
</button>
</div>
</div>
</span>
</span>
</div>
<!-- Room Code & Building name -->
<div class="row">
<div class="col-md-6">
Expand Down
29 changes: 1 addition & 28 deletions ui/src/app/facility/rooms/room.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { AccessibilitySelectorComponent } from 'src/app/facility/accessibility/accessibility-picker.component';
import { AddressComponent } from 'src/app/facility/address/address.component';
import type { ExamRoom, ExceptionWorkingHours } from 'src/app/reservation/reservation.model';
import type { ExamRoom } from 'src/app/reservation/reservation.model';
import { PageContentComponent } from 'src/app/shared/components/page-content.component';
import { PageHeaderComponent } from 'src/app/shared/components/page-header.component';
import { AvailabilityComponent } from './availability.component';
Expand Down Expand Up @@ -66,37 +66,10 @@ export class RoomComponent implements OnInit {
});
}

addExceptions = (exceptions: ExceptionWorkingHours[]) => {
this.roomService.addExceptions([this.room.id], exceptions).then((data) => {
this.room.calendarExceptionEvents = [...this.room.calendarExceptionEvents, ...data];
});
};

deleteException = (exception: ExceptionWorkingHours) => {
this.roomService.deleteException(this.room.id, exception.id).then(() => {
this.room.calendarExceptionEvents = this.room.calendarExceptionEvents.splice(
this.room.calendarExceptionEvents.indexOf(exception),
1,
);
});
};

disableRoom = () => {
this.roomService.disableRoom(this.room);
};

enableRoom = () => {
this.roomService.enableRoom(this.room);
};

validateInputAndUpdateRoom = (event: FocusEvent & { target: HTMLInputElement | HTMLTextAreaElement }) => {
const { name } = event.target;
const ctrl = this.roomForm.controls[name];
if (ctrl.valid) {
this.updateRoom();
}
};

validateAndUpdateRoom = () => {
if (this.roomForm.valid) {
this.updateRoom();
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/facility/rooms/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export class RoomService {
},
error: (err) => this.toast.error(err),
}),
error: (err) => this.toast.error(err),
});

enableRoom = (room: ExamRoom) =>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/review/listing/speed-review.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class SpeedReviewComponent implements OnInit {
this.toast.success(`${this.translate.instant('i18n_csv_uploaded_successfully')}`);
})
.catch(() => {
this.toast.error(`${this.translate.instant('i18n_csv_uploading_failed')}`);
this.toast.info(`${this.translate.instant('i18n_csv_uploading_cancelled')}`);
return noop;
});
};
Expand Down
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,5 +1188,6 @@
"i18n_exam_not_published": "This exam is not published.",
"i18n_show_participants": "Show participants",
"i18n_hide_participants": "Hide participants",
"i18n_exam_owner_info": "Exam needs to have at least one examiner."
"i18n_exam_owner_info": "Exam needs to have at least one examiner.",
"i18n_csv_uploading_cancelled": "CSV file upload cancelled"
}
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,5 +1188,6 @@
"i18n_exam_not_published": "Tätä tenttiä ei ole julkaistu.",
"i18n_show_participants": "Näytä osallistujat",
"i18n_hide_participants": "Piilota osallistujat",
"i18n_exam_owner_info": "Tentissä pitää olla vähintään yksi tentaattori."
"i18n_exam_owner_info": "Tentissä pitää olla vähintään yksi tentaattori.",
"i18n_csv_uploading_cancelled": "CSV tiedoston tuonti peruutettu"
}
3 changes: 2 additions & 1 deletion ui/src/assets/i18n/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,5 +1188,6 @@
"i18n_exam_not_published": "Tentamen inte publicerad. SV",
"i18n_show_participants": "Visa deltagare",
"i18n_hide_participants": "Dölj deltagare",
"i18n_exam_owner_info": "Tentamen behöver minst en bedömare.SV"
"i18n_exam_owner_info": "Tentamen behöver minst en bedömare.SV",
"i18n_csv_uploading_cancelled": "Uppladdning av CSV-fil avbruten"
}

0 comments on commit 0e2e344

Please sign in to comment.