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 @@