bar style, nav buttons in vote

This commit is contained in:
Tykayn 2022-02-11 09:19:34 +01:00 committed by tykayn
parent 0a6531793d
commit e3b9a82928
13 changed files with 82 additions and 63 deletions

View File

@ -3,7 +3,7 @@ import { Owner } from './owner.model';
export class Stack { export class Stack {
public id: number; public id: number;
public poll_custom_url: string; public custom_url: string;
public pass_hash: string; public pass_hash: string;
public pseudo = 'Choque Nourrice'; public pseudo = 'Choque Nourrice';
public comment = 'Le beau commentaire de Choque Nourrice'; public comment = 'Le beau commentaire de Choque Nourrice';

View File

@ -142,10 +142,7 @@ export class ApiService {
public async createComment(slug: string, comment: string): Promise<string> { public async createComment(slug: string, comment: string): Promise<string> {
try { try {
return await this.axiosInstance.post( return await this.axiosInstance.post(`${this.baseHref}${this.commentsEndpoint}/${slug}`, comment);
`${this.baseHref}${this.commentsEndpoint}/${slug}${this.commentsEndpoint}`,
comment
);
} catch (error) { } catch (error) {
ApiService.handleError(error); ApiService.handleError(error);
} }

View File

@ -21,7 +21,6 @@ import { DateUtilitiesService } from './date.utilities.service';
import { Owner } from '../models/owner.model'; import { Owner } from '../models/owner.model';
import { Stack } from '../models/stack.model'; import { Stack } from '../models/stack.model';
import { Vote } from '../models/vote.model'; import { Vote } from '../models/vote.model';
import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs';
import { ClipboardService } from 'ngx-clipboard'; import { ClipboardService } from 'ngx-clipboard';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -211,7 +210,7 @@ export class PollService implements Resolve<Poll> {
} }
const loadedPoll = this._poll.getValue(); const loadedPoll = this._poll.getValue();
if (loadedPoll) { if (loadedPoll) {
this.storageService.vote_stack.poll_custom_url = loadedPoll.custom_url; this.storageService.vote_stack.custom_url = loadedPoll.custom_url;
return loadedPoll; return loadedPoll;
} else { } else {
this.router.navigate(['page-not-found']); this.router.navigate(['page-not-found']);
@ -272,15 +271,15 @@ export class PollService implements Resolve<Poll> {
* update poll and parse its fields * update poll and parse its fields
* @param poll * @param poll
*/ */
public updateCurrentPoll(poll: Poll): Poll { public updateCurrentPoll(poll: Poll, displayToast = false): Poll {
console.log('this.storageService.vote_stack.id', this.storageService.vote_stack.id); console.log('this.storageService.vote_stack.id', this.storageService.vote_stack.id);
// if (!this.storageService.vote_stack.id || this.storageService.vote_stack.poll_custom_url !== poll.custom_url) { // if (!this.storageService.vote_stack.id || this.storageService.vote_stack.custom_url !== poll.custom_url) {
// console.log('set base choices', poll.choices); // console.log('set base choices', poll.choices);
// // set the choices only the first time the poll loads, or if we changed the poll // // set the choices only the first time the poll loads, or if we changed the poll
// console.log( // console.log(
// 'this.storageService.vote_stack.poll_custom_url', // 'this.storageService.vote_stack.custom_url',
// this.storageService.vote_stack.poll_custom_url // this.storageService.vote_stack.custom_url
// ); // );
// this.storageService.setChoicesForVoteStack(poll.choices); // this.storageService.setChoicesForVoteStack(poll.choices);
// } // }
@ -289,8 +288,9 @@ export class PollService implements Resolve<Poll> {
console.log('next poll', poll); console.log('next poll', poll);
this.storageService.setChoicesForVoteStack(poll.choices); this.storageService.setChoicesForVoteStack(poll.choices);
if (displayToast) {
this.toastService.display(`sondage ${poll.title} bien mis à jour`, 'success'); this.toastService.display(`sondage ${poll.title} bien mis à jour`, 'success');
}
return poll; return poll;
} }

View File

@ -8,15 +8,22 @@
{{ 'owner.name_label' | translate }} {{ 'owner.name_label' | translate }}
</label> </label>
<input class="input" type="text" id="pseudo" [(ngModel)]="storageService.vote_stack.pseudo" /> <input class="input" type="text" id="pseudo" [(ngModel)]="storageService.vote_stack.pseudo" />
<button class="button is-default pull-left" [routerLink]="['/poll/' + pollName + '/consultation/vote']"> </div>
{{ 'SENTENCES.Back' | translate }} <div class="bottom-step-buttons">
</button> <div class="contained-in-main-column">
<button <button
class="button is-success pull-right" class="button is-default pull-left"
(click)="sendVoteStack()" [routerLink]="['/poll/' + pollService._poll.getValue().custom_url + '/consultation/vote']"
[disabled]="!storageService.vote_stack.pseudo" >
> {{ 'SENTENCES.Back' | translate }}
{{ 'participation.vote_button' | translate }} </button>
</button> <button
class="button is-success pull-right"
(click)="sendVoteStack()"
[disabled]="!storageService.vote_stack.pseudo"
>
{{ 'participation.vote_button' | translate }}
</button>
</div>
</div> </div>
</div> </div>

View File

@ -37,7 +37,7 @@ export class ConsultationUserComponent implements OnInit {
* create a new vote stack * create a new vote stack
*/ */
addVoteStack(): void { addVoteStack(): void {
this.storageService.vote_stack.poll_custom_url = this.pollService._poll.getValue().custom_url; this.storageService.vote_stack.custom_url = this.pollService._poll.getValue().custom_url;
this.pollService.pass_hash = this.pass_hash; this.pollService.pass_hash = this.pass_hash;
this.toastService.display('envoi du vote ....'); this.toastService.display('envoi du vote ....');

View File

@ -1,6 +1,6 @@
<app-header [linkToHome]="false"></app-header> <app-header [linkToHome]="false"></app-header>
<section class="poll_loaded padded consultation" *ngIf="!fetching && poll"> <section class="poll_loaded padded consultation step" *ngIf="!fetching && poll">
<div class="contained-in-large-column"> <div class="contained-in-large-column">
<div class="rounded-block admin-share-link" *ngIf="poll.admin_key || show_admin_stuff"> <div class="rounded-block admin-share-link" *ngIf="poll.admin_key || show_admin_stuff">
<h2 class="title is-2"> <h2 class="title is-2">

View File

@ -91,7 +91,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
* create a new vote stack * create a new vote stack
*/ */
addVoteStack(): void { addVoteStack(): void {
this.storageService.vote_stack.poll_custom_url = this.poll.custom_url; this.storageService.vote_stack.custom_url = this.poll.custom_url;
this.pollService.pass_hash = this.pass_hash; this.pollService.pass_hash = this.pass_hash;
this.toastService.display('envoi du vote ....'); this.toastService.display('envoi du vote ....');

View File

@ -50,6 +50,12 @@
</div> </div>
<div class="bottom-step-buttons" *ngIf="poll"> <div class="bottom-step-buttons" *ngIf="poll">
<div class="contained-in-main-column"> <div class="contained-in-main-column">
<button
class="button is-default pull-left"
[routerLink]="['/poll/' + pollService._poll.getValue().custom_url + '/consultation']"
>
{{ 'SENTENCES.Back' | translate }}
</button>
<button <button
class="button-next is-primary pull-right" class="button-next is-primary pull-right"
[routerLink]="['/poll/' + poll.custom_url + '/consultation/vote/user-infos']" [routerLink]="['/poll/' + poll.custom_url + '/consultation/vote/user-infos']"

View File

@ -36,7 +36,7 @@ export class PollResultsDetailedComponent {
* create a new vote stack * create a new vote stack
*/ */
addVoteStack(): void { addVoteStack(): void {
this.storageService.vote_stack.poll_custom_url = this.poll.custom_url; this.storageService.vote_stack.custom_url = this.poll.custom_url;
this.toastService.display('envoi du vote ....'); this.toastService.display('envoi du vote ....');
this.api this.api
.sendNewVoteStackOfPoll(this.storageService.vote_stack) .sendNewVoteStackOfPoll(this.storageService.vote_stack)
@ -55,7 +55,7 @@ export class PollResultsDetailedComponent {
*/ */
updateVoteStack(): void { updateVoteStack(): void {
const vote_stack = this.storageService.vote_stack; const vote_stack = this.storageService.vote_stack;
vote_stack.poll_custom_url = this.poll.custom_url; vote_stack.custom_url = this.poll.custom_url;
console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes); console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes);
const handlingError = this.api.ousideHandleError; const handlingError = this.api.ousideHandleError;

View File

@ -30,35 +30,3 @@
font-weight: bold; font-weight: bold;
margin-bottom: 1.25rem; margin-bottom: 1.25rem;
} }
.choice-bars-display {
.is-narrow {
width: 5em;
text-align: right;
padding-right: 1em;
}
.bar {
}
}
.bar-div {
padding: 0.25rem 0.025rem;
text-align: center;
border-radius: 0.25rem;
}
div {
&.has-background-yes {
border: #128149;
background: #ecfff5;
@extend .bar-div;
}
&.has-background-maybe {
border: #86671b;
background: #fffaec;
@extend .bar-div;
}
&.has-background-no {
border: #d51b38;
background: #ffecee;
@extend .bar-div;
}
}

View File

@ -88,7 +88,7 @@ export class ResultsRoundedComponent implements OnInit {
*/ */
updateVoteStack(): void { updateVoteStack(): void {
const vote_stack = this.storageService.vote_stack; const vote_stack = this.storageService.vote_stack;
vote_stack.poll_custom_url = this.poll.custom_url; vote_stack.custom_url = this.poll.custom_url;
console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes); console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes);
const handlingError = this.api.ousideHandleError; const handlingError = this.api.ousideHandleError;
@ -107,7 +107,7 @@ export class ResultsRoundedComponent implements OnInit {
* create a new vote stack * create a new vote stack
*/ */
addVoteStack(): void { addVoteStack(): void {
this.storageService.vote_stack.poll_custom_url = this.poll.custom_url; this.storageService.vote_stack.custom_url = this.poll.custom_url;
this.pollService.pass_hash = this.pass_hash; this.pollService.pass_hash = this.pass_hash;
this.toastService.display('envoi du vote ....'); this.toastService.display('envoi du vote ....');

View File

@ -33,7 +33,7 @@ export const endpoints = {
name: '/choices', name: '/choices',
}, },
comments: { comments: {
name: '/comment', name: '/comment/poll',
}, },
slugs: { slugs: {
name: '/slugs', name: '/slugs',

View File

@ -302,6 +302,9 @@ mat-checkbox {
.column { .column {
padding-left: 0; padding-left: 0;
padding-right: 0; padding-right: 0;
&.is-narrow {
padding-right: 1rem;
}
} }
} }
} }
@ -346,3 +349,41 @@ label {
top: 0; top: 0;
} }
} }
.choice-bars-display {
.is-narrow {
width: 5em;
text-align: right;
padding-right: 1em;
}
.bar {
}
}
.bar-div {
padding: 0.25rem 0.025rem;
text-align: center;
border-radius: 0.25rem;
max-width: 100%;
}
div {
&.has-background-yes {
border: solid 1px #128149;
background: #ecfff5;
color: #128149;
@extend .bar-div;
}
&.has-background-maybe {
border: solid 1px #86671b;
background: #fffaec;
color: #86671b;
@extend .bar-div;
}
&.has-background-no {
border: solid 1px #d51b38;
background: #ffecee;
color: #d51b38;
@extend .bar-div;
}
}