From 3534762f65a84b53c2a3d6599c0735d58ba7fbfa Mon Sep 17 00:00:00 2001 From: f Date: Tue, 1 Sep 2020 18:48:28 -0300 Subject: [PATCH] checkbox con onda --- app/views/posts/attributes/_boolean.haml | 19 ++++++++++--------- .../posts/template_field/_check_box.haml | 8 -------- .../template_field/_check_box_group.haml | 12 ------------ .../posts/template_field/_radio_group.haml | 15 --------------- 4 files changed, 10 insertions(+), 44 deletions(-) delete mode 100644 app/views/posts/template_field/_check_box.haml delete mode 100644 app/views/posts/template_field/_check_box_group.haml delete mode 100644 app/views/posts/template_field/_radio_group.haml diff --git a/app/views/posts/attributes/_boolean.haml b/app/views/posts/attributes/_boolean.haml index 46ab667..c959e4b 100644 --- a/app/views/posts/attributes/_boolean.haml +++ b/app/views/posts/attributes/_boolean.haml @@ -1,11 +1,12 @@ .form-check - = hidden_field_tag "post[#{attribute}]", '0' - = check_box_tag "post[#{attribute}]", '1', metadata.value, - class: "form-check-input #{invalid(post, attribute)}", - aria: { describedby: id_for_help(attribute) }, - autofocus: autofocus - = label_tag "post_#{attribute}", post_label_t(attribute, post: post), - class: 'form-check-label' + = hidden_field_tag "post[#{attribute}]", '0', id: '' + .custom-control.custom-switch + = check_box_tag "post[#{attribute}]", '1', metadata.value, + class: "custom-control-input #{invalid(post, attribute)}", + aria: { describedby: id_for_help(attribute) }, + autofocus: autofocus + = label_tag "post_#{attribute}", post_label_t(attribute, post: post), + class: 'custom-control-label' - = render 'posts/attribute_feedback', - post: post, attribute: attribute, metadata: metadata + = render 'posts/attribute_feedback', + post: post, attribute: attribute, metadata: metadata diff --git a/app/views/posts/template_field/_check_box.haml b/app/views/posts/template_field/_check_box.haml deleted file mode 100644 index 0a8ee02..0000000 --- a/app/views/posts/template_field/_check_box.haml +++ /dev/null @@ -1,8 +0,0 @@ -- field_name = field_name_for_post_as_string(name) -= hidden_field_tag field_name, 'false' -.form-check - = check_box_tag field_name, - 'true', - value == 'true', - class: 'form-check-input' - = label_tag field_name, t('posts.checkbox'), class: 'form-check-label' diff --git a/app/views/posts/template_field/_check_box_group.haml b/app/views/posts/template_field/_check_box_group.haml deleted file mode 100644 index 1a035e9..0000000 --- a/app/views/posts/template_field/_check_box_group.haml +++ /dev/null @@ -1,12 +0,0 @@ --# Obtener el nombre del campo -- field_name = field_name_for_post_as_string(name) --# Obtener todos los valores -- value = [] if value.nil? -- values = template.values.empty? ? [value].flatten : template.values -- values.each do |v| - .form-check - = check_box_tag field_name+'[]', - v, - @post.fetch_front_matter(name, []).include?(v), - class: 'form-check-input' - = label_tag field_name, v, class: 'form-check-label' diff --git a/app/views/posts/template_field/_radio_group.haml b/app/views/posts/template_field/_radio_group.haml deleted file mode 100644 index 02facb0..0000000 --- a/app/views/posts/template_field/_radio_group.haml +++ /dev/null @@ -1,15 +0,0 @@ --# Obtener el nombre del campo -- field_name = field_name_for_post_as_string(name) --# Obtener todos los valores -- value = [] if value.nil? -- values = template.values.empty? ? [value].flatten : template.values -- values.each do |v| - .form-check - = radio_button_tag field_name+'[]', - v, - @post.fetch_front_matter(name, []).include?(v), - class: 'form-check-input' - = label_tag [field_name,v].join(' '), class: 'form-check-label' do - = v.split(':', 2).first - %br/ - %small= v.split(':', 2).last