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 {
public static readonly DELETE_RECORD_TRANSMISSION_URL: string =
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>
<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">
<app-custom-table
[columns]="columns"
[data]="data"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
<app-custom-table [columns]="columns" [data]="data" (emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)" />
</div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Parent'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addAssignment()"
/>
<app-square-button [buttonIcon]="'add'" (emitSquareButtonClick)="addAssignment()" />
</div>
<!-- <app-mat-confirm-dialog /> -->
<!-- <app-mat-confirm-dialog /> -->
\ No newline at end of file
......@@ -4,4 +4,9 @@
right: 0;
padding: 0px 15px;
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';
import { PrepareAssignmentTableDataService } from '../service/prepare-assignment-table-data.service';
import { DataSourceService } from '../../service/data-source.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 { MatDialogConfigService } from '../../service/mat-dialog-config.service';
import { DeleteRecordTransmissionService } from '../../../raintree/transmission/delete-record-transmission.service';
......@@ -17,17 +17,25 @@ import { ToasterService } from '../../../component-library/toaster/toaster.servi
import { CustomTableColumn } from '../../../component-library/interface/custom-table-column';
import { AssignmentTable } from '../interface/assignment-table';
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({
selector: 'app-assignment',
imports: [
CustomTableComponent,
CommonModule,
SquareButtonComponent
],
SquareButtonComponent,
MatFormFieldModule,
MatDatepickerModule,
ReactiveFormsModule
],
standalone:true,
templateUrl: './assignment.component.html',
styleUrl: './assignment.component.scss'
styleUrl: './assignment.component.scss',
providers: [provideNativeDateAdapter(),provideNativeDateAdapter(),DatePipe],
})
export class AssignmentComponent implements OnInit {
......@@ -38,17 +46,23 @@ export class AssignmentComponent implements OnInit {
private _prepareAssignmentTableData: PrepareAssignmentTableDataService,
public matConfig: MatDialogConfigService,
public authService: AuthService,
private _deleteTransmission:DeleteRecordTransmissionService,
private _toaster:ToasterService
private _deleteTransmission: DeleteRecordTransmissionService,
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 data: AssignmentTable[] = [];
public ngOnInit(): void {
this.columns = this._prepareAssignmentTableData.prepareMatTableColumn();
this._getAssignments();
}
......@@ -59,6 +73,19 @@ export class AssignmentComponent implements OnInit {
}
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(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
......@@ -71,9 +98,9 @@ export class AssignmentComponent implements OnInit {
limit: 100,
orderBy: "ASC",
page: 1,
fieldName: this._urlConfig.getFiledNameFilter('assignment'),
operators: this._urlConfig.getFieldOperatorFilter('assignment'),
fieldValues: this._urlConfig.getFieldValuesFilter('assignment'),
fieldName: `${this._urlConfig.getFiledNameFilter('assignment')},${dateRangeFieldname}`,
operators: `${this._urlConfig.getFieldOperatorFilter('assignment')},${dateRangeFieldOperator}`,
fieldValues: `${this._urlConfig.getFieldValuesFilter('assignment')},${dateRangeFieldValue}`,
// this.authService.localStorageGetItemByKey("user_id"),
}),
() => { },
......@@ -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 {
public sectionDropDownData: Dropdown[] = [];
public assignmentForm = new FormGroup({
// class: new FormControl("", [Validators.required]),
section: new FormControl("", [Validators.required]),
subject: new FormControl("", [Validators.required]),
lastDate: new FormControl("", [Validators.required]),
document: new FormControl(""),
document: new FormControl("", [Validators.required])
});
ngOnInit(): void {
// this._getClasses();
......@@ -88,7 +87,8 @@ export class ManageComponent {
() => { },
(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')
},
(error) => {
......@@ -269,9 +269,9 @@ export class ManageComponent {
hindi: `${this._auth.localStorageGetItemByKey('user_id')}`,
},
session: {
en: '86af4d6b5675a82df4581f00c67f0c7f',
beng:'86af4d6b5675a82df4581f00c67f0c7f',
hindi: '86af4d6b5675a82df4581f00c67f0c7f',
en: `${DataSourceService.SESSION_ID}`,
beng:`${DataSourceService.SESSION_ID}`,
hindi: `${DataSourceService.SESSION_ID}`,
},
school: {
en: `${localStorage.getItem('school_id')}`,
......
......@@ -53,7 +53,7 @@ export class Menu {
id: 4,
title: 'Routine',
icon: 'routine',
route: RequestMapperService.ROUTINE_URL,
route: RequestMapperService.ROUTINE_URL + '/class',
selected: false,
roles: [
RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE
......@@ -65,7 +65,8 @@ export class Menu {
id: 5,
title: 'Exam',
icon: 'book_3',
route: RequestMapperService.EXAM_URL,
// route: RequestMapperService.EXAM_URL,
route: RequestMapperService.ROUTINE_URL + '/exam',
selected: false,
roles: [
RoleMapperService.TEACHER_ROLE,RoleMapperService.STUDENT_ROLE
......
......@@ -38,9 +38,10 @@ export class PortalDashboardComponent implements OnInit {
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 = '';
......
......@@ -5,6 +5,6 @@ export interface RoutineTable {
class_details?: string;
section_details?: string;
routine_type: string;
schedule: string;
document:string
action: string[]
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ export interface Routine {
id: string;
class: LocalizedField;
section: LocalizedField;
schedule: LocalizedField;
details: LocalizedField;
session: LocalizedField;
document: LocalizedField;
......@@ -20,5 +19,7 @@ export interface Routine {
session_session_name?: LocalizedField;
class_details?: LocalizedField;
section_details?: LocalizedField;
school: LocalizedField;
school_school_Name?: LocalizedField;
}
......@@ -2,7 +2,7 @@
<div class="container">
<form class="routine_form" [formGroup]="routineForm">
<div class="mat_input_container">
<div class="class_dropdown mat_input">
<!-- <div class="class_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Class</mat-label>
<mat-select formControlName="class">
......@@ -14,12 +14,12 @@
</mat-form-field>
</div>
</div> -->
<div class="section_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Section</mat-label>
<mat-select formControlName="section">
<mat-select formControlName="section" (selectionChange)="onSectionChange()" >
@for (section of sectionDropDownData; track section) {
<mat-option [value]="section.value">{{section.name}}</mat-option>
}
......@@ -31,11 +31,15 @@
<div class="routine_type_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Type</mat-label>
<mat-select formControlName="routineType">
<mat-option value="class_routine">Class Routine</mat-option>
<mat-option value="exam_routine">Exam Routine</mat-option>
</mat-select>
<mat-label>Details</mat-label>
<input
type="text"
matInput
placeholder="Routine details"
#input
formControlName="details"
>
<mat-error>This field is required</mat-error>
</mat-form-field>
......
......@@ -6,7 +6,7 @@ import { Menu } from "../navigation/model/sidebar/menu";
export const ROUTINE_ROUTES: Routes = [
{
path: RequestMapperService.ROUTINE_URL,
path: `${RequestMapperService.ROUTINE_URL}/:type`,
loadComponent: () =>
import(
'./routine/routine.component'
......
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service';
import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service';
import { DataSourceService } from '../../service/data-source.service';
......@@ -16,6 +16,7 @@ import { DeleteRecordTransmissionService } from '../../../raintree/transmission/
import { ToasterService } from '../../../component-library/toaster/toaster.service';
import { RoutineTable } from '../interface/routine-table';
import { CustomTableColumn } from '../../../component-library/interface/custom-table-column';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-routine',
......@@ -28,7 +29,7 @@ import { CustomTableColumn } from '../../../component-library/interface/custom-t
templateUrl: './routine.component.html',
styleUrl: './routine.component.scss'
})
export class RoutineComponent {
export class RoutineComponent {
constructor(
private _routineTransmission: RoutineTransmissionService,
......@@ -38,29 +39,53 @@ export class RoutineComponent {
private _matDialogConfig: MatDialogConfigService,
private _deleteTransmission: DeleteRecordTransmissionService,
private _toaster:ToasterService,
public authService: AuthService
public authService: AuthService,
) { }
public columns: CustomTableColumn[] = [];
public data: RoutineTable[] = [];
ngOnInit(): void {
public routineType:string = '';
public route = inject(ActivatedRoute);
public ngOnInit(): void {
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 {
this._dialog.open(ManageComponent, {
data: '',
data: this.routineType,
...this._matDialogConfig.matModalConfig()
});
}
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');
}
......@@ -77,8 +102,8 @@ export class RoutineComponent {
(response) => { },
(response: RaintreeResponse) => {
this._toaster.success("Routine is deleted successfully", 'ok');
this._getRoutines();
this._toaster.success("Routine is deleted successfully", 'Ok');
this._getRoutines(this.routineType);
},
(error) => {
console.log(error);
......@@ -88,20 +113,21 @@ export class RoutineComponent {
}
private _getRoutines(): void {
private _getRoutines(routineType:string): void {
this._routineTransmission.getRoutine(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.ROUTINE_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
expand: true,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 10,
orderBy: "ASC",
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) => { },
......
......@@ -20,8 +20,9 @@ export class PrepareRoutineTableDataService {
session_session_name: routine.session_session_name?.en,
class_details: routine.class_details?.en,
section_details: routine.section_details?.en,
document: routine.document.en,
routine_type: routine.routine_type.en,
schedule: routine.schedule.en,
details: routine.details['en'],
action: ['view', 'delete']
}
})
......@@ -35,7 +36,7 @@ export class PrepareRoutineTableDataService {
let columnArray = [
{ key: 'class_details', label: 'Class' },
{ key: 'section_details', label: 'Section' },
{ key: 'routine_type', label: 'Type' },
{ key: 'details', label: 'Details' },
{ key: 'action', label: 'Action' },
];
......
......@@ -33,4 +33,10 @@ export class DataSourceService {
public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
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 { AuthService } from '../../auth/service/auth.service';
import { DataSourceService } from './data-source.service';
@Injectable({
providedIn: 'root'
......@@ -16,37 +17,66 @@ export class UrlConfigService {
public getFiledNameFilter(type: string): string {
let fieldName = '';
// let fieldValues = '';
// let fieldOperator = ''
if (type === 'assignment') {
switch (type) {
case 'assignment':
if (this.authService.getUserRole() === 'Teacher') {
if (this.authService.getUserRole() === 'Teacher') {
fieldName = "assigned_by_teacher";
} else if (this.authService.getUserRole() === 'Parent') {
fieldName = "assigned_by_teacher";
} 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;
}
public getFieldOperatorFilter(type: string): string {
let fieldOperator = ''
if (type === 'assignment') {
if (this.authService.getUserRole() === 'Teacher') {
fieldOperator = 'eq';
switch (type) {
case 'assignment':
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;
......@@ -56,18 +86,31 @@ export class UrlConfigService {
let fieldValues = '';
if (type === 'assignment') {
switch (type) {
case 'assignment':
if (this.authService.getUserRole() === 'Teacher') {
fieldValues = `${this.authService.localStorageGetItemByKey('user_id')}`;
} else if (this.authService.getUserRole() === 'Parent') {
if (this.authService.getUserRole() === 'Teacher') {
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;
......
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