diff --git a/src/app/core/components/header/header.component.ts b/src/app/core/components/header/header.component.ts index 3f160443..57146ba7 100644 --- a/src/app/core/components/header/header.component.ts +++ b/src/app/core/components/header/header.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { SettingsComponent } from '../../../shared/components/settings/settings.component'; -import { User } from '../../models/user.model'; +import { Owner } from '../../models/owner.model'; import { ModalService } from '../../services/modal.service'; import { UserService } from '../../services/user.service'; import { environment } from '../../../../environments/environment'; @@ -13,7 +13,7 @@ import { environment } from '../../../../environments/environment'; styleUrls: ['./header.component.scss'], }) export class HeaderComponent implements OnInit { - public _user: Observable = this.userService.user; + public _user: Observable = this.userService.user; public env = environment; @Input() public appTitle: string = 'FramaDate Funky'; @Input() public appLogo: string; diff --git a/src/app/core/models/choice.model.ts b/src/app/core/models/choice.model.ts index e1dca02a..3bafb2eb 100644 --- a/src/app/core/models/choice.model.ts +++ b/src/app/core/models/choice.model.ts @@ -1,5 +1,5 @@ import { Answer } from '../enums/answer.enum'; -import { User } from './user.model'; +import { Owner } from './owner.model'; export class Choice { public id: number; @@ -13,10 +13,10 @@ export class Choice { public maybe?: any; constructor( - public participants: Map> = new Map>([ - [Answer.YES, new Set()], - [Answer.NO, new Set()], - [Answer.MAYBE, new Set()], + public participants: Map> = new Map>([ + [Answer.YES, new Set()], + [Answer.NO, new Set()], + [Answer.MAYBE, new Set()], ]), public counts: Map = new Map([ [Answer.YES, 0], @@ -25,13 +25,13 @@ export class Choice { ]) ) {} - public updateParticipation(user: User, responseType: Answer): void { + public updateParticipation(user: Owner, responseType: Answer): void { this.removeParticipant(user); this.participants.get(responseType).add(user); this.updateCounts(); } - public removeParticipant(user: User): void { + public removeParticipant(user: Owner): void { for (const responseType of Object.values(Answer)) { if (this.participants.get(responseType).has(user)) { this.participants.get(responseType).delete(user); diff --git a/src/app/core/models/user.model.ts b/src/app/core/models/owner.model.ts similarity index 92% rename from src/app/core/models/user.model.ts rename to src/app/core/models/owner.model.ts index a8096ac3..5cebff8b 100644 --- a/src/app/core/models/user.model.ts +++ b/src/app/core/models/owner.model.ts @@ -1,7 +1,7 @@ import { UserRole } from '../enums/user-role.enum'; import { Poll } from './poll.model'; -export class User { +export class Owner { constructor( public pseudo: string = 'pseudo', public email: string = 'example@example.com', diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index f2d5c4f5..cab6ce48 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -3,7 +3,7 @@ import { environment } from 'src/environments/environment'; import { Choice } from './choice.model'; import { Comment } from './comment.model'; import { PollConfiguration } from './configuration.model'; -import { User } from './user.model'; +import { Owner } from './owner.model'; export class Poll { public id = 0; @@ -49,13 +49,13 @@ export class Poll { public dateChoices: Choice[] = []; // sets of days as strings, config to set identical time for days in a special days poll public timeChoices: Choice[] = []; // ranges of time expressed as strings - constructor(public owner: User = new User(), public urlPublic: string = '', public slug: string = '') {} + constructor(public owner: Owner = new Owner(), public urlPublic: string = '', public slug: string = '') {} public static adaptFromLocalJsonServer( item: Pick ): Poll { return new Poll( - new User(item.owner.pseudo, item.owner.email, undefined), + new Owner(item.owner.pseudo, item.owner.email, undefined), '' // item.slug, // item.title, diff --git a/src/app/core/models/stack.model.ts b/src/app/core/models/stack.model.ts new file mode 100644 index 00000000..81c0d5a7 --- /dev/null +++ b/src/app/core/models/stack.model.ts @@ -0,0 +1,10 @@ +import { Vote } from './vote.model'; +import { Owner } from './owner.model'; + +export class Stack { + public id: number; + public pseudo: string = 'Choque Nourrice'; + public comment: string = 'Le beau commentaire de Choque Nourrice'; + public owner: Owner = new Owner(); + public votes: Vote[]; +} diff --git a/src/app/core/models/vote.model.ts b/src/app/core/models/vote.model.ts new file mode 100644 index 00000000..2fab385b --- /dev/null +++ b/src/app/core/models/vote.model.ts @@ -0,0 +1,4 @@ +export class Vote { + public choice_id: number; + public value: string; // valeur de réponse +} diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 98197f9e..10b6aa42 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -5,7 +5,7 @@ import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { Answer } from '../enums/answer.enum'; import { Choice } from '../models/choice.model'; import { Poll } from '../models/poll.model'; -import { User } from '../models/user.model'; +import { Owner } from '../models/owner.model'; import { ApiService } from './api.service'; import { ToastService } from './toast.service'; import { UserService } from './user.service'; @@ -136,7 +136,7 @@ export class PollService implements Resolve { } } - public saveParticipation(choice: Choice, user: User, response: Answer): void { + public saveParticipation(choice: Choice, user: Owner, response: Answer): void { const currentPoll = this._poll.getValue(); currentPoll.choices.find((c) => c.name === choice.name)?.updateParticipation(user, response); this.updateCurrentPoll(currentPoll); @@ -162,8 +162,8 @@ export class PollService implements Resolve { public buildAnswersByChoiceLabelByPseudo(poll: Poll): Map> { const pseudos: Set = new Set(); poll.choices.forEach((choice: Choice) => { - // choice.voters.forEach((users: Set) => { - // users.forEach((user: User) => { + // choice.voters.forEach((users: Set) => { + // users.forEach((user: Owner) => { // pseudos.add(user.pseudo); // }); // }); @@ -182,8 +182,8 @@ export class PollService implements Resolve { }); poll.choices.forEach((choice: Choice) => { - choice.participants.forEach((users: Set, answer: Answer) => { - users.forEach((user: User) => { + choice.participants.forEach((users: Set, answer: Answer) => { + users.forEach((user: Owner) => { list.get(user.pseudo).set(choice.name, answer); }); }); diff --git a/src/app/core/services/storage.service.ts b/src/app/core/services/storage.service.ts index dc6a1744..0fc20dd6 100644 --- a/src/app/core/services/storage.service.ts +++ b/src/app/core/services/storage.service.ts @@ -3,6 +3,7 @@ import { LocalStorage } from 'ngx-webstorage'; import { Language } from '../enums/language.enum'; import { Theme } from '../enums/theme.enum'; +import { Stack } from '../models/stack.model'; @Injectable({ providedIn: 'root', @@ -18,5 +19,5 @@ export class StorageService { public userPollsIds: string[]; @LocalStorage() - public pseudo: string; + public vote_stack: Stack = new Stack(); } diff --git a/src/app/core/services/user.service.ts b/src/app/core/services/user.service.ts index 4305d14c..1ca05b53 100644 --- a/src/app/core/services/user.service.ts +++ b/src/app/core/services/user.service.ts @@ -2,25 +2,25 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { UserRole } from '../enums/user-role.enum'; -import { User } from '../models/user.model'; +import { Owner } from '../models/owner.model'; import { ApiService } from './api.service'; @Injectable({ providedIn: 'root', }) export class UserService { - public anonymous: User = new User('', '', [], UserRole.ANONYMOUS); + public anonymous: Owner = new Owner('', '', [], UserRole.ANONYMOUS); - private _user: BehaviorSubject = new BehaviorSubject(this.anonymous); - public readonly user: Observable = this._user.asObservable(); + private _user: BehaviorSubject = new BehaviorSubject(this.anonymous); + public readonly user: Observable = this._user.asObservable(); constructor(private apiService: ApiService) {} - public updateUser(user: User): void { + public updateUser(user: Owner): void { this._user.next(user); } - public getCurrentUser(): User { + public getCurrentUser(): Owner { return this._user.getValue(); } @@ -29,7 +29,7 @@ export class UserService { } public async getUserPolls(): Promise { - const currentUser: User = this._user.getValue(); + const currentUser: Owner = this._user.getValue(); currentUser.polls = await this.apiService.getPollsUrlsByUserEmail(currentUser.email); this.updateUser(currentUser); } diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 9c5edc39..8da92428 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -1,6 +1,10 @@
+ + mon pseudo : {{ storageService.vote_stack.pseudo }} + +
⚰️ Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires @@ -88,7 +92,7 @@
- +
diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index 87f56e41..0a02873e 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -7,6 +7,7 @@ import { PollService } from '../../core/services/poll.service'; import { DateService } from '../../core/services/date.service'; import { PollUtilities } from '../old-stuff/config/PollUtilities'; import { Comment } from '../../core/models/comment.model'; +import { StorageService } from '../../core/services/storage.service'; @Component({ selector: 'app-consultation', @@ -33,6 +34,7 @@ export class ConsultationComponent implements OnInit, OnDestroy { private router: Router, private utils: PollUtilities, private _Activatedroute: ActivatedRoute, + public storageService: StorageService, public pollService: PollService, public dateService: DateService, private modalService: ModalService diff --git a/src/app/features/participation/add-answer/add-answer.component.ts b/src/app/features/participation/add-answer/add-answer.component.ts index f505370d..6f073200 100644 --- a/src/app/features/participation/add-answer/add-answer.component.ts +++ b/src/app/features/participation/add-answer/add-answer.component.ts @@ -4,7 +4,7 @@ import { Answer } from 'src/app/core/enums/answer.enum'; import { Choice } from '../../../core/models/choice.model'; import { Poll } from '../../../core/models/poll.model'; -import { User } from '../../../core/models/user.model'; +import { Owner } from '../../../core/models/owner.model'; import { ModalService } from '../../../core/services/modal.service'; import { PollService } from '../../../core/services/poll.service'; import { ChoiceDetailsComponent } from '../../../shared/components/choice-details/choice-details.component'; @@ -15,7 +15,7 @@ import { ChoiceDetailsComponent } from '../../../shared/components/choice-detail styleUrls: ['./add-answer.component.scss'], }) export class AddAnswerComponent { - @Input() user: User; + @Input() user: Owner; @Input() poll: Poll; @Input() choice: Choice; public answerEnum = Answer; diff --git a/src/app/features/participation/answers/answers.component.ts b/src/app/features/participation/answers/answers.component.ts index 0060fe05..80436380 100644 --- a/src/app/features/participation/answers/answers.component.ts +++ b/src/app/features/participation/answers/answers.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { Poll } from '../../../core/models/poll.model'; -import { User } from '../../../core/models/user.model'; +import { Owner } from '../../../core/models/owner.model'; @Component({ selector: 'app-answers', @@ -10,7 +10,7 @@ import { User } from '../../../core/models/user.model'; }) export class AnswersComponent implements OnInit { @Input() poll: Poll; - @Input() user: User; + @Input() user: Owner; constructor() {} diff --git a/src/app/features/participation/participation.component.ts b/src/app/features/participation/participation.component.ts index 84806981..8642b8a4 100644 --- a/src/app/features/participation/participation.component.ts +++ b/src/app/features/participation/participation.component.ts @@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { Observable, Subscription } from 'rxjs'; import { Poll } from '../../core/models/poll.model'; -import { User } from '../../core/models/user.model'; +import { Owner } from '../../core/models/owner.model'; import { ModalService } from '../../core/services/modal.service'; import { UserService } from '../../core/services/user.service'; import { SettingsComponent } from '../../shared/components/settings/settings.component'; @@ -15,7 +15,7 @@ import { SettingsComponent } from '../../shared/components/settings/settings.com }) export class ParticipationComponent implements OnInit, OnDestroy { public poll: Poll; - public _user: Observable = this.userService.user; + public _user: Observable = this.userService.user; private routeSubscription: Subscription; constructor( diff --git a/src/app/features/user-profile/user-polls/user-polls.component.ts b/src/app/features/user-profile/user-polls/user-polls.component.ts index 2d5a27ff..f0c8b5e6 100644 --- a/src/app/features/user-profile/user-polls/user-polls.component.ts +++ b/src/app/features/user-profile/user-polls/user-polls.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; -import { User } from '../../../core/models/user.model'; +import { Owner } from '../../../core/models/owner.model'; import { UserService } from '../../../core/services/user.service'; @Component({ @@ -10,7 +10,7 @@ import { UserService } from '../../../core/services/user.service'; styleUrls: ['./user-polls.component.scss'], }) export class UserPollsComponent implements OnInit { - public _user: Observable = this.userService.user; + public _user: Observable = this.userService.user; public isModalOpened = false; public pollsAreLoaded = false; diff --git a/src/app/shared/components/comments/comments.component.html b/src/app/shared/components/comments/comments.component.html index f3ca856e..30ab74e8 100644 --- a/src/app/shared/components/comments/comments.component.html +++ b/src/app/shared/components/comments/comments.component.html @@ -1,62 +1,8 @@
-
-

Laisser un commentaire

-
-
-
- - - - - - - - - - - - -
- - - - -
-
- -
- - - -
-
-
⚰️ Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires
- -
+

{{ poll.comments.length }} Commentaires @@ -82,4 +28,57 @@

+
+

Laisser un commentaire

+
+
+
+ + + + + + + + + + + + +
+ + + + +
+
+ +
+ + + +
+
+
diff --git a/src/app/shared/components/comments/comments.component.ts b/src/app/shared/components/comments/comments.component.ts index 086fef07..93eec15e 100644 --- a/src/app/shared/components/comments/comments.component.ts +++ b/src/app/shared/components/comments/comments.component.ts @@ -1,6 +1,8 @@ import { Component, Input } from '@angular/core'; import { PollService } from '../../../core/services/poll.service'; import * as moment from 'moment'; +import { Stack } from '../../../core/models/stack.model'; +import { Poll } from '../../../core/models/poll.model'; @Component({ selector: 'app-comments', @@ -8,7 +10,8 @@ import * as moment from 'moment'; styleUrls: ['./comments.component.scss'], }) export class CommentsComponent { - @Input() public poll: any; + @Input() public vote_stack: Stack; + @Input() public poll: Poll; public config: any = { myName: '', diff --git a/src/app/shared/components/settings/settings.component.ts b/src/app/shared/components/settings/settings.component.ts index 7420fcc6..e52272dd 100644 --- a/src/app/shared/components/settings/settings.component.ts +++ b/src/app/shared/components/settings/settings.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { MatDialogRef } from '@angular/material/dialog'; import { Subscription } from 'rxjs'; -import { User } from '../../../core/models/user.model'; +import { Owner } from '../../../core/models/owner.model'; import { UserService } from '../../../core/services/user.service'; @Component({ @@ -11,7 +11,7 @@ import { UserService } from '../../../core/services/user.service'; styleUrls: ['./settings.component.scss'], }) export class SettingsComponent implements OnInit { - public user: User; + public user: Owner; private userSubscription: Subscription; constructor(private userService: UserService, public dialogRef: MatDialogRef) {} diff --git a/src/assets/i18n/po/br.po b/src/assets/i18n/po/br.po index b543f54e..17b6d231 100755 --- a/src/assets/i18n/po/br.po +++ b/src/assets/i18n/po/br.po @@ -1014,7 +1014,7 @@ msgid "Respond-to mail address" msgstr "Chomlec'h postel respont" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Arveriad" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/ca.po b/src/assets/i18n/po/ca.po index 128173e6..bf9318bb 100644 --- a/src/assets/i18n/po/ca.po +++ b/src/assets/i18n/po/ca.po @@ -1031,7 +1031,7 @@ msgid "Respond-to mail address" msgstr "Respon a l'adreça de correu" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Usuari" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/de.po b/src/assets/i18n/po/de.po index 9c7d77a3..c58da819 100644 --- a/src/assets/i18n/po/de.po +++ b/src/assets/i18n/po/de.po @@ -1042,7 +1042,7 @@ msgstr "" "werden)" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Datenbank-Benutzername" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/el.po b/src/assets/i18n/po/el.po index 8ea02db9..baede0eb 100644 --- a/src/assets/i18n/po/el.po +++ b/src/assets/i18n/po/el.po @@ -1024,7 +1024,7 @@ msgid "Respond-to mail address" msgstr "Email απάντησης" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Χρήστης" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/en.po b/src/assets/i18n/po/en.po index c7a27f7a..c4a61dea 100755 --- a/src/assets/i18n/po/en.po +++ b/src/assets/i18n/po/en.po @@ -1029,8 +1029,8 @@ msgid "Respond-to mail address" msgstr "Respond-to mail address" #: .Installation.User -msgid "User" -msgstr "User" +msgid "Owner" +msgstr "Owner" #: .Language+selector.Change+language msgid "Change language" diff --git a/src/assets/i18n/po/es.po b/src/assets/i18n/po/es.po index 1e2364d9..b4e15118 100644 --- a/src/assets/i18n/po/es.po +++ b/src/assets/i18n/po/es.po @@ -1043,7 +1043,7 @@ msgid "Respond-to mail address" msgstr "Correo electrónico para \"responder a\"" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Usuario" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/fr.po b/src/assets/i18n/po/fr.po index b3483986..1f012675 100644 --- a/src/assets/i18n/po/fr.po +++ b/src/assets/i18n/po/fr.po @@ -1047,7 +1047,7 @@ msgid "Respond-to mail address" msgstr "Mail de réponse" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Utilisateur·rice" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/framadate.pot b/src/assets/i18n/po/framadate.pot index 7d9e5139..681e19e4 100644 --- a/src/assets/i18n/po/framadate.pot +++ b/src/assets/i18n/po/framadate.pot @@ -959,7 +959,7 @@ msgid "Respond-to mail address" msgstr "" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/gl.po b/src/assets/i18n/po/gl.po index 38e61af5..43623f03 100644 --- a/src/assets/i18n/po/gl.po +++ b/src/assets/i18n/po/gl.po @@ -1016,7 +1016,7 @@ msgid "Respond-to mail address" msgstr "Correo electrónico para as respostas" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Persoa usuaria" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/hu.po b/src/assets/i18n/po/hu.po index 80f64f18..c1723630 100644 --- a/src/assets/i18n/po/hu.po +++ b/src/assets/i18n/po/hu.po @@ -1024,7 +1024,7 @@ msgid "Respond-to mail address" msgstr "Válasz e-mail cím" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Felhasználó" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/it.po b/src/assets/i18n/po/it.po index e63a4b6e..79877da9 100644 --- a/src/assets/i18n/po/it.po +++ b/src/assets/i18n/po/it.po @@ -1039,7 +1039,7 @@ msgid "Respond-to mail address" msgstr "E-mail per le risposte" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Utente" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/nl.po b/src/assets/i18n/po/nl.po index 587e6a6c..c2864d78 100755 --- a/src/assets/i18n/po/nl.po +++ b/src/assets/i18n/po/nl.po @@ -1020,7 +1020,7 @@ msgid "Respond-to mail address" msgstr "Antwoordmail" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Gebruiker" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/oc.po b/src/assets/i18n/po/oc.po index a575c064..44c4c94b 100644 --- a/src/assets/i18n/po/oc.po +++ b/src/assets/i18n/po/oc.po @@ -1040,7 +1040,7 @@ msgid "Respond-to mail address" msgstr "Adreça de responsa" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Utilizaire" #: .Language+selector.Change+language diff --git a/src/assets/i18n/po/sv.po b/src/assets/i18n/po/sv.po index bba5ff90..2430434e 100644 --- a/src/assets/i18n/po/sv.po +++ b/src/assets/i18n/po/sv.po @@ -1015,7 +1015,7 @@ msgid "Respond-to mail address" msgstr "E-postadress för svar" #: .Installation.User -msgid "User" +msgid "Owner" msgstr "Användare" #: .Language+selector.Change+language