meta_workflows 0.9.21 → 0.9.23

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ece4bc1842d69733d2b951c9406fda3e83f070ca2f6603e97a826d8fd0cd87d
4
- data.tar.gz: 8208fa70b0e19259a21eaad10aa915d111b4cdc4135c16d9bc7e7929186fa7c6
3
+ metadata.gz: 726c1853fd74d44442e6948f4ecad0f15b0f4bc8c0ca178f5d74339478b4c5f1
4
+ data.tar.gz: 4831f59cb31e16def136625e45fbaf5260e6dd5d1eaa26caf0514a9959d4beaf
5
5
  SHA512:
6
- metadata.gz: be5e764d6188da7ea34398d3ab7649ee0c8bf3964deab167ee1c778b21ea2b3e8f4f86018bfdf2a3a6aea549f44187549ddc6803c76516c886c7f06184ba16d8
7
- data.tar.gz: '028a513a4c38ea854f5f15798f3c6d8546653b94edf5bb41a14938f3dddf1c1ba6e40421956fd9f0a8c4e9982fea17879f53557911caefd1928012c72c36b97c'
6
+ metadata.gz: d4f4f00a82d6f151797509c0caf49fc1c65b967c459815c77d70e06cbba1afdf2a1a118a5525743feeb3d8097d64d2d59278fae989b946b11435b6ab66e4fda1
7
+ data.tar.gz: 1d04504d3da419f77e23be6bb244c8e759e98904bcbf21d680c4cfe7875321c45ca5fb381a25f967b81c1e64b904d0cd4eff295feb34305377c3c30d06e848e9
@@ -1,12 +1,16 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
3
  export default class extends Controller {
4
- static targets = ['textarea', 'form'];
4
+ static targets = ['textarea', 'form', 'structuredInputForm'];
5
5
 
6
6
  connect() {
7
7
  this.submitted = false;
8
8
  }
9
9
 
10
+ textareaTargetConnected() {
11
+ this.submitted = false;
12
+ }
13
+
10
14
  handleKeyDown(event) {
11
15
  if (event.key === 'Enter' && !event.shiftKey) {
12
16
  event.preventDefault();
@@ -25,6 +29,13 @@ export default class extends Controller {
25
29
  }
26
30
 
27
31
  this.submitted = true;
32
+ this.hideStructuredInputForm();
28
33
  this.formTarget.requestSubmit();
29
34
  }
35
+
36
+ hideStructuredInputForm() {
37
+ if (this.hasStructuredInputFormTarget) {
38
+ this.structuredInputFormTarget.style.display = 'none';
39
+ }
40
+ }
30
41
  }
@@ -1,18 +1,53 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
3
  export default class extends Controller {
4
- static targets = ['form', 'radioInput', 'checkboxInput', 'sliderInput'];
4
+ static targets = ['form', 'submitButton', 'checkbox'];
5
5
 
6
6
  connect() {
7
7
  this.submitted = false;
8
8
  }
9
9
 
10
+ checkboxTargetConnected() {
11
+ this.updateSubmitButtonState();
12
+ }
13
+
14
+ checkboxTargetDisconnected() {
15
+ this.updateSubmitButtonState();
16
+ }
17
+
18
+ updateSubmitButtonState() {
19
+ if (!this.hasSubmitButtonTarget) return;
20
+
21
+ const hasSelection = this.checkboxTargets.some(checkbox => checkbox.checked);
22
+ this.submitButtonTarget.disabled = !hasSelection;
23
+ }
24
+
25
+ handleCheckboxChange() {
26
+ this.updateSubmitButtonState();
27
+ }
28
+
10
29
  handleSubmit() {
11
30
  if (this.submitted) {
12
31
  return;
13
32
  }
14
33
 
15
34
  this.submitted = true;
35
+ this.hideFormAndSubmit();
36
+ }
37
+
38
+ handleCheckboxSubmit(event) {
39
+ event.preventDefault();
40
+
41
+ if (this.submitted) {
42
+ return;
43
+ }
44
+
45
+ this.submitted = true;
46
+ this.hideFormAndSubmit();
47
+ }
48
+
49
+ hideFormAndSubmit() {
50
+ this.formTarget.style.display = 'none';
16
51
  this.formTarget.requestSubmit();
17
52
  }
18
53
  }
@@ -992,6 +992,13 @@
992
992
  border: 1px solid var(--purple-200);
993
993
  }
