mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
better mix on creation of poll
This commit is contained in:
parent
9a013f6d2c
commit
d40aa6a3ae
@ -20,6 +20,7 @@ export class Poll {
|
|||||||
public kind: string;
|
public kind: string;
|
||||||
|
|
||||||
public description?: string;
|
public description?: string;
|
||||||
|
public password?: string;
|
||||||
|
|
||||||
public expiracy_date?: string;
|
public expiracy_date?: string;
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ export class Poll {
|
|||||||
public is_archived?: boolean;
|
public is_archived?: boolean;
|
||||||
public is_zero_knowledge?: boolean = false;
|
public is_zero_knowledge?: boolean = false;
|
||||||
public allow_comments?: boolean = true;
|
public allow_comments?: boolean = true;
|
||||||
|
public allowComments?: boolean = true;
|
||||||
public has_several_hours?: boolean = false;
|
public has_several_hours?: boolean = false;
|
||||||
|
|
||||||
public allowSeveralHours?: boolean;
|
public allowSeveralHours?: boolean;
|
||||||
@ -41,8 +43,9 @@ export class Poll {
|
|||||||
public max_score?: number;
|
public max_score?: number;
|
||||||
|
|
||||||
public max_count_of_answers?: number = 150;
|
public max_count_of_answers?: number = 150;
|
||||||
|
public maxCountOfAnswers?: number = 150;
|
||||||
|
|
||||||
public configuration: PollConfiguration = new PollConfiguration();
|
// public configuration: PollConfiguration = new PollConfiguration();
|
||||||
|
|
||||||
public comments: Comment[] = [];
|
public comments: Comment[] = [];
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { TimeSlices } from '../../../../mocks/old-stuff/config/defaultConfigs';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -93,6 +92,7 @@ export class PollService implements Resolve<Poll> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loadPollBycustom_urlWithPasswordHash(custom_url: string, hash: string): Promise<void> {
|
public async loadPollBycustom_urlWithPasswordHash(custom_url: string, hash: string): Promise<void> {
|
||||||
console.log('custom_url', custom_url);
|
console.log('custom_url', custom_url);
|
||||||
if (custom_url) {
|
if (custom_url) {
|
||||||
@ -107,9 +107,6 @@ export class PollService implements Resolve<Poll> {
|
|||||||
* @param poll
|
* @param poll
|
||||||
*/
|
*/
|
||||||
public updateCurrentPoll(poll: Poll): void {
|
public updateCurrentPoll(poll: Poll): void {
|
||||||
if (poll.kind == 'date') {
|
|
||||||
poll.choices = this.parseDateChoices(poll.choices);
|
|
||||||
}
|
|
||||||
this.storageService.setChoicesForVoteStack(poll.choices);
|
this.storageService.setChoicesForVoteStack(poll.choices);
|
||||||
|
|
||||||
this.toastService.display('sondage bien mis à jour', 'success');
|
this.toastService.display('sondage bien mis à jour', 'success');
|
||||||
@ -120,21 +117,22 @@ export class PollService implements Resolve<Poll> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* make a uniq custom_url for the current poll creation
|
* make a uniq custom_url for the current poll creation
|
||||||
* @param config
|
* @param poll
|
||||||
*/
|
*/
|
||||||
makecustom_url(config: Poll): string {
|
makecustom_url(poll: Poll): string {
|
||||||
console.log('config', config);
|
console.log('config', poll);
|
||||||
let str = '';
|
let str = '';
|
||||||
|
const creation_date = new Date(poll.creation_date);
|
||||||
str =
|
str =
|
||||||
config.configuration.dateCreated.getFullYear() +
|
creation_date.getFullYear() +
|
||||||
'_' +
|
'_' +
|
||||||
(config.configuration.dateCreated.getMonth() + 1) +
|
(creation_date.getMonth() + 1) +
|
||||||
'_' +
|
'_' +
|
||||||
config.configuration.dateCreated.getDate() +
|
creation_date.getDate() +
|
||||||
'_' +
|
'_' +
|
||||||
config.owner.pseudo +
|
poll.owner.pseudo +
|
||||||
'_' +
|
'_' +
|
||||||
config.title;
|
poll.title;
|
||||||
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
|
|
||||||
@ -205,11 +203,21 @@ export class PollService implements Resolve<Poll> {
|
|||||||
const pollKeys = Object.keys(newpoll);
|
const pollKeys = Object.keys(newpoll);
|
||||||
const formFields = Object.keys(form.value);
|
const formFields = Object.keys(form.value);
|
||||||
|
|
||||||
for (const fieldOfForm of formFields) {
|
console.log('pollKeys, formFields', pollKeys, formFields);
|
||||||
if (pollKeys.indexOf(fieldOfForm) !== -1) {
|
|
||||||
newpoll[fieldOfForm] = form.value[fieldOfForm];
|
for (const pk of pollKeys) {
|
||||||
|
if (formFields.indexOf(pk) !== -1) {
|
||||||
|
newpoll[pk] = form.value[pk];
|
||||||
|
} else {
|
||||||
|
console.log('manque pollKey', pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
newpoll.description = form.value.description;
|
||||||
|
newpoll.max_count_of_answers = form.value.allowComments;
|
||||||
|
newpoll.maxCountOfAnswers = form.value.maxCountOfAnswers;
|
||||||
|
newpoll.password = form.value.password;
|
||||||
|
newpoll.kind = form.value.kind;
|
||||||
|
newpoll.allow_comments = form.value.allowComments;
|
||||||
newpoll.dateChoices = this.storageService.dateList;
|
newpoll.dateChoices = this.storageService.dateList;
|
||||||
newpoll.timeSlices = this.storageService.timeSlices;
|
newpoll.timeSlices = this.storageService.timeSlices;
|
||||||
|
|
||||||
@ -217,20 +225,26 @@ export class PollService implements Resolve<Poll> {
|
|||||||
return newpoll;
|
return newpoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public getAdministrationUrl(): string {
|
||||||
* regrouper les jours et périodes de temps
|
let url = '';
|
||||||
* @param choices
|
if (this._poll && this._poll.getValue) {
|
||||||
*/
|
const polltemp = this._poll.getValue();
|
||||||
public parseDateChoices(choices: Choice[]) {
|
if (polltemp) {
|
||||||
console.log('choices before', choices);
|
url = `${environment.frontDomain}#/poll/admin/${polltemp.admin_key}`;
|
||||||
return choices;
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAdministrationUrl(): string {
|
|
||||||
return `${environment.frontDomain}#/poll/admin/${this._poll.getValue().admin_key}`;
|
|
||||||
}
|
|
||||||
public getParticipationUrl(): string {
|
public getParticipationUrl(): string {
|
||||||
|
let url = '';
|
||||||
|
if (this._poll && this._poll.getValue) {
|
||||||
|
const polltemp = this._poll.getValue();
|
||||||
|
if (polltemp) {
|
||||||
|
url = `${environment.frontDomain}#/poll/${polltemp.custom_url}/consultation`;
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO handle pass access
|
// TODO handle pass access
|
||||||
return `${environment.frontDomain}#/poll/${this._poll.getValue().custom_url}/consultation`;
|
return url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,4 @@ export class StorageService {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseDateChoices(datechoices) {
|
|
||||||
const choices: Choice[] = [];
|
|
||||||
|
|
||||||
return choices;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
custom url:
|
||||||
|
{{ form.value.custom_url }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
@ -115,13 +115,16 @@ export class FormComponent implements OnInit {
|
|||||||
isAboutDate: true,
|
isAboutDate: true,
|
||||||
// hasSeveralHours: true,
|
// hasSeveralHours: true,
|
||||||
kind: 'date',
|
kind: 'date',
|
||||||
|
password: '',
|
||||||
whoCanChangeAnswers: 'everybody',
|
whoCanChangeAnswers: 'everybody',
|
||||||
isProtectedByPassword: false,
|
isProtectedByPassword: false,
|
||||||
isOwnerNotifiedByEmailOnNewVote: false,
|
isOwnerNotifiedByEmailOnNewVote: false,
|
||||||
isOwnerNotifiedByEmailOnNewComment: false,
|
isOwnerNotifiedByEmailOnNewComment: false,
|
||||||
isMaybeAnswerAvailable: false,
|
isMaybeAnswerAvailable: false,
|
||||||
areResultsPublic: true,
|
areResultsPublic: true,
|
||||||
|
allowComments: true,
|
||||||
expiresDaysDelay: 60,
|
expiresDaysDelay: 60,
|
||||||
|
maxCountOfAnswers: 150,
|
||||||
comments: [],
|
comments: [],
|
||||||
choices: [
|
choices: [
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,6 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
if (resp) {
|
if (resp) {
|
||||||
const response: Promise<Poll | undefined> = this.api.getPollByCustomUrl(this.poll.custom_url);
|
const response: Promise<Poll | undefined> = this.api.getPollByCustomUrl(this.poll.custom_url);
|
||||||
response.then((res: Poll | undefined) => {
|
response.then((res: Poll | undefined) => {
|
||||||
res.choices = this.pollService.parseDateChoices(res.choices);
|
|
||||||
this.pollService._poll.next(res);
|
this.pollService._poll.next(res);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user