⚡ add some types interfaces in the config
This commit is contained in:
parent
4ec9b174ad
commit
49b7939564
|
@ -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, otherDefaultDates, otherTimeOfDay} from "./defaultConfigs";
|
import {DateChoice, defaultAnswers, otherDefaultDates, PollAnswer} from "./defaultConfigs";
|
||||||
|
|
||||||
export interface DateOption {
|
export interface DateOption {
|
||||||
timeList: any;
|
timeList: any;
|
||||||
|
@ -18,6 +18,7 @@ const baseConfigValues = {
|
||||||
myEmail: "",
|
myEmail: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* configuration of the poll, add new fields at will
|
* configuration of the poll, add new fields at will
|
||||||
*/
|
*/
|
||||||
|
@ -56,13 +57,13 @@ export class PollConfig {
|
||||||
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
|
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
|
||||||
adminKey = ''; // key to change config of the poll
|
adminKey = ''; // key to change config of the poll
|
||||||
owner_modifier_token = ''; // key to change a vote stack
|
owner_modifier_token = ''; // key to change a vote stack
|
||||||
canModifyAnswers = true;// bool for the frontend selector
|
canModifyAnswers: boolean = 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 = otherDefaultDates; // 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 = otherTimeOfDay; // ranges of time expressed as strings
|
timeList: DateChoice[] = otherDefaultDates; // ranges of time expressed as strings
|
||||||
|
|
||||||
answers: any = defaultAnswers;
|
answers: PollAnswer[] = defaultAnswers;
|
||||||
|
|
||||||
resetConfig() {
|
resetConfig() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
|
@ -1,78 +1,80 @@
|
||||||
export const basicSlicesOfDay = [
|
export interface DateChoice {
|
||||||
|
literal: string,
|
||||||
|
timeList: TimeSlices[],
|
||||||
|
date_object: Date
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TimeSlices {
|
||||||
|
literal: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PollAnswer {
|
||||||
|
id: number,
|
||||||
|
text: string,
|
||||||
|
url: string,
|
||||||
|
literal: string,
|
||||||
|
date_object: Date,
|
||||||
|
timeList: TimeSlices[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const basicSlicesOfDay: TimeSlices[] = [
|
||||||
{literal: 'matin'},
|
{literal: 'matin'},
|
||||||
{literal: 'midi'},
|
{literal: 'midi'},
|
||||||
{literal: 'soir'}
|
{literal: 'soir'}
|
||||||
];
|
];
|
||||||
export const otherSlicesOfDay = [
|
export const otherSlicesOfDay: TimeSlices[] = [
|
||||||
{literal: 'aux aurores'},
|
{literal: 'aux aurores'},
|
||||||
{literal: 'au petit dej'},
|
{literal: 'au petit dej'},
|
||||||
{literal: 'au deuxième petit dej des hobbits'}
|
{literal: 'au deuxième petit dej des hobbits'}
|
||||||
];
|
];
|
||||||
export const defaultTimeOfDay = Array.from([{
|
export const defaultTimeOfDay: TimeSlices[] = (() => {
|
||||||
timeList: [...basicSlicesOfDay],
|
return [...basicSlicesOfDay]
|
||||||
literal: 'matin'
|
})();
|
||||||
},
|
|
||||||
{timeList: [...basicSlicesOfDay], literal: 'midi'},
|
export const otherTimeOfDay: TimeSlices[] = (() => {
|
||||||
{timeList: [...basicSlicesOfDay], literal: 'après-midi'},
|
return [...otherSlicesOfDay]
|
||||||
{timeList: [...basicSlicesOfDay], literal: 'soirée'}]);
|
})();
|
||||||
export const otherTimeOfDay = Array.from([{
|
export const defaultDates: DateChoice[] = [
|
||||||
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 = [
|
|
||||||
{
|
{
|
||||||
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: [...otherSlicesOfDay]
|
timeList: defaultTimeOfDay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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: [...basicSlicesOfDay]
|
timeList: defaultTimeOfDay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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: [...otherSlicesOfDay]
|
timeList: defaultTimeOfDay
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
export const otherDefaultDates = [
|
export const otherDefaultDates: DateChoice[] = [
|
||||||
{
|
{
|
||||||
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: [...otherSlicesOfDay]
|
timeList: otherTimeOfDay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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: [...basicSlicesOfDay]
|
timeList: defaultTimeOfDay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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: [...otherSlicesOfDay]
|
timeList: otherTimeOfDay
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
export const defaultAnswers = [{
|
export const defaultAnswers: PollAnswer[] = [{
|
||||||
id: 0,
|
id: 0,
|
||||||
text: 'réponse de démo 1',
|
text: 'réponse de démo 1',
|
||||||
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: Array.from(otherSlicesOfDay)
|
timeList: otherSlicesOfDay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -80,7 +82,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)
|
timeList: basicSlicesOfDay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
|
@ -88,5 +90,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)
|
timeList: otherSlicesOfDay
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -183,6 +183,10 @@
|
||||||
*ngIf=" 'true' === config.allowSeveralHours"
|
*ngIf=" 'true' === config.allowSeveralHours"
|
||||||
class="several-times"
|
class="several-times"
|
||||||
>
|
>
|
||||||
|
<pre class='debug padded warning' >
|
||||||
|
choice.timeList :
|
||||||
|
{{choice.timeList|json}}
|
||||||
|
</pre >
|
||||||
<h2 >Several hours</h2 >
|
<h2 >Several hours</h2 >
|
||||||
<div
|
<div
|
||||||
*ngFor="let timeItem of choice.timeList; index as idTime"
|
*ngFor="let timeItem of choice.timeList; index as idTime"
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {ConfigService} from '../../services/config.service';
|
||||||
import {BaseComponent} from '../base-page/base.component';
|
import {BaseComponent} from '../base-page/base.component';
|
||||||
import {DOCUMENT} from '@angular/common';
|
import {DOCUMENT} from '@angular/common';
|
||||||
import {MessageService} from "primeng/api";
|
import {MessageService} from "primeng/api";
|
||||||
import {defaultTimeOfDay} from "../../config/defaultConfigs";
|
import {otherDefaultDates} from "../../config/defaultConfigs";
|
||||||
import {DateUtilities} from "../../config/DateUtilities";
|
import {DateUtilities} from "../../config/DateUtilities";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -76,7 +76,7 @@ export class DatesComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
resetTimes() {
|
resetTimes() {
|
||||||
this.config.timeList = defaultTimeOfDay;
|
this.config.timeList = otherDefaultDates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue