From bf7926b98d95b30b1a8b6dc5cf3fd14c53d316df Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Thu, 1 Sep 2022 18:00:37 +0200 Subject: [PATCH] feat(core): More granular hiding of parts This adds new top-level part config settings: - hide: hides this part and only this part (not new) - hideDependencies: Do not hide this part, but hide its dependencies - hideAll: Hide both this part and its dependencies --- packages/core/src/pattern.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/core/src/pattern.mjs b/packages/core/src/pattern.mjs index 6e583cbeb65..ce455b032f7 100644 --- a/packages/core/src/pattern.mjs +++ b/packages/core/src/pattern.mjs @@ -686,6 +686,10 @@ Pattern.prototype.resolveDependency = function ( /** Adds a part as a simple dependency **/ Pattern.prototype.addDependency = function (name, part, dep) { + if (part.hideDependencies || part.hideAll) { + dep.hide = true + dep.hideAll = true + } this.dependencies[name] = mergeDependencies(dep.name, this.dependencies[name]) if (typeof this.__parts[dep.name] === 'undefined') { this.__parts[dep.name] = decoratePartDependency(dep) @@ -713,6 +717,10 @@ Pattern.prototype.preresolveDependencies = function (count=0) { this.inject[name] = part.from.name if (typeof this.__parts[part.from.name] === 'undefined') { this.__parts[part.from.name] = decoratePartDependency(part.from) + if (part.hideDependencies || part.hideAll) { + this.__parts[part.from.name].hide = true + this.__parts[part.from.name].hideAll = true + } addPartConfig(this.__parts[part.from.name], this.config) } } @@ -806,7 +814,10 @@ Pattern.prototype.isHidden = function (partName) { if (this.settings.only.includes(partName)) return false } - return (this.__parts?.[partName]?.hide) ? true : false + if (this.__parts?.[partName]?.hide) return true + if (this.__parts?.[partName]?.hideAll) return true + + return false } /** Determines whether a part is wanted by the user