Commit e9839860 authored by achinta's avatar achinta

wip: routine submit form

parent 43e90da7
...@@ -3,7 +3,7 @@ import { ForeignKeyMap } from "./foreignKeyMap"; ...@@ -3,7 +3,7 @@ import { ForeignKeyMap } from "./foreignKeyMap";
// Data Interface // Data Interface
export interface Data { export interface Data {
count: number; count: number;
id: number; id: number | string;
dataSourceName: string; dataSourceName: string;
websiteId: number; websiteId: number;
type: string; type: string;
...@@ -15,4 +15,5 @@ export interface Data { ...@@ -15,4 +15,5 @@ export interface Data {
dependentFields: any; dependentFields: any;
dsType: any; dsType: any;
[index:string]: any; [index:string]: any;
} }
\ No newline at end of file
// LocalizedField Interface (replaces repeated language-specific fields) // LocalizedField Interface (replaces repeated language-specific fields)
export interface LocalizedField { export interface LocalizedField {
default: string; default?: string;
beng: string; beng: string;
hindi: string; hindi: string;
en: string; en: string;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
justify-content: space-between; justify-content: space-between;
position: relative; // position: relative;
} }
.sidebar_navigation_container a { .sidebar_navigation_container a {
......
...@@ -4,6 +4,7 @@ import { LocalizedField } from "../../data-source/interface/localizedField"; ...@@ -4,6 +4,7 @@ import { LocalizedField } from "../../data-source/interface/localizedField";
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
export interface Routines extends Data { export interface Routines extends Data {
themeDataSourceFields: Routine[]; themeDataSourceFields: Routine[];
dataSourceTypeFieldsList?: Routine[]
} }
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
...@@ -16,8 +17,8 @@ export interface Routine { ...@@ -16,8 +17,8 @@ export interface Routine {
session: LocalizedField; session: LocalizedField;
document: LocalizedField; document: LocalizedField;
routine_type: LocalizedField; routine_type: LocalizedField;
session_session_name: LocalizedField; session_session_name?: LocalizedField;
class_details: LocalizedField; class_details?: LocalizedField;
section_details: LocalizedField; section_details?: LocalizedField;
} }
import { CommonModule } from '@angular/common'; import { CommonModule } from "@angular/common";
import { Component, Inject } from '@angular/core'; import { Component, 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";
import { DataSourceService } from '../../service/data-source.service'; import { DataSourceService } from "../../service/data-source.service";
import { classResponse } from '../../../raintree/interface/class-respons'; import { classResponse } from "../../../raintree/interface/class-respons";
import { UrlConfigService } from '../../service/url-config.service'; import { UrlConfigService } from "../../service/url-config.service";
import { DropDownComponent } from "../../../component-library/dropdown/drop-down/drop-down.component"; import { DropDownComponent } from "../../../component-library/dropdown/drop-down/drop-down.component";
import { Dropdown } from '../../../component-library/dropdown/interface/dropdown'; import { Dropdown } from "../../../component-library/dropdown/interface/dropdown";
import { StudentClass } from '../../data-source/interface/class'; import { StudentClass } from "../../data-source/interface/class";
import { FormControl, FormControlName, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import {
import { MatFormFieldModule } from '@angular/material/form-field'; FormControl,
import { MatInputModule } from '@angular/material/input'; FormControlName,
FormGroup,
ReactiveFormsModule,
Validators,
} from "@angular/forms";
import { MatFormFieldModule } from "@angular/material/form-field";
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 { 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 { Routines } from "../interface/routine";
@Component({ @Component({
selector: 'app-manage', selector: "app-manage",
imports: [ imports: [
CommonModule, CommonModule,
DropDownComponent, DropDownComponent,
...@@ -29,30 +36,28 @@ import { RaintreeResponse } from '../../../raintree/interface/raintree-response' ...@@ -29,30 +36,28 @@ import { RaintreeResponse } from '../../../raintree/interface/raintree-response'
MatFormFieldModule, MatFormFieldModule,
MatInputModule, MatInputModule,
MatIconModule, MatIconModule,
SquareButtonComponent SquareButtonComponent,
], ],
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: any,
private _classTransmission: ClassTransmissionService, private _classTransmission: ClassTransmissionService,
private _urlConfig: UrlConfigService, private _urlConfig: UrlConfigService,
private _routineTransmission:RoutineTransmissionService, private _routineTransmission: RoutineTransmissionService,
private _auth: AuthService private _auth: AuthService
) { } ) {}
public classDropDownData: Dropdown[] = [] public classDropDownData: Dropdown[] = [];
public sectionDropDownData: Dropdown[] = [] public sectionDropDownData: Dropdown[] = [];
public routineForm = new FormGroup({ public routineForm = new FormGroup({
details: new FormControl('', [Validators.required]) details: new FormControl("", [Validators.required]),
}) });
ngOnInit(): void { ngOnInit(): void {
this._getClasses(); this._getClasses();
this._getSection(); this._getSection();
} }
...@@ -66,8 +71,9 @@ export class ManageComponent { ...@@ -66,8 +71,9 @@ export class ManageComponent {
} }
public submitRoutine(): void { public submitRoutine(): void {
// alert("Submit Clicked!!");
console.log(this.routineFormPayload);
alert("Submit Clicked!!")
// this._routineTransmission.submitRoutine( // this._routineTransmission.submitRoutine(
// TransmissionMapperService.SAVE_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`, // TransmissionMapperService.SAVE_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
...@@ -78,170 +84,170 @@ export class ManageComponent { ...@@ -78,170 +84,170 @@ export class ManageComponent {
// (response: RaintreeResponse) => { // (response: RaintreeResponse) => {
// console.log(response); // console.log(response);
// }, // },
// (error) => { // (error) => {
// console.log(error); // console.log(error);
// }, // },
// () => { } // () => { }
// ); // );
} }
private _getClasses() { private _getClasses() {
this._classTransmission.getClasses( this._classTransmission.getClasses(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({ TransmissionMapperService.GET_TRANSMISSION_URL +
aggregationOnUniqueFld: false, this._urlConfig.generateDatasourceConfigUrl({
datasourceId: DataSourceService.CLASS_DATA_SOURCE_ID, aggregationOnUniqueFld: false,
dontIncludeForeignKey: false, datasourceId: DataSourceService.CLASS_DATA_SOURCE_ID,
expand: false, dontIncludeForeignKey: false,
isUniqueValueRequiredForFieldToDisplay: false, expand: false,
language: "en", isUniqueValueRequiredForFieldToDisplay: false,
limit: 100, language: "en",
orderBy: "ASC", limit: 100,
page: 1, orderBy: "ASC",
roleBasedFiltering: true page: 1,
}), roleBasedFiltering: true,
() => { }, }),
(response) => { }, () => {},
(response) => {},
(response: classResponse) => { (response: classResponse) => {
this.classDropDownData = response.data["themeDataSourceFields"].map(
this.classDropDownData = response.data['themeDataSourceFields'].map((sClass: StudentClass) => { (sClass: StudentClass) => {
return { return {
['name']: sClass.details['en'], ["name"]: sClass.details["en"],
['value']: sClass.id ["value"]: sClass.id,
};
} }
}) );
}, },
(error) => { (error) => {
console.log(error); console.log(error);
}, },
() => { } () => {}
) );
} }
private _getSection(){ private _getSection() {
this._classTransmission.getSection( this._classTransmission.getSection(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({ TransmissionMapperService.GET_TRANSMISSION_URL +
aggregationOnUniqueFld: false, this._urlConfig.generateDatasourceConfigUrl({
datasourceId: DataSourceService.SECTION_DATA_SOURCE_ID, aggregationOnUniqueFld: false,
dontIncludeForeignKey: false, datasourceId: DataSourceService.SECTION_DATA_SOURCE_ID,
expand: false, dontIncludeForeignKey: false,
isUniqueValueRequiredForFieldToDisplay: false, expand: false,
language: "en", isUniqueValueRequiredForFieldToDisplay: false,
limit: 100, language: "en",
orderBy: "ASC", limit: 100,
page: 1, orderBy: "ASC",
roleBasedFiltering: true page: 1,
}), roleBasedFiltering: true,
() => { }, }),
(response) => { }, () => {},
(response) => {},
(response: SectionResponse) => { (response: SectionResponse) => {
this.sectionDropDownData = response.data['themeDataSourceFields'].map((sSection: StudentSection) => { this.sectionDropDownData = response.data["themeDataSourceFields"].map(
return { (sSection: StudentSection) => {
['name']: sSection.section['en'], return {
['value']: sSection.id ["name"]: sSection.section["en"],
["value"]: sSection.id,
};
} }
}) );
}, },
(error) => { (error) => {
console.log(error); console.log(error);
}, },
() => { } () => {}
) );
} }
private routineFormPayload:Routines = {
private routineFormPayload = themeDataSourceFields: [
{
"themeDataSourceFields": [
{ {
"id": "", id: "",
"class": { class: {
"en": "48f353051f9d724f619491d4f0d0a8ec", en: "48f353051f9d724f619491d4f0d0a8ec",
"beng": "48f353051f9d724f619491d4f0d0a8ec", beng: "48f353051f9d724f619491d4f0d0a8ec",
"hindi": "48f353051f9d724f619491d4f0d0a8ec" hindi: "48f353051f9d724f619491d4f0d0a8ec",
}, },
"section": { section: {
"en": "5d53b27058d1f6067a4b4bd1350a24d4", en: "5d53b27058d1f6067a4b4bd1350a24d4",
"beng": "5d53b27058d1f6067a4b4bd1350a24d4", beng: "5d53b27058d1f6067a4b4bd1350a24d4",
"hindi": "5d53b27058d1f6067a4b4bd1350a24d4" hindi: "5d53b27058d1f6067a4b4bd1350a24d4",
}, },
"schedule": { schedule: {
"en": "BASE_URL/webomagic/getFile?fid=2910", en: "BASE_URL/webomagic/getFile?fid=2910",
"beng": "BASE_URL/webomagic/getFile?fid=2910", beng: "BASE_URL/webomagic/getFile?fid=2910",
"hindi": "BASE_URL/webomagic/getFile?fid=2910" hindi: "BASE_URL/webomagic/getFile?fid=2910",
}, },
"details": { details: {
"en": "test 1 c", en: "test 1 c",
"beng": "test 1 c", beng: "test 1 c",
"hindi": "test 1 c" hindi: "test 1 c",
}, },
"session": { session: {
"en": "86af4d6b5675a82df4581f00c67f0c7f", en: "86af4d6b5675a82df4581f00c67f0c7f",
"beng": "86af4d6b5675a82df4581f00c67f0c7f", beng: "86af4d6b5675a82df4581f00c67f0c7f",
"hindi": "86af4d6b5675a82df4581f00c67f0c7f" hindi: "86af4d6b5675a82df4581f00c67f0c7f",
}, },
"document": { document: {
"en": "", en: "",
"beng": "", beng: "",
"hindi": "" hindi: "",
}, },
"routine_type": { routine_type: {
"en": "class_routine", en: "class_routine",
"beng": "class_routine", beng: "class_routine",
"hindi": "class_routine" hindi: "class_routine",
} },
} },
], ],
"dataSourceName": "Routine", dataSourceName: "Routine",
"id": "3021", id: "3021",
"type": "1327", type: "1327",
"themeId": "278", themeId: "278",
"slideLst": null, slideLst: null,
"heading": "undefined", heading: "undefined",
"dataSourceTypeFieldsList": [ dataSourceTypeFieldsList: [
{ {
"id": "", id: "",
"class": { class: {
"en": "48f353051f9d724f619491d4f0d0a8ec", en: "48f353051f9d724f619491d4f0d0a8ec",
"beng": "48f353051f9d724f619491d4f0d0a8ec", beng: "48f353051f9d724f619491d4f0d0a8ec",
"hindi": "48f353051f9d724f619491d4f0d0a8ec" hindi: "48f353051f9d724f619491d4f0d0a8ec",
}, },
"section": { section: {
"en": "5d53b27058d1f6067a4b4bd1350a24d4", en: "5d53b27058d1f6067a4b4bd1350a24d4",
"beng": "5d53b27058d1f6067a4b4bd1350a24d4", beng: "5d53b27058d1f6067a4b4bd1350a24d4",
"hindi": "5d53b27058d1f6067a4b4bd1350a24d4" hindi: "5d53b27058d1f6067a4b4bd1350a24d4",
}, },
"schedule": { schedule: {
"en": "BASE_URL/webomagic/getFile?fid=2910", en: "BASE_URL/webomagic/getFile?fid=2910",
"beng": "BASE_URL/webomagic/getFile?fid=2910", beng: "BASE_URL/webomagic/getFile?fid=2910",
"hindi": "BASE_URL/webomagic/getFile?fid=2910" hindi: "BASE_URL/webomagic/getFile?fid=2910",
}, },
"details": { details: {
"en": "test 1 c", en: "test 1 c",
"beng": "test 1 c", beng: "test 1 c",
"hindi": "test 1 c" hindi: "test 1 c",
}, },
"session": { session: {
"en": "86af4d6b5675a82df4581f00c67f0c7f", en: "86af4d6b5675a82df4581f00c67f0c7f",
"beng": "86af4d6b5675a82df4581f00c67f0c7f", beng: "86af4d6b5675a82df4581f00c67f0c7f",
"hindi": "86af4d6b5675a82df4581f00c67f0c7f" hindi: "86af4d6b5675a82df4581f00c67f0c7f",
}, },
"document": { document: {
"en": "", en: "",
"beng": "", beng: "",
"hindi": "" hindi: "",
}, },
"routine_type": { routine_type: {
"en": "class_routine", en: "class_routine",
"beng": "class_routine", beng: "class_routine",
"hindi": "class_routine" hindi: "class_routine",
} },
} },
] ],
} };
} }
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