forked from tykayn/funky-framadate-front
remove lib date value accessor, start date interval form
This commit is contained in:
parent
075d434c6f
commit
6638ba1060
@ -45,7 +45,6 @@
|
|||||||
"@fullcalendar/core": "^4.4.0",
|
"@fullcalendar/core": "^4.4.0",
|
||||||
"@ngx-translate/core": "^12.1.2",
|
"@ngx-translate/core": "^12.1.2",
|
||||||
"@ngx-translate/http-loader": "^5.0.0",
|
"@ngx-translate/http-loader": "^5.0.0",
|
||||||
"angular-date-value-accessor": "^1.0.2",
|
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"bulma": "^0.9.0",
|
"bulma": "^0.9.0",
|
||||||
"bulma-switch": "^2.0.0",
|
"bulma-switch": "^2.0.0",
|
||||||
|
@ -8,7 +8,7 @@ export class ToastService {
|
|||||||
constructor(private _snackBar: MatSnackBar) {}
|
constructor(private _snackBar: MatSnackBar) {}
|
||||||
|
|
||||||
public display(message: string, action?: string): void {
|
public display(message: string, action?: string): void {
|
||||||
const config: MatSnackBarConfig = { duration: 2000 };
|
const config: MatSnackBarConfig = { duration: 4000, verticalPosition: 'top' };
|
||||||
this._snackBar.open(message, action, config);
|
this._snackBar.open(message, action, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import { AdministrationComponent } from './administration.component';
|
|||||||
import { StepperComponent } from './stepper/stepper.component';
|
import { StepperComponent } from './stepper/stepper.component';
|
||||||
import { NamingComponent } from './naming/naming.component';
|
import { NamingComponent } from './naming/naming.component';
|
||||||
import { FormComponent } from './form/form.component';
|
import { FormComponent } from './form/form.component';
|
||||||
import { DateValueAccessorModule } from 'angular-date-value-accessor';
|
|
||||||
import { SuccessComponent } from './success/success.component';
|
import { SuccessComponent } from './success/success.component';
|
||||||
import { DateSelectComponent } from './form/date-select/date-select.component';
|
import { DateSelectComponent } from './form/date-select/date-select.component';
|
||||||
import { TextSelectComponent } from './form/text-select/text-select.component';
|
import { TextSelectComponent } from './form/text-select/text-select.component';
|
||||||
@ -47,7 +46,6 @@ import { TimeListComponent } from './form/date/list/time/time-list.component';
|
|||||||
SharedModule,
|
SharedModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
TranslateModule.forChild({ extend: true }),
|
TranslateModule.forChild({ extend: true }),
|
||||||
DateValueAccessorModule,
|
|
||||||
DragDropModule,
|
DragDropModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{{ 'dates.add' | translate }}
|
{{ 'dates.add' | translate }}
|
||||||
|
|
||||||
<!-- interval-->
|
<!-- interval-->
|
||||||
<!-- <app-date-interval></app-date-interval>-->
|
<app-date-interval [form]="form"></app-date-interval>
|
||||||
</form>
|
</form>
|
||||||
<div class="dates-list">
|
<div class="dates-list">
|
||||||
<!-- différentes horaires-->
|
<!-- différentes horaires-->
|
||||||
|
@ -11,6 +11,7 @@ import { DateChoice, defaultTimeOfDay, TimeSlices } from '../../../../../../mock
|
|||||||
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { StorageService } from '../../../../core/services/storage.service';
|
import { StorageService } from '../../../../core/services/storage.service';
|
||||||
|
import { environment } from '../../../../../environments/environment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-date-select',
|
selector: 'app-date-select',
|
||||||
@ -26,7 +27,7 @@ export class DateSelectComponent implements OnInit {
|
|||||||
today = new Date();
|
today = new Date();
|
||||||
endDateInterval: string;
|
endDateInterval: string;
|
||||||
|
|
||||||
intervalDaysDefault = 7;
|
intervalDaysDefault = environment.interval_days_default;
|
||||||
dateChoices: DateChoice[] = []; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
|
dateChoices: DateChoice[] = []; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
|
||||||
timeSlices: TimeSlices[] = []; // ranges of time expressed as strings
|
timeSlices: TimeSlices[] = []; // ranges of time expressed as strings
|
||||||
|
|
||||||
|
@ -13,11 +13,36 @@
|
|||||||
<fieldset *ngIf="showDateInterval" class="date-interval form-row is-boxed">
|
<fieldset *ngIf="showDateInterval" class="date-interval form-row is-boxed">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
<app-wip-todo></app-wip-todo>
|
||||||
{{ 'dates.interval_propose' | translate }}
|
{{ 'dates.interval_propose' | translate }}
|
||||||
|
<input type="text" formControlName="natural_lang_interval" />
|
||||||
|
<sub>
|
||||||
|
exemple "du 10 au 17", ou "lundi à samedi"
|
||||||
|
</sub>
|
||||||
|
<button (click)="addNaturalInstruction()" class="btn btn-block btn--primary">
|
||||||
|
interpréter
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<!-- <mat-form-field appearance="fill">-->
|
||||||
|
<!-- <mat-label>Enter a date range</mat-label>-->
|
||||||
|
<!-- <mat-date-range-input [formGroup]="form" [rangePicker]="picker">-->
|
||||||
|
<!-- <input matStartDate formControlName="startDateInterval" placeholder="Start date">-->
|
||||||
|
<!-- <input matEndDate formControlName="endDateInterval" placeholder="End date">-->
|
||||||
|
<!-- </mat-date-range-input>-->
|
||||||
|
<!-- <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>-->
|
||||||
|
<!-- <mat-date-range-picker #picker></mat-date-range-picker>-->
|
||||||
|
|
||||||
|
<!-- <mat-error *ngIf="form.controls.startDateInterval.hasError('matStartDateInvalid')">Invalid start date</mat-error>-->
|
||||||
|
<!-- <mat-error *ngIf="form.controls.endDateInterval.hasError('matEndDateInvalid')">Invalid end date</mat-error>-->
|
||||||
|
<!-- </mat-form-field>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<label for="start_interval" class="hidden">start</label>
|
<label for="start_interval" class="hidden">start</label>
|
||||||
<input id="start_interval" (change)="countDays()" formControlName="startDateInterval" type="date" />
|
{{ form.value.startDateInterval }}
|
||||||
|
<input id="start_interval" formControlName="startDateInterval" type="date" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
@ -27,12 +52,19 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<label for="end_interval" class="hidden">end</label>
|
<label for="end_interval" class="hidden">end</label>
|
||||||
<input id="end_interval" formControlName="endDateInterval" type="date" />
|
<input id="end_interval" formControlName="endDateInterval" type="date" />
|
||||||
<div class="well">
|
{{ form.value.endDateInterval }}
|
||||||
{{ form.value.endDateInterval }}
|
<div class="span resume">
|
||||||
|
<div class="well">
|
||||||
|
Du
|
||||||
|
{{ form.value.startDateInterval | date: 'EEEE d':'Europe/Paris':'fr_FR' }}
|
||||||
|
au
|
||||||
|
{{ form.value.endDateInterval | date: 'EEEE d':'Europe/Paris':'fr_FR' }}
|
||||||
|
, soit {{ intervalDays }} jours.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="span resume">soit {{ intervalDays }} jours.</div>
|
|
||||||
<button (click)="addIntervalOfDates()" class="btn btn-block btn--primary">
|
<button (click)="addIntervalOfDates()" class="btn btn-block btn--primary">
|
||||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||||
{{ 'dates.interval_button' | translate }}
|
{{ 'dates.interval_button' | translate }}
|
||||||
|
@ -22,19 +22,42 @@ export class IntervalComponent implements OnInit {
|
|||||||
endDateIntervalString: string;
|
endDateIntervalString: string;
|
||||||
dateList: DateChoice[]; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
|
dateList: DateChoice[]; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
|
||||||
dateCalendarEnum: Date[] = [new Date('02/09/2021')];
|
dateCalendarEnum: Date[] = [new Date('02/09/2021')];
|
||||||
|
natural_lang_interval: string;
|
||||||
|
|
||||||
constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) {}
|
constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.form.get('startDateInterval').valueChanges.subscribe((val) => {
|
||||||
|
console.log('val', val);
|
||||||
|
if (typeof val === typeof String) {
|
||||||
|
this.startDateIntervalString = val;
|
||||||
|
this.countDays();
|
||||||
|
} else {
|
||||||
|
this.startDateInterval = val;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.form.get('endDateInterval').valueChanges.subscribe((val) => {
|
||||||
|
console.log('val', val);
|
||||||
|
if (typeof val === typeof String) {
|
||||||
|
this.endDateIntervalString = val;
|
||||||
|
this.countDays();
|
||||||
|
}
|
||||||
|
// this.endDateInterval = val;
|
||||||
|
// this.countDays();
|
||||||
|
});
|
||||||
|
|
||||||
this.setDefaultDatesForInterval();
|
this.setDefaultDatesForInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
countDays(): void {
|
countDays(): void {
|
||||||
this.intervalDays = this.dateUtilities.countDays(
|
|
||||||
this.dateUtilities.parseInputDateToDateObject(this.startDateInterval),
|
|
||||||
this.dateUtilities.parseInputDateToDateObject(this.endDateInterval)
|
|
||||||
);
|
|
||||||
// this.cd.detectChanges();
|
// this.cd.detectChanges();
|
||||||
|
this.intervalDays = this.dateUtilities.countDays(
|
||||||
|
this.startDateInterval,
|
||||||
|
this.endDateInterval
|
||||||
|
// this.dateUtilities.parseInputDateToDateObject(this.startDateIntervalString),
|
||||||
|
// this.dateUtilities.parseInputDateToDateObject(this.endDateIntervalString)
|
||||||
|
);
|
||||||
|
console.log('this.intervalDays ', this.intervalDays);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,4 +113,9 @@ export class IntervalComponent implements OnInit {
|
|||||||
this.countDays();
|
this.countDays();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addNaturalInstruction() {
|
||||||
|
this.toastService.display(`TODO addNaturalInstruction`);
|
||||||
|
console.log('TODO', this.natural_lang_interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ export class DayListComponent {
|
|||||||
@Inject(DOCUMENT) private document: any,
|
@Inject(DOCUMENT) private document: any,
|
||||||
private storageService: StorageService
|
private storageService: StorageService
|
||||||
) {
|
) {
|
||||||
this.setDemoTextChoices();
|
// this.setDemoTextChoices();
|
||||||
}
|
}
|
||||||
|
|
||||||
reinitChoices(): void {
|
reinitChoices(): void {
|
||||||
@ -45,7 +45,6 @@ export class DayListComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dropDayItem(event: any): void {
|
dropDayItem(event: any): void {
|
||||||
// moveItemInArray(this.timeSlices, event.previousIndex, event.currentIndex);
|
|
||||||
if (event.previousContainer === event.container) {
|
if (event.previousContainer === event.container) {
|
||||||
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
|
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
|
||||||
} else {
|
} else {
|
||||||
@ -134,8 +133,6 @@ export class DayListComponent {
|
|||||||
date_object: new Date(),
|
date_object: new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.cd.detectChanges();
|
|
||||||
|
|
||||||
this.focusOnChoice(this.storageService.dateChoices.length - 1);
|
this.focusOnChoice(this.storageService.dateChoices.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import { environment } from '../../../../environments/environment';
|
|||||||
import { PollUtilitiesService } from '../../../core/services/poll.utilities.service';
|
import { PollUtilitiesService } from '../../../core/services/poll.utilities.service';
|
||||||
import { StorageService } from '../../../core/services/storage.service';
|
import { StorageService } from '../../../core/services/storage.service';
|
||||||
import { DateUtilitiesService } from '../../../core/services/date.utilities.service';
|
import { DateUtilitiesService } from '../../../core/services/date.utilities.service';
|
||||||
|
import { formatDate } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin-form',
|
selector: 'app-admin-form',
|
||||||
@ -87,6 +88,7 @@ export class FormComponent implements OnInit, AfterViewInit {
|
|||||||
allowComments: [true, [Validators.required]],
|
allowComments: [true, [Validators.required]],
|
||||||
password: ['', []],
|
password: ['', []],
|
||||||
voterEmailList: ['', []],
|
voterEmailList: ['', []],
|
||||||
|
natural_lang_interval: ['', []],
|
||||||
dateCreated: [creationDate, [Validators.required]],
|
dateCreated: [creationDate, [Validators.required]],
|
||||||
hasSeveralHours: [false, [Validators.required]],
|
hasSeveralHours: [false, [Validators.required]],
|
||||||
hasMaxCountOfAnswers: [true, [Validators.required, Validators.min(1)]],
|
hasMaxCountOfAnswers: [true, [Validators.required, Validators.min(1)]],
|
||||||
@ -109,12 +111,9 @@ export class FormComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDefaultFormValues(): void {
|
setDefaultFormValues(): void {
|
||||||
const dateStart = this.dateUtils.formateDateToInputStringNg(new Date());
|
|
||||||
const dateEnd = this.dateUtils.formateDateToInputStringNg(this.dateUtils.addDaysToDate(5, new Date()));
|
|
||||||
|
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
creatorPseudo: 'Anne Onyme',
|
creatorPseudo: 'Anne Onyme',
|
||||||
creatorEmail: '',
|
creatorEmail: 'anne_onyme@anonymous_email.com',
|
||||||
description: 'RSVP',
|
description: 'RSVP',
|
||||||
isAboutDate: true,
|
isAboutDate: true,
|
||||||
hasSeveralHours: false,
|
hasSeveralHours: false,
|
||||||
@ -130,12 +129,19 @@ export class FormComponent implements OnInit, AfterViewInit {
|
|||||||
isZeroKnoledge: true,
|
isZeroKnoledge: true,
|
||||||
areResultsPublic: true,
|
areResultsPublic: true,
|
||||||
allowComments: true,
|
allowComments: true,
|
||||||
expiresDaysDelay: 60,
|
expiresDaysDelay: environment.expiresDaysDelay,
|
||||||
maxCountOfAnswers: 150,
|
maxCountOfAnswers: environment.maxCountOfAnswers,
|
||||||
allowNewDateTime: false,
|
allowNewDateTime: false,
|
||||||
startDateInterval: dateStart,
|
// startDateInterval: formatDate(new Date(), 'yyyy-MM-dd', 'fr_FR'),
|
||||||
endDateInterval: dateEnd,
|
endDateInterval: formatDate(
|
||||||
|
this.dateUtils.addDaysToDate(environment.interval_days_default, new Date()),
|
||||||
|
'yyyy-MM-dd',
|
||||||
|
'fr_FR'
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
console.log("this.form.controls['startDateInterval']", this.form.controls['startDateInterval']);
|
||||||
|
this.form.controls['startDateInterval'].setValue(formatDate(new Date(), 'yyyy-MM-dd', 'fr_FR'));
|
||||||
|
console.log("this.form.controls['startDateInterval']", this.form.controls['startDateInterval']);
|
||||||
this.automaticSlug();
|
this.automaticSlug();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,17 +153,12 @@ export class FormComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
this.form.patchValue({ creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com' });
|
this.form.patchValue({ creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com' });
|
||||||
|
|
||||||
const dateStart = this.dateUtils.formateDateToInputStringNg(new Date());
|
|
||||||
const dateEnd = this.dateUtils.formateDateToInputStringNg(this.dateUtils.addDaysToDate(5, new Date()));
|
|
||||||
|
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
title: title,
|
title: title,
|
||||||
custom_url: this.pollUtilitiesService.makeSlugFromString(title),
|
custom_url: this.pollUtilitiesService.makeSlugFromString(title),
|
||||||
description: 'répondez SVP <3 ! *-*',
|
description: 'répondez SVP <3 ! *-*',
|
||||||
creatorPseudo: 'Chuck Norris',
|
creatorPseudo: 'Chuck Norris',
|
||||||
creatorEmail: 'chucknorris@example.com',
|
creatorEmail: 'chucknorris@example.com',
|
||||||
dateStart,
|
|
||||||
dateEnd,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,13 @@ export const environment = {
|
|||||||
frontDomain: 'http://127.0.0.1:4200',
|
frontDomain: 'http://127.0.0.1:4200',
|
||||||
production: false,
|
production: false,
|
||||||
display_routes: true,
|
display_routes: true,
|
||||||
// autofill: true,
|
autofill: true,
|
||||||
autofill: false,
|
// autofill: false,
|
||||||
showDemoWarning: true,
|
showDemoWarning: true,
|
||||||
autoSendNewPoll: false,
|
autoSendNewPoll: false,
|
||||||
interval_days_default: 7,
|
interval_days_default: 7,
|
||||||
|
expiresDaysDelay: 60,
|
||||||
|
maxCountOfAnswers: 150,
|
||||||
appTitle: 'funky',
|
appTitle: 'funky',
|
||||||
appVersion: '0.6.0',
|
appVersion: '0.6.0',
|
||||||
appLogo: 'assets/img/logo.png',
|
appLogo: 'assets/img/logo.png',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user