Skip to content

Commit

Permalink
The reactions module has been created. A connection between reactions…
Browse files Browse the repository at this point in the history
… and sessions has been created
  • Loading branch information
NK-sudo committed Oct 5, 2024
1 parent f47bf0e commit e2026ca
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/chunk-5G2SSBTM.js

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

2 changes: 1 addition & 1 deletion docs/chunk-KTVWHLU2.js → docs/chunk-7DXRFCOT.js

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

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-Y6WHMPQY.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-ANNWPSS5.js" type="module"></script></body>
</html>
1 change: 1 addition & 0 deletions docs/main-ANNWPSS5.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/main-Y6WHMPQY.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ const routes: Routes = [
import(
'./modules/conferencequestion/pages/questions/questions.module'
).then((m) => m.QuestionsModule)
},
{
path: 'reactions',
canActivate: [MetaGuard],
data: {
meta: {
title: 'Reactions'
}
},
loadChildren: () =>
import(
'./modules/conferencereaction/pages/reactions/reactions.module'
).then((m) => m.ReactionsModule)
}
]
},
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 @@ -177,6 +177,16 @@
<i class="material-icons">contact_support</i>
<span translate>Theme.Questions</span>
</a>
<a
[routerLinkActiveOptions]="{ exact: true }"
routerLinkActive="_activeLink"
routerLink="/reactions"
class="nav__burger-link"
(click)="hideSidebar()"
>
<i class="material-icons">favorite</i>
<span translate>Theme.Reactions</span>
</a>
<hr *ngIf="us.role('admin')" />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wtable
title="Reactions"
[columns]="columns"
[config]="config"
[rows]="rows"
></wtable>
Empty file.
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 { ConferencereactionService, Conferencereaction } from "../../services/conferencereaction.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: "./reactions.component.html",
styleUrls: ["./reactions.component.scss"],
})
export class ReactionsComponent {
sessionId = this._router.url.includes('/reactions/') ? this._router.url.replace('/reactions/', '') : '';

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

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

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

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

get rows(): Conferencereaction[] {
return this.sessionId
?this._sc.reactionsBySessionId[this.sessionId] || []
:this._sc.conferencereactions;
}

constructor(
private _translate: TranslateService,
private _alert: AlertService,
private _sc: ConferencereactionService,
private _form: FormService,
private _core: CoreService,
private _router:Router
) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { NgModule } from '@angular/core';
import { CoreModule } from 'src/app/core/core.module';
import { ReactionsComponent } from './reactions.component';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
component: ReactionsComponent
},
{
path: ':reaction_id',
component: ReactionsComponent
},
];

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

})

export class ReactionsModule { }
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 Conferencereaction extends CrudDocument {
name: string;
description: string;
session:string;
}

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

conferencereactions: Conferencereaction[] = [];

reactionsBySessionId:Record<string, Conferencereaction[]>={}
setReactionsBySessionId=this._helper.createParentIdToChildrenIds<Conferencereaction[]>(this.reactionsBySessionId,this.conferencereactions,"session")

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

this.get().subscribe((conferencereactions: Conferencereaction[]) =>{
this.conferencereactions.push(...conferencereactions)

this.setReactionsBySessionId()
});

_core.on("conferencereaction_create").subscribe((conferencereaction: Conferencereaction) => {
this.conferencereactions.push(conferencereaction);

this.setReactionsBySessionId()
});

_core.on("conferencereaction_delete").subscribe((conferencereaction: Conferencereaction) => {
this.conferencereactions.splice(
this.conferencereactions.findIndex((o) => o._id === conferencereaction._id),
1
);

this.setReactionsBySessionId()
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ export class SessionsComponent {
this._router.navigateByUrl('/questions/'+doc._id)
},
},
{
icon: "favorite",
click: (doc: Conferencesession) => {
this._router.navigateByUrl('/reactions/'+doc._id)
},
},
],
};

Expand Down

0 comments on commit e2026ca

Please sign in to comment.