I can save form (but user interaction is broken)
This commit is contained in:
@@ -128,6 +128,24 @@
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
.wkf-properties-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%; /* or inherit from a fixed-height parent */
|
||||
}
|
||||
|
||||
.wkf-properties-content-header {
|
||||
flex-shrink: 0; /* optional: prevent it from shrinking */
|
||||
}
|
||||
|
||||
.wkf-properties-content-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
overflow: hidden; /* prevent double scrollbars if needed */
|
||||
}
|
||||
|
||||
|
||||
.wkf-canvas {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
@@ -272,5 +290,3 @@
|
||||
.wkf-connection-path-arrowhead-selected {
|
||||
fill:#ef4444 !important;;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,12 +34,6 @@ class WorkflowDesignerCommandManager(BaseCommandManager):
|
||||
def __init__(self, owner):
|
||||
super().__init__(owner)
|
||||
|
||||
def on_save(self):
|
||||
return {}
|
||||
|
||||
def on_cancel(self):
|
||||
return {}
|
||||
|
||||
def select_processor(self, component_id: str):
|
||||
return {
|
||||
"hx_post": f"{ROUTE_ROOT}{Routes.SelectProcessor}",
|
||||
|
||||
@@ -4,6 +4,7 @@ from dataclasses import dataclass
|
||||
from components.BaseComponent import BaseComponent
|
||||
from components.workflows.constants import COMPONENT_TYPES, PROCESSOR_TYPES
|
||||
from components_helpers import mk_dialog_buttons
|
||||
from core.jira import JiraRequestTypes, DEFAULT_SEARCH_FIELDS
|
||||
from core.utils import merge_classes
|
||||
|
||||
|
||||
@@ -89,10 +90,7 @@ class WorkflowDesignerProperties(BaseComponent):
|
||||
),
|
||||
|
||||
# Properties content
|
||||
self._mk_content(cls="flex-1 overflow-y-auto"),
|
||||
|
||||
# Dialog buttons
|
||||
mk_dialog_buttons(cls="flex-none mt-auto pb-2"),
|
||||
self._mk_content(),
|
||||
|
||||
# Left resize handle
|
||||
Div(
|
||||
@@ -111,12 +109,12 @@ class WorkflowDesignerProperties(BaseComponent):
|
||||
cls="wkf-properties-properties flex flex-col",
|
||||
)
|
||||
|
||||
def _mk_content(self, cls=None, oob=False):
|
||||
def _mk_content(self, oob=False):
|
||||
|
||||
return Div(
|
||||
self._header(),
|
||||
self._form(),
|
||||
cls=merge_classes(cls),
|
||||
cls="wkf-properties-content",
|
||||
id=f"ppc_{self._id}",
|
||||
hx_swap_oob=f'true' if oob else None,
|
||||
)
|
||||
@@ -133,20 +131,32 @@ class WorkflowDesignerProperties(BaseComponent):
|
||||
H4(self._component.title, cls="font-semibold text-xs"),
|
||||
cls=f"rounded-lg border-2 {color} flex text-center px-2"
|
||||
),
|
||||
cls=merge_classes("flex"),
|
||||
Div(self._component.id, cls="ml-2"),
|
||||
cls="flex wkf-properties-content-header",
|
||||
)
|
||||
|
||||
def _form(self):
|
||||
if self._component is None:
|
||||
return None
|
||||
|
||||
component_id = self._component.id
|
||||
return Form(
|
||||
Div(
|
||||
self._mk_select_processor(),
|
||||
self._content_details(),
|
||||
style="flex-grow: 1; overflow-y: auto;"
|
||||
),
|
||||
mk_dialog_buttons(cls="pb-2",
|
||||
on_ok=self._commands.save_properties(component_id),
|
||||
on_cancel=self._commands.cancel_properties(component_id)
|
||||
),
|
||||
id=f"ppf_{self._id}",
|
||||
cls="wkf-properties-content-form",
|
||||
#style=" flex-grow: 1;overflow: auto;"
|
||||
)
|
||||
|
||||
def _mk_select_processor(self):
|
||||
selected_processor_name = self._component.properties["processor_name"]
|
||||
selected_processor_name = self._component.properties.get("processor_name", None)
|
||||
return Select(
|
||||
*[Option(processor_name, selected="selected" if processor_name == selected_processor_name else None)
|
||||
for processor_name in PROCESSOR_TYPES[self._component.type]],
|
||||
@@ -159,12 +169,84 @@ class WorkflowDesignerProperties(BaseComponent):
|
||||
def _content_details(self):
|
||||
component_type = self._component.type
|
||||
processor_name = self._component.properties.get("processor_name", None)
|
||||
key = f"_mk_details_{component_type}_{processor_name}"
|
||||
key = f"_mk_details_{component_type}_{processor_name}".lower()
|
||||
if hasattr(self, key):
|
||||
return getattr(self, key)()
|
||||
else:
|
||||
return Div(f"Component '{key}' not found")
|
||||
|
||||
def _mk_details_producer_jira(self):
|
||||
def _mk_option(name):
|
||||
"""
|
||||
Generic helper to create options
|
||||
:param name:
|
||||
:return:
|
||||
"""
|
||||
return Option(name.name,
|
||||
value=name.value,
|
||||
selected="selected" if name.value == request_type else None)
|
||||
|
||||
def _mk_input_group():
|
||||
if request_type == JiraRequestTypes.Issues.value:
|
||||
return [
|
||||
Div(
|
||||
Input(type="text",
|
||||
name="fields",
|
||||
value=self._component.properties.get("fields", DEFAULT_SEARCH_FIELDS),
|
||||
placeholder="default fields",
|
||||
cls="input w-full"),
|
||||
P("Jira fields to retrieve"),
|
||||
),
|
||||
Div(
|
||||
Input(type="text",
|
||||
name="request",
|
||||
value=self._component.properties.get("request", ""),
|
||||
placeholder="Enter JQL",
|
||||
cls="input w-full"),
|
||||
P("Write your jql code"),
|
||||
)
|
||||
]
|
||||
elif request_type == JiraRequestTypes.Comments.value:
|
||||
return [
|
||||
Div(
|
||||
Input(type="text",
|
||||
name="request",
|
||||
value=self._component.properties.get("request", ""),
|
||||
placeholder="Issue id",
|
||||
cls="input w-full"),
|
||||
P("Put the issue id here"),
|
||||
)
|
||||
]
|
||||
|
||||
def _mk_extra_parameters():
|
||||
if request_type == JiraRequestTypes.Issues.value:
|
||||
return Input(type="text",
|
||||
name="fields",
|
||||
value=self._component.properties.get("fields", DEFAULT_SEARCH_FIELDS),
|
||||
placeholder="default fields",
|
||||
cls="input w-full ml-2")
|
||||
else:
|
||||
return None
|
||||
|
||||
request_type = self._component.properties.get("request_type", JiraRequestTypes.Issues.value)
|
||||
return Div(
|
||||
Fieldset(
|
||||
Legend("Jira", cls="fieldset-legend"),
|
||||
Div(
|
||||
Select(
|
||||
*[_mk_option(enum) for enum in JiraRequestTypes],
|
||||
cls="select w-xs",
|
||||
name="request_type",
|
||||
**self._commands.on_processor_details_event(self._component.id, "OnJiraRequestTypeChanged"),
|
||||
),
|
||||
P("Jira ressource type"),
|
||||
cls="mb-4"
|
||||
),
|
||||
*_mk_input_group(),
|
||||
cls="fieldset bg-base-200 border-base-300 rounded-box border p-4"
|
||||
),
|
||||
)
|
||||
|
||||
def __ft__(self, oob=False):
|
||||
# return self.render()
|
||||
return Div(
|
||||
|
||||
Reference in New Issue
Block a user