Default to day grouping if invalid parameter
This commit is contained in:
parent
ea994df145
commit
e800147eaa
@ -14,12 +14,24 @@ export default class Calendar {
|
|||||||
|
|
||||||
constructor(json: object) {
|
constructor(json: object) {
|
||||||
this.jsonContent = json;
|
this.jsonContent = json;
|
||||||
this.groupType = json["group"]
|
this.groupType = this.getGroupType(json);
|
||||||
? json["group"].charAt(0).toUpperCase()
|
|
||||||
: GroupTypes.Day;
|
|
||||||
this.events = new Events(json["events"]);
|
this.events = new Events(json["events"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getGroupType(json: object): GroupTypes {
|
||||||
|
if (!json["group"]) {
|
||||||
|
return GroupTypes.Day;
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupType = json["group"].charAt(0).toUpperCase();
|
||||||
|
|
||||||
|
if (!Object.values(GroupTypes).includes(groupType)) {
|
||||||
|
return GroupTypes.Day;
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupType;
|
||||||
|
}
|
||||||
|
|
||||||
render(): HTMLDivElement {
|
render(): HTMLDivElement {
|
||||||
switch (this.groupType) {
|
switch (this.groupType) {
|
||||||
case GroupTypes.Day:
|
case GroupTypes.Day:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user