From 71a15ae693f25210feebcfc82cf033c1d7fc9efa Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 May 2024 18:29:34 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20desde=20el=20modal,=20tener=20interfaz?= =?UTF-8?q?=20para=20agregar=20un=20art=C3=ADculo=20nuevo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/attributes/_new_has_many.haml | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/views/posts/attributes/_new_has_many.haml b/app/views/posts/attributes/_new_has_many.haml index 76cf299f..27d682c4 100644 --- a/app/views/posts/attributes/_new_has_many.haml +++ b/app/views/posts/attributes/_new_has_many.haml @@ -5,6 +5,7 @@ name = "#{base}[#{attribute}][]" form_id = "form-#{Nanoid.generate}" modal_id = "modal-#{Nanoid.generate}" + post_form_id = "post-form-#{Nanoid.generate}" %div{ id: modal_id, data: { controller: 'modal array', 'array-original-value': metadata.value.to_json, 'array-new-array-value': site_posts_new_related_post_path(site) } } .form-group @@ -39,7 +40,28 @@ .mb-2{ data: { target: 'array.item', 'searchable-value': value.remove_diacritics.downcase, value: uuid } } = render 'bootstrap/custom_checkbox', name: name, id: "value-#{Nanoid.generate}", value: uuid, checked: metadata.value.include?(uuid), content: value + -# + Según la definición del campo, si hay un filtro, tenemos que poder + elegir qué tipo de esquema queremos o si hay uno solo, siempre + vamos a enviar ese. Si no hay ninguno, tendríamos que poder elegir + entre todos los esquemas. + - content_for :"#{id}_footer" do - .flex-grow-1 + - layout = metadata.filter[:layout] + - if layout.is_a?(String) + %input{ type: 'hidden', name: 'layout', value: layout, form: post_form_id } + = render 'bootstrap/btn', content: t('.add', layout: site.layouts[layout].humanized_name), form: post_form_id, type: 'submit', class: 'm-0 mr-1' + - else + - layouts = layout&.map { |x| site.layouts[x] } + - layouts ||= site.layouts.values + .input-group.w-auto.flex-grow-1.my-0 + %select.form-control{ form: post_form_id, name: 'layout' } + - layouts.each do |layout| + %option{ value: layout.name }= layout.humanized_name + .input-group-append + = render 'bootstrap/btn', content: t('.add', layout: ''), form: post_form_id, type: 'submit', class: 'mb-0 mr-0' = render 'bootstrap/btn', content: t('.accept'), action: 'array#accept modal#hide', class: 'm-0 mr-1' = render 'bootstrap/btn', content: t('.cancel'), action: 'array#cancel modal#hide', class: 'm-0' + +- content_for :post_form do + %form{ id: post_form_id }