diff --git a/mocks/old-stuff/config/PollConfig.ts b/mocks/old-stuff/config/PollConfig.ts index 32e5d94f..fd45ce06 100644 --- a/mocks/old-stuff/config/PollConfig.ts +++ b/mocks/old-stuff/config/PollConfig.ts @@ -40,7 +40,7 @@ export class PollConfig { myEmail: string = environment.production ? '' : 'tktest@tktest.com'; myPolls: any = []; // list of retrieved polls from the backend api /* - 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 (timeSlices) for all possible dates (dateList), or use the same hours for all dates */ allowSeveralHours = 'true'; // access diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index a9fc1241..805662aa 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -4,6 +4,7 @@ import { Choice } from './choice.model'; import { Comment } from './comment.model'; import { PollConfiguration } from './configuration.model'; import { Owner } from './owner.model'; +import { DateChoice, TimeSlices } from '../../../../mocks/old-stuff/config/defaultConfigs'; export class Poll { public id = 0; @@ -23,11 +24,18 @@ export class Poll { public creatorEmail?: string; public is_archived?: boolean; + public is_zero_knowledge?: boolean = false; + public allow_comments?: boolean = true; + public has_several_hours?: boolean = false; + public allowSeveralHours?: boolean; public archiveNumberOfDays?: number; + public max_score?: number; + public max_count_of_answers?: number = 150; + public configuration: PollConfiguration = new PollConfiguration(); public comments: Comment[] = []; @@ -42,9 +50,9 @@ export class Poll { public modification_policy = 'everybody'; - public dateChoices: Choice[] = []; + public dateChoices: DateChoice[] = []; // sets of days as strings, config to set identical time for days in a special days poll - public timeChoices: Choice[] = []; // ranges of time expressed as strings + public timeSlices: TimeSlices[] = []; // ranges of time expressed as strings constructor(public owner: Owner = new Owner(), public title = 'mon titre', public custom_url: string = '') {} public getAdministrationUrl(): string { diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 7197c678..904a4e14 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -14,6 +14,7 @@ import { HttpClient } from '@angular/common/http'; import { environment } from '../../../environments/environment'; import { StorageService } from './storage.service'; import { Title } from '@angular/platform-browser'; +import { TimeSlices } from '../../../../mocks/old-stuff/config/defaultConfigs'; @Injectable({ providedIn: 'root', @@ -200,7 +201,8 @@ export class PollService implements Resolve { newpoll[fieldOfForm] = form.value[fieldOfForm]; } } - newpoll.expiracy_date = form.value.expiracy_date; + newpoll.dateChoices = this.storageService.dateList; + newpoll.timeSlices = this.storageService.timeSlices; console.log('newpoll', newpoll); return newpoll; diff --git a/src/app/core/services/storage.service.ts b/src/app/core/services/storage.service.ts index b4c72bbc..d7e4e2fc 100644 --- a/src/app/core/services/storage.service.ts +++ b/src/app/core/services/storage.service.ts @@ -7,6 +7,12 @@ import { Stack } from '../models/stack.model'; import { Choice } from '../models/choice.model'; import { Vote } from '../models/vote.model'; import { environment } from '../../../environments/environment'; +import { + DateChoice, + moreTimeOfDay, + otherDefaultDates, + TimeSlices, +} from '../../../../mocks/old-stuff/config/defaultConfigs'; @Injectable({ providedIn: 'root', @@ -21,13 +27,19 @@ export class StorageService { @LocalStorage() public userPollsIds: string[]; + @LocalStorage() + public dateList: DateChoice[] = otherDefaultDates; + + @LocalStorage() + public timeSlices: TimeSlices[] = moreTimeOfDay; + @LocalStorage() public vote_stack: Stack = new Stack(); setChoicesForVoteStack(choices_list: Choice[]) { this.vote_stack.votes = []; - for (let choice of choices_list) { + for (const choice of choices_list) { if (environment.autofill) { this.vote_stack.votes.push(new Vote(choice.id, 'yes')); } else { @@ -37,7 +49,7 @@ export class StorageService { } toggleAnswer(choice_id: number, value: string) { - for (let vote of this.vote_stack.votes) { + for (const vote of this.vote_stack.votes) { if (vote.choice_id == choice_id) { if (vote.value == value) { vote.value = ''; @@ -49,7 +61,7 @@ export class StorageService { } choiceHasAnswerOfValue(choice_id: number, value: any) { - for (let vote of this.vote_stack.votes) { + for (const vote of this.vote_stack.votes) { if (vote.choice_id == choice_id) { if (vote.value == value) { return true; diff --git a/src/app/features/administration/form/advanced-config/advanced-config.component.html b/src/app/features/administration/form/advanced-config/advanced-config.component.html index d378952f..223b9325 100644 --- a/src/app/features/administration/form/advanced-config/advanced-config.component.html +++ b/src/app/features/administration/form/advanced-config/advanced-config.component.html @@ -148,7 +148,7 @@ Nombre de réponses limitées à ce nombre
- + Chaque jour aura ses plages de temps personnalisées - + Tous les jours auront les mêmes plages de temps
@@ -68,7 +68,7 @@
-
+

{{ 'dates.count_time' | translate }} @@ -182,12 +182,12 @@ -
+
plage horaire distincte
diff --git a/src/app/features/administration/form/date-select/date-select.component.ts b/src/app/features/administration/form/date-select/date-select.component.ts index 227e8839..d5a9cb7c 100644 --- a/src/app/features/administration/form/date-select/date-select.component.ts +++ b/src/app/features/administration/form/date-select/date-select.component.ts @@ -15,6 +15,7 @@ import { } from '../../../../../../mocks/old-stuff/config/defaultConfigs'; import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; import { TranslateService } from '@ngx-translate/core'; +import { StorageService } from '../../../../core/services/storage.service'; @Component({ selector: 'app-date-select', @@ -32,8 +33,8 @@ export class DateSelectComponent implements OnInit { endDateInterval: string; intervalDays: any; intervalDaysDefault = 7; - dateList: DateChoice[] = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll - timeList: TimeSlices[] = moreTimeOfDay; // ranges of time expressed as strings + dateList: DateChoice[]; // sets of days as strings, config to set identical time for days in a special days poll + timeList: TimeSlices[]; // ranges of time expressed as strings dateCalendarEnum: Date[] = [new Date('02/09/2021')]; selectionKind = 'range'; @@ -45,10 +46,14 @@ export class DateSelectComponent implements OnInit { private pollService: PollService, public dateUtilities: DateUtilitiesService, private apiService: ApiService, + private storageService: StorageService, private router: Router, private translateService: TranslateService, @Inject(DOCUMENT) private document: any - ) {} + ) { + this.dateList = this.storageService.dateList; + this.timeList = this.storageService.timeSlices; + } ngOnInit(): void { // this.setDefaultDatesForInterval(); @@ -249,7 +254,7 @@ export class DateSelectComponent implements OnInit { } dropTimeItem(event: any) { - // moveItemInArray(this.timeList, event.previousIndex, event.currentIndex); + // moveItemInArray(this.timeSlices, event.previousIndex, event.currentIndex); if (event.previousContainer === event.container) { moveItemInArray(event.container.data, event.previousIndex, event.currentIndex); } else { diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index d91f5c6d..50adfa27 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -37,10 +37,7 @@
- +