toast todo things

This commit is contained in:
Baptiste Lemoine 2020-01-16 15:35:11 +01:00
parent 113609e945
commit 7b790e3cdc
16 changed files with 2603 additions and 2478 deletions

4580
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@
"@angular/language-service": "~8.2.14", "@angular/language-service": "~8.2.14",
"@types/jasmine": "~3.3.8", "@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.8", "@types/jasminewd2": "~2.0.8",
"@types/node": "~8.9.4", "@types/node": "^13.1.7",
"codelyzer": "^5.2.1", "codelyzer": "^5.2.1",
"jasmine-core": "~3.4.0", "jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",

View File

@ -41,16 +41,21 @@
<option value="en" >English</option > <option value="en" >English</option >
<option value="fr" >Français</option > <option value="fr" >Français</option >
</select > </select >
<span (click)="toggleMenu()" class="menu_label">Menu</span> <span
(click)="toggleMenu()"
class="menu_label" >Menu</span >
</div > </div >
</div > </div >
</header > </header >
<framadate-navigation *ngIf="menuVisible" [step]="step"></framadate-navigation>
<main > <main >
<router-outlet ></router-outlet > <router-outlet ></router-outlet >
</main > </main >
<framadate-debugger ></framadate-debugger > <framadate-debugger ></framadate-debugger >
<framadate-navigation
*ngIf="menuVisible"
[step]="step" ></framadate-navigation >
<p-toast position="top-right" ></p-toast > <p-toast position="top-right" ></p-toast >

View File

