diff --git a/app/javascript/controllers/array_controller.js b/app/javascript/controllers/array_controller.js index fb74a673..fea690d2 100644 --- a/app/javascript/controllers/array_controller.js +++ b/app/javascript/controllers/array_controller.js @@ -108,7 +108,7 @@ export default class extends Controller { if (!this.isChecked(itemTarget)) continue; this.originalValue.push(itemTarget.dataset.value); - this.newArrayValueURL.searchParams.set("value", itemTarget.dataset?.humanValue || itemTarget.dataset?.value); + this.newArrayValueURL.searchParams.set("value", itemTarget.dataset?.sendValue || itemTarget.dataset?.value); const placeholder = this.placeholderTarget.content.firstElementChild.cloneNode(true); diff --git a/app/views/posts/attributes/_new_belongs_to.haml b/app/views/posts/attributes/_new_belongs_to.haml index 20b40140..d23301d9 100644 --- a/app/views/posts/attributes/_new_belongs_to.haml +++ b/app/views/posts/attributes/_new_belongs_to.haml @@ -58,7 +58,7 @@ - content_for :"#{id}_body" do .form-group.mb-0{ id: value_list_id } - metadata.values.each_pair do |value, uuid| - = render 'targets/array/item', value: uuid, 'human-value': value, class: 'mb-2' do + = render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do = render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, type: 'radio' -# diff --git a/app/views/posts/attributes/_new_has_and_belongs_to_many.haml b/app/views/posts/attributes/_new_has_and_belongs_to_many.haml index d70d9eb4..bf5e45e9 100644 --- a/app/views/posts/attributes/_new_has_and_belongs_to_many.haml +++ b/app/views/posts/attributes/_new_has_and_belongs_to_many.haml @@ -59,7 +59,7 @@ - content_for :"#{id}_body" do .form-group.mb-0{ id: value_list_id } - metadata.values.each_pair do |value, uuid| - = render 'targets/array/item', value: uuid, 'human-value': value, class: 'mb-2' do + = render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do = render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, data: { action: 'required-checkbox#change', target: 'required-checkbox.checkbox' } -# diff --git a/app/views/posts/attributes/_new_has_many.haml b/app/views/posts/attributes/_new_has_many.haml index 601a7e38..39d4538d 100644 --- a/app/views/posts/attributes/_new_has_many.haml +++ b/app/views/posts/attributes/_new_has_many.haml @@ -59,7 +59,7 @@ - content_for :"#{id}_body" do .form-group.mb-0{ id: value_list_id } - metadata.values.each_pair do |value, uuid| - = render 'targets/array/item', value: uuid, 'human-value': value, class: 'mb-2' do + = render 'targets/array/item', value: uuid, 'send-value': uuid, 'human-value': value, class: 'mb-2' do = render 'bootstrap/custom_checkbox', name: name, id: random_id, value: uuid, checked: metadata.value.include?(uuid), content: value, data: { action: 'required-checkbox#change', target: 'required-checkbox.checkbox' } -# diff --git a/app/views/targets/array/_item.haml b/app/views/targets/array/_item.haml index f89a42e5..ead9f4e2 100644 --- a/app/views/targets/array/_item.haml +++ b/app/views/targets/array/_item.haml @@ -6,16 +6,19 @@ @param :value [String] El valor (requerido) @param :human-value [String] El valor legible por humanes (opcional) + @param :send-value [String] El valor que se envĂ­a al controlador (opcional) @param :searchable-value [String] El valor para usar en el filtro (opcional) :ruby local_assigns[:'human-value'] ||= value + local_assigns[:'send-value'] ||= local_assigns[:'human-value'] local_assigns[:'searchable-value'] ||= local_assigns[:'human-value'].remove_diacritics.downcase local_assigns.delete(:value) data = local_assigns.delete(:data) data ||= {} data[:'human-value'] = local_assigns.delete(:'human-value') + data[:'send-value'] = local_assigns.delete(:'send-value') data[:'searchable-value'] = local_assigns.delete(:'searchable-value') %div{ **local_assigns, data: { target: 'array.item', value: value, **data } }= yield