fixes for building in prod

This commit is contained in:
Tykayn 2021-04-27 13:04:32 +02:00 committed by tykayn
parent 729dac9599
commit 7a0061eeb1
9 changed files with 15 additions and 51 deletions

View File

@ -8,6 +8,9 @@ export class Choice {
public score: number; public score: number;
public enabled: boolean; public enabled: boolean;
public url?: string; public url?: string;
public yes?: any;
public no?: any;
public maybe?: any;
constructor( constructor(
public participants: Map<Answer, Set<User>> = new Map<Answer, Set<User>>([ public participants: Map<Answer, Set<User>> = new Map<Answer, Set<User>>([

View File

@ -44,7 +44,7 @@ export class Poll {
public allowed_answers = []; public allowed_answers = [];
public modification_policy = []; public modification_policy = 'everybody';
public dateChoices: Choice[] = []; public dateChoices: Choice[] = [];
// sets of days as strings, config to set identical time for days in a special days poll // sets of days as strings, config to set identical time for days in a special days poll

View File

@ -1,10 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { UserRole } from '../enums/user-role.enum';
import { Choice } from '../models/choice.model';
import { Poll } from '../models/poll.model'; import { Poll } from '../models/poll.model';
import { User } from '../models/user.model';
import { ApiService } from './api.service'; import { ApiService } from './api.service';
import { UserService } from './user.service'; import { UserService } from './user.service';
import { UuidService } from './uuid.service'; import { UuidService } from './uuid.service';
@ -18,38 +14,7 @@ export class MockingService {
constructor(private apiService: ApiService, private userService: UserService, private uuidService: UuidService) {} constructor(private apiService: ApiService, private userService: UserService, private uuidService: UuidService) {}
public async init(): Promise<void> { public async init(): Promise<void> {}
const pollsAvailable = await this.apiService.getAllAvailablePolls();
this._pollsAvailables.next(pollsAvailable);
if (this._pollsAvailables.getValue() && this._pollsAvailables.getValue().length > 0) { public loadMock(): void {}
// arbitrary choose first owner available
const currentUser = this._pollsAvailables.getValue()[0].owner;
currentUser.polls = [this._pollsAvailables.getValue()[0]];
this.userService.updateUser(currentUser);
} else {
this.loadMock();
}
}
public loadMock(): void {
const owner = new User('TOTO', 'toto@gafam.com', [], UserRole.REGISTERED);
const poll1: Poll = new Poll(owner, this.uuidService.getUUID(), 'Quand le picnic ?', 'Pour faire la teuf');
const poll2: Poll = new Poll(
owner,
this.uuidService.getUUID(),
'On fait quoi à la soirée ?',
'Balancez vos idées'
);
poll1.choices = [new Choice('mardi prochain'), new Choice('mercredi')];
poll2.choices = [new Choice('jeux'), new Choice('danser'), new Choice('discuter en picolant')];
this._pollsAvailables.next([poll1, poll2]);
owner.polls = [poll1, poll2];
this.userService.updateUser(owner);
console.info('MOCKING user', { user: owner });
}
} }

View File

@ -105,7 +105,6 @@
<a [href]="'/vote/poll/slug/' + config.customUrl"> <a [href]="'/vote/poll/slug/' + config.customUrl">
{{ '/vote/poll/slug/' + config.customUrl }} {{ '/vote/poll/slug/' + config.customUrl }}
</a> </a>
<app-copy-text [textToCopy]="config.urlPublic"></app-copy-text>
</div> </div>
<br /> <br />
<label for="passwordAccess"> <label for="passwordAccess">

View File

@ -21,7 +21,7 @@ export class VisibilityComponent extends BaseComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.config.customUrl = this.utils.makeSlug(this.config); this.config.customUrl = 'un slug';
this.config.expirationDate = this.config this.config.expirationDate = this.config
.addDaysToDate(this.config.expiracyDateDefaultInDays, new Date()) .addDaysToDate(this.config.expiracyDateDefaultInDays, new Date())
.toISOString() .toISOString()

View File

@ -97,7 +97,7 @@ export class ConfigService extends PollConfig {
// TODO: http requests moved to apiService // TODO: http requests moved to apiService
this.customUrlIsUnique = null; this.customUrlIsUnique = null;
if (!slug) { if (!slug) {
slug = this.utils.makeSlug(this); slug = 'un slug';
} }
this.loading = true; this.loading = true;
@ -472,6 +472,8 @@ export class ConfigService extends PollConfig {
this.toastService.display(`this poll is not administrable, it has no ID`); this.toastService.display(`this poll is not administrable, it has no ID`);
return; return;
} }
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this; const self = this;
// prompt for confirmation // prompt for confirmation
this.confirmationService.confirm({ this.confirmationService.confirm({
@ -570,8 +572,7 @@ export class ConfigService extends PollConfig {
const encodedUri = encodeURI(csvContent); const encodedUri = encodeURI(csvContent);
const link = document.createElement('a'); const link = document.createElement('a');
link.setAttribute('href', encodedUri); link.setAttribute('href', encodedUri);
const exportFileName = const exportFileName = this.urlPublic ? this.urlPublic : 'un_slug' + '_export_' + new Date() + '.csv';
(this.urlPublic ? this.urlPublic : this.utils.makeSlug(this)) + '_export_' + new Date() + '.csv';
link.setAttribute('download', exportFileName); link.setAttribute('download', exportFileName);
document.body.appendChild(link); // Required for FF document.body.appendChild(link); // Required for FF
link.click(); // This will download the data file named "my_data.csv". link.click(); // This will download the data file named "my_data.csv".

View File

@ -1,7 +1,7 @@
<div class="box"> <div class="box">
<div class="columns is-vcentered"> <div class="columns is-vcentered">
<div class="column"> <div class="column">
<label class="label">{{ choice.label }}</label> <label class="label">{{ choice.name }}</label>
</div> </div>
<div class="column"> <div class="column">
<div class="buttons has-addons is-centered"> <div class="buttons has-addons is-centered">

View File

@ -14,17 +14,15 @@ import { ChoiceDetailsComponent } from '../../../shared/components/choice-detail
templateUrl: './add-answer.component.html', templateUrl: './add-answer.component.html',
styleUrls: ['./add-answer.component.scss'], styleUrls: ['./add-answer.component.scss'],
}) })
export class AddAnswerComponent implements OnInit { export class AddAnswerComponent {
@Input() user: User; @Input() user: User;
@Input() poll: Poll; @Input() poll: Poll;
@Input() choice: Choice; @Input() choice: Choice;
public answerEnum = Answer; public answerEnum = Answer;
public answer: Answer; public answer: any;
constructor(private pollService: PollService, private modalService: ModalService) {} constructor(private pollService: PollService, private modalService: ModalService) {}
ngOnInit(): void {}
public openModal(choice: Choice): void { public openModal(choice: Choice): void {
const config: MatDialogConfig<Choice> = { data: choice }; const config: MatDialogConfig<Choice> = { data: choice };
this.modalService.openModal<ChoiceDetailsComponent, Choice>(ChoiceDetailsComponent, config); this.modalService.openModal<ChoiceDetailsComponent, Choice>(ChoiceDetailsComponent, config);

View File

@ -3,9 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ParticipationComponent } from './participation.component'; import { ParticipationComponent } from './participation.component';
const routes: Routes = [ const routes: Routes = [{ path: '', component: ParticipationComponent }];
{ path: '', component: ParticipationComponent },
];
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],