mirror of
https://github.com/opelly27/WinStudentGoalTracker.git
synced 2026-05-20 14:37:34 +00:00
Updates to see others' students
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
<div class="scope-bar">
|
||||
<label class="scope-toggle">
|
||||
<span>All Students</span>
|
||||
<span class="toggle-track" [class.active]="showAll()">
|
||||
<span class="toggle-thumb"></span>
|
||||
</span>
|
||||
<input type="checkbox" [checked]="showAll()" (change)="onToggleScope()" hidden>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@if (loaded() && students().length === 0) {
|
||||
<div class="empty-state">
|
||||
<p>You don't currently have any students.</p>
|
||||
|
||||
@@ -16,4 +16,47 @@
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.scope-bar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.scope-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
font-size: 0.875rem;
|
||||
color: #4b5563;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.toggle-track {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
width: 36px;
|
||||
height: 20px;
|
||||
background: #d1d5db;
|
||||
border-radius: 10px;
|
||||
padding: 2px;
|
||||
transition: background 0.2s;
|
||||
|
||||
&.active {
|
||||
background: #4f46e5;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-thumb {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.2s;
|
||||
|
||||
.active > & {
|
||||
transform: translateX(16px);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ export class Students {
|
||||
private readonly studentService = inject(StudentService);
|
||||
protected readonly students = signal<StudentCardDto[]>([]);
|
||||
protected readonly loaded = signal(false);
|
||||
protected readonly showAll = signal(false);
|
||||
|
||||
public errorMessage = signal<String | null>(null);
|
||||
|
||||
@@ -32,13 +33,24 @@ export class Students {
|
||||
|
||||
// ************************ Event Handlers *************************
|
||||
|
||||
// *****************************************************************
|
||||
// Toggles between "My Students" and "All Students" scope, then
|
||||
// reloads the student list from the API.
|
||||
// *****************************************************************
|
||||
onToggleScope() {
|
||||
this.showAll.update(v => !v);
|
||||
this.loaded.set(false);
|
||||
this.loadStudents();
|
||||
}
|
||||
|
||||
// ********************** Support Procedures ***********************
|
||||
|
||||
// *****************************************************************
|
||||
// Loads the list of students assigned to the current user.
|
||||
// *****************************************************************
|
||||
private loadStudents() {
|
||||
this.studentService.getMyStudents().then(data => {
|
||||
const scope = this.showAll() ? 'all' : undefined;
|
||||
this.studentService.getMyStudents(scope).then(data => {
|
||||
|
||||
if (!data.success)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user