diff --git a/app/models/madmp_fragment.rb b/app/models/madmp_fragment.rb index 04c3177..46b5f53 100644 --- a/app/models/madmp_fragment.rb +++ b/app/models/madmp_fragment.rb @@ -100,7 +100,7 @@ end def get_dmp_fragments - MadmpFragment.where(dmp_id: dmp_id).group_by(&:madmp_schema_id) + MadmpFragment.where(dmp_id: dmp_id) end # Returns a human readable version of the structured answer diff --git a/app/views/branded/shared/dynamic_form/_form.html.erb b/app/views/branded/shared/dynamic_form/_form.html.erb index b624327..b09fafe 100644 --- a/app/views/branded/shared/dynamic_form/_form.html.erb +++ b/app/views/branded/shared/dynamic_form/_form.html.erb @@ -43,7 +43,7 @@ <% if prop['items']['type'] == 'object' && prop['items']['schema_id'].present? %> <% unless classname == "research_output" %> <% sub_schema = @schemas.find_by(id: prop['items']['schema_id']) %> - <% values = dmp_fragments[sub_schema.id] unless dmp_fragments.empty? %> + <% values = dmp_fragments.where(madmp_schema_id: sub_schema.id, parent_id: fragment.id) unless dmp_fragments.empty? %> <%= render(partial: 'shared/dynamic_form/fields/complex_multiple_field', locals: { field_values: values, readonly: readonly, @@ -80,7 +80,7 @@ <% sub_schema = @schemas.find_by(id: prop["schema_id"]) - sub_fragment = dmp_fragments[sub_schema.id].first unless dmp_fragments[sub_schema.id].nil? + sub_fragment = dmp_fragments.find_by(madmp_schema_id: sub_schema.id, parent_id: fragment.id) unless dmp_fragments.empty? # TODO : SINGLE SUB FRAGMENT SAVING #sub_fragment = dmp_fragments[sub_schema.id].find { |f| f.id == value["dbid"] } unless value.nil? %> diff --git a/app/views/branded/shared/export/_display_madmp_fragment.erb b/app/views/branded/shared/export/_display_madmp_fragment.erb index 50bb8a9..8af889c 100644 --- a/app/views/branded/shared/export/_display_madmp_fragment.erb +++ b/app/views/branded/shared/export/_display_madmp_fragment.erb @@ -16,12 +16,12 @@ <% sub_schema = sub_schemas[prop['items']['schema_id']] %> - <% unless dmp_fragments[sub_schema.id].nil? %> + <% unless dmp_fragments.empty? %>
| <%= field_name.capitalize.pluralize(2) %> | ||
|---|---|---|
|
<%= render(partial: 'shared/export/display_madmp_fragment', locals: {
fragment: val,
@@ -53,7 +53,7 @@
<%= field_name.capitalize %>
<%= render(partial: 'shared/export/display_madmp_fragment', locals: {
- fragment: dmp_fragments[sub_schema.id], #TODO : Implement Person fragments display
+ fragment: dmp_fragments.find_by(madmp_schema_id: sub_schema.id, parent_id: fragment.id) unless dmp_fragments.empty?, #TODO : Implement Person fragments display
schema: sub_schema,
classname: sub_schema.classname
} ) %>
diff --git a/app/views/branded/shared/fragments/_display.html.erb b/app/views/branded/shared/fragments/_display.html.erb
index 4301106..2428405 100644
--- a/app/views/branded/shared/fragments/_display.html.erb
+++ b/app/views/branded/shared/fragments/_display.html.erb
@@ -20,8 +20,8 @@
|