mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
keep entity ids and entity type on action item
This commit is contained in:
parent
723932cfac
commit
53848ad366
4 changed files with 37 additions and 22 deletions
|
|
@ -318,17 +318,21 @@ class ActionItem:
|
|||
|
||||
Args:
|
||||
identifier (str): Action identifier.
|
||||
entity_ids (set[str]): Entity ids.
|
||||
entity_type (str): Entity type.
|
||||
label (str): Action label.
|
||||
icon (dict[str, Any]): Action icon definition.
|
||||
tooltip (str): Action tooltip.
|
||||
options (Union[list[AbstractAttrDef], list[qargparse.QArgument]]):
|
||||
Action options. Note: 'qargparse' is considered as deprecated.
|
||||
order (int): Action order.
|
||||
"""
|
||||
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
identifier,
|
||||
entity_ids,
|
||||
entity_type,
|
||||
label,
|
||||
icon,
|
||||
tooltip,
|
||||
|
|
@ -336,6 +340,8 @@ class ActionItem:
|
|||
order,
|
||||
):
|
||||
self.identifier = identifier
|
||||
self.entity_ids = entity_ids
|
||||
self.entity_type = entity_type
|
||||
self.label = label
|
||||
self.icon = icon
|
||||
self.tooltip = tooltip
|
||||
|
|
@ -362,6 +368,8 @@ class ActionItem:
|
|||
options = self._options_to_data()
|
||||
return {
|
||||
"identifier": self.identifier,
|
||||
"entity_ids": list(self.entity_ids),
|
||||
"entity_type": self.entity_type,
|
||||
"label": self.label,
|
||||
"icon": self.icon,
|
||||
"tooltip": self.tooltip,
|
||||
|
|
@ -375,6 +383,7 @@ class ActionItem:
|
|||
if options:
|
||||
options = deserialize_attr_defs(options)
|
||||
data["options"] = options
|
||||
data["entity_ids"] = set(data["entity_ids"])
|
||||
return cls(**data)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -145,15 +145,16 @@ class LoaderActionsModel:
|
|||
ACTIONS_MODEL_SENDER,
|
||||
)
|
||||
loader = self._get_loader_by_identifier(project_name, identifier)
|
||||
if entity_type == "representation":
|
||||
error_info = self._trigger_representation_loader(
|
||||
|
||||
if entity_type == "version":
|
||||
error_info = self._trigger_version_loader(
|
||||
loader,
|
||||
options,
|
||||
project_name,
|
||||
entity_ids,
|
||||
)
|
||||
elif entity_type == "version":
|
||||
error_info = self._trigger_version_loader(
|
||||
elif entity_type == "representation":
|
||||
error_info = self._trigger_representation_loader(
|
||||
loader,
|
||||
options,
|
||||
project_name,
|
||||
|
|
@ -277,6 +278,8 @@ class LoaderActionsModel:
|
|||
self,
|
||||
loader,
|
||||
contexts,
|
||||
entity_ids,
|
||||
entity_type,
|
||||
repre_name=None,
|
||||
):
|
||||
label = self._get_action_label(loader)
|
||||
|
|
@ -284,6 +287,8 @@ class LoaderActionsModel:
|
|||
label = "{} ({})".format(label, repre_name)
|
||||
return ActionItem(
|
||||
get_loader_identifier(loader),
|
||||
entity_ids=entity_ids,
|
||||
entity_type=entity_type,
|
||||
label=label,
|
||||
icon=self._get_action_icon(loader),
|
||||
tooltip=self._get_action_tooltip(loader),
|
||||
|
|
@ -548,19 +553,16 @@ class LoaderActionsModel:
|
|||
if not filtered_repre_contexts:
|
||||
continue
|
||||
|
||||
repre_ids = set()
|
||||
repre_version_ids = set()
|
||||
repre_product_ids = set()
|
||||
repre_folder_ids = set()
|
||||
for repre_context in filtered_repre_contexts:
|
||||
repre_ids.add(repre_context["representation"]["id"])
|
||||
repre_product_ids.add(repre_context["product"]["id"])
|
||||
repre_version_ids.add(repre_context["version"]["id"])
|
||||
repre_folder_ids.add(repre_context["folder"]["id"])
|
||||
repre_ids = {
|
||||
repre_context["representation"]["id"]
|
||||
for repre_context in filtered_repre_contexts
|
||||
}
|
||||
|
||||
item = self._create_loader_action_item(
|
||||
loader,
|
||||
repre_contexts,
|
||||
repre_ids,
|
||||
"representation",
|
||||
repre_name=repre_name,
|
||||
)
|
||||
action_items.append(item)
|
||||
|
|
@ -572,11 +574,14 @@ class LoaderActionsModel:
|
|||
product_ids.add(product_context["product"]["id"])
|
||||
product_folder_ids.add(product_context["folder"]["id"])
|
||||
|
||||
version_ids = set(version_context_by_id.keys())
|
||||
version_contexts = list(version_context_by_id.values())
|
||||
for loader in product_loaders:
|
||||
item = self._create_loader_action_item(
|
||||
loader,
|
||||
version_contexts,
|
||||
version_ids,
|
||||
"version",
|
||||
)
|
||||
action_items.append(item)
|
||||
|
||||
|
|
|
|||
|
|
@ -420,8 +420,9 @@ class ProductsWidget(QtWidgets.QWidget):
|
|||
if version_id is not None:
|
||||
version_ids.add(version_id)
|
||||
|
||||
action_items = self._controller.get_versions_action_items(
|
||||
project_name, version_ids)
|
||||
action_items = self._controller.get_action_items(
|
||||
project_name, version_ids, "version"
|
||||
)
|
||||
|
||||
# Prepare global point where to show the menu
|
||||
global_point = self._products_view.mapToGlobal(point)
|
||||
|
|
@ -440,8 +441,8 @@ class ProductsWidget(QtWidgets.QWidget):
|
|||
action_item.identifier,
|
||||
options,
|
||||
project_name,
|
||||
version_ids,
|
||||
"version",
|
||||
action_item.entity_ids,
|
||||
action_item.entity_type,
|
||||
)
|
||||
|
||||
def _on_selection_change(self):
|
||||
|
|
|
|||
|
|
@ -384,8 +384,8 @@ class RepresentationsWidget(QtWidgets.QWidget):
|
|||
|
||||
def _on_context_menu(self, point):
|
||||
repre_ids = self._get_selected_repre_ids()
|
||||
action_items = self._controller.get_representations_action_items(
|
||||
self._selected_project_name, repre_ids
|
||||
action_items = self._controller.get_action_items(
|
||||
self._selected_project_name, repre_ids, "representation"
|
||||
)
|
||||
global_point = self._repre_view.mapToGlobal(point)
|
||||
result = show_actions_menu(
|
||||
|
|
@ -402,6 +402,6 @@ class RepresentationsWidget(QtWidgets.QWidget):
|
|||
action_item.identifier,
|
||||
options,
|
||||
self._selected_project_name,
|
||||
repre_ids,
|
||||
"representation",
|
||||
action_item.entity_ids,
|
||||
action_item.entity_type,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue