diff --git a/app/models/metadata_email.rb b/app/models/metadata_email.rb new file mode 100644 index 00000000..18ee2392 --- /dev/null +++ b/app/models/metadata_email.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# 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 diff --git a/app/views/posts/attribute_ro/_email.haml b/app/views/posts/attribute_ro/_email.haml new file mode 100644 index 00000000..cf15531c --- /dev/null +++ b/app/views/posts/attribute_ro/_email.haml @@ -0,0 +1,4 @@ +%tr{ id: attribute } + %th= post_label_t(attribute, post: post) + %td + %a{ href: "mailto:#{metadata.value}" }= metadata.value diff --git a/app/views/posts/attributes/_email.haml b/app/views/posts/attributes/_email.haml new file mode 100644 index 00000000..b2a301c3 --- /dev/null +++ b/app/views/posts/attributes/_email.haml @@ -0,0 +1,6 @@ +.form-group + = label_tag "post_#{attribute}", post_label_t(attribute, post: post) + = email_field 'post', attribute, value: metadata.value, + **field_options(attribute, metadata) + = render 'posts/attribute_feedback', + post: post, attribute: attribute, metadata: metadata