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 {
public id: number;
public poll_custom_url: string;
public custom_url: string;
public pass_hash: string;
public pseudo = '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> {
try {
return await this.axiosInstance.post(
`${this.baseHref}${this.commentsEndpoint}/${slug}${this.commentsEndpoint}`,
comment
);
return await this.axiosInstance.post(`${this.baseHref}${this.commentsEndpoint}/${slug}`, comment);
} catch (error) {
ApiService.handleError(error);
}

View File

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

View File

@ -8,7 +8,13 @@
{{ 'owner.name_label' | translate }}
</label>
<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>
<div class="bottom-step-buttons">
<div class="contained-in-main-column">
<button
class="button is-default pull-left"
[routerLink]="['/poll/' + pollService._poll.getValue().custom_url + '/consultation/vote']"
>
{{ 'SENTENCES.Back' | translate }}
</button>
<button
@ -19,4 +25,5 @@
{{ 'participation.vote_button' | translate }}
</button>
</div>
</div>
</div>

View File

@ -37,7 +37,7 @@ export class ConsultationUserComponent implements OnInit {
* create a new vote stack
*/
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.toastService.display('envoi du vote ....');

View File

@ -1,6 +1,6 @@
<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="rounded-block admin-share-link" *ngIf="poll.admin_key || show_admin_stuff">
<h2 class="title is-2">

View File

@ -91,7 +91,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
* create a new vote stack
*/
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.toastService.display('envoi du vote ....');

View File

@ -50,6 +50,12 @@
</div>
<div class="bottom-step-buttons" *ngIf="poll">
<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
class="button-next is-primary pull-right"
[routerLink]="['/poll/' + poll.custom_url + '/consultation/vote/user-infos']"

View File

@ -36,7 +36,7 @@ export class PollResultsDetailedComponent {
* create a new vote stack
*/
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.api
.sendNewVoteStackOfPoll(this.storageService.vote_stack)
@ -55,7 +55,7 @@ export class PollResultsDetailedComponent {
*/
updateVoteStack(): void {
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);
const handlingError = this.api.ousideHandleError;

View File

@ -30,35 +30,3 @@
font-weight: bold;
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 {
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);
const handlingError = this.api.ousideHandleError;
@ -107,7 +107,7 @@ export class ResultsRoundedComponent implements OnInit {
* create a new vote stack
*/
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.toastService.display('envoi du vote ....');

View File

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

View File

@ -302,6 +302,9 @@ mat-checkbox {
.column {
padding-left: 0;
padding-right: 0;
&.is-narrow {
padding-right: 1rem;
}
}
}
}
@ -346,3 +349,41 @@ label {
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;
}
}