computeShown()

in src/rules.js [131:157]


	computeShown(fieldConfig, partialShownMap) {
		const shownRule = (fieldConfig.rules || []).find(rule => rule.property === properties.SHOWN);

		if (!shownRule) {
			return true;
		}

		const dependencies = new Set();
		// This will add any dependencies to the dependencies set, need to make this functional
		this.getConditionDependencies(shownRule.when, dependencies);

		dependencies.forEach(dependencyPath => {
			const dependencyFields = this.pathsToTreeMap[dependencyPath];

			// If we know there's a field with this path already shown, there's no need for extra calculations
			if (dependencyFields && !partialShownMap[dependencyPath]) {
				const isShown = dependencyFields.reduce((acc, field) => {
					const dependencyConfig = field.fieldConfig;
					return acc || this.computeShown(dependencyConfig, partialShownMap);
				}, false);

				partialShownMap[dependencyPath] = isShown;
			}
		});

		return this.parseCondition(shownRule.when, partialShownMap);
	}