diff --git a/app/controllers/madmp_fragments_controller.rb b/app/controllers/madmp_fragments_controller.rb index 67cd032..d795dc4 100644 --- a/app/controllers/madmp_fragments_controller.rb +++ b/app/controllers/madmp_fragments_controller.rb @@ -252,6 +252,7 @@ schema = MadmpSchema.find(params[:schema_id]) template_locale = params[:locale] query_id = params[:query_id] + readonly = params[:readonly] == "true" is_custom = params[:custom_value].present? ? true : false @fragment = MadmpFragment.new( @@ -294,7 +295,7 @@ params[:property_name], template_locale, query_id, - true + readonly ) } end diff --git a/app/javascript/utils/select2.js b/app/javascript/utils/select2.js index d6ddf8c..bc88ee4 100644 --- a/app/javascript/utils/select2.js +++ b/app/javascript/utils/select2.js @@ -43,6 +43,7 @@ schema_id: selectField.data('schema-id'), query_id: selectField.data('query-id'), property_name: selectField.data('property-name'), + readonly: selectField.data('readonly'), }; if (selected) { requestData.registry_value_id = value; diff --git a/app/views/branded/shared/dynamic_form/fields/registry/_multiple_complex.html.erb b/app/views/branded/shared/dynamic_form/fields/registry/_multiple_complex.html.erb index 6ef9055..f7e140b 100644 --- a/app/views/branded/shared/dynamic_form/fields/registry/_multiple_complex.html.erb +++ b/app/views/branded/shared/dynamic_form/fields/registry/_multiple_complex.html.erb @@ -5,17 +5,18 @@ <% query_id = Digest::MD5.hexdigest("#{parent_id}-#{property_name}") %> <% intermediate_message = overridable ? d_("dmpopidor", "Select a value you want to add to your plan or type a new one.") : d_("dmpopidor", "Select a value you want to add to your plan.")%> -
-
- <%= field_label %> -
- <%= intermediate_message %> +
+ <%= field_label %> +
+ <%= intermediate_message %> +
<%= select_tag "#{f.object_name}[#{field_name}]", options_for_select( select_values.map {|v| [ @@ -24,9 +25,6 @@ ] } ), - data: { - "tags" => overridable - }, disabled: readonly, multiple: false, include_blank: true, @@ -35,23 +33,46 @@ class: "form-control #{field_class}", id: field_id %> - - - - - <%= render(partial: 'shared/dynamic_form/linked_fragment/list', locals: { - obj_list: value, - parent_id: parent_id, - schema_id: schema_id, - readonly: true, - deletable: true, - template_locale: locale, - property_name: property_name, - query_id: query_id - } - ) if value.present? %> - -
+ <% if parent_id.present? || overridable %> + + <%= link_to new_edit_linked_madmp_fragments_url( + nil, + :parent_id => parent_id, + :schema_id => schema_id, + :template_locale => locale, + :source => "list-modal", + :property_name => property_name, + :query_id => query_id + ), { + :remote => true, + :target => "_self", + :class => "add-fragment", + 'data-toggle' => "tooltip", + 'data-original-title' => d_("dmpopidor", "Click here to add a new item") + } do %> + + <% end %> + + <% end %>
-
-
\ No newline at end of file + +
+
+ + + + <%= render(partial: 'shared/dynamic_form/linked_fragment/list', locals: { + obj_list: value, + parent_id: parent_id, + schema_id: schema_id, + readonly: !overridable, + deletable: true, + template_locale: locale, + property_name: property_name, + query_id: query_id + } + ) if value.present? %> + +
+
+ \ No newline at end of file