Skip to content

Commit

Permalink
Fix: Allow missing parent config (fixes #210) (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Feb 5, 2024
1 parent 4341507 commit dd30506
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions js/TrickleButtonModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class TrickleButtonModel extends ComponentModel {
*/
isEnabled() {
const trickleConfig = getModelConfig(this.getParent());
if (!trickleConfig) return false;
const isEnabled = trickleConfig._isEnabled && trickleConfig._button?._isEnabled;
return isEnabled;
}
Expand All @@ -29,6 +30,7 @@ export default class TrickleButtonModel extends ComponentModel {
*/
isStepLocking() {
const config = getModelConfig(this.getParent());
if (!config) return false;
const isStepLocking = config._stepLocking?._isEnabled;
return isStepLocking;
}
Expand All @@ -38,6 +40,7 @@ export default class TrickleButtonModel extends ComponentModel {
*/
isStepLockingCompletionRequired() {
const config = getModelConfig(this.getParent());
if (!config) return false;
const isStepLockingCompletionRequired = config._stepLocking &&
config._stepLocking._isEnabled &&
config._stepLocking._isCompletionRequired;
Expand Down Expand Up @@ -111,6 +114,7 @@ export default class TrickleButtonModel extends ComponentModel {
calculateButtonText() {
const parentModel = this.getParent();
const trickleConfig = getModelConfig(parentModel);
if (!trickleConfig) return;
let isStart = false;
let isFinal = false;
if (trickleConfig._onChildren) {
Expand Down
6 changes: 3 additions & 3 deletions js/TrickleButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class TrickleButtonView extends ComponentView {
return [
'trickle',
this.model.get('_id'),
config._button._component,
config._button._isFullWidth && 'is-full-width',
config._button._className
config?._button._component,
config?._button._isFullWidth && 'is-full-width',
config?._button._className
].filter(Boolean).join(' ');
}

Expand Down

0 comments on commit dd30506

Please sign in to comment.