From 2cb7412432a7fb02b9df5624bfceeee6457446de Mon Sep 17 00:00:00 2001 From: Julien Cochuyt Date: Mon, 26 Aug 2024 03:04:04 +0200 Subject: [PATCH] Support the "multiple" property for rules of type "parent" Step towards #46 --- .../webAccess/ruleHandler/properties.py | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/addon/globalPlugins/webAccess/ruleHandler/properties.py b/addon/globalPlugins/webAccess/ruleHandler/properties.py index 0cfb1ec2..08694ee3 100644 --- a/addon/globalPlugins/webAccess/ruleHandler/properties.py +++ b/addon/globalPlugins/webAccess/ruleHandler/properties.py @@ -33,6 +33,8 @@ from typing import Any, TypeAlias import weakref +from . import ruleTypes + import addonHandler @@ -69,7 +71,7 @@ def getDisplayName(self, ruleType) -> str: class PropertySpec(Enum): autoAction = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.ZONE), valueType=str, default=None, # Translators: The display name for a rule property @@ -79,7 +81,7 @@ class PropertySpec(Enum): isRestrictedChoice=True ) multiple = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.PARENT, ruleTypes.ZONE), valueType=bool, default=False, # Translators: The display name for a rule property @@ -88,7 +90,7 @@ class PropertySpec(Enum): isRestrictedChoice=False ) formMode = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.ZONE), valueType=bool, default=False, # Translators: The display name for a rule property @@ -97,7 +99,7 @@ class PropertySpec(Enum): isRestrictedChoice=False ) skip = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.ZONE), valueType=bool, default=False, # Translators: The display name for a rule property @@ -106,7 +108,7 @@ class PropertySpec(Enum): isRestrictedChoice=False ) sayName = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.ZONE), valueType=bool, default=False, # Translators: The display name for a rule property @@ -115,7 +117,7 @@ class PropertySpec(Enum): isRestrictedChoice=False ) customName = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.ZONE), valueType=str, default="", # Translators: The display name for a rule property @@ -125,11 +127,16 @@ class PropertySpec(Enum): isRestrictedChoice=False ) customValue = PropertySpecValue( - ruleTypes=("marker", "pageTitle1", "pageTitle2", "zone"), + ruleTypes=( + ruleTypes.MARKER, + ruleTypes.PAGE_TITLE_1, + ruleTypes.PAGE_TITLE_2, + ruleTypes.ZONE + ), valueType=str, default="", displayName={ - ("marker", "zone"): + (ruleTypes.MARKER, ruleTypes.ZONE): # Translators: The display name for a rule property pgettext("webAccess.ruleProperty", "Custom message"), ("pageTitle1", "pageTitle2"): @@ -141,7 +148,7 @@ class PropertySpec(Enum): isRestrictedChoice=False ) mutation = PropertySpecValue( - ruleTypes=("marker", "zone"), + ruleTypes=(ruleTypes.MARKER, ruleTypes.ZONE), valueType=str, default=None, # Translators: The display name for a rule property @@ -151,7 +158,7 @@ class PropertySpec(Enum): isRestrictedChoice=True ) subModule = PropertySpecValue( - ruleTypes=("zone",), + ruleTypes=(ruleTypes.ZONE,), valueType=str, default="", # Translators: The display name for a rule property