@ -31,15 +31,18 @@ export const defaultDates = [
]; ];
export const defaultAnswers = [{ export const defaultAnswers = [{
id: 0, id: 0,
text: 'réponse de démo 1' text: 'réponse de démo 1',
pictureUrl: '',
}, },
{ {
id: 1, id: 1,
text: 'réponse 2' text: 'réponse 2',
pictureUrl: '',
}, },
{ {
id: 2, id: 2,
text: 'la réponse D' text: 'la réponse D',
pictureUrl: '',
}]; }];
/** /**
@ -54,6 +57,7 @@ export class PollConfig {
title = 'titre'; title = 'titre';
description = 'ma description'; description = 'ma description';
myName = 'mon pseudo'; myName = 'mon pseudo';
myComment = 'wouah trop bien framadate!';
myEmail: string = ""; myEmail: string = "";
// date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates // date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates
allowSeveralHours = 'false'; allowSeveralHours = 'false';

View File

@ -39,10 +39,14 @@
> >
get my polls get my polls
</button > </button >
<button class="btn btn--success" (click)="launchToast()"> <button
class="btn btn--success"
(click)="launchToast()" >
launch success toast launch success toast
</button > </button >
<a [routerLink]="'/vote/poll/id/3'" class="btn btn--success"> <a
[routerLink]="'/vote/poll/id/3'"
class="btn btn--success" >
See example of vote page See example of vote page
</a > </a >
</div > </div >

View File

@ -3,22 +3,36 @@
Choisir les propositions Choisir les propositions
</h1 > </h1 >
<p class="subtitle" i18n> <p
Vous pouvez utiliser la syntaxe markdown class="subtitle"
i18n >
Vous pouvez utiliser la syntaxe markdown, et naviguer entre les inputs avec les flèches du clavier.
</p > </p >
<ol > <ol >
<li #answers *ngFor="let answer of config.answers; index as i;trackBy trackFunction" <li
#answers
*ngFor="let answer of config.answers; index as i;trackBy trackFunction"
class="answer-item" > class="answer-item" >
<button
class='btn btn--default'
title='ajouter une image'
(click)='showModalForPictureOfAnswer(answer)' >
<i class='fa fa-image' ></i >
</button >
<input <input
type="name" type="name"
class="answer" class="answer"
id='answer_{{answer.id}}'
[(ngModel)]="answer.text" [(ngModel)]="answer.text"
(keyup.enter)="addAnswer()" (keyup.enter)="addAnswer()"
(keyup)="navigateOrDelete($event,i)" (keyup)="navigateOrDelete($event,i)"
placeholder="réponse" placeholder="réponse"
> >
<button class="btn btn--alert" (click)="config.answers.splice(i,1)">X</button> <button
class="btn btn--alert"
(click)="config.answers.splice(i,1)" >X
</button >
</li > </li >
</ol > </ol >
@ -37,7 +51,10 @@
> >
Voyons ce que ça donne Voyons ce que ça donne
</button > </button >
<a class="prev" i18n> <br >
<a
class="prev"
i18n >
Retour Retour
</a > </a >
</div > </div >

View File

@ -64,4 +64,9 @@ export class AnswersComponent extends BaseComponent implements OnInit, AfterView
this.focusOnAnswer(i + 1); this.focusOnAnswer(i + 1);
} }
} }
showModalForPictureOfAnswer(answer) {
// TODO
this.config.todo();
}
} }

View File

@ -11,7 +11,7 @@ import {ConfigService} from '../../services/config.service';
*/ */
export class BaseComponent implements OnInit { export class BaseComponent implements OnInit {
constructor(config: ConfigService) { constructor(private config: ConfigService) {
} }
ngOnInit() { ngOnInit() {
@ -20,11 +20,13 @@ export class BaseComponent implements OnInit {
checkValidity() { checkValidity() {
// TODO with form controls // TODO with form controls
this.config.todo();
return true; return true;
} }
displayErrorMessage() { displayErrorMessage() {
// TODO // TODO
this.config.todo();
return true; return true;
} }
} }

View File

@ -9,39 +9,89 @@
{{pollConfigFetched.choices_count}} choix, {{pollConfigFetched.choices_count}} choix,
</p > </p >
</div > </div >
<section class="row name"> <section class="name" >
<label for="name" >Votre nom :</label > <label for="name" >Votre nom :</label >
<input type="text" name="name" id="name" [(ngModel)]="config.myName"> <input
type="text"
name="name"
id="name"
[(ngModel)]="config.myName" >
</section > </section >
<div class="list-of-choices" > <div class="list-of-choices" >
<div *ngFor="let choice of pollConfigFetched.choices" > <div *ngFor="let choice of pollConfigFetched.choices" >
<framadate-vote-choice [choice]="choice" ></framadate-vote-choice > <framadate-vote-choice [choice]="choice" ></framadate-vote-choice >
</div > </div >
</div > </div >
<button
class='btn btn--primary btn-block'
(click)='config.addVote()' >
<i class='fa fa-paper-plane' ></i > Envoyer
</button >
<framadate-voting-graph ></framadate-voting-graph > <framadate-voting-graph ></framadate-voting-graph >
<framadate-voting-summary ></framadate-voting-summary > <framadate-voting-summary ></framadate-voting-summary >
<div class="comments" > <div class="comments" >
<h2 class="margin-top-x7" >Laisser un commentaire</h2 > <h2 class="margin-top-x7" >Laisser un commentaire</h2 >
<label for="crname" >Votre nom :</label > <label for="crname" >Votre nom :</label >
<input type="text" class="margin-btm-x3" name="crname" id="crname"> <input
type="text"
class="margin-btm-x3"
name="crname"
[(ngModel)]='config.myName'
id="crname" >
<div > <div >
<label for="comment" >Votre commentaire :</label > <label for="comment" >Votre commentaire :</label >
<textarea name="comment" id="comment"> <br >
<textarea
name="comment"
id="comment"
[(ngModel)]='config.myComment'
>
</textarea > </textarea >
</div > </div >
<input type="submit" name="add-comment" class="btn btn--primary btn--outline" value="Ajouter mon commentaire"> <input
<framadate-voting-comment [comment]="c" *ngFor="let c of comments"></framadate-voting-comment> type="submit"
name="add-comment"
class="btn btn--primary btn--outline"
value="Ajouter mon commentaire"
(click)='config.addComment()' >
<framadate-voting-comment
[comment]="c"
*ngFor="let c of comments" >
</framadate-voting-comment >
</div > </div >
<div class="sharing" > <div class="sharing" >
<h3 class="margin-top-x8">Partager le sondage</h3> <h3 class="margin-top-x8" >Partager le sondage
<label class="nobold text-14" for="copyLink">Pour partager le sondage, vous pouvez diffuser ce lien :
<code> <i class='fa fa-share' ></i ></h3 >
{{config.urlAdmin}} <p
</code> class="nobold text-14"
</label> for="copyLink" >Pour partager le sondage, vous pouvez diffuser ce lien :
<input type="submit" name="copy-link" class=" btn btn--primary btn--outline" value="Copier le lien" id="copyLink"> <a href='{{config.urlPublic}}' >
<h3 class="margin-top-x6 margin-btm-x3">Exporter/Imprimer</h3> {{config.urlPublic}}
<input type="submit" name="export" class="margin-btm-x3 btn btn--primary btn--outline" value="Exporter en .csv" (click)="exportCSV()"> </a >
<input type="submit" name="copy-link" class="btn btn--primary btn--outline" value="Imprimer le sondage"> </p >
<button
class=" btn btn--primary btn--outline"
[ngxClipboard]
[cbContent]="config.urlPublic"
id="copyLink" >
<i class='fa fa-copy' ></i >
{{"admin.copy_link" |translate}}
</button >
<h3 class="margin-top-x6 margin-btm-x3" >
Exporter/Imprimer
</h3 >
<input
type="submit"
name="export"
class="margin-btm-x3 btn btn--primary btn--outline"
value="Exporter en .csv"
(click)="config.exportCSV()" >
<input
type="submit"
name="copy-link"
class="btn btn--primary btn--outline"
value="Imprimer le sondage"
(click)="config.print()" >
</div > </div >

View File

@ -23,7 +23,4 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
// store it in the poll property here // store it in the poll property here
} }
exportCSV() {
// TODO
}
} }

