diff --git a/src/app/core/models/choice.model.ts b/src/app/core/models/choice.model.ts index 54ba74f4..0535cb51 100644 --- a/src/app/core/models/choice.model.ts +++ b/src/app/core/models/choice.model.ts @@ -5,6 +5,7 @@ export class Choice { constructor( public id: number, public name: string, + public enabled: boolean, public imageUrl?: string, public participants: Map> = new Map>([ [Answer.YES, new Set()], diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index c764df20..212d904c 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -6,41 +6,59 @@ import { PollConfiguration } from './configuration.model'; import { User } from './user.model'; export class Poll { - constructor( - public owner: User = new User(), - public urlPublic: string = '', - public slug: string = '', - public id: number = 0, - public default_expiracy_days_from_now: number = 60, - public title: string = 'mon titre', - public kind: string, - public description?: string, - public custom_url?: string, - public expiracy_date?: string, - public creation_date?: string, - public creatorPseudo?: string, - public creatorEmail?: string, - public allowSeveralHours?: boolean, - public archiveNumberOfDays?: number, - public configuration: PollConfiguration = new PollConfiguration(), - public comments: Comment[] = [], - public choices: Choice[] = [], - public votes = [], - public stacks_of_votes = [], - public allowed_answers = [], - public modification_policy = [], - 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 - ) {} + public id = 0; + + public default_expiracy_days_from_now = 60; + + public title = 'mon titre'; + + public kind: string; + + public description?: string; + + public custom_url?: string; + + public expiracy_date?: string; + + public creation_date?: string; + + public creatorPseudo?: string; + + public creatorEmail?: string; + + public is_archived?: boolean; + public allowSeveralHours?: boolean; + + public archiveNumberOfDays?: number; + + public configuration: PollConfiguration = new PollConfiguration(); + + public comments: Comment[] = []; + + public choices: Choice[] = []; + + public votes = []; + + public stacks_of_votes = []; + + public allowed_answers = []; + + public modification_policy = []; + + 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 = '') {} public static adaptFromLocalJsonServer( item: Pick ): Poll { return new Poll( new User(item.owner.pseudo, item.owner.email, undefined), - item.slug, - item.title, - item.description + '' + // item.slug, + // item.title, + // item.description // item.configuration, // item.comments // .map( diff --git a/src/app/core/services/api.service.ts b/src/app/core/services/api.service.ts index 4ce80383..0cf3ae3b 100644 --- a/src/app/core/services/api.service.ts +++ b/src/app/core/services/api.service.ts @@ -153,14 +153,6 @@ export class ApiService { const adapterInterceptor: number = this.axiosInstance.interceptors.response.use( (response: AxiosResponse): AxiosResponse => { console.log('response', response); - - if (response.data['poll']) { - // response from cipherbliss backend, actually used by oldstuffModule - response.data = response.data['poll']; - } else if (response.data[0] && response.data[0]['slug'] && response.data[0]['question']) { - // response from local json-server - response.data = Poll.adaptFromLocalJsonServer(response.data[0]); - } return response; } ); diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index d0611c04..635b07da 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -137,9 +137,9 @@ export class PollService implements Resolve { public saveParticipation(choice: Choice, user: User, response: Answer): void { const currentPoll = this._poll.getValue(); - currentPoll.choices.find((c) => c.label === choice.label)?.updateParticipation(user, response); + currentPoll.choices.find((c) => c.name === choice.name)?.updateParticipation(user, response); this.updateCurrentPoll(currentPoll); - this.apiService.createParticipation(currentPoll.slug, choice.label, user.pseudo, response); + this.apiService.createParticipation(currentPoll.slug, choice.name, user.pseudo, response); this.toastService.display('Votre participation au sondage a été enregistrée.'); } @@ -174,7 +174,7 @@ export class PollService implements Resolve { pseudo, new Map( poll.choices.map((choice: Choice) => { - return [choice.label, undefined]; + return [choice.name, undefined]; }) ) ); @@ -183,7 +183,7 @@ export class PollService implements Resolve { poll.choices.forEach((choice: Choice) => { choice.participants.forEach((users: Set, answer: Answer) => { users.forEach((user: User) => { - list.get(user.pseudo).set(choice.label, answer); + list.get(user.pseudo).set(choice.name, answer); }); }); }); diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 4351fe6a..7cce6e23 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -11,6 +11,11 @@ aucun vote pour le moment +
+
+ Vous ne pouvez modifier que votre propre vote à ce sondage +
+
@@ -32,15 +37,19 @@

Exporter/Imprimer

- + - - @@ -83,7 +92,7 @@ -
+
+
diff --git a/src/app/shared/components/comments/comments.component.html b/src/app/shared/components/comments/comments.component.html index 5104bb02..73205cfd 100644 --- a/src/app/shared/components/comments/comments.component.html +++ b/src/app/shared/components/comments/comments.component.html @@ -1,67 +1,76 @@ -
-

Laisser un commentaire

-
-
-
- - - - +
+
+

Laisser un commentaire

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

{{ poll.comments.length }} Commentaires

+
+

+ + {{ poll.comments.length }} Commentaires +

- {{ comment.pseudo }} , le - + {{ comment.pseudo }} , + + il y a {{ calculateDaysAgoOfComment(comment.owner.created_at) }} jours, le {{ comment.owner.created_at }} + > {{ comment.owner.created_at }}

@@ -70,5 +79,5 @@

-
+