Commit 7b70909f authored by achinta's avatar achinta

feat: date-range in assignment

parent 44642347
<mat-form-field>
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [formGroup]="range" [rangePicker]="picker" >
<input formControlName="start" matStartDate placeholder="Start date" (dateChange)="onDateChange()">
<input formControlName="end" matEndDate placeholder="End date" (dateChange)="onDateChange()">
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DateRangeComponent } from './date-range.component';
describe('DateRangeComponent', () => {
let component: DateRangeComponent;
let fixture: ComponentFixture<DateRangeComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DateRangeComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DateRangeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, signal } from '@angular/core';
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { provideNativeDateAdapter } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
@Component({
selector: 'app-date-range',
imports: [
CommonModule,
MatInputModule,
MatDatepickerModule,
ReactiveFormsModule,
MatFormFieldModule,
FormsModule
],
standalone:true,
templateUrl: './date-range.component.html',
styleUrl: './date-range.component.scss',
providers: [provideNativeDateAdapter()],
})
export class DateRangeComponent {
public startDate = signal<string[]>([]);
public range = new FormGroup({
start: new FormControl<Date | null>(null),
end: new FormControl<Date | null>(null),
});
public onDateChange():void {
// this.startDate.update(startDate => [...startDate ,this.range.value.start])
}
}
...@@ -28,25 +28,5 @@ export class TransmissionMapperService { ...@@ -28,25 +28,5 @@ export class TransmissionMapperService {
public static readonly DELETE_RECORD_TRANSMISSION_URL: string = public static readonly DELETE_RECORD_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/deleteWebsiteDataSourceFieldsBasedOnDataSourceType?'; TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/deleteWebsiteDataSourceFieldsBasedOnDataSourceType?';
// aggregationOnUniqueFld=false&datasourceId=3188&dontIncludeForeignKey=false&expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&user_id=206&roleBasedFiltering=true
// public static readonly SCHEDULE_OF_RATES_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL +
// '/schedule-of-rates/get-all';
// public static readonly SCHEDULE_OF_RATES_ADD_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL + '/schedule-of-rates/add';
// public static readonly SCHEDULE_OF_RATES_UPDATE_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL +
// '/schedule-of-rates/update';
// public static readonly SCHEDULE_OF_RATE_TYPE_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL +
// '/schedule-of-rate-type/get-all';
// public static readonly AUDIT_LOG_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL + '/entry-log/get';
// public static readonly AUDIT_LOG_COUNT_TRANSMISSION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL + '/entry-log/count';
// public static readonly CHARTS_OF_ACCOUNT_TRANSMISION_URL: string =
// TransmissionMapperService.DEV_TRANSMISSION_URL +
// '/chart-of-account/get-all?head_type=income&get_only_head=false&get_nested_preview=true&page=1&page_size=100';
} }
<h3> Assignments </h3> <h3> Assignments </h3>
<div class="date_range_picker">
<mat-form-field>
<mat-label>Enter a date range</mat-label>
<mat-date-range-input [formGroup]="range" [rangePicker]="picker" >
<input formControlName="start" matStartDate placeholder="Start date" (dateChange)="onDateChange()">
<input formControlName="end" matEndDate placeholder="End date" (dateChange)="onDateChange()">
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>
</mat-form-field>
</div>
<div class="custom_table"> <div class="custom_table">
<app-custom-table <app-custom-table [columns]="columns" [data]="data" (emitDelete)="emitDeleteFromTable($event)"
[columns]="columns" (emitView)="emitViewFromTable($event)" />
[data]="data"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div> </div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Parent'"> <div class="add_btn" *ngIf="authService.getUserRole() !== 'Parent'">
<app-square-button <app-square-button [buttonIcon]="'add'" (emitSquareButtonClick)="addAssignment()" />
[buttonIcon]="'add'"
(emitSquareButtonClick)="addAssignment()"
/>
</div> </div>
<!-- <app-mat-confirm-dialog /> --> <!-- <app-mat-confirm-dialog /> -->
\ No newline at end of file
...@@ -4,4 +4,9 @@ ...@@ -4,4 +4,9 @@
right: 0; right: 0;
padding: 0px 15px; padding: 0px 15px;
margin: auto; margin: auto;
} }
\ No newline at end of file
.date_range_picker{
margin-bottom: 20px;
}
...@@ -9,7 +9,7 @@ import { UrlConfigService } from '../../service/url-config.service'; ...@@ -9,7 +9,7 @@ import { UrlConfigService } from '../../service/url-config.service';
import { PrepareAssignmentTableDataService } from '../service/prepare-assignment-table-data.service'; import { PrepareAssignmentTableDataService } from '../service/prepare-assignment-table-data.service';
import { DataSourceService } from '../../service/data-source.service'; import { DataSourceService } from '../../service/data-source.service';
import { AuthService } from '../../../auth/service/auth.service'; import { AuthService } from '../../../auth/service/auth.service';
import { CommonModule } from '@angular/common'; import { CommonModule, DatePipe } from '@angular/common';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response'; import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service'; import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
import { DeleteRecordTransmissionService } from '../../../raintree/transmission/delete-record-transmission.service'; import { DeleteRecordTransmissionService } from '../../../raintree/transmission/delete-record-transmission.service';
...@@ -17,17 +17,25 @@ import { ToasterService } from '../../../component-library/toaster/toaster.servi ...@@ -17,17 +17,25 @@ import { ToasterService } from '../../../component-library/toaster/toaster.servi
import { CustomTableColumn } from '../../../component-library/interface/custom-table-column'; import { CustomTableColumn } from '../../../component-library/interface/custom-table-column';
import { AssignmentTable } from '../interface/assignment-table'; import { AssignmentTable } from '../interface/assignment-table';
import { MatConfirmDialogComponent } from "../../../component-library/mat-confirm-dialog/mat-confirm-dialog.component"; import { MatConfirmDialogComponent } from "../../../component-library/mat-confirm-dialog/mat-confirm-dialog.component";
import { RoleMapperService } from '../../../mappers/role-mapper.service'; import { MatFormFieldModule } from '@angular/material/form-field';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { provideNativeDateAdapter } from '@angular/material/core';
@Component({ @Component({
selector: 'app-assignment', selector: 'app-assignment',
imports: [ imports: [
CustomTableComponent, CustomTableComponent,
CommonModule, CommonModule,
SquareButtonComponent SquareButtonComponent,
], MatFormFieldModule,
MatDatepickerModule,
ReactiveFormsModule
],
standalone:true,
templateUrl: './assignment.component.html', templateUrl: './assignment.component.html',
styleUrl: './assignment.component.scss' styleUrl: './assignment.component.scss',
providers: [provideNativeDateAdapter(),provideNativeDateAdapter(),DatePipe],
}) })
export class AssignmentComponent implements OnInit { export class AssignmentComponent implements OnInit {
...@@ -38,17 +46,23 @@ export class AssignmentComponent implements OnInit { ...@@ -38,17 +46,23 @@ export class AssignmentComponent implements OnInit {
private _prepareAssignmentTableData: PrepareAssignmentTableDataService, private _prepareAssignmentTableData: PrepareAssignmentTableDataService,
public matConfig: MatDialogConfigService, public matConfig: MatDialogConfigService,
public authService: AuthService, public authService: AuthService,
private _deleteTransmission:DeleteRecordTransmissionService, private _deleteTransmission: DeleteRecordTransmissionService,
private _toaster:ToasterService private _toaster: ToasterService,
private _datePipe:DatePipe,
) { } ) { }
public range = new FormGroup({
start: new FormControl<Date | null>(null),
end: new FormControl<Date | null>(null),
});
public columns: CustomTableColumn[] = []; public columns: CustomTableColumn[] = [];
public data: AssignmentTable[] = []; public data: AssignmentTable[] = [];
public ngOnInit(): void { public ngOnInit(): void {
this.columns = this._prepareAssignmentTableData.prepareMatTableColumn(); this.columns = this._prepareAssignmentTableData.prepareMatTableColumn();
this._getAssignments(); this._getAssignments();
} }
...@@ -59,6 +73,19 @@ export class AssignmentComponent implements OnInit { ...@@ -59,6 +73,19 @@ export class AssignmentComponent implements OnInit {
} }
private _getAssignments(): void { private _getAssignments(): void {
// fieldName: assigned_on,assigned_on
// operators: gt,lt
// fieldValues: hhfj,nfw
let dateRangeFieldname = '';
let dateRangeFieldOperator = '';
let dateRangeFieldValue = '';
if(this.range.value.start && this.range.value.end){
dateRangeFieldname = 'assigned_on,assigned_on';
dateRangeFieldOperator = 'ge,le';
dateRangeFieldValue = `${this._datePipe.transform(this.range.value.start,'yyyy-MM-dd')},${this._datePipe.transform(this.range.value.end,'yyyy-MM-dd')}`
}
this._assignmentTransmission.getAssignment( this._assignmentTransmission.getAssignment(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({ TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
...@@ -71,9 +98,9 @@ export class AssignmentComponent implements OnInit { ...@@ -71,9 +98,9 @@ export class AssignmentComponent implements OnInit {
limit: 100, limit: 100,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
fieldName: this._urlConfig.getFiledNameFilter('assignment'), fieldName: `${this._urlConfig.getFiledNameFilter('assignment')},${dateRangeFieldname}`,
operators: this._urlConfig.getFieldOperatorFilter('assignment'), operators: `${this._urlConfig.getFieldOperatorFilter('assignment')},${dateRangeFieldOperator}`,
fieldValues: this._urlConfig.getFieldValuesFilter('assignment'), fieldValues: `${this._urlConfig.getFieldValuesFilter('assignment')},${dateRangeFieldValue}`,
// this.authService.localStorageGetItemByKey("user_id"), // this.authService.localStorageGetItemByKey("user_id"),
}), }),
() => { }, () => { },
...@@ -129,4 +156,10 @@ export class AssignmentComponent implements OnInit { ...@@ -129,4 +156,10 @@ export class AssignmentComponent implements OnInit {
}); });
} }
public onDateChange(): void {
if(this.range.value.start && this.range.value.end)
this._getAssignments();
}
} }
...@@ -60,11 +60,10 @@ export class ManageComponent { ...@@ -60,11 +60,10 @@ export class ManageComponent {
public sectionDropDownData: Dropdown[] = []; public sectionDropDownData: Dropdown[] = [];
public assignmentForm = new FormGroup({ public assignmentForm = new FormGroup({
// class: new FormControl("", [Validators.required]),
section: new FormControl("", [Validators.required]), section: new FormControl("", [Validators.required]),
subject: new FormControl("", [Validators.required]), subject: new FormControl("", [Validators.required]),
lastDate: new FormControl("", [Validators.required]), lastDate: new FormControl("", [Validators.required]),
document: new FormControl(""), document: new FormControl("", [Validators.required])
}); });
ngOnInit(): void { ngOnInit(): void {
// this._getClasses(); // this._getClasses();
...@@ -88,7 +87,8 @@ export class ManageComponent { ...@@ -88,7 +87,8 @@ export class ManageComponent {
() => { }, () => { },
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this.assignmentForm.value.document = `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}` this.assignmentForm.get('document')?.setValue(`${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}`)
this._toaster.success(response.message, 'Ok') this._toaster.success(response.message, 'Ok')
}, },
(error) => { (error) => {
...@@ -269,9 +269,9 @@ export class ManageComponent { ...@@ -269,9 +269,9 @@ export class ManageComponent {
hindi: `${this._auth.localStorageGetItemByKey('user_id')}`, hindi: `${this._auth.localStorageGetItemByKey('user_id')}`,
}, },
session: { session: {
en: '86af4d6b5675a82df4581f00c67f0c7f', en: `${DataSourceService.SESSION_ID}`,
beng:'86af4d6b5675a82df4581f00c67f0c7f', beng:`${DataSourceService.SESSION_ID}`,
hindi: '86af4d6b5675a82df4581f00c67f0c7f', hindi: `${DataSourceService.SESSION_ID}`,
}, },
school: { school: {
en: `${localStorage.getItem('school_id')}`, en: `${localStorage.getItem('school_id')}`,
......
...@@ -53,7 +53,7 @@ export class Menu { ...@@ -53,7 +53,7 @@ export class Menu {
id: 4, id: 4,
title: 'Routine', title: 'Routine',
icon: 'routine', icon: 'routine',
route: RequestMapperService.ROUTINE_URL, route: RequestMapperService.ROUTINE_URL + '/class',
selected: false, selected: false,
roles: [ roles: [
RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE
...@@ -65,7 +65,8 @@ export class Menu { ...@@ -65,7 +65,8 @@ export class Menu {
id: 5, id: 5,
title: 'Exam', title: 'Exam',
icon: 'book_3', icon: 'book_3',
route: RequestMapperService.EXAM_URL, // route: RequestMapperService.EXAM_URL,
route: RequestMapperService.ROUTINE_URL + '/exam',
selected: false, selected: false,
roles: [ roles: [
RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE
......
...@@ -38,9 +38,10 @@ export class PortalDashboardComponent implements OnInit { ...@@ -38,9 +38,10 @@ export class PortalDashboardComponent implements OnInit {
public assignmentUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ASSIGNMENT_URL}`; public assignmentUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ASSIGNMENT_URL}`;
public routineUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ROUTINE_URL}`; public routineUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ROUTINE_URL}/class`;
public examUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.EXAM_URL}`; public examUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ROUTINE_URL}/exam`;
// public examUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.EXAM_URL}/exam`;
public selectedStudent: string = ''; public selectedStudent: string = '';
......
...@@ -5,6 +5,6 @@ export interface RoutineTable { ...@@ -5,6 +5,6 @@ export interface RoutineTable {
class_details?: string; class_details?: string;
section_details?: string; section_details?: string;
routine_type: string; routine_type: string;
schedule: string; document:string
action: string[] action: string[]
} }
\ No newline at end of file
...@@ -12,7 +12,6 @@ export interface Routine { ...@@ -12,7 +12,6 @@ export interface Routine {
id: string; id: string;
class: LocalizedField; class: LocalizedField;
section: LocalizedField; section: LocalizedField;
schedule: LocalizedField;
details: LocalizedField; details: LocalizedField;
session: LocalizedField; session: LocalizedField;
document: LocalizedField; document: LocalizedField;
...@@ -20,5 +19,7 @@ export interface Routine { ...@@ -20,5 +19,7 @@ export interface Routine {
session_session_name?: LocalizedField; session_session_name?: LocalizedField;
class_details?: LocalizedField; class_details?: LocalizedField;
section_details?: LocalizedField; section_details?: LocalizedField;
school: LocalizedField;
school_school_Name?: LocalizedField;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="container"> <div class="container">
<form class="routine_form" [formGroup]="routineForm"> <form class="routine_form" [formGroup]="routineForm">
<div class="mat_input_container"> <div class="mat_input_container">
<div class="class_dropdown mat_input"> <!-- <div class="class_dropdown mat_input">
<mat-form-field class="full_width"> <mat-form-field class="full_width">
<mat-label>Select Class</mat-label> <mat-label>Select Class</mat-label>
<mat-select formControlName="class"> <mat-select formControlName="class">
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
</mat-form-field> </mat-form-field>
</div> </div> -->
<div class="section_dropdown mat_input"> <div class="section_dropdown mat_input">
<mat-form-field class="full_width"> <mat-form-field class="full_width">
<mat-label>Select Section</mat-label> <mat-label>Select Section</mat-label>
<mat-select formControlName="section"> <mat-select formControlName="section" (selectionChange)="onSectionChange()" >
@for (section of sectionDropDownData; track section) { @for (section of sectionDropDownData; track section) {
<mat-option [value]="section.value">{{section.name}}</mat-option> <mat-option [value]="section.value">{{section.name}}</mat-option>
} }
...@@ -31,11 +31,15 @@ ...@@ -31,11 +31,15 @@
<div class="routine_type_dropdown mat_input"> <div class="routine_type_dropdown mat_input">
<mat-form-field class="full_width"> <mat-form-field class="full_width">
<mat-label>Select Type</mat-label> <mat-label>Details</mat-label>
<mat-select formControlName="routineType"> <input
<mat-option value="class_routine">Class Routine</mat-option> type="text"
<mat-option value="exam_routine">Exam Routine</mat-option> matInput
</mat-select> placeholder="Routine details"
#input
formControlName="details"
>
<mat-error>This field is required</mat-error> <mat-error>This field is required</mat-error>
</mat-form-field> </mat-form-field>
......
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { Component, Inject } from "@angular/core"; import { Component, inject, Inject } from "@angular/core";
import { MAT_DIALOG_DATA } from "@angular/material/dialog"; import { MAT_DIALOG_DATA } from "@angular/material/dialog";
import { ClassTransmissionService } from "../../../raintree/transmission/class-transmission.service"; import { ClassTransmissionService } from "../../../raintree/transmission/class-transmission.service";
import { TransmissionMapperService } from "../../../mappers/transmission-mapper.service"; import { TransmissionMapperService } from "../../../mappers/transmission-mapper.service";
...@@ -19,13 +19,11 @@ import { MatFormFieldModule } from "@angular/material/form-field"; ...@@ -19,13 +19,11 @@ import { MatFormFieldModule } from "@angular/material/form-field";
import { MatInputModule } from "@angular/material/input"; import { MatInputModule } from "@angular/material/input";
import { MatIconModule } from "@angular/material/icon"; import { MatIconModule } from "@angular/material/icon";
import { SquareButtonComponent } from "../../../component-library/square-button/square-button.component"; import { SquareButtonComponent } from "../../../component-library/square-button/square-button.component";
import { SectionResponse } from "../../../raintree/interface/section-respons";
import { StudentSection } from "../../data-source/interface/section"; import { StudentSection } from "../../data-source/interface/section";
import { RoutineTransmissionService } from "../../../raintree/transmission/routine-transmission.service"; import { RoutineTransmissionService } from "../../../raintree/transmission/routine-transmission.service";
import { AuthService } from "../../../auth/service/auth.service"; import { AuthService } from "../../../auth/service/auth.service";
import { RaintreeResponse } from "../../../raintree/interface/raintree-response"; import { RaintreeResponse } from "../../../raintree/interface/raintree-response";
import { Routine, Routines } from "../interface/routine"; import { Routines } from "../interface/routine";
import { ForeignKeyMap } from "../../data-source/interface/foreignKeyMap";
import { MatSelectModule } from "@angular/material/select"; import { MatSelectModule } from "@angular/material/select";
import { FileInputComponent } from "../../../component-library/file-input/file-input.component"; import { FileInputComponent } from "../../../component-library/file-input/file-input.component";
import { FileUploadTransmissionService } from "../../../raintree/transmission/file-upload-transmission.service"; import { FileUploadTransmissionService } from "../../../raintree/transmission/file-upload-transmission.service";
...@@ -42,34 +40,38 @@ import { ToasterService } from "../../../component-library/toaster/toaster.servi ...@@ -42,34 +40,38 @@ import { ToasterService } from "../../../component-library/toaster/toaster.servi
SquareButtonComponent, SquareButtonComponent,
MatSelectModule, MatSelectModule,
FileInputComponent FileInputComponent
], ],
templateUrl: "./manage.component.html", templateUrl: "./manage.component.html",
styleUrl: "./manage.component.scss", styleUrl: "./manage.component.scss",
}) })
export class ManageComponent { export class ManageComponent {
constructor( constructor(
// @Inject(MAT_DIALOG_DATA) public data: any, @Inject(MAT_DIALOG_DATA) public data: string,
private _classTransmission: ClassTransmissionService, private _classTransmission: ClassTransmissionService,
private _urlConfig: UrlConfigService, private _urlConfig: UrlConfigService,
private _routineTransmission: RoutineTransmissionService, private _routineTransmission: RoutineTransmissionService,
private _auth: AuthService, private _auth: AuthService,
private _fileUpload: FileUploadTransmissionService, private _fileUpload: FileUploadTransmissionService,
private _toaster:ToasterService private _toaster: ToasterService
) {} ) { }
public classDropDownData: Dropdown[] = []; public classDropDownData: Dropdown[] = [];
public sectionDropDownData: Dropdown[] = []; public sectionDropDownData: Dropdown[] = [];
public sectionData:StudentSection[] = [];
public routineForm = new FormGroup({ public routineForm = new FormGroup({
class: new FormControl("", [Validators.required]), class: new FormControl(""),
section: new FormControl("", [Validators.required]), section: new FormControl("", [Validators.required]),
routineType: new FormControl("", [Validators.required]), details: new FormControl("", [Validators.required]),
schedule: new FormControl(""), schedule: new FormControl("", [Validators.required]),
}); });
public routineType:string = '';
ngOnInit(): void { ngOnInit(): void {
this._getClasses(); // this._getClasses();
this._getSection(); this._getSection();
// console.log(this.data);
} }
public onFilesChanged(files: File[]): void { public onFilesChanged(files: File[]): void {
...@@ -77,19 +79,22 @@ export class ManageComponent { ...@@ -77,19 +79,22 @@ export class ManageComponent {
const formData = new FormData(); const formData = new FormData();
files.forEach(file => formData.append('file', file, file.name)); files.forEach(file => formData.append('file', file, file.name));
this._fileUpload.uploadFile( this._fileUpload.uploadFile(
TransmissionMapperService.FILE_UPLOAD_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`, TransmissionMapperService.FILE_UPLOAD_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
formData, formData,
() => { }, () => { },
() => { }, () => { },
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this.routineForm.value.schedule = `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}` this.routineForm.get('schedule')?.setValue(
this._toaster.success(response.message,'Ok') `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}`
);
this._toaster.success(response.message, 'Ok');
}, },
(error) => { (error) => {
console.log(error); console.log(error);
...@@ -100,9 +105,16 @@ export class ManageComponent { ...@@ -100,9 +105,16 @@ export class ManageComponent {
} }
public submitRoutine(): void { public onSectionChange():void {
let selectedSectionId = this.routineForm.value.section
let selectedClass = this.sectionData.find(sectionInfo => sectionInfo.id === selectedSectionId );
this.routineForm.get('class')?.setValue(`${selectedClass?.class.en}`)
}
if(this.routineForm.invalid) return; public submitRoutine(): void {
if (this.routineForm.invalid) return;
this._routineTransmission.submitRoutine( this._routineTransmission.submitRoutine(
...@@ -113,7 +125,7 @@ export class ManageComponent { ...@@ -113,7 +125,7 @@ export class ManageComponent {
() => { }, () => { },
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this._toaster.success("Routine added successfully",'Done'); this._toaster.success("Routine added successfully", 'Done');
window.location.reload(); window.location.reload();
}, },
...@@ -125,62 +137,67 @@ export class ManageComponent { ...@@ -125,62 +137,67 @@ export class ManageComponent {
); );
} }
private _getClasses() { // private _getClasses() {
this._classTransmission.getClasses( // this._classTransmission.getClasses(
TransmissionMapperService.GET_TRANSMISSION_URL + // TransmissionMapperService.GET_TRANSMISSION_URL +
this._urlConfig.generateDatasourceConfigUrl({ // this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false, // aggregationOnUniqueFld: false,
datasourceId: DataSourceService.CLASS_DATA_SOURCE_ID, // datasourceId: DataSourceService.CLASS_DATA_SOURCE_ID,
dontIncludeForeignKey: false, // dontIncludeForeignKey: false,
expand: false, // expand: false,
isUniqueValueRequiredForFieldToDisplay: false, // isUniqueValueRequiredForFieldToDisplay: false,
language: "en", // language: "en",
limit: 100, // limit: 100,
orderBy: "ASC", // orderBy: "ASC",
page: 1, // page: 1,
roleBasedFiltering: true, // fieldName: "teacher",
}), // operators: "eq",
() => {}, // fieldValues: this._auth.localStorageGetItemByKey("user_id")
(response) => {}, // }),
(response: RaintreeResponse) => { // () => { },
this.classDropDownData = response['data']["themeDataSourceFields"].map( // (response) => { },
(sClass: StudentClass) => { // (response: RaintreeResponse) => {
return { // this.classDropDownData = response['data']["themeDataSourceFields"].map(
["name"]: sClass.details["en"], // (sClass: StudentClass) => {
["value"]: sClass.id, // return {
}; // ["name"]: sClass.details["en"],
} // ["value"]: sClass.id,
); // };
}, // }
(error) => { // );
console.log(error); // },
}, // (error) => {
() => {} // console.log(error);
); // },
} // () => { }
// );
// }
private _getSection() { private _getSection() {
this._classTransmission.getSection( this._classTransmission.getSection(
TransmissionMapperService.GET_TRANSMISSION_URL + TransmissionMapperService.GET_TRANSMISSION_URL +
this._urlConfig.generateDatasourceConfigUrl({ this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false, aggregationOnUniqueFld: false,
datasourceId: DataSourceService.SECTION_DATA_SOURCE_ID, datasourceId: DataSourceService.SECTION_DATA_SOURCE_ID,
dontIncludeForeignKey: false, dontIncludeForeignKey: false,
expand: false, expand: false,
isUniqueValueRequiredForFieldToDisplay: false, isUniqueValueRequiredForFieldToDisplay: false,
language: "en", language: "en",
limit: 100, limit: 100,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
roleBasedFiltering: true, fieldName: "teacher",
}), operators: "eq",
() => {}, fieldValues: this._auth.localStorageGetItemByKey("user_id")
(response) => {}, }),
() => { },
(response) => { },
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this.sectionData = response['data']['themeDataSourceFields'];
this.sectionDropDownData = response['data']["themeDataSourceFields"].map( this.sectionDropDownData = response['data']["themeDataSourceFields"].map(
(sSection: StudentSection) => { (sSection: StudentSection) => {
return { return {
["name"]: sSection.section["en"], ["name"]: sSection.details['en'],
["value"]: sSection.id, ["value"]: sSection.id,
}; };
} }
...@@ -189,12 +206,12 @@ export class ManageComponent { ...@@ -189,12 +206,12 @@ export class ManageComponent {
(error) => { (error) => {
console.log(error); console.log(error);
}, },
() => {} () => { }
); );
} }
private _prepareRoutinePayload(): Routines{ private _prepareRoutinePayload(): Routines {
return { return {
themeDataSourceFields: [ themeDataSourceFields: [
{ {
...@@ -209,30 +226,31 @@ export class ManageComponent { ...@@ -209,30 +226,31 @@ export class ManageComponent {
beng: `${this.routineForm.value.section}`, beng: `${this.routineForm.value.section}`,
hindi: `${this.routineForm.value.section}`, hindi: `${this.routineForm.value.section}`,
}, },
schedule: {
en: `${this.routineForm.value.schedule}`,
beng: `${this.routineForm.value.schedule}`,
hindi: `${this.routineForm.value.schedule}`,
},
details: { details: {
en: "", en: `${this.routineForm.value.details}`,
beng: "", beng: `${this.routineForm.value.details}`,
hindi: "", hindi: `${this.routineForm.value.details}`,
}, },
session: { session: {
en: `${this.routineForm.value.section}`, en: `${DataSourceService.SESSION_ID}`,
beng: `${this.routineForm.value.section}`, beng: `${DataSourceService.SESSION_ID}`,
hindi: `${this.routineForm.value.section}`, hindi: `${DataSourceService.SESSION_ID}`,
}, },
document: { document: {
en: "", en: `${this.routineForm.value.schedule}`,
beng: "", beng: `${this.routineForm.value.schedule}`,
hindi: "", hindi: `${this.routineForm.value.schedule}`,
}, },
routine_type: { routine_type: {
en: `${this.routineForm.value.routineType}`, en: `${this.data === 'class' ? 'class_routine':'exam_routine'}`,
beng:`${this.routineForm.value.routineType}`, beng: `${this.data === 'class' ? 'class_routine':'exam_routine'}`,
hindi: `${this.routineForm.value.routineType}`, hindi: `${this.data === 'class' ? 'class_routine':'exam_routine'}`,
},
school: {
en: `${localStorage.getItem('school_id')}`,
beng: `${localStorage.getItem('school_id')}`,
hindi: `${localStorage.getItem('school_id')}`,
}, },
}, },
], ],
...@@ -255,36 +273,35 @@ export class ManageComponent { ...@@ -255,36 +273,35 @@ export class ManageComponent {
beng: `${this.routineForm.value.section}`, beng: `${this.routineForm.value.section}`,
hindi: `${this.routineForm.value.section}`, hindi: `${this.routineForm.value.section}`,
}, },
schedule: {
en: `${this.routineForm.value.schedule}`,
beng: `${this.routineForm.value.schedule}`,
hindi: `${this.routineForm.value.schedule}`,
},
details: { details: {
en: "", en: `${this.routineForm.value.details}`,
beng: "", beng: `${this.routineForm.value.details}`,
hindi: "", hindi: `${this.routineForm.value.details}`,
}, },
session: { session: {
en: "", en: `${DataSourceService.SESSION_ID}`,
beng: "", beng: `${DataSourceService.SESSION_ID}`,
hindi: "", hindi: `${DataSourceService.SESSION_ID}`,
}, },
document: { document: {
en: "", en: `${this.routineForm.value.schedule}`,
beng: "", beng: `${this.routineForm.value.schedule}`,
hindi: "", hindi: `${this.routineForm.value.schedule}`,
}, },
routine_type: { routine_type: {
en: `${this.routineForm.value.routineType}`, en: `${this.data === 'class' ? 'class_routine':'exam_routine'}`,
beng: `${this.routineForm.value.routineType}`, beng: `${this.data === 'class' ? 'class_routine':'exam_routine'}`,
hindi: `${this.routineForm.value.routineType}`, hindi: `${this.data === 'class' ? 'class_routine':'exam_routine'}`,
},
school: {
en: `${localStorage.getItem('school_id')}`,
beng: `${localStorage.getItem('school_id')}`,
hindi: `${localStorage.getItem('school_id')}`,
}, },
}, },
], ],
count: 0,
favourite: true
}; };
} }
} }
...@@ -6,7 +6,7 @@ import { Menu } from "../navigation/model/sidebar/menu"; ...@@ -6,7 +6,7 @@ import { Menu } from "../navigation/model/sidebar/menu";
export const ROUTINE_ROUTES: Routes = [ export const ROUTINE_ROUTES: Routes = [
{ {
path: RequestMapperService.ROUTINE_URL, path: `${RequestMapperService.ROUTINE_URL}/:type`,
loadComponent: () => loadComponent: () =>
import( import(
'./routine/routine.component' './routine/routine.component'
......
import { Component } from '@angular/core'; import { Component, inject } from '@angular/core';
import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service'; import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service';
import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service'; import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service';
import { DataSourceService } from '../../service/data-source.service'; import { DataSourceService } from '../../service/data-source.service';
...@@ -16,6 +16,7 @@ import { DeleteRecordTransmissionService } from '../../../raintree/transmission/ ...@@ -16,6 +16,7 @@ import { DeleteRecordTransmissionService } from '../../../raintree/transmission/
import { ToasterService } from '../../../component-library/toaster/toaster.service'; import { ToasterService } from '../../../component-library/toaster/toaster.service';
import { RoutineTable } from '../interface/routine-table'; import { RoutineTable } from '../interface/routine-table';
import { CustomTableColumn } from '../../../component-library/interface/custom-table-column'; import { CustomTableColumn } from '../../../component-library/interface/custom-table-column';
import { ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'app-routine', selector: 'app-routine',
...@@ -28,7 +29,7 @@ import { CustomTableColumn } from '../../../component-library/interface/custom-t ...@@ -28,7 +29,7 @@ import { CustomTableColumn } from '../../../component-library/interface/custom-t
templateUrl: './routine.component.html', templateUrl: './routine.component.html',
styleUrl: './routine.component.scss' styleUrl: './routine.component.scss'
}) })
export class RoutineComponent { export class RoutineComponent {
constructor( constructor(
private _routineTransmission: RoutineTransmissionService, private _routineTransmission: RoutineTransmissionService,
...@@ -38,29 +39,53 @@ export class RoutineComponent { ...@@ -38,29 +39,53 @@ export class RoutineComponent {
private _matDialogConfig: MatDialogConfigService, private _matDialogConfig: MatDialogConfigService,
private _deleteTransmission: DeleteRecordTransmissionService, private _deleteTransmission: DeleteRecordTransmissionService,
private _toaster:ToasterService, private _toaster:ToasterService,
public authService: AuthService public authService: AuthService,
) { } ) { }
public columns: CustomTableColumn[] = []; public columns: CustomTableColumn[] = [];
public data: RoutineTable[] = []; public data: RoutineTable[] = [];
ngOnInit(): void { public routineType:string = '';
public route = inject(ActivatedRoute);
public ngOnInit(): void {
this.columns = this._prepareRoutineTableData.prepareMatTableColumn(); this.columns = this._prepareRoutineTableData.prepareMatTableColumn();
this._getRoutines(); this.routineType = this.route.snapshot.paramMap.get('type') as string;
this._getRoutines(this.routineType);
this.onRoutesChange()
}
public onRoutesChange(){
this.route.paramMap.subscribe(params => {
const newRoutineType = params.get('type');
if (newRoutineType !== this.routineType) {
this.routineType = newRoutineType as string;
this._getRoutines(this.routineType);
}
});
} }
public addRoutine(): void { public addRoutine(): void {
this._dialog.open(ManageComponent, { this._dialog.open(ManageComponent, {
data: '', data: this.routineType,
...this._matDialogConfig.matModalConfig() ...this._matDialogConfig.matModalConfig()
}); });
} }
public emitViewFromTable(emitData: RoutineTable) { public emitViewFromTable(emitData: RoutineTable) {
let docLink = emitData.schedule.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL); let docLink = emitData.document.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL);
window.open(docLink, '_blank'); window.open(docLink, '_blank');
} }
...@@ -77,8 +102,8 @@ export class RoutineComponent { ...@@ -77,8 +102,8 @@ export class RoutineComponent {
(response) => { }, (response) => { },
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this._toaster.success("Routine is deleted successfully", 'ok'); this._toaster.success("Routine is deleted successfully", 'Ok');
this._getRoutines(); this._getRoutines(this.routineType);
}, },
(error) => { (error) => {
console.log(error); console.log(error);
...@@ -88,20 +113,21 @@ export class RoutineComponent { ...@@ -88,20 +113,21 @@ export class RoutineComponent {
} }
private _getRoutines(routineType:string): void {
private _getRoutines(): void {
this._routineTransmission.getRoutine( this._routineTransmission.getRoutine(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({ TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false, aggregationOnUniqueFld: false,
datasourceId: DataSourceService.ROUTINE_DATA_SOURCE_ID, datasourceId: DataSourceService.ROUTINE_DATA_SOURCE_ID,
dontIncludeForeignKey: false, dontIncludeForeignKey: false,
expand: false, expand: true,
isUniqueValueRequiredForFieldToDisplay: false, isUniqueValueRequiredForFieldToDisplay: false,
language: "en", language: "en",
limit: 10, limit: 10,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
roleBasedFiltering: true fieldName: `${this._urlConfig.getFiledNameFilter('routine')},routine_type`,
operators: `${this._urlConfig.getFieldOperatorFilter('routine')},eq`,
fieldValues: `${this._urlConfig.getFieldValuesFilter('routine')},${routineType === 'class' ? 'class_routine':'exam_routine'}`,
}), }),
() => { }, () => { },
(response) => { }, (response) => { },
......
...@@ -20,8 +20,9 @@ export class PrepareRoutineTableDataService { ...@@ -20,8 +20,9 @@ export class PrepareRoutineTableDataService {
session_session_name: routine.session_session_name?.en, session_session_name: routine.session_session_name?.en,
class_details: routine.class_details?.en, class_details: routine.class_details?.en,
section_details: routine.section_details?.en, section_details: routine.section_details?.en,
document: routine.document.en,
routine_type: routine.routine_type.en, routine_type: routine.routine_type.en,
schedule: routine.schedule.en, details: routine.details['en'],
action: ['view', 'delete'] action: ['view', 'delete']
} }
}) })
...@@ -35,7 +36,7 @@ export class PrepareRoutineTableDataService { ...@@ -35,7 +36,7 @@ export class PrepareRoutineTableDataService {
let columnArray = [ let columnArray = [
{ key: 'class_details', label: 'Class' }, { key: 'class_details', label: 'Class' },
{ key: 'section_details', label: 'Section' }, { key: 'section_details', label: 'Section' },
{ key: 'routine_type', label: 'Type' }, { key: 'details', label: 'Details' },
{ key: 'action', label: 'Action' }, { key: 'action', label: 'Action' },
]; ];
......
...@@ -33,4 +33,10 @@ export class DataSourceService { ...@@ -33,4 +33,10 @@ export class DataSourceService {
public static readonly SECTION_DATA_SOURCE_ID: number = 3013; public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
public static readonly CLASS_SECTION_SUBJECT_DATA_SOURCE_ID: number = 3016; public static readonly CLASS_SECTION_SUBJECT_DATA_SOURCE_ID: number = 3016;
public static readonly SESSION_ID: string = '86af4d6b5675a82df4581f00c67f0c7f';
} }
import { inject, Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { AuthService } from '../../auth/service/auth.service'; import { AuthService } from '../../auth/service/auth.service';
import { DataSourceService } from './data-source.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -16,37 +17,66 @@ export class UrlConfigService { ...@@ -16,37 +17,66 @@ export class UrlConfigService {
public getFiledNameFilter(type: string): string { public getFiledNameFilter(type: string): string {
let fieldName = ''; let fieldName = '';
// let fieldValues = '';
// let fieldOperator = '' switch (type) {
if (type === 'assignment') { case 'assignment':
if (this.authService.getUserRole() === 'Teacher') { if (this.authService.getUserRole() === 'Teacher') {
fieldName = "assigned_by_teacher"; fieldName = "assigned_by_teacher";
} else if (this.authService.getUserRole() === 'Parent') { } else if (this.authService.getUserRole() === 'Parent') {
fieldName = "school,section_class,section";
}
break;
case 'routine':
if (this.authService.getUserRole() === 'Teacher') {
fieldName = "school,section_class,section"; fieldName = "session,school,section_teacher";
} } else if (this.authService.getUserRole() === 'Parent') {
fieldName = "section,session,school";
}
break;
} }
return fieldName; return fieldName;
} }
public getFieldOperatorFilter(type: string): string { public getFieldOperatorFilter(type: string): string {
let fieldOperator = '' let fieldOperator = ''
if (type === 'assignment') {
if (this.authService.getUserRole() === 'Teacher') { switch (type) {
case 'assignment':
fieldOperator = 'eq';
if (this.authService.getUserRole() === 'Teacher') {
} else if (this.authService.getUserRole() === 'Parent') { fieldOperator = 'eq';
} else if (this.authService.getUserRole() === 'Parent') {
fieldOperator = 'eq,eq,eq';
}
break;
case 'routine':
if (this.authService.getUserRole() === 'Teacher') {
fieldOperator = 'eq,eq,eq'; fieldOperator = "eq,eq,eq";
} } else if (this.authService.getUserRole() === 'Parent') {
fieldOperator = "eq,eq,eq";
}
break;
} }
return fieldOperator; return fieldOperator;
...@@ -56,18 +86,31 @@ export class UrlConfigService { ...@@ -56,18 +86,31 @@ export class UrlConfigService {
let fieldValues = ''; let fieldValues = '';
if (type === 'assignment') { switch (type) {
case 'assignment':
if (this.authService.getUserRole() === 'Teacher') { if (this.authService.getUserRole() === 'Teacher') {
fieldValues = `${this.authService.localStorageGetItemByKey('user_id')}`;
} else if (this.authService.getUserRole() === 'Parent') {
fieldValues = `${localStorage.getItem('student_school_id')},${localStorage.getItem('student_class_id')},${localStorage.getItem('student_section_id')}`; fieldValues = `${this.authService.localStorageGetItemByKey('user_id')}`;
} else if (this.authService.getUserRole() === 'Parent') {
fieldValues = `${localStorage.getItem('student_school_id')},${localStorage.getItem('student_class_id')},${localStorage.getItem('student_section_id')}`;
}
break;
case 'routine':
if (this.authService.getUserRole() === 'Teacher') {
} fieldValues = `${DataSourceService.SESSION_ID},${localStorage.getItem('school_id')},${this.authService.localStorageGetItemByKey('user_id')}`;
} else if (this.authService.getUserRole() === 'Parent') {
fieldValues = `${localStorage.getItem('student_section_id')},${DataSourceService.SESSION_ID},${localStorage.getItem('student_school_id')}`;
}
break;
} }
return fieldValues; return fieldValues;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment