mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
allow multiselection
This commit is contained in:
parent
37e43de5de
commit
6968d2fdfd
1 changed files with 59 additions and 47 deletions
|
|
@ -11,55 +11,59 @@ class CreateFolders(BaseAction):
|
||||||
icon = statics_icon("ftrack", "action_icons", "CreateFolders.svg")
|
icon = statics_icon("ftrack", "action_icons", "CreateFolders.svg")
|
||||||
|
|
||||||
def discover(self, session, entities, event):
|
def discover(self, session, entities, event):
|
||||||
if len(entities) != 1:
|
for entity_item in event["data"]["selection"]:
|
||||||
return False
|
if entity_item.get("entityType").lower() in ("task", "show"):
|
||||||
|
return True
|
||||||
not_allowed = ["assetversion", "project"]
|
return False
|
||||||
if entities[0].entity_type.lower() in not_allowed:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def interface(self, session, entities, event):
|
def interface(self, session, entities, event):
|
||||||
if event["data"].get("values", {}):
|
if event["data"].get("values", {}):
|
||||||
return
|
return
|
||||||
entity = entities[0]
|
|
||||||
without_interface = True
|
with_interface = False
|
||||||
for child in entity["children"]:
|
for entity in entities:
|
||||||
if child["object_type"]["name"].lower() != "task":
|
if entity.entity_type.lower() != "task":
|
||||||
without_interface = False
|
with_interface = True
|
||||||
break
|
break
|
||||||
self.without_interface = without_interface
|
|
||||||
if without_interface:
|
if "values" not in event["data"]:
|
||||||
|
event["data"]["values"] = {}
|
||||||
|
|
||||||
|
event["data"]["values"]["with_interface"] = with_interface
|
||||||
|
if not with_interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
title = "Create folders"
|
title = "Create folders"
|
||||||
|
|
||||||
entity_name = entity["name"]
|
entity_name = entity["name"]
|
||||||
msg = (
|
msg = (
|
||||||
"<h2>Do you want create folders also"
|
"<h2>Do you want create folders also"
|
||||||
" for all children of \"{}\"?</h2>"
|
" for all children of your selection?</h2>"
|
||||||
)
|
)
|
||||||
if entity.entity_type.lower() == "project":
|
if entity.entity_type.lower() == "project":
|
||||||
entity_name = entity["full_name"]
|
entity_name = entity["full_name"]
|
||||||
msg = msg.replace(" also", "")
|
msg = msg.replace(" also", "")
|
||||||
msg += "<h3>(Project root won't be created if not checked)</h3>"
|
msg += "<h3>(Project root won't be created if not checked)</h3>"
|
||||||
items = []
|
items = [
|
||||||
item_msg = {
|
{
|
||||||
"type": "label",
|
"type": "label",
|
||||||
"value": msg.format(entity_name)
|
"value": msg.format(entity_name)
|
||||||
}
|
},
|
||||||
item_label = {
|
{
|
||||||
"type": "label",
|
"type": "label",
|
||||||
"value": "With all chilren entities"
|
"value": "With all chilren entities"
|
||||||
}
|
},
|
||||||
item = {
|
{
|
||||||
"name": "children_included",
|
"name": "children_included",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"value": False
|
"value": False
|
||||||
}
|
},
|
||||||
items.append(item_msg)
|
{
|
||||||
items.append(item_label)
|
"type": "hidden",
|
||||||
items.append(item)
|
"name": "with_interface",
|
||||||
|
"value": with_interface
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"items": items,
|
"items": items,
|
||||||
|
|
@ -68,26 +72,34 @@ class CreateFolders(BaseAction):
|
||||||
|
|
||||||
def launch(self, session, entities, event):
|
def launch(self, session, entities, event):
|
||||||
'''Callback method for custom action.'''
|
'''Callback method for custom action.'''
|
||||||
|
|
||||||
|
if "values" not in event["data"]:
|
||||||
|
return
|
||||||
|
|
||||||
|
with_interface = event["data"]["values"]["with_interface"]
|
||||||
with_childrens = True
|
with_childrens = True
|
||||||
if self.without_interface is False:
|
if with_interface:
|
||||||
if "values" not in event["data"]:
|
|
||||||
return
|
|
||||||
with_childrens = event["data"]["values"]["children_included"]
|
with_childrens = event["data"]["values"]["children_included"]
|
||||||
|
|
||||||
entity = entities[0]
|
filtered_entities = []
|
||||||
if entity.entity_type.lower() == "project":
|
for entity in entities:
|
||||||
proj = entity
|
low_context_type = entity["context_type"].lower()
|
||||||
else:
|
if low_context_type in ("task", "show"):
|
||||||
proj = entity["project"]
|
if not with_childrens and low_context_type == "show":
|
||||||
project_name = proj["full_name"]
|
continue
|
||||||
project_code = proj["name"]
|
filtered_entities.append(entity)
|
||||||
|
|
||||||
if entity.entity_type.lower() == 'project' and with_childrens is False:
|
if not filtered_entities:
|
||||||
return {
|
return {
|
||||||
'success': True,
|
"success": True,
|
||||||
'message': 'Nothing was created'
|
"message": 'Nothing was created'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project_entity = self.get_project_from_entity(filtered_entities[0])
|
||||||
|
|
||||||
|
project_name = project_entity["full_name"]
|
||||||
|
project_code = project_entity["name"]
|
||||||
|
|
||||||
task_entities = []
|
task_entities = []
|
||||||
other_entities = []
|
other_entities = []
|
||||||
self.get_all_entities(
|
self.get_all_entities(
|
||||||
|
|
@ -209,7 +221,7 @@ class CreateFolders(BaseAction):
|
||||||
|
|
||||||
no_task_entity_ids = [entity["id"] for entity in no_task_entities]
|
no_task_entity_ids = [entity["id"] for entity in no_task_entities]
|
||||||
next_entities = session.query((
|
next_entities = session.query((
|
||||||
"select id, object_type_id, parent_id"
|
"select id, parent_id"
|
||||||
" from TypedContext where parent_id in ({})"
|
" from TypedContext where parent_id in ({})"
|
||||||
).format(self.join_query_keys(no_task_entity_ids))).all()
|
).format(self.join_query_keys(no_task_entity_ids))).all()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue