forked from tykayn/funky-framadate-front
⚡ 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
|
||||
*/
|
||||
import {environment} from "../../environments/environment";
|
||||
import {defaultAnswers, otherDefaultDates, otherTimeOfDay} from "./defaultConfigs";
|
||||
import {DateChoice, defaultAnswers, otherDefaultDates, PollAnswer} from "./defaultConfigs";
|
||||
|
||||
export interface DateOption {
|
||||
timeList: any;
|
||||
@ -18,6 +18,7 @@ const baseConfigValues = {
|
||||
myEmail: "",
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* configuration of the poll, add new fields at will
|
||||
*/
|
||||
@ -56,13 +57,13 @@ export class PollConfig {
|
||||
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
|
||||
adminKey = ''; // key to change config of the poll
|
||||
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)
|
||||
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
|
||||
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() {
|
||||
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: 'midi'},
|
||||
{literal: 'soir'}
|
||||
];
|
||||
export const otherSlicesOfDay = [
|
||||
export const otherSlicesOfDay: TimeSlices[] = [
|
||||
{literal: 'aux aurores'},
|
||||
{literal: 'au petit dej'},
|
||||
{literal: 'au deuxième petit dej des hobbits'}
|
||||
];
|
||||
export const defaultTimeOfDay = Array.from([{
|
||||
timeList: [...basicSlicesOfDay],
|
||||
literal: 'matin'
|
||||
},
|
||||
{timeList: [...basicSlicesOfDay], literal: 'midi'},
|
||||
{timeList: [...basicSlicesOfDay], literal: 'après-midi'},
|
||||
{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 defaultTimeOfDay: TimeSlices[] = (() => {
|
||||
return [...basicSlicesOfDay]
|
||||
})();
|
||||
|
||||
export const otherTimeOfDay: TimeSlices[] = (() => {
|
||||
return [...otherSlicesOfDay]
|
||||
})();
|
||||
export const defaultDates: DateChoice[] = [
|
||||
{
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`,
|
||||
date_object: new Date(),
|
||||
timeList: [...otherSlicesOfDay]
|
||||
timeList: defaultTimeOfDay
|
||||
},
|
||||
{
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
|
||||
date_object: new Date(),
|
||||
timeList: [...basicSlicesOfDay]
|
||||
timeList: defaultTimeOfDay
|
||||
},
|
||||
{
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
|
||||
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()}`,
|
||||
date_object: new Date(),
|
||||
timeList: [...otherSlicesOfDay]
|
||||
timeList: otherTimeOfDay
|
||||
},
|
||||
{
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
|
||||
date_object: new Date(),
|
||||
timeList: [...basicSlicesOfDay]
|
||||
timeList: defaultTimeOfDay
|
||||
},
|
||||
{
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
|
||||
date_object: new Date(),
|
||||
timeList: [...otherSlicesOfDay]
|
||||
timeList: otherTimeOfDay
|
||||
}
|
||||
];
|
||||
export const defaultAnswers = [{
|
||||
export const defaultAnswers: PollAnswer[] = [{
|
||||
id: 0,
|
||||
text: 'réponse de démo 1',
|
||||
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()}`,
|
||||
date_object: new Date(),
|
||||
timeList: Array.from(otherSlicesOfDay)
|
||||
timeList: otherSlicesOfDay
|
||||
},
|
||||
{
|
||||
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',
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
|
||||
date_object: new Date(),
|
||||
timeList: Array.from(basicSlicesOfDay)
|
||||
timeList: basicSlicesOfDay
|
||||
},
|
||||
{
|
||||
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',
|
||||
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
|
||||
date_object: new Date(),
|
||||
timeList: Array.from(otherSlicesOfDay)
|
||||
timeList: otherSlicesOfDay
|
||||
}];
|
||||
|
@ -183,6 +183,10 @@
|
||||
*ngIf=" 'true' === config.allowSeveralHours"
|
||||
class="several-times"
|
||||
>
|
||||
<pre class='debug padded warning' >
|
||||
choice.timeList :
|
||||
{{choice.timeList|json}}
|
||||
</pre >
|
||||
<h2 >Several hours</h2 >
|
||||
<div
|
||||
*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 {DOCUMENT} from '@angular/common';
|
||||
import {MessageService} from "primeng/api";
|
||||
import {defaultTimeOfDay} from "../../config/defaultConfigs";
|
||||
import {otherDefaultDates} from "../../config/defaultConfigs";
|
||||
import {DateUtilities} from "../../config/DateUtilities";
|
||||
|
||||
@Component({
|
||||
@ -76,7 +76,7 @@ export class DatesComponent extends BaseComponent implements OnInit {
|
||||
}
|
||||
|
||||
resetTimes() {
|
||||
this.config.timeList = defaultTimeOfDay;
|
||||
this.config.timeList = otherDefaultDates;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user