diff --git a/src/app/core/components/header/header.component.html b/src/app/core/components/header/header.component.html index 41034276..86fa1fe5 100644 --- a/src/app/core/components/header/header.component.html +++ b/src/app/core/components/header/header.component.html @@ -6,11 +6,6 @@ {{ appTitle }} - - - (dev) - - - menu mobile + menu mobile --- + fermer + + + + Imprimer + + + Exporter CSV + + + Modifier + + + URL administrateur + + copier + + + Supprimer tous les votes + + + Supprimer tous les commentaires + + + Supprimer le sondage + + + diff --git a/src/app/core/components/sibebar/navigation/navigation.component.html b/src/app/core/components/sibebar/navigation/navigation.component.html index fa4f467a..68a74da5 100644 --- a/src/app/core/components/sibebar/navigation/navigation.component.html +++ b/src/app/core/components/sibebar/navigation/navigation.component.html @@ -5,10 +5,10 @@ - « {{ poll.slug }} » + « {{ poll.custom_url }} » diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 34d27688..d66183ee 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common'; import { NgModule, Optional, SkipSelf } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; @@ -14,7 +14,7 @@ import { SharedModule } from '../shared/shared.module'; @NgModule({ declarations: [FooterComponent, HeaderComponent, HomeComponent, LogoComponent, NavigationComponent], - imports: [CommonModule, FormsModule, RouterModule, TranslateModule, SharedModule], + imports: [CommonModule, FormsModule, ReactiveFormsModule, RouterModule, TranslateModule, SharedModule], exports: [HeaderComponent, FooterComponent, NavigationComponent, LogoComponent], }) export class CoreModule { diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index d597e52d..5c9eda45 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -1,5 +1,5 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router'; +import { ChangeDetectorRef, Inject, Injectable } from '@angular/core'; +import { ActivatedRoute, ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { Answer } from '../enums/answer.enum'; @@ -12,6 +12,10 @@ import { UserService } from './user.service'; import { UuidService } from './uuid.service'; import { HttpClient } from '@angular/common/http'; import { environment } from '../../../environments/environment'; +import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { DateChoice, defaultTimeOfDay, otherDefaultDates } from '../../features/old-stuff/config/defaultConfigs'; +import { DateUtilities } from '../../features/old-stuff/config/DateUtilities'; +import { DOCUMENT } from '@angular/common'; @Injectable({ providedIn: 'root', @@ -19,6 +23,23 @@ import { environment } from '../../../environments/environment'; export class PollService implements Resolve { private _poll: BehaviorSubject = new BehaviorSubject(undefined); public readonly poll: Observable = this._poll.asObservable(); + public form: FormGroup; + public startDateInterval: string; + public endDateInterval: string; + public intervalDays: any; + public intervalDaysDefault = 7; + public dateList: DateChoice[] = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll + public timeList: any = defaultTimeOfDay; // ranges of time expressed as strings + public previousRouteName: string = '/administration'; + public nextRouteName: string = '/administration/step/2'; + public step_current: number = 1; + public step_max: number = 5; + public round: Function; + public urlPrefix: string = window.location.origin + '/participation/'; + public advancedDisplayEnabled = false; + public showDateInterval = false; + public allowSeveralHours = false; + public richTextMode = false; constructor( private http: HttpClient, @@ -26,8 +47,78 @@ export class PollService implements Resolve { private apiService: ApiService, private userService: UserService, private uuidService: UuidService, - private toastService: ToastService - ) {} + private toastService: ToastService, + public dateUtilities: DateUtilities, + public route: ActivatedRoute, + @Inject(DOCUMENT) private document: any, + private fb: FormBuilder + ) { + this.createFormGroup(); + if (environment.poll.autoFillDemo) { + this.setDemoValues(); + } + } + + /** + * add example values to the form + */ + setDemoValues(): void { + this.addChoice('orange'); + this.addChoice('raisin'); + this.addChoice('abricot'); + + this.form.patchValue({ + title: 'mon titre', + description: 'répondez SVP <3 ! *-* ', + custom_url: this.uuidService.getUUID(), + creatorPseudo: 'Chuck Norris', + creatorEmail: 'chucknorris@example.com', + isAboutDate: true, + whoModifiesAnswers: 'everybody', + whoCanChangeAnswers: 'everybody', + isProtectedByPassword: false, + isOwnerNotifiedByEmailOnNewVote: false, + isOwnerNotifiedByEmailOnNewComment: false, + isMaybeAnswerAvailable: false, + richTextMode: false, + areResultsPublic: true, + expiracyNumberOfDays: 60, + }); + this.automaticSlug(); + } + + /** + * set the poll slug from other data of the poll + */ + automaticSlug() { + this.form.patchValue({ custom_url: this.makeSlug(this.form) }); + } + + public createFormGroup() { + let form = this.fb.group({ + title: ['', [Validators.required, Validators.minLength(12)]], + creatorPseudo: ['', [Validators.required]], + created_at: [new Date(), [Validators.required]], + creatorEmail: ['', [Validators.required]], + custom_url: [this.uuidService.getUUID(), [Validators.required]], + description: ['', [Validators.required]], + choices: new FormArray([]), + whoModifiesAnswers: ['', [Validators.required]], + whoCanChangeAnswers: ['', [Validators.required]], + isAboutDate: [true, [Validators.required]], + startDateInterval: ['', [Validators.required]], + endDateInterval: ['', [Validators.required]], + isProtectedByPassword: [false, [Validators.required]], + isOwnerNotifiedByEmailOnNewVote: [false, [Validators.required]], + isOwnerNotifiedByEmailOnNewComment: [false, [Validators.required]], + isMaybeAnswerAvailable: [false, [Validators.required]], + areResultsPublic: [true, [Validators.required]], + richTextMode: [false, [Validators.required]], + expiracyNumberOfDays: [60, [Validators.required, Validators.min(0)]], + }); + this.form = form; + return form; + } /** * auto fetch a poll when route is looking for one in the administration pattern @@ -82,21 +173,217 @@ export class PollService implements Resolve { } /** - * make a uniq slug for the current poll creation - * @param config + * add all the dates between the start and end dates in the interval section */ - makeSlug(config: Poll): string { + addIntervalOfDates(): void { + const newIntervalArray = this.dateUtilities.getDatesInRange( + this.dateUtilities.parseInputDateToDateObject(this.startDateInterval), + this.dateUtilities.parseInputDateToDateObject(this.endDateInterval), + 1 + ); + + const converted = []; + newIntervalArray.forEach((element) => { + converted.push({ + literal: element.literal, + date_object: element.date_object, + timeList: [], + }); + }); + this.dateList = [...new Set(converted)]; + // add only dates that are not already present with a Set of unique items + console.log('this.dateList', this.dateList); + this.showDateInterval = false; + + this.form.patchValue({ choices: this.dateList }); + + this.toastService.display(`les dates ont été ajoutées aux réponses possibles.`); + } + + /** + * handle keyboard shortcuts + * @param $event + * @param choice_number + */ + keyOnChoice($event: KeyboardEvent, choice_number: number): void { + $event.preventDefault(); + + console.log('this.choices.length', this.choices.length); + console.log('choice_number', choice_number); + const lastChoice = this.choices.length - 1 === choice_number; + // reset field with Ctrl + D + // add a field with Ctrl + N + // go to previous choice with arrow up + // go to next choice with arrow down + console.log('$event', $event); + + if ($event.key == 'ArrowUp' && choice_number > 0) { + this.focusOnChoice(choice_number - 1); + } + if ($event.key == 'ArrowDown') { + // add a field if we are on the last choice + if (lastChoice) { + this.addChoice(); + this.toastService.display('choix ajouté par raccourci "flèche bas"'); + } else { + this.focusOnChoice(choice_number + 1); + } + } + if ($event.ctrlKey && $event.key == 'Backspace') { + this.deleteChoiceField(choice_number); + this.toastService.display('choix supprimé par raccourci "Ctrl + retour"'); + this.focusOnChoice(Math.min(choice_number - 1, 0)); + } + if ($event.ctrlKey && $event.key == 'Enter') { + // go to other fields + const elem = this.document.querySelector('#creatorEmail'); + if (elem) { + elem.focus(); + } + } + } + + /** + * change time spans + */ + addTime() { + this.timeList.push({ + literal: '', + timeList: [], + date_object: new Date(), + }); + } + + removeAllTimes() { + this.timeList = []; + } + + resetTimes() { + this.timeList = otherDefaultDates; + } + + /** + * add a time period to a specific date choice, + * focus on the new input + * @param config + * @param id + */ + addTimeToDate(config: any, id: number) { + this.timeList.push({ + literal: '', + timeList: [], + date_object: new Date(), + }); + const selector = '[ng-reflect-choice_label="dateTime_' + id + '_Choices_' + (this.timeList.length - 1) + '"]'; + const elem = this.document.querySelector(selector); + if (elem) { + elem.focus(); + } + } + + public createPoll(): void { + console.log('this.form', this.form); + const newpoll = this.newPollFromForm(this.form); + console.log('newpoll', newpoll); + this.apiService.createPoll(newpoll); + } + + /** + * default interval of dates proposed is from today to 7 days more + */ + setDefaultDatesForInterval(): void { + const dateCurrent = new Date(); + const dateJson = dateCurrent.toISOString(); + this.startDateInterval = dateJson.substring(0, 10); + this.endDateInterval = this.dateUtilities + .addDaysToDate(this.intervalDaysDefault, dateCurrent) + .toISOString() + .substring(0, 10); + this.form.patchValue({ + startDateInterval: this.startDateInterval, + endDateInterval: this.endDateInterval, + }); + this.countDays(); + } + + askInitFormDefault(): void { + this.initFormDefault(false); + this.toastService.display('formulaire réinitialisé'); + } + + countDays(): void { + this.intervalDays = this.dateUtilities.countDays( + this.dateUtilities.parseInputDateToDateObject(this.startDateInterval), + this.dateUtilities.parseInputDateToDateObject(this.endDateInterval) + ); + } + + focusOnChoice(index): void { + const selector = '#choice_label_' + index; + const elem = this.document.querySelector(selector); + if (elem) { + elem.focus(); + } + } + + deleteChoiceField(index: number): void { + if (this.choices.length !== 1) { + this.choices.removeAt(index); + } + } + + initFormDefault(showDemoValues = true): void { + this.form = this.createFormGroup(); + console.log('this.form ', this.form); + this.setDefaultDatesForInterval(); + + if (showDemoValues) { + this.setDemoValues(); + } + } + + get choices(): FormArray { + return this.form.get('choices') as FormArray; + } + + reinitChoices(): void { + this.choices.setValue([]); + } + + addChoice(optionalLabel = ''): void { + const newControlGroup = this.fb.group({ + label: this.fb.control('', [Validators.required]), + imageUrl: ['', [Validators.required]], + }); + + if (optionalLabel) { + newControlGroup.patchValue({ + label: optionalLabel, + imageUrl: 'mon url', + }); + } + this.choices.push(newControlGroup); + console.log('this.choices.length', this.choices.length); + + this.focusOnChoice(this.choices.length - 1); + } + + /** + * make a uniq slug for the current poll creation + * @param form + */ + makeSlug(form: FormGroup): string { let str = ''; str = - config.configuration.dateCreated.getFullYear() + + form.value.created_at.getFullYear() + '_' + - (config.configuration.dateCreated.getMonth() + 1) + + (form.value.created_at.getMonth() + 1) + '_' + - config.configuration.dateCreated.getDate() + + form.value.created_at.getDate() + '_' + - config.owner.pseudo + + form.value.creatorPseudo + '_' + - config.title; + form.value.title; str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.toLowerCase(); @@ -212,7 +499,7 @@ export class PollService implements Resolve { // access visibility: newpoll.configuration.areResultsPublic, // visible to one with the link: voteChoices: newpoll.configuration.isMaybeAnswerAvailable ? 'yes, maybe, no' : 'yes', // possible answers to a vote choice: only "yes", "yes, maybe, no" - creationDate: new Date(), + created_at: new Date(), expirationDate: '', // expiracy date voteStackId: null, // id of the vote stack to update pollId: null, // id of the current poll when created. data given by the backend api diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index 2844b1f8..1b609363 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -3,22 +3,32 @@ {{ 'creation.title' | translate }} - + - + diff --git a/src/app/features/administration/form/form.component.ts b/src/app/features/administration/form/form.component.ts index 2f80c69c..f9085508 100644 --- a/src/app/features/administration/form/form.component.ts +++ b/src/app/features/administration/form/form.component.ts @@ -9,7 +9,7 @@ import { DateUtilities } from '../../old-stuff/config/DateUtilities'; import { DOCUMENT } from '@angular/common'; import { DateChoice, defaultTimeOfDay, otherDefaultDates } from '../../old-stuff/config/defaultConfigs'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'app-admin-form', @@ -21,23 +21,6 @@ export class FormComponent implements OnInit { public poll?: Poll; public form: FormGroup; - public urlPrefix: string = window.location.origin + '/participation/'; - public advancedDisplayEnabled = false; - public showDateInterval = false; - public allowSeveralHours = false; - public richTextMode = false; - startDateInterval: string; - 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: any = defaultTimeOfDay; // ranges of time expressed as strings - step_current: number = 1; - step_max: number = 5; - public round: Function; - private nextRouteName: string = '/administration/step/2'; - previousRouteName: string = '/administration'; - constructor( private fb: FormBuilder, private cd: ChangeDetectorRef, @@ -46,273 +29,16 @@ export class FormComponent implements OnInit { private pollService: PollService, private router: Router, public dateUtilities: DateUtilities, + public route: ActivatedRoute, private apiService: ApiService, @Inject(DOCUMENT) private document: any - ) {} - drop(event: CdkDragDrop) { - // moveItemInArray(this.choices, event.previousIndex, event.currentIndex); - } - get choices(): FormArray { - return this.form.get('choices') as FormArray; + ) { + this.form = this.pollService.form; } ngOnInit(): void { - this.initFormDefault(); - const pollsAvailable = this.pollService.getAllAvailablePolls(); - console.log('pollsAvailable', pollsAvailable); + this.pollService.askInitFormDefault(); } - public createPoll(): void { - console.log('this.form', this.form); - const newpoll = this.pollService.newPollFromForm(this.form); - console.log('newpoll', newpoll); - this.apiService.createPoll(newpoll); - } - - addChoice(optionalLabel = ''): void { - const newControlGroup = this.fb.group({ - label: this.fb.control('', [Validators.required]), - imageUrl: ['', [Validators.required]], - }); - - if (optionalLabel) { - newControlGroup.patchValue({ - label: optionalLabel, - imageUrl: 'mon url', - }); - } - this.choices.push(newControlGroup); - this.cd.detectChanges(); - console.log('this.choices.length', this.choices.length); - - this.focusOnChoice(this.choices.length - 1); - } - - focusOnChoice(index): void { - const selector = '#choice_label_' + index; - const elem = this.document.querySelector(selector); - if (elem) { - elem.focus(); - } - } - - deleteChoiceField(index: number): void { - if (this.choices.length !== 1) { - this.choices.removeAt(index); - } - } - - reinitChoices(): void { - this.choices.setValue([]); - } - - initFormDefault(showDemoValues = true): void { - this.form = this.fb.group({ - title: ['', [Validators.required, Validators.minLength(12)]], - creatorPseudo: ['', [Validators.required]], - creatorEmail: ['', [Validators.required]], - slug: [this.uuidService.getUUID(), [Validators.required]], - description: ['', [Validators.required]], - choices: new FormArray([]), - whoModifiesAnswers: ['', [Validators.required]], - whoCanChangeAnswers: ['', [Validators.required]], - isAboutDate: [true, [Validators.required]], - startDateInterval: ['', [Validators.required]], - endDateInterval: ['', [Validators.required]], - isProtectedByPassword: [false, [Validators.required]], - isOwnerNotifiedByEmailOnNewVote: [false, [Validators.required]], - isOwnerNotifiedByEmailOnNewComment: [false, [Validators.required]], - isMaybeAnswerAvailable: [false, [Validators.required]], - areResultsPublic: [true, [Validators.required]], - richTextMode: [false, [Validators.required]], - expiracyNumberOfDays: [60, [Validators.required, Validators.min(0)]], - }); - console.log('this.form ', this.form); - this.setDefaultDatesForInterval(); - - if (showDemoValues) { - this.setDemoValues(); - } - } - - /** - * default interval of dates proposed is from today to 7 days more - */ - setDefaultDatesForInterval(): void { - const dateCurrent = new Date(); - const dateJson = dateCurrent.toISOString(); - this.startDateInterval = dateJson.substring(0, 10); - this.endDateInterval = this.dateUtilities - .addDaysToDate(this.intervalDaysDefault, dateCurrent) - .toISOString() - .substring(0, 10); - this.form.patchValue({ - startDateInterval: this.startDateInterval, - endDateInterval: this.endDateInterval, - }); - this.countDays(); - } - - /** - * add example values to the form - */ - setDemoValues(): void { - this.addChoice('orange'); - this.addChoice('raisin'); - this.addChoice('abricot'); - - this.form.patchValue({ - title: 'mon titre', - description: 'répondez SVP <3 ! *-* ', - slug: this.uuidService.getUUID(), - creatorPseudo: 'Chuck Norris', - creatorEmail: 'chucknorris@example.com', - isAboutDate: true, - whoModifiesAnswers: 'everybody', - whoCanChangeAnswers: 'everybody', - isProtectedByPassword: false, - isOwnerNotifiedByEmailOnNewVote: false, - isOwnerNotifiedByEmailOnNewComment: false, - isMaybeAnswerAvailable: false, - richTextMode: false, - areResultsPublic: true, - expiracyNumberOfDays: 60, - }); - this.automaticSlug(); - } - - askInitFormDefault(): void { - this.initFormDefault(false); - this.toastService.display('formulaire réinitialisé'); - } - - countDays(): void { - this.intervalDays = this.dateUtilities.countDays( - this.dateUtilities.parseInputDateToDateObject(this.startDateInterval), - this.dateUtilities.parseInputDateToDateObject(this.endDateInterval) - ); - this.cd.detectChanges(); - } - - /** - * add all the dates between the start and end dates in the interval section - */ - addIntervalOfDates(): void { - const newIntervalArray = this.dateUtilities.getDatesInRange( - this.dateUtilities.parseInputDateToDateObject(this.startDateInterval), - this.dateUtilities.parseInputDateToDateObject(this.endDateInterval), - 1 - ); - - const converted = []; - newIntervalArray.forEach((element) => { - converted.push({ - literal: element.literal, - date_object: element.date_object, - timeList: [], - }); - }); - this.dateList = [...new Set(converted)]; - // add only dates that are not already present with a Set of unique items - console.log('this.dateList', this.dateList); - this.showDateInterval = false; - - this.form.patchValue({ choices: this.dateList }); - - this.toastService.display(`les dates ont été ajoutées aux réponses possibles.`); - } - - /** - * handle keyboard shortcuts - * @param $event - * @param choice_number - */ - keyOnChoice($event: KeyboardEvent, choice_number: number): void { - $event.preventDefault(); - - console.log('this.choices.length', this.choices.length); - console.log('choice_number', choice_number); - const lastChoice = this.choices.length - 1 === choice_number; - // reset field with Ctrl + D - // add a field with Ctrl + N - // go to previous choice with arrow up - // go to next choice with arrow down - console.log('$event', $event); - - if ($event.key == 'ArrowUp' && choice_number > 0) { - this.focusOnChoice(choice_number - 1); - } - if ($event.key == 'ArrowDown') { - // add a field if we are on the last choice - if (lastChoice) { - this.addChoice(); - this.toastService.display('choix ajouté par raccourci "flèche bas"'); - } else { - this.focusOnChoice(choice_number + 1); - } - } - if ($event.ctrlKey && $event.key == 'Backspace') { - this.deleteChoiceField(choice_number); - this.toastService.display('choix supprimé par raccourci "Ctrl + retour"'); - this.cd.detectChanges(); - this.focusOnChoice(Math.min(choice_number - 1, 0)); - } - if ($event.ctrlKey && $event.key == 'Enter') { - // go to other fields - const elem = this.document.querySelector('#creatorEmail'); - if (elem) { - elem.focus(); - } - } - } - - /** - * change time spans - */ - addTime() { - this.timeList.push({ - literal: '', - timeList: [], - date_object: new Date(), - }); - } - - removeAllTimes() { - this.timeList = []; - } - - resetTimes() { - this.timeList = otherDefaultDates; - } - - /** - * add a time period to a specific date choice, - * focus on the new input - * @param config - * @param id - */ - addTimeToDate(config: any, id: number) { - this.timeList.push({ - literal: '', - timeList: [], - date_object: new Date(), - }); - const selector = '[ng-reflect-choice_label="dateTime_' + id + '_Choices_' + (this.timeList.length - 1) + '"]'; - this.cd.detectChanges(); - const elem = this.document.querySelector(selector); - if (elem) { - elem.focus(); - } - } - - /** - * set the poll slug from other data of the poll - */ - automaticSlug() { - this.poll.slug = this.pollService.makeSlug(this.poll); - } - - goNextStep() { - this.router.navigate([this.nextRouteName]); - } + goNextStep() {} } diff --git a/src/app/features/administration/form/step-five/step-five.component.html b/src/app/features/administration/form/step-five/step-five.component.html index 6c0cc0ca..829f19a4 100644 --- a/src/app/features/administration/form/step-five/step-five.component.html +++ b/src/app/features/administration/form/step-five/step-five.component.html @@ -25,7 +25,7 @@ - {{ poll.slug }} + {{ poll.custom_url }} le formulaire est invalide diff --git a/src/app/features/administration/form/step-four/step-four.component.html b/src/app/features/administration/form/step-four/step-four.component.html index f30221d0..41c2e770 100644 --- a/src/app/features/administration/form/step-four/step-four.component.html +++ b/src/app/features/administration/form/step-four/step-four.component.html @@ -1,5 +1,27 @@ + + + + {{ 'creation.name' | translate }} + + + + + {{ 'creation.email' | translate }} + + + + + + @@ -13,13 +35,13 @@ Url pour les participants {{ urlPrefix }} {{ form.controls.slug.value }} + >{{ urlPrefix }} {{ form.controls.custom_url.value }} - + {{ 'creation.choose_title' | translate }} - Titre - - - - + + + Titre + + + + + + + + - Description (optionnel) - - mode de saisie avancée - - - - - 300 caractères maximum + + + Description (optionnel) + + mode de saisie avancée + + + + + + 300 caractères maximum + + + + + + + - - - diff --git a/src/app/features/administration/form/step-three/step-three.component.html b/src/app/features/administration/form/step-three/step-three.component.html index ccf44df9..e030c75b 100644 --- a/src/app/features/administration/form/step-three/step-three.component.html +++ b/src/app/features/administration/form/step-three/step-three.component.html @@ -1,23 +1,127 @@ - - - - {{ 'creation.name' | translate }} + + + + + {{ timeList.length }} - - - - {{ 'creation.email' | translate }} + + {{ 'dates.count_time' | translate }} + (pour chaque jour) - - - + + + + + {{ 'dates.add_time' | translate }} + + + + Aucune plage horaire + + + + réinitialiser + + + + + + + + + + + + + + + + + + + {{ dateList.length }} + + + {{ 'dates.count_dates' | translate }} + + + {{ 'dates.add' | translate }} + + + + + + + + {{ 'dates.add_time' | translate }} + + + + + + + + + + + + + + {{ 'dates.add_interval' | translate }} + + + {{ 'dates.add_interval' | translate }} + + + {{ 'dates.interval_propose' | translate }} + + + start + + + + + + {{ 'dates.interval_span' | translate }} + + + end + + + + + + {{ 'dates.interval_button' | translate }} + {{ intervalDays }} + {{ 'dates.interval_button_dates' | translate }} + + diff --git a/src/app/features/administration/form/step-two/step-two.component.html b/src/app/features/administration/form/step-two/step-two.component.html index 320a3c6d..72821dbe 100644 --- a/src/app/features/administration/form/step-two/step-two.component.html +++ b/src/app/features/administration/form/step-two/step-two.component.html @@ -1,4 +1,4 @@ - + {{ 'creation.want' | translate }} @@ -7,8 +7,8 @@ {{ 'creation.kind.date' | translate }} @@ -17,8 +17,8 @@ {{ 'creation.kind.classic' | translate }} @@ -26,129 +26,3 @@ - - - - - - {{ timeList.length }} - - - {{ 'dates.count_time' | translate }} - (pour chaque jour) - - - - - - {{ 'dates.add_time' | translate }} - - - - Aucune plage horaire - - - - réinitialiser - - - - - - - - - - - - - - - - - - - {{ dateList.length }} - - - {{ 'dates.count_dates' | translate }} - - - {{ 'dates.add' | translate }} - - - - - - - - {{ 'dates.add_time' | translate }} - - - - - - - - - - - - - - - {{ 'dates.add_interval' | translate }} - - - {{ 'dates.add_interval' | translate }} - - - {{ 'dates.interval_propose' | translate }} - - - start - - - - - - {{ 'dates.interval_span' | translate }} - - - end - - - - - - {{ 'dates.interval_button' | translate }} - {{ intervalDays }} - {{ 'dates.interval_button_dates' | translate }} - - diff --git a/src/app/features/administration/form/step-two/step-two.component.scss b/src/app/features/administration/form/step-two/step-two.component.scss index e69de29b..182a819e 100644 --- a/src/app/features/administration/form/step-two/step-two.component.scss +++ b/src/app/features/administration/form/step-two/step-two.component.scss @@ -0,0 +1,3 @@ +.fa { + margin-right: 1em; +} diff --git a/src/app/features/administration/form/step-two/step-two.component.ts b/src/app/features/administration/form/step-two/step-two.component.ts index ca14d447..f6d26010 100644 --- a/src/app/features/administration/form/step-two/step-two.component.ts +++ b/src/app/features/administration/form/step-two/step-two.component.ts @@ -1,4 +1,13 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, Inject, Input, OnInit } from '@angular/core'; +import { FormArray, FormBuilder } from '@angular/forms'; +import { UuidService } from '../../../../core/services/uuid.service'; +import { ApiService } from '../../../../core/services/api.service'; +import { ToastService } from '../../../../core/services/toast.service'; +import { PollService } from '../../../../core/services/poll.service'; +import { DateUtilities } from '../../../old-stuff/config/DateUtilities'; +import { DOCUMENT } from '@angular/common'; +import { CdkDragDrop } from '@angular/cdk/drag-drop'; +import { Router } from '@angular/router'; @Component({ selector: 'app-step-two', @@ -6,12 +15,51 @@ import { Component, Input, OnInit } from '@angular/core'; styleUrls: ['./step-two.component.scss'], }) export class StepTwoComponent implements OnInit { - constructor() {} - ngOnInit(): void {} + @Input() form: any; @Input() step_max: any; + timeList: any; + allowSeveralHours: string; + dateList: any; + showDateInterval: boolean; + intervalDays: any; + + constructor( + private fb: FormBuilder, + private cd: ChangeDetectorRef, + private uuidService: UuidService, + private toastService: ToastService, + public pollService: PollService, + private router: Router, + public dateUtilities: DateUtilities, + private apiService: ApiService, + @Inject(DOCUMENT) private document: any + ) { + this.form = this.pollService.form; + } + addIntervalOfDates() {} + + get choices(): FormArray { + return this.form.get('choices') as FormArray; + } + + addTime() {} + + removeAllTimes() {} + + resetTimes() {} + + drop(event: CdkDragDrop) { + // moveItemInArray(this.choices, event.previousIndex, event.currentIndex); + } + + addChoice() {} + + addTimeToDate(choice: any, id: number) {} + + countDays() {} } diff --git a/src/app/features/administration/stepper/stepper.component.scss b/src/app/features/administration/stepper/stepper.component.scss index 4967d1b5..186e7dd5 100644 --- a/src/app/features/administration/stepper/stepper.component.scss +++ b/src/app/features/administration/stepper/stepper.component.scss @@ -5,7 +5,7 @@ height: 0.5em; display: inline-block; min-width: 1px; - background: $grey-light; + background: $border-color !important; width: 100%; } .step-bar-progress { @@ -15,5 +15,5 @@ height: 0.5em; display: inline-block; min-width: 1px; - background: $primary; + background: $primary_color; } diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index b32322e7..8ce89a4a 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -27,10 +27,10 @@ diff --git a/src/app/features/user-profile/user-polls/user-polls.component.html b/src/app/features/user-profile/user-polls/user-polls.component.html index eca9d4f9..8ffe0db1 100644 --- a/src/app/features/user-profile/user-polls/user-polls.component.html +++ b/src/app/features/user-profile/user-polls/user-polls.component.html @@ -13,8 +13,8 @@ {{ poll.title }} - - {{ poll.slug }} + + {{ poll.custom_url }} diff --git a/src/app/shared/components/selectors/language-selector/language-selector.component.html b/src/app/shared/components/selectors/language-selector/language-selector.component.html index ea87ffb2..47ed68c2 100644 --- a/src/app/shared/components/selectors/language-selector/language-selector.component.html +++ b/src/app/shared/components/selectors/language-selector/language-selector.component.html @@ -2,7 +2,7 @@ {{ 'selector.lang' | translate }} - + {{ language }} - {{ 'LANGUAGES.' + language | translate }} diff --git a/src/app/shared/components/selectors/theme-selector/theme-selector.component.html b/src/app/shared/components/selectors/theme-selector/theme-selector.component.html index e8a55d39..14056773 100644 --- a/src/app/shared/components/selectors/theme-selector/theme-selector.component.html +++ b/src/app/shared/components/selectors/theme-selector/theme-selector.component.html @@ -2,21 +2,21 @@ diff --git a/src/assets/i18n/FR.json b/src/assets/i18n/FR.json index 6038a875..650df2d2 100644 --- a/src/assets/i18n/FR.json +++ b/src/assets/i18n/FR.json @@ -30,8 +30,8 @@ "want": "Je veux créer un sondage", "advanced": "Options avancées", "kind": { - "classic": "classique", - "date": "spécial dates" + "classic": "Textes", + "date": "Dates" }, "choose_title": "Renseignez un nom pour votre sondage", "choose_title_placeholder": "Quel resto ce soir?", diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 605f23be..bc0499d3 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -38,6 +38,7 @@ export const environment = { }, }, poll: { + autoFillDemo: false, defaultConfig: { expiracyInDays: 60, expiracyAfterLastModificationInDays: 180, diff --git a/src/environments/environment.ts b/src/environments/environment.ts index e03be58e..0709d2b4 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -16,7 +16,7 @@ const apiV1 = { export const environment = { production: false, - appTitle: 'FramaDate', + appTitle: 'FunkyDate', appVersion: '2.0.0', appLogo: 'assets/img/logo.png', api: { @@ -53,6 +53,7 @@ export const environment = { }, }, poll: { + autoFillDemo: true, defaultConfig: { expiracyInDays: 60, expiracyAfterLastModificationInDays: 180, diff --git a/src/styles.scss b/src/styles.scss index e3635b48..a22bcb9f 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -34,7 +34,7 @@ @import './styles/variables'; @import './styles/dev-utilities/mixins'; @import './styles/dev-utilities/helpers'; -// @import './styles/dev-utilities/debug'; +@import './styles/dev-utilities/debug'; @import './styles/libraries/frameworks'; @import './styles/libraries/overrides'; // typography diff --git a/src/styles/libraries/_overrides.scss b/src/styles/libraries/_overrides.scss index 3df4e377..e4ef9f02 100644 --- a/src/styles/libraries/_overrides.scss +++ b/src/styles/libraries/_overrides.scss @@ -9,8 +9,8 @@ $fullhd-enabled: false; // Update some of Bulma's component variables $body-background-color: $black; $control-border-width: 2px; -$input-border-color: transparent; -$input-shadow: none; +$input-border-color: $border-color; +// $input-shadow: none; // bulma css override $colors: mergeColorMaps( diff --git a/src/styles/partials/_form-controls.scss b/src/styles/partials/_form-controls.scss index 96e166b3..2bafd105 100644 --- a/src/styles/partials/_form-controls.scss +++ b/src/styles/partials/_form-controls.scss @@ -2,14 +2,9 @@ input, select, textarea { @extend .clickable; - margin-bottom: 0.25rem; - padding: 0.5rem; - - &:active, - &:focus, - &:hover { - color: $primary_color; - } + @extend .input; + padding: calc(0.5em - 1px); + border-color: $border-color !important; } textarea { diff --git a/src/styles/partials/_forms.scss b/src/styles/partials/_forms.scss index 6a465dee..126ba19f 100644 --- a/src/styles/partials/_forms.scss +++ b/src/styles/partials/_forms.scss @@ -1,78 +1,6 @@ @charset "UTF-8"; -label { - line-height: 2.5em; -} -.ui-inputswitch { - margin-left: 1ch; - margin-right: 1ch; -} - -.input-lg { - display: block; - width: 100%; -} - -select { - margin-right: 1ch; -} - -input { - margin-right: 1ch; - - &[type='date']::after { - content: 'au format JJ/MM/AAAA'; - display: inline-block; - position: relative; - } -} - -input, -select, -textarea { - width: 100%; - padding: 1rem; - border: 1px solid $border-color; -} - -input, -select { - display: inline-block; - margin-bottom: 10px; - margin-left: 5px; -} - -.next { - max-width: 200px; -} - -input[type='text'], -textarea { - max-width: 350px; -} - -li { - list-style-type: none; -} - -.next { - margin-bottom: 50px; -} - -.nobold { - font-weight: normal; -} - -.btn-block { - display: block; - width: 100%; -} - -button[type='submit'] { - margin-top: 2em; -} - hr { margin: 4em 0; - border: solid 3px $primary; + border: solid 3px $primary_color; } diff --git a/src/styles/partials/_responsive.scss b/src/styles/partials/_responsive.scss index be856ee5..d1bd9188 100644 --- a/src/styles/partials/_responsive.scss +++ b/src/styles/partials/_responsive.scss @@ -1,21 +1,2 @@ @media (min-width: $widescreen) { - select, - input, - label + select, - label { - width: 45%; - } - .date-choice > input:first-of-type { - width: 80%; - } - .date-choice .btn--primary, - .several-times { - margin-left: 1rem; - display: inline-block; - } - .time-choice { - input { - width: 70%; - } - } } diff --git a/src/styles/partials/global.scss b/src/styles/partials/global.scss index 0c7f03c8..73a57f4e 100644 --- a/src/styles/partials/global.scss +++ b/src/styles/partials/global.scss @@ -1,9 +1,6 @@ @charset "UTF-8"; html { - font-size: 1rem; /* 10px */ + font-size: 1rem; /* 16px */ color: $font_color; } -main { - min-height: 90vh; -} diff --git a/src/styles/themes/_light.scss b/src/styles/themes/_light.scss index eab5078e..86458142 100644 --- a/src/styles/themes/_light.scss +++ b/src/styles/themes/_light.scss @@ -1,5 +1,5 @@ #big_container { - background: $primary; + background: $primary_color; &.theme-light-watermelon { .big-header { diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 3d27c00c..0b0e3f4b 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -51,7 +51,7 @@ $choice_select_border_color: $d-info; $hover-color: $d-neutral; $border-color: $d-neutral; $grey-dark: $d-primary; -$grey-light: $beige-light; +$grey-lighter: $beige-light; $clicked-color: $d-primary; $mini-button-color: $d-primary-intense; $warning: $d-warning;