fix display of several time slices under days choices

This commit is contained in:
Tykayn 2021-05-20 09:53:20 +02:00 committed by tykayn
parent cf6395936e
commit 4a47e9fea3
5 changed files with 28 additions and 19 deletions

View File

@ -64,8 +64,8 @@
réinitialiser réinitialiser
</span> </span>
</button> </button>
<fieldset class="range-container is-boxed"> <fieldset class="range-container is-boxed" *ngIf="!form.value.hasSeveralHours">
<div class="range-time" *ngIf="!form.value.hasSeveralHours"> <div class="range-time">
<h2> <h2>
<span class="count-dates-txt"> <span class="count-dates-txt">
{{ 'dates.count_time' | translate }} {{ 'dates.count_time' | translate }}
@ -82,8 +82,8 @@
<i class="fa fa-refresh"></i> <i class="fa fa-refresh"></i>
</button> </button>
</div> </div>
<app-time-list [timeSlices]="timeSlices"></app-time-list>
</div> </div>
<app-time-list [timeSlices]="timeSlices"></app-time-list>
</fieldset> </fieldset>
</div> </div>
</div> </div>
@ -91,9 +91,10 @@
<hr /> <hr />
<div class="main-box is-boxed"> <div class="main-box is-boxed">
liste de jours :
<app-day-list <app-day-list
[form]="form" [form]="form"
[dateList]="dateList" [dateChoices]="dateChoices"
[hasSeveralHours]="form.value.hasSeveralHours" [hasSeveralHours]="form.value.hasSeveralHours"
></app-day-list> ></app-day-list>
</div> </div>

View File

@ -27,7 +27,7 @@ export class DateSelectComponent implements OnInit {
endDateInterval: string; endDateInterval: string;
intervalDaysDefault = 7; intervalDaysDefault = 7;
dateList: 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
selectionKind = 'range'; selectionKind = 'range';
@ -44,7 +44,7 @@ export class DateSelectComponent implements OnInit {
private translateService: TranslateService, private translateService: TranslateService,
@Inject(DOCUMENT) private document: any @Inject(DOCUMENT) private document: any
) { ) {
this.dateList = this.storageService.dateChoices; this.dateChoices = this.storageService.dateChoices;
this.timeSlices = this.storageService.timeSlices; this.timeSlices = this.storageService.timeSlices;
} }
@ -61,14 +61,14 @@ export class DateSelectComponent implements OnInit {
removeAllTimes() { removeAllTimes() {
this.timeSlices = []; this.timeSlices = [];
this.dateList.map((elem) => (elem.timeSlices = [])); this.dateChoices.map((elem) => (elem.timeSlices = []));
this.toastService.display('périodes horaires vidées'); this.toastService.display('périodes horaires vidées');
} }
resetTimes(slices = Object.create(defaultTimeOfDay)) { resetTimes(slices = Object.create(defaultTimeOfDay)) {
this.timeSlices = slices; this.timeSlices = slices;
this.dateList.map((elem) => (elem.timeSlices = Object.create(slices))); this.dateChoices.map((elem) => (elem.timeSlices = Object.create(slices)));
this.toastService.display('périodes horaires réinitialisées'); this.toastService.display('périodes horaires réinitialisées');
} }
} }

View File

@ -8,7 +8,7 @@
</div> </div>
<div class="column"> <div class="column">
<span class="count-dates title"> <span class="count-dates title">
{{ dateList.length }} {{ dateChoices.length }}
</span> </span>
<span> <span>
{{ 'dates.count_dates' | translate }} {{ 'dates.count_dates' | translate }}
@ -16,7 +16,12 @@
</div> </div>
</div> </div>
<div class="columns days-list" cdkDropList [cdkDropListData]="dateList" (cdkDropListDropped)="dropDayItem($event)"> <div
class="columns days-list"
cdkDropList
[cdkDropListData]="dateChoices"
(cdkDropListDropped)="dropDayItem($event)"
>
<div class="column"> <div class="column">
<h2>Dates</h2> <h2>Dates</h2>
<button class="btn button-help" mat-raised-button (click)="openSimple()"> <button class="btn button-help" mat-raised-button (click)="openSimple()">
@ -26,7 +31,7 @@
<br /> <br />
<br /> <br />
<div <div
*ngFor="let choice of dateList; index as id" *ngFor="let choice of dateChoices; index as id"
class="date-choice padded" class="date-choice padded"
cdkDrag cdkDrag
[ngClass]="{ 'day-weekend': isWeekendDay(choice.date_object) }" [ngClass]="{ 'day-weekend': isWeekendDay(choice.date_object) }"
@ -45,7 +50,7 @@
useValueAsDate useValueAsDate
type="date" type="date"
/> />
<button (click)="dateList.splice(id, 1)" class="btn btn-warning"> <button (click)="dateChoices.splice(id, 1)" class="btn btn-warning">
<i class="fa fa-times" aria-hidden="true"></i> <i class="fa fa-times" aria-hidden="true"></i>
</button> </button>
<button (click)="addTimeToDate(choice, id)" *ngIf="hasSeveralHours" class="btn btn--primary"> <button (click)="addTimeToDate(choice, id)" *ngIf="hasSeveralHours" class="btn btn--primary">
@ -53,7 +58,7 @@
</button> </button>
<div *ngIf="hasSeveralHours" class="several-times"> <div *ngIf="hasSeveralHours" class="several-times">
<br /> <br />
<app-time-list [timeSlices]="choice.timeList"></app-time-list> <app-time-list [timeSlices]="choice.timeSlices"></app-time-list>
</div> </div>
</div> </div>
</div> </div>

View File

@ -8,3 +8,6 @@
margin-right: 1ch; margin-right: 1ch;
display: inline-block; display: inline-block;
} }
.several-times {
padding-left: 2em;
}

View File

@ -18,7 +18,7 @@ export class DayListComponent {
@Input() @Input()
form: FormGroup; form: FormGroup;
@Input() @Input()
public dateList: Array<any> = []; public dateChoices: Array<DateChoice> = [];
@Input() @Input()
public hasSeveralHours: boolean; public hasSeveralHours: boolean;
timeList: any; timeList: any;
@ -35,7 +35,7 @@ export class DayListComponent {
} }
reinitChoices(): void { reinitChoices(): void {
this.dateList = []; this.dateChoices = [];
} }
setDemoTextChoices(): void { setDemoTextChoices(): void {
@ -88,9 +88,9 @@ export class DayListComponent {
keyOnChoice($event: KeyboardEvent, choice_number: number): void { keyOnChoice($event: KeyboardEvent, choice_number: number): void {
$event.preventDefault(); $event.preventDefault();
console.log('this. dateChoices.length', this.dateList.length); console.log('this. dateChoices.length', this.dateChoices.length);
console.log('choice_number', choice_number); console.log('choice_number', choice_number);
const lastChoice = this.dateList.length - 1 === choice_number; const lastChoice = this.dateChoices.length - 1 === choice_number;
// TODO handle shortcuts // TODO handle shortcuts
// reset field with Ctrl + D // reset field with Ctrl + D
// add a field with Ctrl + N // add a field with Ctrl + N
@ -146,8 +146,8 @@ export class DayListComponent {
} }
deleteChoiceField(index: number): void { deleteChoiceField(index: number): void {
if (this.dateList.length !== 1) { if (this.dateChoices.length !== 1) {
this.dateList.splice(index, 1); this.dateChoices.splice(index, 1);
} }
} }