@nyaruka/temba-components 0.129.3 → 0.129.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/.github/workflows/build.yml +135 -3
- package/CHANGELOG.md +19 -0
- package/demo/data/flows/sample-flow.json +110 -87
- package/demo/field-config-demo.html +135 -0
- package/dist/temba-components.js +1257 -675
- package/dist/temba-components.js.map +1 -1
- package/docs/ActionEditor-Migration.md +118 -0
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/{EditorNode.js → CanvasNode.js} +345 -42
- package/out-tsc/src/flow/CanvasNode.js.map +1 -0
- package/out-tsc/src/flow/Editor.js +107 -3
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +1211 -0
- package/out-tsc/src/flow/NodeEditor.js.map +1 -0
- package/out-tsc/src/flow/Plumber.js +0 -6
- package/out-tsc/src/flow/Plumber.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +40 -0
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -0
- package/out-tsc/src/flow/actions/add_contact_urn.js +16 -0
- package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -0
- package/out-tsc/src/flow/actions/add_input_labels.js +11 -0
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -0
- package/out-tsc/src/flow/actions/call_classifier.js +11 -0
- package/out-tsc/src/flow/actions/call_classifier.js.map +1 -0
- package/out-tsc/src/flow/actions/call_llm.js +11 -0
- package/out-tsc/src/flow/actions/call_llm.js.map +1 -0
- package/out-tsc/src/flow/actions/call_resthook.js +11 -0
- package/out-tsc/src/flow/actions/call_resthook.js.map +1 -0
- package/out-tsc/src/flow/actions/call_webhook.js +122 -0
- package/out-tsc/src/flow/actions/call_webhook.js.map +1 -0
- package/out-tsc/src/flow/actions/enter_flow.js +14 -0
- package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
- package/out-tsc/src/flow/actions/open_ticket.js +11 -0
- package/out-tsc/src/flow/actions/open_ticket.js.map +1 -0
- package/out-tsc/src/flow/actions/play_audio.js +11 -0
- package/out-tsc/src/flow/actions/play_audio.js.map +1 -0
- package/out-tsc/src/flow/actions/remove_contact_groups.js +62 -0
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -0
- package/out-tsc/src/flow/actions/request_optin.js +11 -0
- package/out-tsc/src/flow/actions/request_optin.js.map +1 -0
- package/out-tsc/src/flow/actions/say_msg.js +11 -0
- package/out-tsc/src/flow/actions/say_msg.js.map +1 -0
- package/out-tsc/src/flow/actions/send_broadcast.js +33 -0
- package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -0
- package/out-tsc/src/flow/actions/send_email.js +56 -0
- package/out-tsc/src/flow/actions/send_email.js.map +1 -0
- package/out-tsc/src/flow/actions/send_msg.js +55 -0
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -0
- package/out-tsc/src/flow/actions/set_contact_channel.js +12 -0
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -0
- package/out-tsc/src/flow/actions/set_contact_field.js +12 -0
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -0
- package/out-tsc/src/flow/actions/set_contact_language.js +10 -0
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -0
- package/out-tsc/src/flow/actions/set_contact_name.js +10 -0
- package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -0
- package/out-tsc/src/flow/actions/set_contact_status.js +10 -0
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -0
- package/out-tsc/src/flow/actions/set_run_result.js +10 -0
- package/out-tsc/src/flow/actions/set_run_result.js.map +1 -0
- package/out-tsc/src/flow/actions/split_by_expression_example.js +77 -0
- package/out-tsc/src/flow/actions/split_by_expression_example.js.map +1 -0
- package/out-tsc/src/flow/actions/start_session.js +11 -0
- package/out-tsc/src/flow/actions/start_session.js.map +1 -0
- package/out-tsc/src/flow/actions/transfer_airtime.js +11 -0
- package/out-tsc/src/flow/actions/transfer_airtime.js.map +1 -0
- package/out-tsc/src/flow/config.js +88 -193
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/execute_actions.js +4 -0
- package/out-tsc/src/flow/nodes/execute_actions.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_airtime.js +9 -0
- package/out-tsc/src/flow/nodes/split_by_airtime.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_contact_field.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_expression.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_groups.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_groups.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_random.js +10 -0
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_run_result.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_scheme.js +7 -0
- package/out-tsc/src/flow/nodes/split_by_scheme.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_subflow.js +9 -0
- package/out-tsc/src/flow/nodes/split_by_subflow.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_webhook.js +18 -0
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_digits.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_image.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_image.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_location.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_location.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_menu.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_response.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_video.js +7 -0
- package/out-tsc/src/flow/nodes/wait_for_video.js.map +1 -0
- package/out-tsc/src/flow/types.js +79 -0
- package/out-tsc/src/flow/types.js.map +1 -0
- package/out-tsc/src/flow/utils.js +65 -0
- package/out-tsc/src/flow/utils.js.map +1 -0
- package/out-tsc/src/form/ArrayEditor.js +199 -0
- package/out-tsc/src/form/ArrayEditor.js.map +1 -0
- package/out-tsc/src/form/BaseListEditor.js +128 -0
- package/out-tsc/src/form/BaseListEditor.js.map +1 -0
- package/out-tsc/src/form/Checkbox.js +17 -2
- package/out-tsc/src/form/Checkbox.js.map +1 -1
- package/out-tsc/src/form/Completion.js +6 -0
- package/out-tsc/src/form/Completion.js.map +1 -1
- package/out-tsc/src/form/FormField.js +110 -11
- package/out-tsc/src/form/FormField.js.map +1 -1
- package/out-tsc/src/form/KeyValueEditor.js +223 -0
- package/out-tsc/src/form/KeyValueEditor.js.map +1 -0
- package/out-tsc/src/form/select/Select.js +92 -32
- package/out-tsc/src/form/select/Select.js.map +1 -1
- package/out-tsc/src/interfaces.js +6 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +2 -76
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/temba-modules.js +9 -2
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/ActionHelper.js +116 -0
- package/out-tsc/test/ActionHelper.js.map +1 -0
- package/out-tsc/test/actions/add_contact_groups.test.js +66 -0
- package/out-tsc/test/actions/add_contact_groups.test.js.map +1 -0
- package/out-tsc/test/actions/remove_contact_groups.test.js +226 -0
- package/out-tsc/test/actions/remove_contact_groups.test.js.map +1 -0
- package/out-tsc/test/actions/send_email.test.js +160 -0
- package/out-tsc/test/actions/send_email.test.js.map +1 -0
- package/out-tsc/test/actions/send_msg.test.js +95 -0
- package/out-tsc/test/actions/send_msg.test.js.map +1 -0
- package/out-tsc/test/temba-action-editing-integration.test.js +183 -0
- package/out-tsc/test/temba-action-editing-integration.test.js.map +1 -0
- package/out-tsc/test/temba-checkbox.test.js +1 -1
- package/out-tsc/test/temba-checkbox.test.js.map +1 -1
- package/out-tsc/test/temba-field-config.test.js +133 -0
- package/out-tsc/test/temba-field-config.test.js.map +1 -0
- package/out-tsc/test/temba-flow-editor-node.test.js +14 -14
- package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
- package/out-tsc/test/temba-node-editor.test.js +283 -0
- package/out-tsc/test/temba-node-editor.test.js.map +1 -0
- package/out-tsc/test/temba-select.test.js +158 -0
- package/out-tsc/test/temba-select.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/send_msg.png +0 -0
- package/screenshots/truth/editor/set_contact_language.png +0 -0
- package/screenshots/truth/editor/set_contact_name.png +0 -0
- package/screenshots/truth/editor/set_run_result.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/formfield/markdown-errors.png +0 -0
- package/screenshots/truth/formfield/plain-text-errors.png +0 -0
- package/screenshots/truth/formfield/widget-only-markdown-errors.png +0 -0
- package/screenshots/truth/integration/checkbox-markdown-errors.png +0 -0
- package/src/events.ts +1 -40
- package/src/flow/{EditorNode.ts → CanvasNode.ts} +424 -48
- package/src/flow/Editor.ts +140 -4
- package/src/flow/NodeEditor.ts +1454 -0
- package/src/flow/Plumber.ts +0 -9
- package/src/flow/actions/add_contact_groups.ts +42 -0
- package/src/flow/actions/add_contact_urn.ts +17 -0
- package/src/flow/actions/add_input_labels.ts +12 -0
- package/src/flow/actions/call_classifier.ts +12 -0
- package/src/flow/actions/call_llm.ts +12 -0
- package/src/flow/actions/call_resthook.ts +12 -0
- package/src/flow/actions/call_webhook.ts +133 -0
- package/src/flow/actions/enter_flow.ts +15 -0
- package/src/flow/actions/open_ticket.ts +12 -0
- package/src/flow/actions/play_audio.ts +12 -0
- package/src/flow/actions/remove_contact_groups.ts +66 -0
- package/src/flow/actions/request_optin.ts +12 -0
- package/src/flow/actions/say_msg.ts +12 -0
- package/src/flow/actions/send_broadcast.ts +35 -0
- package/src/flow/actions/send_email.ts +60 -0
- package/src/flow/actions/send_msg.ts +58 -0
- package/src/flow/actions/set_contact_channel.ts +13 -0
- package/src/flow/actions/set_contact_field.ts +13 -0
- package/src/flow/actions/set_contact_language.ts +11 -0
- package/src/flow/actions/set_contact_name.ts +11 -0
- package/src/flow/actions/set_contact_status.ts +11 -0
- package/src/flow/actions/set_run_result.ts +11 -0
- package/src/flow/actions/split_by_expression_example.ts +88 -0
- package/src/flow/actions/start_session.ts +12 -0
- package/src/flow/actions/transfer_airtime.ts +12 -0
- package/src/flow/config.ts +93 -232
- package/src/flow/nodes/execute_actions.ts +5 -0
- package/src/flow/nodes/split_by_airtime.ts +9 -0
- package/src/flow/nodes/split_by_contact_field.ts +7 -0
- package/src/flow/nodes/split_by_expression.ts +7 -0
- package/src/flow/nodes/split_by_groups.ts +7 -0
- package/src/flow/nodes/split_by_random.ts +10 -0
- package/src/flow/nodes/split_by_run_result.ts +7 -0
- package/src/flow/nodes/split_by_scheme.ts +7 -0
- package/src/flow/nodes/split_by_subflow.ts +9 -0
- package/src/flow/nodes/split_by_webhook.ts +19 -0
- package/src/flow/nodes/wait_for_audio.ts +7 -0
- package/src/flow/nodes/wait_for_digits.ts +7 -0
- package/src/flow/nodes/wait_for_image.ts +7 -0
- package/src/flow/nodes/wait_for_location.ts +7 -0
- package/src/flow/nodes/wait_for_menu.ts +7 -0
- package/src/flow/nodes/wait_for_response.ts +7 -0
- package/src/flow/nodes/wait_for_video.ts +7 -0
- package/src/flow/types.ts +352 -0
- package/src/flow/utils.ts +76 -0
- package/src/form/ArrayEditor.ts +240 -0
- package/src/form/BaseListEditor.ts +177 -0
- package/src/form/Checkbox.ts +22 -3
- package/src/form/Completion.ts +6 -0
- package/src/form/FormField.ts +115 -11
- package/src/form/KeyValueEditor.ts +251 -0
- package/src/form/select/Select.ts +105 -32
- package/src/interfaces.ts +7 -2
- package/src/live/ContactChat.ts +3 -97
- package/src/store/flow-definition.d.ts +6 -1
- package/static/api/contacts.json +30 -0
- package/static/api/groups.json +4 -426
- package/static/api/locations.json +24 -0
- package/static/api/media.json +5 -0
- package/static/api/optins.json +16 -0
- package/static/api/orgs.json +13 -0
- package/static/api/topics.json +21 -0
- package/static/api/users.json +26 -0
- package/static/css/temba-components.css +3 -6
- package/temba-modules.ts +9 -2
- package/test/ActionHelper.ts +142 -0
- package/test/actions/add_contact_groups.test.ts +89 -0
- package/test/actions/remove_contact_groups.test.ts +265 -0
- package/test/actions/send_email.test.ts +214 -0
- package/test/actions/send_msg.test.ts +130 -0
- package/test/temba-action-editing-integration.test.ts +240 -0
- package/test/temba-checkbox.test.ts +1 -1
- package/test/temba-field-config.test.ts +152 -0
- package/test/temba-flow-editor-node.test.ts +18 -18
- package/test/temba-node-editor.test.ts +353 -0
- package/test/temba-select.test.ts +234 -0
- package/test-assets/contacts/history.json +11 -33
- package/web-dev-server.config.mjs +34 -0
- package/.github/workflows/coverage.yml +0 -80
- package/demo/sticky-note-demo.html +0 -155
- package/out-tsc/src/flow/EditorNode.js.map +0 -1
- package/out-tsc/src/flow/render.js +0 -358
- package/out-tsc/src/flow/render.js.map +0 -1
- package/out-tsc/test/temba-flow-render.test.js +0 -794
- package/out-tsc/test/temba-flow-render.test.js.map +0 -1
- package/src/flow/render.ts +0 -443
- package/test/temba-flow-render.test.ts +0 -1003
package/src/flow/Editor.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { html, TemplateResult } from 'lit-html';
|
|
2
2
|
import { css, PropertyValueMap, unsafeCSS } from 'lit';
|
|
3
3
|
import { property, state } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
FlowDefinition,
|
|
6
|
+
FlowPosition,
|
|
7
|
+
Action,
|
|
8
|
+
Node,
|
|
9
|
+
NodeUI
|
|
10
|
+
} from '../store/flow-definition';
|
|
5
11
|
import { getStore } from '../store/Store';
|
|
6
12
|
import { AppState, fromStore, zustand } from '../store/AppState';
|
|
7
13
|
import { RapidElement } from '../RapidElement';
|
|
8
14
|
import { repeat } from 'lit-html/directives/repeat.js';
|
|
15
|
+
import { CustomEventType } from '../interfaces';
|
|
9
16
|
|
|
10
17
|
import { Plumber } from './Plumber';
|
|
11
|
-
import {
|
|
18
|
+
import { CanvasNode } from './CanvasNode';
|
|
12
19
|
import { Dialog } from '../layout/Dialog';
|
|
13
20
|
import { Connection } from '@jsplumb/browser-ui';
|
|
14
21
|
|
|
@@ -81,6 +88,11 @@ export class Editor extends RapidElement {
|
|
|
81
88
|
private isMouseDown = false;
|
|
82
89
|
private dragStartPos = { x: 0, y: 0 };
|
|
83
90
|
|
|
91
|
+
// Public getter for drag state
|
|
92
|
+
public get dragging(): boolean {
|
|
93
|
+
return this.isDragging;
|
|
94
|
+
}
|
|
95
|
+
|
|
84
96
|
@state()
|
|
85
97
|
private currentDragItem: DraggableItem | null = null;
|
|
86
98
|
private startPos = { left: 0, top: 0 };
|
|
@@ -107,6 +119,16 @@ export class Editor extends RapidElement {
|
|
|
107
119
|
@state()
|
|
108
120
|
private isValidTarget = true;
|
|
109
121
|
|
|
122
|
+
// NodeEditor state - handles both node and action editing
|
|
123
|
+
@state()
|
|
124
|
+
private editingNode: Node | null = null;
|
|
125
|
+
|
|
126
|
+
@state()
|
|
127
|
+
private editingNodeUI: NodeUI | null = null;
|
|
128
|
+
|
|
129
|
+
@state()
|
|
130
|
+
private editingAction: Action | null = null;
|
|
131
|
+
|
|
110
132
|
private canvasMouseDown = false;
|
|
111
133
|
|
|
112
134
|
// Bound event handlers to maintain proper 'this' context
|
|
@@ -392,6 +414,18 @@ export class Editor extends RapidElement {
|
|
|
392
414
|
if (canvas) {
|
|
393
415
|
canvas.addEventListener('dblclick', this.boundCanvasDoubleClick);
|
|
394
416
|
}
|
|
417
|
+
|
|
418
|
+
// Listen for action edit requests from flow nodes
|
|
419
|
+
this.addEventListener(
|
|
420
|
+
CustomEventType.ActionEditRequested,
|
|
421
|
+
this.handleActionEditRequested.bind(this)
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
// Listen for node edit requests from flow nodes
|
|
425
|
+
this.addEventListener(
|
|
426
|
+
CustomEventType.NodeEditRequested,
|
|
427
|
+
this.handleNodeEditRequested.bind(this)
|
|
428
|
+
);
|
|
395
429
|
}
|
|
396
430
|
|
|
397
431
|
private getPosition(uuid: string, type: 'node' | 'sticky'): FlowPosition {
|
|
@@ -929,11 +963,100 @@ export class Editor extends RapidElement {
|
|
|
929
963
|
event.stopPropagation();
|
|
930
964
|
}
|
|
931
965
|
|
|
966
|
+
private handleActionEditRequested(event: CustomEvent): void {
|
|
967
|
+
// For action editing, we set the action and find the corresponding node
|
|
968
|
+
this.editingAction = event.detail.action;
|
|
969
|
+
|
|
970
|
+
// Find the node that contains this action
|
|
971
|
+
const nodeUuid = event.detail.nodeUuid;
|
|
972
|
+
const node = this.definition.nodes.find((n) => n.uuid === nodeUuid);
|
|
973
|
+
|
|
974
|
+
if (node) {
|
|
975
|
+
this.editingNode = node;
|
|
976
|
+
this.editingNodeUI = this.definition._ui.nodes[nodeUuid];
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
private handleNodeEditRequested(event: CustomEvent): void {
|
|
980
|
+
this.editingNode = event.detail.node;
|
|
981
|
+
this.editingNodeUI = event.detail.nodeUI;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
private handleActionSaved(updatedAction: Action): void {
|
|
985
|
+
if (this.editingNode && this.editingAction) {
|
|
986
|
+
// Update the specific action in the node
|
|
987
|
+
const updatedActions = this.editingNode.actions.map((action) =>
|
|
988
|
+
action.uuid === this.editingAction.uuid ? updatedAction : action
|
|
989
|
+
);
|
|
990
|
+
const updatedNode = { ...this.editingNode, actions: updatedActions };
|
|
991
|
+
|
|
992
|
+
// Update the node in the store
|
|
993
|
+
getStore()?.getState().updateNode(this.editingNode.uuid, updatedNode);
|
|
994
|
+
|
|
995
|
+
// Repaint jsplumb connections in case node size changed
|
|
996
|
+
if (this.plumber) {
|
|
997
|
+
// Use requestAnimationFrame to ensure DOM has been updated first
|
|
998
|
+
requestAnimationFrame(() => {
|
|
999
|
+
this.plumber.repaintEverything();
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
this.closeNodeEditor();
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
private closeNodeEditor(): void {
|
|
1007
|
+
this.editingNode = null;
|
|
1008
|
+
this.editingNodeUI = null;
|
|
1009
|
+
this.editingAction = null;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
private handleActionEditCanceled(): void {
|
|
1013
|
+
this.closeNodeEditor();
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
private handleNodeSaved(updatedNode: Node): void {
|
|
1017
|
+
if (this.editingNode) {
|
|
1018
|
+
// Clean up jsPlumb connections for removed exits before updating the node
|
|
1019
|
+
if (this.plumber) {
|
|
1020
|
+
const oldExits = this.editingNode.exits || [];
|
|
1021
|
+
const newExits = updatedNode.exits || [];
|
|
1022
|
+
|
|
1023
|
+
// Find exits that were removed
|
|
1024
|
+
const removedExits = oldExits.filter(
|
|
1025
|
+
(oldExit) =>
|
|
1026
|
+
!newExits.find((newExit) => newExit.uuid === oldExit.uuid)
|
|
1027
|
+
);
|
|
1028
|
+
|
|
1029
|
+
// Remove jsPlumb connections for removed exits
|
|
1030
|
+
removedExits.forEach((exit) => {
|
|
1031
|
+
this.plumber.removeExitConnection(exit.uuid);
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
this.plumber.revalidate([updatedNode.uuid]);
|
|
1036
|
+
|
|
1037
|
+
// Update the node in the store
|
|
1038
|
+
getStore()?.getState().updateNode(this.editingNode.uuid, updatedNode);
|
|
1039
|
+
|
|
1040
|
+
// Repaint jsplumb connections in case node size changed
|
|
1041
|
+
if (this.plumber) {
|
|
1042
|
+
// Use requestAnimationFrame to ensure DOM has been updated first
|
|
1043
|
+
requestAnimationFrame(() => {
|
|
1044
|
+
this.plumber.repaintEverything();
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
this.closeNodeEditor();
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
private handleNodeEditCanceled(): void {
|
|
1052
|
+
this.closeNodeEditor();
|
|
1053
|
+
}
|
|
1054
|
+
|
|
932
1055
|
public render(): TemplateResult {
|
|
933
1056
|
// we have to embed our own style since we are in light DOM
|
|
934
1057
|
const style = html`<style>
|
|
935
1058
|
${unsafeCSS(Editor.styles.cssText)}
|
|
936
|
-
${unsafeCSS(
|
|
1059
|
+
${unsafeCSS(CanvasNode.styles.cssText)}
|
|
937
1060
|
</style>`;
|
|
938
1061
|
|
|
939
1062
|
const stickies = this.definition?._ui?.stickies || {};
|
|
@@ -1002,6 +1125,19 @@ export class Editor extends RapidElement {
|
|
|
1002
1125
|
${this.renderSelectionBox()}
|
|
1003
1126
|
</div>
|
|
1004
1127
|
</div>
|
|
1005
|
-
</div
|
|
1128
|
+
</div>
|
|
1129
|
+
|
|
1130
|
+
${this.editingNode || this.editingAction
|
|
1131
|
+
? html`<temba-node-editor
|
|
1132
|
+
.node=${this.editingNode}
|
|
1133
|
+
.nodeUI=${this.editingNodeUI}
|
|
1134
|
+
.action=${this.editingAction}
|
|
1135
|
+
@temba-node-saved=${(e: CustomEvent) =>
|
|
1136
|
+
this.handleNodeSaved(e.detail.node)}
|
|
1137
|
+
@temba-action-saved=${(e: CustomEvent) =>
|
|
1138
|
+
this.handleActionSaved(e.detail.action)}
|
|
1139
|
+
@temba-node-edit-cancelled=${this.handleNodeEditCanceled}
|
|
1140
|
+
></temba-node-editor>`
|
|
1141
|
+
: ''} `;
|
|
1006
1142
|
}
|
|
1007
1143
|
}
|