forked from tykayn/funky-framadate-front
transmettre l'information d'expiration du sondage au front
This commit is contained in:
parent
1e90d92ab9
commit
163b89b03f
@ -5,6 +5,7 @@ export class Choice {
|
|||||||
constructor(
|
constructor(
|
||||||
public id: number,
|
public id: number,
|
||||||
public name: string,
|
public name: string,
|
||||||
|
public enabled: boolean,
|
||||||
public imageUrl?: string,
|
public imageUrl?: string,
|
||||||
public participants: Map<Answer, Set<User>> = new Map<Answer, Set<User>>([
|
public participants: Map<Answer, Set<User>> = new Map<Answer, Set<User>>([
|
||||||
[Answer.YES, new Set<User>()],
|
[Answer.YES, new Set<User>()],
|
||||||
|
@ -6,41 +6,59 @@ import { PollConfiguration } from './configuration.model';
|
|||||||
import { User } from './user.model';
|
import { User } from './user.model';
|
||||||
|
|
||||||
export class Poll {
|
export class Poll {
|
||||||
constructor(
|
public id = 0;
|
||||||
public owner: User = new User(),
|
|
||||||
public urlPublic: string = '',
|
public default_expiracy_days_from_now = 60;
|
||||||
public slug: string = '',
|
|
||||||
public id: number = 0,
|
public title = 'mon titre';
|
||||||
public default_expiracy_days_from_now: number = 60,
|
|
||||||
public title: string = 'mon titre',
|
public kind: string;
|
||||||
public kind: string,
|
|
||||||
public description?: string,
|
public description?: string;
|
||||||
public custom_url?: string,
|
|
||||||
public expiracy_date?: string,
|
public custom_url?: string;
|
||||||
public creation_date?: string,
|
|
||||||
public creatorPseudo?: string,
|
public expiracy_date?: string;
|
||||||
public creatorEmail?: string,
|
|
||||||
public allowSeveralHours?: boolean,
|
public creation_date?: string;
|
||||||
public archiveNumberOfDays?: number,
|
|
||||||
public configuration: PollConfiguration = new PollConfiguration(),
|
public creatorPseudo?: string;
|
||||||
public comments: Comment[] = [],
|
|
||||||
public choices: Choice[] = [],
|
public creatorEmail?: string;
|
||||||
public votes = [],
|
|
||||||
public stacks_of_votes = [],
|
public is_archived?: boolean;
|
||||||
public allowed_answers = [],
|
public allowSeveralHours?: boolean;
|
||||||
public modification_policy = [],
|
|
||||||
public dateChoices: Choice[] = [], // sets of days as strings, config to set identical time for days in a special days poll
|
public archiveNumberOfDays?: number;
|
||||||
public timeChoices: Choice[] = [] // ranges of time expressed as strings
|
|
||||||
) {}
|
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(
|
public static adaptFromLocalJsonServer(
|
||||||
item: Pick<Poll, 'owner' | 'title' | 'description' | 'slug' | 'configuration' | 'comments' | 'choices'>
|
item: Pick<Poll, 'owner' | 'title' | 'description' | 'slug' | 'configuration' | 'comments' | 'choices'>
|
||||||
): Poll {
|
): Poll {
|
||||||
return new Poll(
|
return new Poll(
|
||||||
new User(item.owner.pseudo, item.owner.email, undefined),
|
new User(item.owner.pseudo, item.owner.email, undefined),
|
||||||
item.slug,
|
''
|
||||||
item.title,
|
// item.slug,
|
||||||
item.description
|
// item.title,
|
||||||
|
// item.description
|
||||||
// item.configuration,
|
// item.configuration,
|
||||||
// item.comments
|
// item.comments
|
||||||
// .map(
|
// .map(
|
||||||
|
@ -153,14 +153,6 @@ export class ApiService {
|
|||||||
const adapterInterceptor: number = this.axiosInstance.interceptors.response.use(
|
const adapterInterceptor: number = this.axiosInstance.interceptors.response.use(
|
||||||
(response: AxiosResponse): AxiosResponse => {
|
(response: AxiosResponse): AxiosResponse => {
|
||||||
console.log('response', response);
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -137,9 +137,9 @@ export class PollService implements Resolve<Poll> {
|
|||||||
|
|
||||||
public saveParticipation(choice: Choice, user: User, response: Answer): void {
|
public saveParticipation(choice: Choice, user: User, response: Answer): void {
|
||||||
const currentPoll = this._poll.getValue();
|
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.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.');
|
this.toastService.display('Votre participation au sondage a été enregistrée.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ export class PollService implements Resolve<Poll> {
|
|||||||
pseudo,
|
pseudo,
|
||||||
new Map<string, Answer>(
|
new Map<string, Answer>(
|
||||||
poll.choices.map((choice: Choice) => {
|
poll.choices.map((choice: Choice) => {
|
||||||
return [choice.label, undefined];
|
return [choice.name, undefined];
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -183,7 +183,7 @@ export class PollService implements Resolve<Poll> {
|
|||||||
poll.choices.forEach((choice: Choice) => {
|
poll.choices.forEach((choice: Choice) => {
|
||||||
choice.participants.forEach((users: Set<User>, answer: Answer) => {
|
choice.participants.forEach((users: Set<User>, answer: Answer) => {
|
||||||
users.forEach((user: User) => {
|
users.forEach((user: User) => {
|
||||||
list.get(user.pseudo).set(choice.label, answer);
|
list.get(user.pseudo).set(choice.name, answer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,11 @@
|
|||||||
aucun vote pour le moment
|
aucun vote pour le moment
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
<article class="message is-info" *ngIf="poll.modification_policy == 'self'">
|
||||||
|
<div class="message-body">
|
||||||
|
Vous ne pouvez modifier que votre propre vote à ce sondage
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
<!-- actions-->
|
<!-- actions-->
|
||||||
|
|
||||||
@ -32,15 +37,19 @@
|
|||||||
<h3 class="margin-top-x6 margin-btm-x3">
|
<h3 class="margin-top-x6 margin-btm-x3">
|
||||||
Exporter/Imprimer
|
Exporter/Imprimer
|
||||||
</h3>
|
</h3>
|
||||||
<button class="export export-csv" (click)="exportCSV()">
|
<button class="replicate export-csv btn" (click)="duplicate()">
|
||||||
|
<i class="fa fa-copy" aria-hidden="true"></i>
|
||||||
|
Dupliquer
|
||||||
|
</button>
|
||||||
|
<button class="export export-csv btn" (click)="exportCSV()">
|
||||||
<i class="fa fa-file-calc-o" aria-hidden="true"></i>
|
<i class="fa fa-file-calc-o" aria-hidden="true"></i>
|
||||||
Exporter en .csv
|
Exporter en .csv
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn--primary" (click)="exportJson()">
|
<button class="export export-json btn" (click)="exportJson()">
|
||||||
<i class="fa fa-file-archive-o" aria-hidden="true"></i>
|
<i class="fa fa-file-archive-o" aria-hidden="true"></i>
|
||||||
export json
|
export json
|
||||||
</button>
|
</button>
|
||||||
<button class="export export-print" (click)="print()">
|
<button class="export export-print btn" (click)="print()">
|
||||||
<i class="fa fa-print"></i>
|
<i class="fa fa-print"></i>
|
||||||
Imprimer le sondage
|
Imprimer le sondage
|
||||||
</button>
|
</button>
|
||||||
@ -83,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bar-votestack">
|
<div class="bar-votestack" *ngIf="!isArchived">
|
||||||
<button
|
<button
|
||||||
class="btn btn-block submit-votestack"
|
class="btn btn-block submit-votestack"
|
||||||
(click)="addVoteStack()"
|
(click)="addVoteStack()"
|
||||||
|
@ -44,6 +44,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
this.poll = newpoll;
|
this.poll = newpoll;
|
||||||
if (newpoll) {
|
if (newpoll) {
|
||||||
this.isArchived = new Date(newpoll.expiracy_date) < new Date();
|
this.isArchived = new Date(newpoll.expiracy_date) < new Date();
|
||||||
|
this.poll.is_archived = this.isArchived;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -161,4 +162,12 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
document.body.removeChild(element);
|
document.body.removeChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duplicate() {
|
||||||
|
alert('TODO');
|
||||||
|
}
|
||||||
|
|
||||||
|
print() {
|
||||||
|
alert('TODO');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
<img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />
|
<img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />
|
||||||
<!-- {{ choice.counts.get(answerEnum.MAYBE) }}-->
|
<!-- {{ choice.counts.get(answerEnum.MAYBE) }}-->
|
||||||
</button>
|
</button>
|
||||||
|
<button class="button is-white" *ngIf="poll.allowed_answers.indexOf('no') !== -1">
|
||||||
|
<img class="image is-24x24" src="../../../assets/img/icon_voter_NO.svg" />
|
||||||
|
<!-- {{ choice.counts.get(answerEnum.MAYBE) }}-->
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,67 +1,76 @@
|
|||||||
<div class="comments" id="comments">
|
<div class="comments padded" id="comments">
|
||||||
<h2 class="margin-top-x7">Laisser un commentaire</h2>
|
<section class="add-comment" *ngIf="!poll.is_archived">
|
||||||
<article class="message">
|
<h2 class="margin-top-x7">Laisser un commentaire</h2>
|
||||||
<div class="message-header">
|
<article class="message">
|
||||||
<div class="field">
|
<div class="message-header">
|
||||||
<span class="control has-icons-left has-icons-right">
|
<div class="field">
|
||||||
<input
|
<span class="control has-icons-left has-icons-right">
|
||||||
type="email"
|
<input
|
||||||
name="cremail"
|
type="email"
|
||||||
id="email_comment"
|
name="cremail"
|
||||||
[(ngModel)]="config.myEmail"
|
id="email_comment"
|
||||||
placeholder="chuck@norris.com"
|
[(ngModel)]="config.myEmail"
|
||||||
required="required"
|
placeholder="chuck@norris.com"
|
||||||
/>
|
required="required"
|
||||||
<span class="icon is-small is-left">
|
/>
|
||||||
<i class="fa fa-envelope"></i>
|
<span class="icon is-small is-left">
|
||||||
|
<i class="fa fa-envelope"></i>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
<span class="control has-icons-left">
|
||||||
<span class="control has-icons-left">
|
<input
|
||||||
<input
|
type="text"
|
||||||
type="text"
|
class="margin-btm-x3"
|
||||||
class="margin-btm-x3"
|
name="crname"
|
||||||
name="crname"
|
[(ngModel)]="config.myName"
|
||||||
[(ngModel)]="config.myName"
|
id="crname"
|
||||||
id="crname"
|
placeholder="pseudo"
|
||||||
placeholder="pseudo"
|
required="required"
|
||||||
required="required"
|
/>
|
||||||
/>
|
<span class="icon is-small is-left">
|
||||||
<span class="icon is-small is-left">
|
<i class="fa fa-user"></i>
|
||||||
<i class="fa fa-user"></i>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</div>
|
||||||
|
|
||||||
|
<!-- <label for="crname"><i class="fa fa-user" aria-hidden="true"></i> Votre nom / pseudo :</label>-->
|
||||||
|
|
||||||
|
<!-- <label for="cremail"><i class="fa fa-envelope" aria-hidden="true"></i> Votre email :</label>-->
|
||||||
</div>
|
</div>
|
||||||
|
<div class="message-body">
|
||||||
|
<label for="comment">Votre commentaire :</label>
|
||||||
|
<br />
|
||||||
|
<textarea name="comment" id="comment" [(ngModel)]="config.myComment"> </textarea>
|
||||||
|
|
||||||
<!-- <label for="crname"><i class="fa fa-user" aria-hidden="true"></i> Votre nom / pseudo :</label>-->
|
<input
|
||||||
|
type="submit"
|
||||||
|
name="add-comment"
|
||||||
|
class="btn btn--primary btn--outline"
|
||||||
|
value="Ajouter mon commentaire ✉️"
|
||||||
|
(click)="addComment()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<div class="message-body" *ngIf="poll.is_archived">
|
||||||
|
⚰️ Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- <label for="cremail"><i class="fa fa-envelope" aria-hidden="true"></i> Votre email :</label>-->
|
<section class="comments-part" *ngIf="poll && poll.comments">
|
||||||
</div>
|
<h2 class="title is-2">
|
||||||
<div class="message-body">
|
<i class="fa fa-comment"></i>
|
||||||
<label for="comment">Votre commentaire :</label>
|
{{ poll.comments.length }} Commentaires
|
||||||
<br />
|
</h2>
|
||||||
<textarea name="comment" id="comment" [(ngModel)]="config.myComment"> </textarea>
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="submit"
|
|
||||||
name="add-comment"
|
|
||||||
class="btn btn--primary btn--outline"
|
|
||||||
value="Ajouter mon commentaire ✉️"
|
|
||||||
(click)="addComment()"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
<div class="comments-part" *ngIf="poll && poll.comments">
|
|
||||||
<h2 class="title is-2">{{ poll.comments.length }} Commentaires</h2>
|
|
||||||
|
|
||||||
<article class="message" *ngFor="let comment of poll.comments">
|
<article class="message" *ngFor="let comment of poll.comments">
|
||||||
<div class="message-header">
|
<div class="message-header">
|
||||||
<p>
|
<p>
|
||||||
<em class="cname"> {{ comment.pseudo }} </em>, le
|
<em class="cname"> {{ comment.pseudo }} </em>,
|
||||||
<span class="date-days-ago">
|
|
||||||
|
<span class="date-days-ago is-small">
|
||||||
il y a
|
il y a
|
||||||
{{ calculateDaysAgoOfComment(comment.owner.created_at) }} jours, le </span
|
{{ calculateDaysAgoOfComment(comment.owner.created_at) }} jours, le </span
|
||||||
><span class="date"> {{ comment.owner.created_at }} </span>
|
><span class="date is-small"> {{ comment.owner.created_at }} </span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-body">
|
<div class="message-body">
|
||||||
@ -70,5 +79,5 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user