added helper method to change active state

This commit is contained in:
Jakub Trllo 2024-10-14 16:05:59 +02:00
parent a21341ad15
commit 22c3142894
3 changed files with 42 additions and 3 deletions

View file

@ -3,6 +3,7 @@ from typing import (
Optional,
Dict,
List,
Set,
Tuple,
Any,
Callable,
@ -353,6 +354,12 @@ class AbstractPublisherFrontend(AbstractPublisherCommon):
):
pass
@abstractmethod
def set_instances_active_state(
self, active_state_by_id: Dict[str, bool]
):
pass
@abstractmethod
def get_existing_product_names(self, folder_path: str) -> List[str]:
pass

View file

@ -220,6 +220,9 @@ class PublisherController(
changes_by_instance_id
)
def set_instances_active_state(self, active_state_by_id):
self._create_model.set_instances_active_state(active_state_by_id)
def get_convertor_items(self):
return self._create_model.get_convertor_items()

View file

@ -1,6 +1,16 @@
import logging
import re
from typing import Union, List, Dict, Tuple, Any, Optional, Iterable, Pattern
from typing import (
Union,
List,
Dict,
Set,
Tuple,
Any,
Optional,
Iterable,
Pattern,
)
from ayon_core.lib.attribute_definitions import (
serialize_attr_defs,
@ -542,6 +552,21 @@ class CreateModel:
}
)
def set_instances_active_state(
self, active_state_by_id: Dict[str, bool]
):
with self._create_context.bulk_value_changes(CREATE_EVENT_SOURCE):
for instance_id, active in active_state_by_id.items():
instance = self._create_context.get_instance_by_id(instance_id)
instance["active"] = active
self._emit_event(
"create.model.instances.context.changed",
{
"instance_ids": set(active_state_by_id.keys())
}
)
def get_convertor_items(self) -> Dict[str, ConvertorItem]:
return self._create_context.convertor_items_by_id
@ -896,8 +921,12 @@ class CreateModel:
}
)
def _emit_event(self, topic: str, data: Optional[Dict[str, Any]] = None):
self._controller.emit_event(topic, data)
def _emit_event(
self,
topic: str,
data: Optional[Dict[str, Any]] = None
):
self._controller.emit_event(topic, data, CREATE_EVENT_SOURCE)
def _get_current_project_settings(self) -> Dict[str, Any]:
"""Current project settings.