994
994
 
995
+ /* Structured Input Submit Container */
996
+ .structured-submit-container {
997
+ display: flex;
998
+ justify-content: flex-end;
999
+ margin-top: 1rem;
1000
+ }
1001
+
995
1002
  /* Structured Input Submit Button */
996
1003
  .structured-submit-button {
997
1004
  width: 3rem;
@@ -11,7 +11,8 @@
11
11
  name="multiple_choice_selections[]"
12
12
  value="<%= option['value'] %>"
13
13
  class="structured-checkbox-input"
14
- data-action="change->meta-workflows--structured-form-submit#handleSubmit"
14
+ data-meta-workflows--structured-form-submit-target="checkbox"
15
+ data-action="change->meta-workflows--structured-form-submit#handleCheckboxChange"
15
16
  aria-describedby="structured-checkbox-help"
16
17
  >
17
18
  <label for="multiple_choice_<%= index %>" class="structured-checkbox-label">
@@ -21,4 +22,19 @@
21
22
  <% end %>
22
23
  </div>
23
24
  <div id="structured-checkbox-help" class="sr-only">Use space to select/deselect options</div>
25
+
26
+ <div class="structured-submit-container">
27
+ <button
28
+ type="submit"
29
+ class="structured-submit-button"
30
+ data-meta-workflows--structured-form-submit-target="submitButton"
31
+ data-action="click->meta-workflows--structured-form-submit#handleCheckboxSubmit"
32
+ disabled
33
+ aria-describedby="structured-submit-help"
34
+ aria-label="Submit your selections"
35
+ >
36
+ <i class="fa-solid fa-arrow-up"></i>
37
+ </button>
38
+ <div id="structured-submit-help" class="sr-only">Submit your selections. Button is disabled until at least one option is selected.</div>
39
+ </div>
24
40
  </div>
@@ -2,6 +2,10 @@
2
2
  <% active_execution = local_assigns[:record]&.workflow_executions&.order(created_at: :desc)&.first %>
3
3
  <% active_chat = active_execution&.workflow_steps&.last&.chat %>
4
4
  <% chat_history = active_execution&.execution_chat_history %>
5
+ <% current_step_data = active_execution&.step_data(active_execution&.current_step) %>
6
+ <% step_structured_input_config = current_step_data&.dig('structured_input') %>
7
+ <% is_structured_input = step_structured_input_config.present? && current_step_data&.dig('action') == 'structured_human' %>
8
+
5
9
 
6
10
  <div class="lexi-chat-alpha-tray">
7
11
  <%# Header with Lexi logo left and close button right %>
@@ -42,12 +46,12 @@
42
46
 
43
47
  <%# Input area (fixed at bottom) %>
44
48
  <div class="lexi-chat-alpha-input-area">
45
- <div class="lexi-chat-alpha-input-container">
49
+ <div class="lexi-chat-alpha-input-container" data-controller="meta-workflows--lexi-form-submit">
46
50
  <!-- Structured Input (always rendered, conditionally displays content) -->
47
51
  <%= render meta_structured_input, record: local_assigns[:record], structured_input_config: false, is_structured_input: false %>
48
52
 
49
53
  <!-- Regular Form Input (always present) -->
50
- <%= render partial: meta_response_form, locals: {record: local_assigns[:record], response_enabled: true, workflow_execution_id: active_execution&.id, chat_id: active_execution&.workflow_steps&.last&.chat&.id, step_has_repetitions: true } %>
54
+ <%= render partial: meta_response_form, locals: {record: local_assigns[:record], response_enabled: true, workflow_execution_id: active_execution&.id, chat_id: active_execution&.workflow_steps&.last&.chat&.id, step_has_repetitions: true, is_structured_input: is_structured_input } %>
51
55
  </div>
52
56
  </div>
53
57
  </div>
@@ -2,6 +2,9 @@
2
2
  <% active_execution = local_assigns[:record]&.workflow_executions&.order(created_at: :desc)&.first %>
3
3
  <% active_chat = active_execution&.workflow_steps&.last&.chat %>
4
4
  <% chat_history = active_execution&.execution_chat_history %>
5
+ <% current_step_data = active_execution&.step_data(active_execution&.current_step) %>
6
+ <% step_structured_input_config = current_step_data&.dig('structured_input') %>
7
+ <% is_structured_input = step_structured_input_config.present? && current_step_data&.dig('action') == 'structured_human' %>
5
8
 
6
9
  <div class="lexi-chat-tray lexi-chat-container-full">
7
10
  <!-- Header with Lexi logo and action icons -->
@@ -36,8 +39,10 @@
36
39
  <!-- Avatar and input area pinned to bottom -->
37
40
  <div class="lexi-chat-bottom">
38
41
  <%= image_tag("lexi-expanded.png", alt: "Lexi Avatar", class: "lexi-avatar") %>
39
- <div class="lexi-input-wrapper">
40
- <%= render partial: meta_response_form, locals: {record: local_assigns[:record], response_enabled: true, workflow_execution_id: active_execution&.id, chat_id: active_execution&.workflow_steps&.last&.chat&.id, step_has_repetitions: true } %>
42
+ <div class="lexi-input-wrapper" data-controller="meta-workflows--lexi-form-submit">
43
+ <%= render meta_structured_input, record: local_assigns[:record], structured_input_config: false, is_structured_input: false %>
44
+
45
+ <%= render partial: meta_response_form, locals: {record: local_assigns[:record], response_enabled: true, workflow_execution_id: active_execution&.id, chat_id: active_execution&.workflow_steps&.last&.chat&.id, step_has_repetitions: true, is_structured_input: is_structured_input } %>
41
46
  </div>
42
47
  </div>
43
48
  </div>
@@ -3,7 +3,7 @@
3
3
  <%= form_with url: workflow_execution_id.present? ? meta_workflows.human_path(workflow_execution_id) : "#",
4
4
  method: :patch,
5
5
  id: "#{target_frame_id(record, form: true)}_lexi",
6
- data: { controller: "meta-workflows--lexi-form-submit", "meta-workflows--lexi-form-submit-target": "form" } do |form| %>
6
+ data: { "meta-workflows--lexi-form-submit-target": "form" } do |form| %>
7
7
  <%= form.hidden_field :chat_id, value: chat_id %>
8
8
  <% if local_assigns[:is_structured_input] %>
9
9
  <%= form.hidden_field :auto_advance, value: true %>
@@ -11,7 +11,7 @@
11
11
  <!-- Streaming Response Frame -->
12
12
  <%= render partial: meta_streaming_response, locals: {
13
13
  record: record,
14
- show_loader: local_assigns[:show_loader] || true,
14
+ show_loader: local_assigns[:show_loader] || false,
15
15
  show_error: local_assigns[:show_error] || false,
16
16
  step_progress: local_assigns[:step_progress],
17
17
  full_response: local_assigns[:full_response],
@@ -10,7 +10,11 @@
10
10
  <%= form_with url: form_url,
11
11
  method: :patch,
12
12
  id: "#{target_frame_id(record, structured_input: true)}_form",
13
- data: { controller: "meta-workflows--structured-form-submit", "meta-workflows--structured-form-submit-target": "form" } do |form| %>
13
+ data: {
14
+ controller: "meta-workflows--structured-form-submit",
15
+ "meta-workflows--structured-form-submit-target": "form",
16
+ "meta-workflows--lexi-form-submit-target": "structuredInputForm"
17
+ } do |form| %>
14
18
  <%= form.hidden_field :chat_id, value: chat_id %>
15
19
 
16
20
  <div class="structured-input-wrapper">
@@ -3,7 +3,7 @@
3
3
  module MetaWorkflows
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- PATCH = 21 # this is automatically incremented by the build process
6
+ PATCH = 23 # this is automatically incremented by the build process
7
7
 
8
8
  VERSION = "#{MetaWorkflows::MAJOR}.#{MetaWorkflows::MINOR}.#{MetaWorkflows::PATCH}".freeze
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_workflows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.21
4
+ version: 0.9.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Medovyy