From a8fb226820f14744fb461248a6f21ea88861987b Mon Sep 17 00:00:00 2001 From: Frank Weinberg Date: Sun, 28 Jul 2024 15:16:57 +0200 Subject: [PATCH] Fix ruleset editor --- html/components/ruleset-tab/index.html | 21 +++++++++---------- html/components/ruleset-tab/index.js | 28 +++++++++++--------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/html/components/ruleset-tab/index.html b/html/components/ruleset-tab/index.html index c63e782e..d11f4d41 100644 --- a/html/components/ruleset-tab/index.html +++ b/html/components/ruleset-tab/index.html @@ -3,7 +3,7 @@
Current Ruleset: - - + + diff --git a/html/components/ruleset-tab/index.js b/html/components/ruleset-tab/index.js index b34fe0c6..076fb546 100644 --- a/html/components/ruleset-tab/index.js +++ b/html/components/ruleset-tab/index.js @@ -1,20 +1,11 @@ 'use strict'; -let activeRsPrefix = _windowFunctions.hasParam('ruleset') - ? 'ScoreBoard.Rulesets.Ruleset(' + _windowFunctions.getParam('ruleset') + ')' - : 'ScoreBoard.Game(' + _windowFunctions.getParam('game') + ')'; +WS.Register('ScoreBoard.Rulesets.Ruleset(*).Parent'); function rsCompareChildIndex(a, b) { return _sbCompareAttrThenSubId('index', $(a).children('[index]'), $(b).children('[index]')); } -function rsUpdateActive(k, v) { - if (k.Game) { - activeRsPrefix = v ? 'ScoreBoard.Rulesets.Ruleset(' + v + ')' : 'ScoreBoard.Game(' + k.Game + ')'; - } - return v; -} - function rsTriggerFold(k, v, elem) { elem.parent().parent().toggleClass('folded'); } @@ -27,12 +18,16 @@ function rsPart2(k, v) { return v ? v.split('.', 2)[1] : ''; } -function rsDisableToggle() { - return isTrue(WS.state[activeRsPrefix + '.Readonly']) || WS.state[activeRsPrefix + '.Ruleset'] == null; +function rsIsInherited(k, v) { + return (k.field === 'Ruleset' && !!v) || (!k.Game && !v); +} + +function rsIsNotInherited(k, v) { + return !rsIsInherited(k, v); } -function rsDisableSetter() { - return isTrue(WS.state[activeRsPrefix + '.Readonly']); +function rsDisableToggle(k, v) { + return k.Game != null || isTrue(v); } function rsDefinitionOverride(k, v, elem) { @@ -49,8 +44,9 @@ function _rsGetEffectiveValue(rs, rule) { } function rsGetDisplayValue(k, v, elem) { - const value = - WS.state[activeRsPrefix + '.Rule(' + k.Rule + ')'] || _rsGetEffectiveValue(activeRsPrefix.split('(')[1].slice(0, -1), k.Rule); + const value = k.Game + ? v + : _rsGetEffectiveValue(_windowFunctions.getParam('ruleset'), WS._enrichProp(WS._getContext(elem)[0]).RuleDefinition); return ( elem .parent()