Workfile Template Builder: Allow Create Placeholder to define the default 'active' state of the created instance

This commit is contained in:
Roy Nieterau 2024-07-13 02:37:40 +02:00
parent 6786363aac
commit 2841e20e96
2 changed files with 19 additions and 3 deletions

View file

@ -2043,7 +2043,8 @@ class CreateContext:
variant,
folder_entity=None,
task_entity=None,
pre_create_data=None
pre_create_data=None,
active=True
):
"""Trigger create of plugins with standartized arguments.
@ -2061,6 +2062,8 @@ class CreateContext:
of creation (possible context of created instance/s).
task_entity (Dict[str, Any]): Task entity.
pre_create_data (Dict[str, Any]): Pre-create attribute values.
active (Optional[bool]): Whether the created instance defaults
to be active or not. Defaults to True.
Returns:
Any: Output of triggered creator's 'create' method.
@ -2124,7 +2127,8 @@ class CreateContext:
"folderPath": folder_entity["path"],
"task": task_entity["name"] if task_entity else None,
"productType": creator.product_type,
"variant": variant
"variant": variant,
"active": bool(active)
}
return creator.create(
product_name,

View file

@ -1797,6 +1797,16 @@ class PlaceholderCreateMixin(object):
"\ncompiling of product name."
)
),
attribute_definitions.BoolDef(
"active",
label="Active",
default=options.get("active", True),
tooltip=(
"Active"
"\nDefines whether the created instance will default to "
"active or not."
)
),
attribute_definitions.UISeparatorDef(),
attribute_definitions.NumberDef(
"order",
@ -1826,6 +1836,7 @@ class PlaceholderCreateMixin(object):
legacy_create = self.builder.use_legacy_creators
creator_name = placeholder.data["creator"]
create_variant = placeholder.data["create_variant"]
active = placeholder.data.get("active", True)
creator_plugin = self.builder.get_creators_by_name()[creator_name]
@ -1873,7 +1884,8 @@ class PlaceholderCreateMixin(object):
create_variant,
folder_entity,
task_entity,
pre_create_data=pre_create_data
pre_create_data=pre_create_data,
active=active
)
except: # noqa: E722