Skip to content

Commit

Permalink
The qnas module has been created. A connection between qnas and sessi…
Browse files Browse the repository at this point in the history
…ons has been created
  • Loading branch information
NK-sudo committed Oct 5, 2024
1 parent 94f6a7a commit 0838db9
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/chunk-6KALNN6L.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/chunk-JLFGRO6Y.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/chunk-QEHBLJIO.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@

<body>
<app-root></app-root>
<link rel="modulepreload" href="chunk-4M2CC4DW.js"><link rel="modulepreload" href="chunk-6LRXWN5R.js"><link rel="modulepreload" href="chunk-HOEKJOMB.js"><script src="polyfills-AXUTU6D7.js" type="module"></script><script src="main-2MBWUIND.js" type="module"></script></body>
<link rel="modulepreload" href="chunk-4M2CC4DW.js"><link rel="modulepreload" href="chunk-6LRXWN5R.js"><link rel="modulepreload" href="chunk-HOEKJOMB.js"><script src="polyfills-AXUTU6D7.js" type="module"></script><script src="main-C4W4R4FF.js" type="module"></script></body>
</html>
1 change: 0 additions & 1 deletion docs/main-2MBWUIND.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/main-C4W4R4FF.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ const routes: Routes = [
import(
'./modules/conferencepoll/pages/polls/polls.module'
).then((m) => m.PollsModule)
},
{
path: 'qnas',
canActivate: [MetaGuard],
data: {
meta: {
title: 'Qnas'
}
},
loadChildren: () =>
import(
'./modules/conferenceqna/pages/qnas/qnas.module'
).then((m) => m.QnasModule)
}
]
},
Expand Down
10 changes: 10 additions & 0 deletions src/app/core/theme/user/user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@
<i class="material-icons">poll</i>
<span translate>Theme.Polls</span>
</a>
<a
[routerLinkActiveOptions]="{ exact: true }"
routerLinkActive="_activeLink"
routerLink="/qnas"
class="nav__burger-link"
(click)="hideSidebar()"
>
<i class="material-icons">live_help</i>
<span translate>Theme.Qnas</span>
</a>
<hr *ngIf="us.role('admin')" />
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/app/modules/conferenceqna/pages/qnas/qnas.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wtable
title="Qnas"
[columns]="columns"
[config]="config"
[rows]="rows"
></wtable>
Empty file.
116 changes: 116 additions & 0 deletions src/app/modules/conferenceqna/pages/qnas/qnas.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { Component } from "@angular/core";
import { AlertService, CoreService } from "wacom";
import { ConferenceqnaService, Conferenceqna } from "../../services/conferenceqna.service";
import { FormService } from "src/app/core/modules/form/form.service";
import { TranslateService } from "src/app/core/modules/translate/translate.service";
import { FormInterface } from "src/app/core/modules/form/interfaces/form.interface";
import { Router } from "@angular/router";

@Component({
templateUrl: "./qnas.component.html",
styleUrls: ["./qnas.component.scss"],
})
export class QnasComponent {
sessionId = this._router.url.includes('/qnas/') ? this._router.url.replace('/qnas/', '') : '';

columns = ["name", "description"];

form: FormInterface = this._form.getForm("qnas", {
formId: "qnas",
title: "Qnas",
components: [
{
name: "Text",
key: "name",
focused: true,
fields: [
{
name: "Placeholder",
value: "fill qnas title",
},
{
name: "Label",
value: "Title",
},
],
},
{
name: "Text",
key: "description",
fields: [
{
name: "Placeholder",
value: "fill qnas description",
},
{
name: "Label",
value: "Description",
},
],
},
],
});

config = {
create: () => {
this._form.modal<Conferenceqna>(this.form, {
label: "Create",
click: (created: unknown, close: () => void) => {
if(this.sessionId) (created as Conferenceqna).session=this.sessionId

this._sc.create(created as Conferenceqna);
close();
},
});
},
update: (doc: Conferenceqna) => {
this._form
.modal<Conferenceqna>(this.form, [], doc)
.then((updated: Conferenceqna) => {
this._core.copy(updated, doc);
this._sc.update(doc);
});
},
delete: (doc: Conferenceqna) => {
this._alert.question({
text: this._translate.translate(
"Common.Are you sure you want to delete this Conferenceqna?"
),
buttons: [
{
text: this._translate.translate("Common.No"),
},
{
text: this._translate.translate("Common.Yes"),
callback: () => {
this._sc.delete(doc);
},
},
],
});
},
buttons: [
{
icon: "cloud_download",
click: (doc: Conferenceqna) => {
this._form.modalUnique<Conferenceqna>("qnas", "url", doc);
},
},
],
};

get rows(): Conferenceqna[] {
return this.sessionId
?this._sc.qnasBySessionId[this.sessionId] || []
:this._sc.conferenceqnas;
}

constructor(
private _translate: TranslateService,
private _alert: AlertService,
private _sc: ConferenceqnaService,
private _form: FormService,
private _core: CoreService,
private _router:Router
) {}
}
30 changes: 30 additions & 0 deletions src/app/modules/conferenceqna/pages/qnas/qnas.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { NgModule } from '@angular/core';
import { CoreModule } from 'src/app/core/core.module';
import { QnasComponent } from './qnas.component';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
component: QnasComponent
},
{
path: ':qna_id',
component: QnasComponent
},

];

@NgModule({
imports: [
RouterModule.forChild(routes),
CoreModule
],
declarations: [
QnasComponent
],
providers: []

})

export class QnasModule { }
66 changes: 66 additions & 0 deletions src/app/modules/conferenceqna/services/conferenceqna.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { inject, Injectable } from "@angular/core";
import { HelperService } from "src/app/core/services/helper.service";
import {
AlertService,
CoreService,
HttpService,
StoreService,
CrudService,
CrudDocument,
} from "wacom";

export interface Conferenceqna extends CrudDocument {
name: string;
description: string;
session:string;
}

@Injectable({
providedIn: "root",
})
export class ConferenceqnaService extends CrudService<Conferenceqna> {
_helper=inject(HelperService)

conferenceqnas: Conferenceqna[] = [];

qnasBySessionId:Record<string, Conferenceqna[]>={}
setQnasBySessionId=this._helper.createParentIdToChildrenIds<Conferenceqna[]>(this.qnasBySessionId,this.conferenceqnas,"session")

constructor(
_http: HttpService,
_store: StoreService,
_alert: AlertService,
_core: CoreService
) {
super(
{
name: "conferenceqna",
},
_http,
_store,
_alert,
_core
);

this.get().subscribe((conferenceqnas: Conferenceqna[]) =>{
this.conferenceqnas.push(...conferenceqnas)

this.setQnasBySessionId()
});

_core.on("conferenceqna_create").subscribe((conferenceqna: Conferenceqna) => {
this.conferenceqnas.push(conferenceqna);

this.setQnasBySessionId()
});

_core.on("conferenceqna_delete").subscribe((conferenceqna: Conferenceqna) => {
this.conferenceqnas.splice(
this.conferenceqnas.findIndex((o) => o._id === conferenceqna._id),
1
);

this.setQnasBySessionId()
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ export class SessionsComponent {
this._router.navigateByUrl('/polls/'+doc._id)
},
},
{
icon: "live_help",
click: (doc: Conferencesession) => {
this._router.navigateByUrl('/qnas/'+doc._id)
},
},
],
};

Expand Down

0 comments on commit 0838db9

Please sign in to comment.