diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index f64693f1..d4be77a8 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -2,6 +2,7 @@ import { Choice, ChoiceGroup } from './choice.model'; import { Comment } from './comment.model'; import { Owner } from './owner.model'; import { DateChoice, TimeSlices } from './dateChoice.model'; +import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs'; export class Poll { public id = 0; @@ -53,13 +54,13 @@ export class Poll { public stacks = []; - public allowed_answers = []; + public allowed_answers = ['yes']; public modification_policy = 'everybody'; public dateChoices: DateChoice[] = []; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll - public timeSlices: TimeSlices[] = []; // ranges of time expressed as strings + public timeSlices: TimeSlices[] = Object.create(defaultTimeOfDay); // ranges of time expressed as strings constructor(public owner: Owner = new Owner(), public title = 'mon titre', public custom_url: string = '') {} } diff --git a/src/app/core/services/date.utilities.service.ts b/src/app/core/services/date.utilities.service.ts index 0b3f2ba7..0f5a52a2 100644 --- a/src/app/core/services/date.utilities.service.ts +++ b/src/app/core/services/date.utilities.service.ts @@ -96,10 +96,12 @@ export class DateUtilitiesService { */ makeDefaultDateChoices(): DateChoice[] { const today = new Date(); - const ladate = this.addDaysToDate(1, today); - const ladate2 = this.addDaysToDate(2, today); - const ladate3 = this.addDaysToDate(3, today); - const ladate4 = this.addDaysToDate(4, today); + const ladate = this.addDaysToDate(0, today); + const ladate2 = this.addDaysToDate(1, today); + const ladate3 = this.addDaysToDate(2, today); + const ladate4 = this.addDaysToDate(3, today); + const ladate5 = this.addDaysToDate(4, today); + const ladate6 = this.addDaysToDate(5, today); return [ { @@ -122,6 +124,16 @@ export class DateUtilitiesService { timeSlices: Object.create(defaultTimeOfDay), date_object: ladate4, }, + { + literal: this.formateDateToInputStringNg(ladate5), + timeSlices: Object.create(defaultTimeOfDay), + date_object: ladate5, + }, + { + literal: this.formateDateToInputStringNg(ladate6), + timeSlices: Object.create(defaultTimeOfDay), + date_object: ladate6, + }, ]; } } diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 72241e7c..e1a4943e 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -198,14 +198,23 @@ export class PollService implements Resolve { const formFields = Object.keys(form.value); console.log('pollKeys, formFields', pollKeys, formFields); + newpoll.allowed_answers = ['yes']; for (const pk of pollKeys) { if (formFields.indexOf(pk) !== -1) { - newpoll[pk] = form.value[pk]; + const field = form.value[pk]; + newpoll[pk] = field; } else { console.log('manque pollKey', pk); } } + + if (form.value.isMaybeAnswerAvailable) { + newpoll.allowed_answers.push('maybe'); + } + if (form.value.isNoAnswerAvailable) { + newpoll.allowed_answers.push('no'); + } newpoll.description = form.value.description; newpoll.has_several_hours = form.value.hasSeveralHours; newpoll.hasSeveralHours = form.value.hasSeveralHours; @@ -215,9 +224,11 @@ export class PollService implements Resolve { newpoll.kind = form.value.kind; newpoll.allow_comments = form.value.allowComments; // merge choices from storage - newpoll.choices = this.storageService.choices; - newpoll.dateChoices = this.storageService.dateChoices; - newpoll.timeSlices = this.storageService.timeSlices; + newpoll.choices = Object.assign([], this.storageService.choices); + newpoll.dateChoices = Object.assign([], this.storageService.dateChoices); + newpoll.timeSlices = Object.assign([], this.storageService.timeSlices); + + console.log('this.storageService.timeSlices', this.storageService.timeSlices, newpoll.timeSlices); return newpoll; } diff --git a/src/app/features/administration/form/form.component.ts b/src/app/features/administration/form/form.component.ts index b228e0e0..94d69204 100644 --- a/src/app/features/administration/form/form.component.ts +++ b/src/app/features/administration/form/form.component.ts @@ -95,7 +95,7 @@ export class FormComponent implements OnInit, AfterViewInit { }); // take back values from pollservice - this.form.patchValue(this.pollService.poll); + // this.form.patchValue(this.pollService.poll); this.setDefaultFormValues(); if (showDemoValues) { @@ -136,6 +136,7 @@ export class FormComponent implements OnInit, AfterViewInit { startDateInterval: dateStart, endDateInterval: dateEnd, }); + this.automaticSlug(); } /** @@ -155,6 +156,8 @@ export class FormComponent implements OnInit, AfterViewInit { description: 'répondez SVP <3 ! *-*', creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com', + dateStart, + dateEnd, }); } diff --git a/src/styles/partials/_forms.scss b/src/styles/partials/_forms.scss index 1e7f2a8c..fbafaa39 100644 --- a/src/styles/partials/_forms.scss +++ b/src/styles/partials/_forms.scss @@ -133,7 +133,6 @@ mat-checkbox { .cdk-drag { cursor: pointer; - //border-left: 3px white solid; &:hover { background: #fefefe; } @@ -208,7 +207,7 @@ mat-checkbox { } .ng-pristine, .ng-dirty { - border-left: $white 3px solid; + border-left: blue 3px solid; padding-left: 1em; } .ng-touched.ng-invalid {