From 55a37edae0bd0ae6e801911ab490d1f91dff0249 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 22 Jan 2020 17:42:08 -0300 Subject: [PATCH] color --- app/models/metadata_color.rb | 5 +++++ app/models/metadata_email.rb | 11 +---------- app/views/posts/attribute_ro/_color.haml | 3 +++ app/views/posts/attributes/_color.haml | 6 ++++++ 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 app/models/metadata_color.rb create mode 100644 app/views/posts/attribute_ro/_color.haml create mode 100644 app/views/posts/attributes/_color.haml diff --git a/app/models/metadata_color.rb b/app/models/metadata_color.rb new file mode 100644 index 00000000..ce359215 --- /dev/null +++ b/app/models/metadata_color.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +# Un campo de correo +# TODO: Validar que tenga un formato correo +class MetadataString < MetadataString; end diff --git a/app/models/metadata_email.rb b/app/models/metadata_email.rb index 18ee2392..ce359215 100644 --- a/app/models/metadata_email.rb +++ b/app/models/metadata_email.rb @@ -2,13 +2,4 @@ # Un campo de correo # TODO: Validar que tenga un formato correo -class MetadataString < MetadataTemplate - # Una string vacĂ­a - def default_value - '' - end - - def value - super.strip - end -end +class MetadataString < MetadataString; end diff --git a/app/views/posts/attribute_ro/_color.haml b/app/views/posts/attribute_ro/_color.haml new file mode 100644 index 00000000..787aacd5 --- /dev/null +++ b/app/views/posts/attribute_ro/_color.haml @@ -0,0 +1,3 @@ +%tr{ id: attribute } + %th= post_label_t(attribute, post: post) + %td{ style: "background-color: #{metadata.value}" } = metadata.value diff --git a/app/views/posts/attributes/_color.haml b/app/views/posts/attributes/_color.haml new file mode 100644 index 00000000..a2945016 --- /dev/null +++ b/app/views/posts/attributes/_color.haml @@ -0,0 +1,6 @@ +.form-group + = label_tag "post_#{attribute}", post_label_t(attribute, post: post) + = color_field 'post', attribute, value: metadata.value, + **field_options(attribute, metadata) + = render 'posts/attribute_feedback', + post: post, attribute: attribute, metadata: metadata