Default to day grouping if no setting is provided

This commit is contained in:
Franco Speziali 2022-03-17 21:47:46 +01:00
parent a1d1621a75
commit df41f60101
2 changed files with 3 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import { GroupTypes } from "../types";
import Config from "../Config/Config"; import Config from "../Config/Config";
import Events from "../Events/"; import Events from "../Events/";
import EventGrouping from "../EventGrouping"; import EventGrouping from "../EventGrouping";
@ -11,7 +12,7 @@ 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"].charAt(0), groupTypes: 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(

View File

@ -4,6 +4,6 @@ export default class Config {
groupTypes: GroupTypes; groupTypes: GroupTypes;
constructor({ groupTypes }) { constructor({ groupTypes }) {
this.groupTypes = groupTypes.toUpperCase() || GroupTypes.Week; this.groupTypes = groupTypes.toUpperCase();
} }
} }