From aabeedd78f80b6048b186c3590043ec917290126 Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Fri, 20 Sep 2024 11:56:19 +0100 Subject: [PATCH] WIP UI --- .../projects/extracts_controller.rb | 8 ++++++++ app/views/projects/dataset/keys/_key.html.erb | 9 +++++++++ .../dataset/keys/_numeric_key.html.erb | 2 +- app/views/projects/extracts/_sidebar.html.erb | 20 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects/extracts_controller.rb b/app/controllers/projects/extracts_controller.rb index 9cc041ab24..fde6adea5e 100644 --- a/app/controllers/projects/extracts_controller.rb +++ b/app/controllers/projects/extracts_controller.rb @@ -20,6 +20,14 @@ def show return end + @insights = Project::Insight.find_by( + project: @project, info_request: @info_request + ) + + @main_insight = @insights.output.find do |i| + i[:answers].values.any?(&:present?) + end + @value_set = Dataset::ValueSet.new end diff --git a/app/views/projects/dataset/keys/_key.html.erb b/app/views/projects/dataset/keys/_key.html.erb index 509170d6a1..be0d162aad 100644 --- a/app/views/projects/dataset/keys/_key.html.erb +++ b/app/views/projects/dataset/keys/_key.html.erb @@ -1,6 +1,15 @@ <% value = f.object.values.find { |v| v.key.order == key.order } %> + <%= f.fields_for :values, value || Dataset::Value.new do |nested_form| %> <%= render partial: "projects/dataset/keys/#{key.format}_key", locals: { f: nested_form, key: key } %> <%= nested_form.hidden_field :dataset_key_id, value: key.to_param %> + + <% ai_value = @main_insight[:answers]["question#{nested_form.options[:child_index] + 1}"] %> + <%= content_tag :span, class: 'ai-insights', onclick: "fillAIValue(#{nested_form.options[:child_index]}, '#{ai_value}')" do %> + + + + + <% end %> <% end %> diff --git a/app/views/projects/dataset/keys/_numeric_key.html.erb b/app/views/projects/dataset/keys/_numeric_key.html.erb index df6171ca0d..973f004063 100644 --- a/app/views/projects/dataset/keys/_numeric_key.html.erb +++ b/app/views/projects/dataset/keys/_numeric_key.html.erb @@ -1,4 +1,4 @@
<%= f.label :value, key.title %> - <%= f.number_field :value %> + <%= f.text_field :value %>
diff --git a/app/views/projects/extracts/_sidebar.html.erb b/app/views/projects/extracts/_sidebar.html.erb index 4f66830042..ab85e3b1ba 100644 --- a/app/views/projects/extracts/_sidebar.html.erb +++ b/app/views/projects/extracts/_sidebar.html.erb @@ -5,5 +5,25 @@ <%= render partial: 'form', locals: { project: project, info_request: info_request, value_set: value_set } %> + +
+ Debug: HUMAN + <%= debug Project::Export::InfoRequest.new(@project, @info_request).send(:extracted_values).pluck(:value) %> +
+ +
+ Debug: AI + <%= debug @insights&.output %> +
+ +