From 6434d1c896b89ae4ec03be005787ca6c01c89d74 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 12 Sep 2019 15:11:39 -0300 Subject: [PATCH] autofocus --- app/helpers/application_helper.rb | 1 + app/views/posts/_form.haml | 3 ++- app/views/posts/attributes/_boolean.haml | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7f007135..ab046469 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -65,6 +65,7 @@ module ApplicationHelper { class: "form-control #{invalid(metadata.post, attribute)}", required: metadata.required, + autofocus: (metadata.post.attributes.first == attribute), aria: { describedby: id_for_help(attribute), required: metadata.required diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 2b92b613..26b4e183 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -29,7 +29,8 @@ = render("posts/attributes/#{type}", post: post, attribute: attribute, - metadata: metadata, site: site) + metadata: metadata, site: site, + autofocus: (post.attributes.first == attribute)) -# Botones de guardado = render 'posts/submit', site: site, post: post diff --git a/app/views/posts/attributes/_boolean.haml b/app/views/posts/attributes/_boolean.haml index 55d69176..976c4b86 100644 --- a/app/views/posts/attributes/_boolean.haml +++ b/app/views/posts/attributes/_boolean.haml @@ -1,7 +1,8 @@ .form-check = check_box_tag "post[#{attribute}", metadata.value, metadata.value, class: "form-check-input #{invalid(post, attribute)}", - aria: { describedby: id_for_help(attribute) } + aria: { describedby: id_for_help(attribute) }, + autofocus: autofocus = label_tag "post_#{attribute}", post_label_t(attribute, post: post), class: 'form-check-label'