FIX: prevents exception on /admin/badges page when model is not set (#8849)

Exception:

TypeError: Cannot read property 'badge_type_id' of null
This commit is contained in:
Joffrey JAFFEUX 2020-02-04 15:34:19 +01:00 committed by GitHub
parent 5d31f353f4
commit 1d54e78311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

View File

@ -24,19 +24,24 @@ export default Controller.extend(bufferedProperty("model"), {
// and as we are using a bufferedProperty it's not accessible
// in any other way
Ember.run.next(() => {
if (!this.model.badge_type_id) {
this.model.set("badge_type_id", this.get("badgeTypes.firstObject.id"));
}
if (this.model) {
if (!this.model.badge_type_id) {
this.model.set(
"badge_type_id",
this.get("badgeTypes.firstObject.id")
);
}
if (!this.model.badge_grouping_id) {
this.model.set(
"badge_grouping_id",
this.get("badgeGroupings.firstObject.id")
);
}
if (!this.model.badge_grouping_id) {
this.model.set(
"badge_grouping_id",
this.get("badgeGroupings.firstObject.id")
);
}
if (!this.model.trigger) {
this.model.set("trigger", this.get("badgeTriggers.firstObject.id"));
if (!this.model.trigger) {
this.model.set("trigger", this.get("badgeTriggers.firstObject.id"));
}
}
});
},