-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The questions module has been created. A connection between questions…
… and sessions has been created
- Loading branch information
Showing
14 changed files
with
250 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/app/modules/conferencequestion/pages/questions/questions.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<wtable | ||
title="Questions" | ||
[columns]="columns" | ||
[config]="config" | ||
[rows]="rows" | ||
></wtable> |
Empty file.
116 changes: 116 additions & 0 deletions
116
src/app/modules/conferencequestion/pages/questions/questions.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { ConferencequestionService, Conferencequestion } from "../../services/conferencequestion.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: "./questions.component.html", | ||
styleUrls: ["./questions.component.scss"], | ||
}) | ||
export class QuestionsComponent { | ||
sessionId = this._router.url.includes('/questions/') ? this._router.url.replace('/questions/', '') : ''; | ||
|
||
columns = ["name", "description"]; | ||
|
||
form: FormInterface = this._form.getForm("questions", { | ||
formId: "questions", | ||
title: "Questions", | ||
components: [ | ||
{ | ||
name: "Text", | ||
key: "name", | ||
focused: true, | ||
fields: [ | ||
{ | ||
name: "Placeholder", | ||
value: "fill questions title", | ||
}, | ||
{ | ||
name: "Label", | ||
value: "Title", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "Text", | ||
key: "description", | ||
fields: [ | ||
{ | ||
name: "Placeholder", | ||
value: "fill questions description", | ||
}, | ||
{ | ||
name: "Label", | ||
value: "Description", | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
config = { | ||
create: () => { | ||
this._form.modal<Conferencequestion>(this.form, { | ||
label: "Create", | ||
click: (created: unknown, close: () => void) => { | ||
if(this.sessionId) (created as Conferencequestion).session=this.sessionId | ||
|
||
this._sc.create(created as Conferencequestion); | ||
close(); | ||
}, | ||
}); | ||
}, | ||
update: (doc: Conferencequestion) => { | ||
this._form | ||
.modal<Conferencequestion>(this.form, [], doc) | ||
.then((updated: Conferencequestion) => { | ||
this._core.copy(updated, doc); | ||
this._sc.update(doc); | ||
}); | ||
}, | ||
delete: (doc: Conferencequestion) => { | ||
this._alert.question({ | ||
text: this._translate.translate( | ||
"Common.Are you sure you want to delete this Conferencequestion?" | ||
), | ||
buttons: [ | ||
{ | ||
text: this._translate.translate("Common.No"), | ||
}, | ||
{ | ||
text: this._translate.translate("Common.Yes"), | ||
callback: () => { | ||
this._sc.delete(doc); | ||
}, | ||
}, | ||
], | ||
}); | ||
}, | ||
buttons: [ | ||
{ | ||
icon: "cloud_download", | ||
click: (doc: Conferencequestion) => { | ||
this._form.modalUnique<Conferencequestion>("questions", "url", doc); | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
get rows(): Conferencequestion[] { | ||
return this.sessionId | ||
?this._sc.questionsBySessionId[this.sessionId] || [] | ||
:this._sc.conferencequestions; | ||
} | ||
|
||
constructor( | ||
private _translate: TranslateService, | ||
private _alert: AlertService, | ||
private _sc: ConferencequestionService, | ||
private _form: FormService, | ||
private _core: CoreService, | ||
private _router:Router | ||
) {} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/app/modules/conferencequestion/pages/questions/questions.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { QuestionsComponent } from './questions.component'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: QuestionsComponent | ||
}, | ||
{ | ||
path: ':question_id', | ||
component: QuestionsComponent | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forChild(routes), | ||
CoreModule | ||
], | ||
declarations: [ | ||
QuestionsComponent | ||
], | ||
providers: [] | ||
|
||
}) | ||
|
||
export class QuestionsModule { } |
66 changes: 66 additions & 0 deletions
66
src/app/modules/conferencequestion/services/conferencequestion.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Conferencequestion extends CrudDocument { | ||
name: string; | ||
description: string; | ||
session:string; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class ConferencequestionService extends CrudService<Conferencequestion> { | ||
_helper=inject(HelperService) | ||
|
||
conferencequestions: Conferencequestion[] = []; | ||
|
||
questionsBySessionId:Record<string, Conferencequestion[]>={} | ||
setQuestionsBySessionId=this._helper.createParentIdToChildrenIds<Conferencequestion[]>(this.questionsBySessionId,this.conferencequestions,"session") | ||
|
||
constructor( | ||
_http: HttpService, | ||
_store: StoreService, | ||
_alert: AlertService, | ||
_core: CoreService | ||
) { | ||
super( | ||
{ | ||
name: "conferencequestion", | ||
}, | ||
_http, | ||
_store, | ||
_alert, | ||
_core | ||
); | ||
|
||
this.get().subscribe((conferencequestions: Conferencequestion[]) =>{ | ||
this.conferencequestions.push(...conferencequestions) | ||
|
||
this.setQuestionsBySessionId() | ||
}); | ||
|
||
_core.on("conferencequestion_create").subscribe((conferencequestion: Conferencequestion) => { | ||
this.conferencequestions.push(conferencequestion); | ||
|
||
this.setQuestionsBySessionId() | ||
}); | ||
|
||
_core.on("conferencequestion_delete").subscribe((conferencequestion: Conferencequestion) => { | ||
this.conferencequestions.splice( | ||
this.conferencequestions.findIndex((o) => o._id === conferencequestion._id), | ||
1 | ||
); | ||
|
||
this.setQuestionsBySessionId() | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters