feat: Made additions to grades. Closes #4
This commit is contained in:
46
src/app/admin-view/grades/attendence/attendence.component.ts
Normal file
46
src/app/admin-view/grades/attendence/attendence.component.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AdminCommService } from '../../admin-comm.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-attendence',
|
||||
templateUrl: './attendence.component.html',
|
||||
styleUrl: './attendence.component.scss'
|
||||
})
|
||||
export class AttendenceComponent implements OnInit {
|
||||
|
||||
constructor (private fb: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: {room: string}, public dialogRef: MatDialogRef<AttendenceComponent>, private ac: AdminCommService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.room = this.data.room
|
||||
this.ac.clean.attendence.getUsers(this.room).subscribe(query => {
|
||||
query.users.forEach(v => {
|
||||
var att = query.attendence ? query.attendence.find(z => z.id == v._id) : false
|
||||
this.users.push(this.fb.group({
|
||||
id: v._id,
|
||||
label: `${v.fname} ${v.surname}`,
|
||||
att: this.fb.control(att),
|
||||
hour: this.fb.control(att ? att.hour : ""),
|
||||
}))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
save() {
|
||||
this.dialogRef.close({
|
||||
room: this.room,
|
||||
...this.form.value
|
||||
})
|
||||
}
|
||||
|
||||
room: string = "";
|
||||
|
||||
form: FormGroup = this.fb.group({
|
||||
users: this.fb.array([])
|
||||
})
|
||||
|
||||
get users() {
|
||||
return this.form.get('users') as FormArray
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user