dates and recap side to side

This commit is contained in:
Baptiste Lemoine 2020-02-13 17:41:36 +01:00
parent 15bbf0e375
commit 61bf6a289c
4 changed files with 169 additions and 115 deletions

View File

@ -2,7 +2,7 @@
* une option de date dans les sondages spéciaux * une option de date dans les sondages spéciaux
*/ */
import {environment} from "../../environments/environment"; import {environment} from "../../environments/environment";
import {defaultAnswers, defaultDates, defaultTimeOfDay} from "./defaultConfigs"; import {defaultAnswers, otherDefaultDates, otherTimeOfDay} from "./defaultConfigs";
export interface DateOption { export interface DateOption {
timeList: any; timeList: any;
@ -59,8 +59,8 @@ export class PollConfig {
canModifyAnswers = true;// bool for the frontend selector canModifyAnswers = true;// bool for the frontend selector
whoModifiesAnswers = "everybody";// everybody, self, nobody (= just admin) whoModifiesAnswers = "everybody";// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin) whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
dateList: any = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll dateList: any = 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 timeList: any = otherTimeOfDay; // ranges of time expressed as strings
answers: any = defaultAnswers; answers: any = defaultAnswers;

View File

@ -3,28 +3,67 @@ export const basicSlicesOfDay = [
{literal: 'midi'}, {literal: 'midi'},
{literal: 'soir'} {literal: 'soir'}
]; ];
export const defaultTimeOfDay = [{ export const otherSlicesOfDay = [
timeList: Object.create(basicSlicesOfDay), {literal: 'aux aurores'},
{literal: 'au petit dej'},
{literal: 'au deuxième petit dej des hobbits'}
];
export const defaultTimeOfDay = Array.from([{
timeList: [...basicSlicesOfDay],
literal: 'matin' literal: 'matin'
}, },
{timeList: Object.create(basicSlicesOfDay), literal: 'midi'}, {timeList: [...basicSlicesOfDay], literal: 'midi'},
{timeList: Object.create(basicSlicesOfDay), literal: 'après-midi'}, {timeList: [...basicSlicesOfDay], literal: 'après-midi'},
{timeList: Object.create(basicSlicesOfDay), literal: 'soirée'}]; {timeList: [...basicSlicesOfDay], literal: 'soirée'}]);
export const otherTimeOfDay = Array.from([{
timeList: [
{literal: 'aux aurores'},
{literal: 'au petit dej'},
{literal: 'au deuxième petit dej des hobbits'}
],
literal: 'matin'
},
{
timeList: [
{literal: 'matin'},
{literal: 'midi'},
{literal: 'soir'}
], literal: 'midi'
},
{timeList: [...otherSlicesOfDay], literal: 'après-midi'},
{timeList: [...basicSlicesOfDay], literal: 'soirée'}]);
export const defaultDates = [ export const defaultDates = [
{ {
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`, literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`,
date_object: new Date(), date_object: new Date(),
timeList: Object.create(basicSlicesOfDay) timeList: [...otherSlicesOfDay]
}, },
{ {
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`, literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
date_object: new Date(), date_object: new Date(),
timeList: Object.create(basicSlicesOfDay) timeList: [...basicSlicesOfDay]
}, },
{ {
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`, literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
date_object: new Date(), date_object: new Date(),
timeList: Object.create(basicSlicesOfDay) timeList: [...otherSlicesOfDay]
}
];
export const otherDefaultDates = [
{
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`,
date_object: new Date(),
timeList: [...otherSlicesOfDay]
},
{
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
date_object: new Date(),
timeList: [...basicSlicesOfDay]
},
{
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
date_object: new Date(),
timeList: [...otherSlicesOfDay]
} }
]; ];
export const defaultAnswers = [{ export const defaultAnswers = [{
@ -33,7 +72,7 @@ export const defaultAnswers = [{
url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574', url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`, literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`,
date_object: new Date(), date_object: new Date(),
timeList: Object.create(basicSlicesOfDay) timeList: Array.from(otherSlicesOfDay)
}, },
{ {
id: 1, id: 1,
@ -41,6 +80,7 @@ export const defaultAnswers = [{
url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574', url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`, literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
date_object: new Date(), date_object: new Date(),
timeList: Array.from(basicSlicesOfDay)
}, },
{ {
id: 2, id: 2,
@ -48,4 +88,5 @@ export const defaultAnswers = [{
url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574', url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`, literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
date_object: new Date(), date_object: new Date(),
timeList: Array.from(otherSlicesOfDay)
}]; }];

View File

@ -77,6 +77,8 @@
</button > </button >
<hr > <hr >
</section > </section >
<div class='columns' >
<div class='column' >
<div class="dates-list " > <div class="dates-list " >
<div class='title' > <div class='title' >
<span class="count-dates" > <span class="count-dates" >
@ -157,6 +159,7 @@
*ngFor="let choice of config.dateList; index as id" *ngFor="let choice of config.dateList; index as id"
class="date-choice" class="date-choice"
> >
{{id}})
<input <input
[(ngModel)]="choice.date_object" [(ngModel)]="choice.date_object"
name="dateChoices_{{id}}" name="dateChoices_{{id}}"
@ -180,15 +183,16 @@
*ngIf=" 'true' === config.allowSeveralHours" *ngIf=" 'true' === config.allowSeveralHours"
class="several-times" class="several-times"
> >
<h2 >Several hours</h2 >
<div <div
*ngFor="let time of choice.timeList; index as idTime" *ngFor="let timeItem of choice.timeList; index as idTime"
class="time-choice" class="time-choice"
> >
<input <input
[(ngModel)]="time.date_object" [(ngModel)]="timeItem.literal"
name="dateTime_{{id}}_Choices_{{idTime}}" name="dateTime_{{id}}_Choices_{{idTime}}"
id="dateTime_{{id}}_Choices_{{idTime}}" id="dateTime_{{id}}_Choices_{{idTime}}"
useValueAsDate
type="text" type="text"
> >
<button <button
@ -200,6 +204,12 @@
</div > </div >
</div > </div >
</div > </div >
</div >
<div class='column' >
<framadate-resume ></framadate-resume >
</div >
</div >
<a <a
[routerLink]="'/step/resume'" [routerLink]="'/step/resume'"
class="btn btn--full btn--primary" class="btn btn--full btn--primary"

View File

@ -38,12 +38,12 @@
<i class='fa fa-clock-o' ></i > <i class='fa fa-clock-o' ></i >
<span <span
class='well' class='well'
*ngIf="true ===!!config.allowSeveralHours" > *ngIf="'true' === config.allowSeveralHours" >
{{"dates.multiple.different"|translate}} {{"dates.multiple.different"|translate}}
</span > </span >
<span <span
class='well' class='well'
*ngIf="false ===!!config.allowSeveralHours" > *ngIf="'false' === config.allowSeveralHours" >
{{"dates.multiple.identical"|translate}} {{"dates.multiple.identical"|translate}}
</span > </span >
<div <div
@ -59,13 +59,15 @@
<!-- CASE different slices of the day--> <!-- CASE different slices of the day-->
<div <div
*ngIf="true ===!!config.allowSeveralHours" *ngIf="'true' === config.allowSeveralHours"
class="several-times" class="several-times"
> >
<div <div
*ngFor="let time of choice.timeList " *ngFor="let time of choice.timeList ; index as idTime"
class="time-choice" class="time-choice"
> >
{{idTime}})
<i class='fa fa-square-o' ></i > <i class='fa fa-square-o' ></i >
{{time.literal}} {{time.literal}}
</div > </div >
@ -73,13 +75,14 @@
</div > </div >
<!-- CASE all dates having the same slices of the day--> <!-- CASE all dates having the same slices of the day-->
<div <div
*ngIf="false ===!!config.allowSeveralHours" *ngIf="'false' === config.allowSeveralHours"
class="same-times" class="same-times"
> >
<div <div
*ngFor="let time of config.timeList " *ngFor="let time of config.timeList "
class="time-choice" class="time-choice"
> >
<i class='fa fa-square-o' ></i >
{{time.literal}} {{time.literal}}
</div > </div >
</div > </div >