import type { IFieldBase } from './field.types'; import { FieldBase } from './field.types'; export interface IDay { id: string; time: number; date: Date; name: string; monthLong: string; monthShort: string; weekdayLong: string; weekdayShort: string; year: number; dayOfWeek: number; dayOfMonth: number; dayOfYear: number; weekOfYear: number; selected: boolean, types: string[]; tags: string[]; // TODO --> make this time / d3 intelligent. Could work well with scheduling. // Thinking about this more - these activities could be mapped to your identity model // which would allow you to view them in the main graph, build analytics etc. // It would also allow you to fill them out with check-ins at those activities, timestamps etc // If this is all kept completely private and for the individuals use only it could prove to be // a very powerful day-to-day use for the iamme application which could benefit them with YAAS etc. data: any; } export class Day implements IDay { id = ''; time = 0; date = new Date(); name= ''; monthLong = ''; monthShort = ''; weekdayLong = ''; weekdayShort = ''; year = 2020; dayOfWeek = 1; dayOfMonth = 1; dayOfYear = 1; weekOfYear = 1; selected = false; types = []; tags = []; data = null; constructor(day: Partial) { this.id = day.id ? day.id : this.id; this.time = day.time ? day.time : this.time; this.date = day.date ? day.date : this.date; this.monthLong = day.monthLong ? day.monthLong : this.monthLong; this.monthShort = day.monthShort ? day.monthShort : this.monthShort; this.weekdayLong = day.weekdayLong ? day.weekdayLong : this.weekdayLong; this.weekdayShort = day.weekdayShort ? day.weekdayShort : this.weekdayShort; this.name = day.weekdayLong ? day.weekdayLong : this.name; this.year = day.year ? day.year : this.year; this.dayOfWeek = day.dayOfWeek ? day.dayOfWeek : this.dayOfWeek; this.dayOfMonth = day.dayOfMonth ? day.dayOfMonth : this.dayOfMonth; this.dayOfYear = day.dayOfYear ? day.dayOfYear : this.dayOfYear; this.weekOfYear = day.weekOfYear ? day.weekOfYear : this.weekOfYear; this.selected = day.selected ? day.selected : this.selected; this.types = day.types ? day.types : this.types; this.tags = day.tags ? day.tags : this.tags; this.data = day.data || this.data; } } export interface Month { name: string, days: Day[], year: number }; export interface IDateRange { startDate: Date, endDate?: Date, type: string } export class DateRange implements IDateRange { startDate = new Date(); endDate = null; type = ''; constructor(dateRange: Partial) { this.startDate = dateRange.startDate || this.startDate; this.endDate = dateRange.endDate || this.endDate; this.type = dateRange.type || this.type; } } export interface ICalendar extends IFieldBase { placeholder?: string; } export class CalendarModel extends FieldBase implements ICalendar { type = 'calendar'; subType = "singleLine"; placeholder = 'Placeholder text'; constructor(input: Partial) { super(input); this.subType = input.subType || this.subType; this.placeholder = input.placeholder || this.placeholder; } } // SCHEMA export interface CalendarStateScaffold { orienation: { time: any, data: any }; information: { simple: any, detailed: any, heat: any, tree: any }; engagement: { selectingStart: any, selectingEnd: any } } export interface CalendarStates extends CalendarStateScaffold { orienation: { time: any, data: any }; information: { simple: any, detailed: any, heat: any, tree: any }; engagement: { selectingStart: any, selectingEnd: any } } // EVENTS that the machine handles export type Calendar_Event_Sort = { type: 'SORT'; metric: string }; export type Calendar_Event_Orientate = { type: 'ORIENTATE'; value: string, activeDate: any }; export type Calendar_Event_ViewSimple = { type: 'VIEW_SIMPLE'; value: string }; export type Calendar_Event_ViewDetailed = { type: 'VIEW_DETAILED'; value: string }; export type Calendar_Event_ViewTree = { type: 'VIEW_TREE'; value: string }; export type Calendar_Event_ViewHeat = { type: 'VIEW_HEAT'; value: string }; export type Calendar_Event_ActivateDate = { type: 'ACTIVATE_DATE'; value: string }; export type Calendar_Event_SelectDate = { type: 'SELECT_DATE'; value: any }; export type CalendarEvent = Calendar_Event_Sort | Calendar_Event_Orientate | Calendar_Event_ViewSimple | Calendar_Event_ViewDetailed | Calendar_Event_ViewTree | Calendar_Event_ViewHeat | Calendar_Event_ActivateDate | Calendar_Event_SelectDate export interface CalendarEventsScaffold { 'SORT': Function, 'ORIENTATE': Function, 'ACTIVATE_DATE': Function, 'SELECT_DATE': Function, 'VIEW_SIMPLE': Function, 'VIEW_DETAILED': Function, 'VIEW_TREE': Function, 'VIEW_HEAT': Function } // CONTEXT export interface CalendarContext { field: ICalendar; calendar: Month[]; activeDate: any; startDate: Day; endDate: Day; // Note --> if this is a range picker graph: any; // multiple choice machines in here for range picking? } interface CalendarContextUndefined { field: undefined; activeDate: undefined; startDate: undefined; endDate: undefined; graph: undefined; } export interface CalendarStateSchema { initial: string; context: CalendarContext; states: CalendarStates }; export type CalendarState = { value: { orienation: 'time', information: 'simple', engagement: 'selectingStart' }; context: CalendarContext; } | { value: { orienation: 'time', information: 'detailed', engagement: 'selectingStart' }; context: CalendarContext; } | { value: { orienation: 'time', information: 'heat', engagement: 'selectingStart' }; context: CalendarContext; } | { value: { orienation: 'data', information: 'detailed', engagement: 'selectingStart' }; context: CalendarContext; } | { value: { orienation: 'data', information: 'tree', engagement: 'selectingStart' }; context: CalendarContext; } | { value: { orienation: 'data', information: 'heat', engagement: 'selectingStart' }; context: CalendarContext; } | { value: { orienation: 'time', information: 'simple', engagement: 'selectingEnd' }; context: CalendarContext; } | { value: { orienation: 'time', information: 'detailed', engagement: 'selectingEnd' }; context: CalendarContext; } | { value: { orienation: 'time', information: 'heat', engagement: 'selectingEnd' }; context: CalendarContext; } | { value: { orienation: 'data', information: 'detailed', engagement: 'selectingEnd' }; context: CalendarContext; } | { value: { orienation: 'data', information: 'tree', engagement: 'selectingEnd' }; context: CalendarContext; } | { value: { orienation: 'data', information: 'heat', engagement: 'selectingEnd' }; context: CalendarContext; }; // Calendar tree types --> these are not really identifiable as the id's (and hence the state names) are // dynamically generated. Also, they are not truly necessary.