Some renamed groupTypes => groupType as this references a single groupType
This commit is contained in:
parent
88a21c5cf2
commit
1e3688ca04
@ -12,12 +12,12 @@ export default class Calendar {
|
|||||||
constructor(json) {
|
constructor(json) {
|
||||||
this.jsonContent = json;
|
this.jsonContent = json;
|
||||||
this.config = new Config({
|
this.config = new Config({
|
||||||
groupTypes: json["group"] ? json["group"].charAt(0) : GroupTypes.Day,
|
groupType: json["group"] ? json["group"].charAt(0) : GroupTypes.Day,
|
||||||
});
|
});
|
||||||
this.events = new Events(json["events"]);
|
this.events = new Events(json["events"]);
|
||||||
this.eventGrouping = new EventGrouping(
|
this.eventGrouping = new EventGrouping(
|
||||||
this.events.sortedEvents,
|
this.events.sortedEvents,
|
||||||
this.config.groupTypes
|
this.config.groupType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { GroupTypes } from "../types";
|
import { GroupTypes } from "../types";
|
||||||
|
|
||||||
export default class Config {
|
export default class Config {
|
||||||
groupTypes: GroupTypes;
|
groupType: GroupTypes;
|
||||||
|
|
||||||
constructor({ groupTypes }) {
|
constructor({ groupType }) {
|
||||||
this.groupTypes = groupTypes.toUpperCase();
|
this.groupType = groupType.toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export default class EventGrouping {
|
|||||||
private readonly sortedEvents: Event[];
|
private readonly sortedEvents: Event[];
|
||||||
private readonly firstEvent: Event;
|
private readonly firstEvent: Event;
|
||||||
private readonly lastEvent: Event;
|
private readonly lastEvent: Event;
|
||||||
public readonly groupTypes: GroupTypes;
|
public readonly groupType: GroupTypes;
|
||||||
public readonly groups: Groups;
|
public readonly groups: Groups;
|
||||||
|
|
||||||
public static generateEmptyGroups(length: number): Groups {
|
public static generateEmptyGroups(length: number): Groups {
|
||||||
@ -24,16 +24,16 @@ export default class EventGrouping {
|
|||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(sortedEvents: Event[], groupTypes: GroupTypes) {
|
constructor(sortedEvents: Event[], groupType: GroupTypes) {
|
||||||
this.sortedEvents = sortedEvents;
|
this.sortedEvents = sortedEvents;
|
||||||
this.firstEvent = this.sortedEvents[0];
|
this.firstEvent = this.sortedEvents[0];
|
||||||
this.lastEvent = this.sortedEvents[this.sortedEvents.length - 1];
|
this.lastEvent = this.sortedEvents[this.sortedEvents.length - 1];
|
||||||
this.groupTypes = groupTypes;
|
this.groupType = groupType;
|
||||||
this.groups = this.group(groupTypes);
|
this.groups = this.group(groupType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private group(groupTypes: GroupTypes): Groups {
|
private group(groupType: GroupTypes): Groups {
|
||||||
switch (groupTypes) {
|
switch (groupType) {
|
||||||
case GroupTypes.Day:
|
case GroupTypes.Day:
|
||||||
return this.byDay();
|
return this.byDay();
|
||||||
case GroupTypes.Week:
|
case GroupTypes.Week:
|
||||||
@ -100,7 +100,7 @@ export default class EventGrouping {
|
|||||||
public getDateFromGroupIndex(index: number): Date {
|
public getDateFromGroupIndex(index: number): Date {
|
||||||
const startDate = this.firstEvent.date;
|
const startDate = this.firstEvent.date;
|
||||||
|
|
||||||
switch (this.groupTypes) {
|
switch (this.groupType) {
|
||||||
case GroupTypes.Day:
|
case GroupTypes.Day:
|
||||||
return add(startDate, { days: index });
|
return add(startDate, { days: index });
|
||||||
case GroupTypes.Week:
|
case GroupTypes.Week:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user