From c0590164f0b2a1c8848ac80a48bf31314b3183dc Mon Sep 17 00:00:00 2001 From: f Date: Mon, 23 Jul 2018 16:23:53 -0300 Subject: [PATCH] los campos tienen etiquetas y ayudas --- app/models/post/template_field.rb | 6 +++++- app/views/posts/_form.haml | 4 +++- app/views/posts/template_field/_nested.haml | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/models/post/template_field.rb b/app/models/post/template_field.rb index d97cafd..681fefb 100644 --- a/app/models/post/template_field.rb +++ b/app/models/post/template_field.rb @@ -222,8 +222,12 @@ class Post h end + def label + (complex? && contents.dig('label')) || human + end + def help - (complex? && contents.dig('help')) || human + complex? && contents.dig('help') end def nested_fields diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 3493a15..71fcb87 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -94,7 +94,9 @@ = fa_icon 'link', title: t('posts.anchor') - if template.private? = fa_icon 'lock', title: t('posts.private') - = template.help + = template.label + - if template.help + %small.text-muted.form-text= template.help = render "posts/template_field/#{type}", template: template, name: template.key, value: value .invalid-feedback= t('posts.invalid') .form-group diff --git a/app/views/posts/template_field/_nested.haml b/app/views/posts/template_field/_nested.haml index 147930b..e0f957e 100644 --- a/app/views/posts/template_field/_nested.haml +++ b/app/views/posts/template_field/_nested.haml @@ -1,5 +1,10 @@ .form-group - = label_tag name.join('_'), template.help, id: name.join('_') + = label_tag name.join('_'), id: name.join('_') do + - if template.private? + = fa_icon 'lock', title: t('posts.private') + = template.label + - if template.help + %small.text-muted.form-text= template.help = render "posts/template_field/#{template.type}", template: template, name: name,