View File

@ -185,7 +185,6 @@ export class ConfigService extends PollConfig {
* @param err * @param err
*/ */
handleError(err: any) { handleError(err: any) {
// TODO handle a toast message
console.error('err', err); console.error('err', err);
this.loading = false; this.loading = false;
this.messageService.add({severity: 'warning', summary: "Erreur lors de l'appel ", detail: err.message}); this.messageService.add({severity: 'warning', summary: "Erreur lors de l'appel ", detail: err.message});
@ -294,7 +293,13 @@ export class ConfigService extends PollConfig {
* /api/v1/poll/{id}/vote * /api/v1/poll/{id}/vote
* @param voteStack * @param voteStack
*/ */
addVote(voteStack: any) { addVote(voteStack?: any) {
if (!voteStack) {
voteStack = {
pseudo: this.myName,
answers: this.answers
}
}
this.http.post( this.http.post(
`${this.baseHref}/poll/${this.pollId}/vote`, `${this.baseHref}/poll/${this.pollId}/vote`,
voteStack, voteStack,
@ -334,7 +339,13 @@ export class ConfigService extends PollConfig {
* /api/v1/poll/{id}/comment * /api/v1/poll/{id}/comment
* @param comment * @param comment
*/ */
addComment(comment: any) { addComment(comment?: any) {
if (!comment) {
comment = {
pseudo: this.myName,
comment: this.myComment,
}
}
this.http.post( this.http.post(
`${this.baseHref}/poll/${this.pollId}/comment`, `${this.baseHref}/poll/${this.pollId}/comment`,
comment, comment,
@ -345,6 +356,8 @@ export class ConfigService extends PollConfig {
summary: 'Commentaire Créé', summary: 'Commentaire Créé',
detail: 'Via MessageService' detail: 'Via MessageService'
}); });
// empty comment after success
this.myComment = '';
}, (e) => { }, (e) => {
this.handleError(e) this.handleError(e)
} }
@ -456,4 +469,38 @@ export class ConfigService extends PollConfig {
} }
); );
} }
/**
* export all the poll data available to the public as a CSV single file
*/
exportCSV() {
// TODO
const rows = [
["name1", "city1", "some other info"],
["name2", "city2", "more info"]
];
let csvContent = "data:text/csv;charset=utf-8,"
+ rows.map(e => e.join(",")).join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", this.makeSlug() + "_export_" + new Date() + ".csv");
document.body.appendChild(link); // Required for FF
this.todo();
link.click(); // This will download the data file named "my_data.csv".
}
print() {
alert('TODO');
}
todo() {
this.messageService.add({
severity: 'info',
detail: "cette fonctionnalité n'est pas encore disponible. Venez en discuter sur framateam.org / Ux et design libre / Framasoft",
summary: "Work in progress",
});
}
} }

View File

@ -164,3 +164,8 @@ select, input, textarea {
color: $primary_color; color: $primary_color;
} }
} }
.btn-block {
display: block;
width: 100%;
}

View File

@ -2,7 +2,12 @@
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./out-tsc/app", "outDir": "./out-tsc/app",
"types": [] "types": [
"node"
],
"typeRoots": [
"./node_modules/@types"
]
}, },
"files": [ "files": [
"src/main.ts", "src/main.ts",

View File

@ -1,5 +1,6 @@
{ {
"compileOnSave": false, "compileOnSave": false,
"node": true,
"compilerOptions": { "compilerOptions": {
"baseUrl": "./", "baseUrl": "./",
"outDir": "./dist/out-tsc", "outDir": "./dist/out-tsc",
@ -11,6 +12,9 @@
"moduleResolution": "node", "moduleResolution": "node",
"importHelpers": true, "importHelpers": true,
"target": "es2018", "target": "es2018",
"types": [
"node"
],
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types"
], ],

View File

@ -1187,10 +1187,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.4.tgz#64db61e0359eb5a8d99b55e05c729f130a678b04" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.4.tgz#64db61e0359eb5a8d99b55e05c729f130a678b04"
integrity sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ== integrity sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ==
"@types/node@~8.9.4": "@types/node@^13.1.7":
version "8.9.5" version "13.1.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.9.5.tgz#162b864bc70be077e6db212b322754917929e976" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.7.tgz#db51d28b8dfacfe4fb2d0da88f5eb0a2eca00675"
integrity sha512-jRHfWsvyMtXdbhnz5CVHxaBgnV6duZnPlQuRSo/dm/GnmikNcmZhxIES4E9OZjUmQ8C+HCl4KJux+cXN/ErGDQ== integrity sha512-HU0q9GXazqiKwviVxg9SI/+t/nAsGkvLDkIdxz+ObejG2nX6Si00TeLqHMoS+a/1tjH7a8YpKVQwtgHuMQsldg==
"@types/q@^0.0.32": "@types/q@^0.0.32":
version "0.0.32" version "0.0.32"