From 517f16c573725021764b5211f64d3167f323bb0b Mon Sep 17 00:00:00 2001 From: f Date: Fri, 14 Dec 2018 10:32:35 -0300 Subject: [PATCH] =?UTF-8?q?informar=20cu=C3=A1ndo=20el=20formulario=20es?= =?UTF-8?q?=20inv=C3=A1lido?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/validation.js | 4 ++++ app/views/posts/_form.haml | 2 ++ config/locales/en.yml | 1 + config/locales/es.yml | 1 + 4 files changed, 8 insertions(+) diff --git a/app/assets/javascripts/validation.js b/app/assets/javascripts/validation.js index a26df10..fd48b14 100644 --- a/app/assets/javascripts/validation.js +++ b/app/assets/javascripts/validation.js @@ -8,10 +8,14 @@ $(document).on('turbolinks:load', function() { $('.submit-post').click(function(e) { var form = $(this).parents('form.form'); + var invalid_help = $('.invalid_help'); + + invalid_help.addClass('d-none'); if (form[0].checkValidity() === false) { e.preventDefault(); e.stopPropagation(); + invalid_help.removeClass('d-none'); } form.addClass('was-validated'); diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index b2270c7..9feade4 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -23,6 +23,7 @@ = hidden_field_tag 'template', params[:template] .form-group = submit_tag t('posts.save'), class: 'btn btn-success submit-post' + .invalid_help.alert.alert-danger.d-none= @site.config.dig('invalid_help') || t('posts.invalid_help') - if current_user.is_a? Usuaria .form-group = label_tag 'post_author', t('posts.author') @@ -125,5 +126,6 @@ .invalid-feedback= t('posts.invalid') .form-group = submit_tag t('posts.save'), class: 'btn btn-success submit-post' + .invalid_help.alert.alert-danger.d-none= @site.config.dig('invalid_help') || t('posts.invalid_help') - if post = @post.template.get_front_matter('post') = render 'layouts/help', help: CommonMarker.render_doc(post).to_html diff --git a/config/locales/en.yml b/config/locales/en.yml index 75b3970..6c6bb2f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -241,3 +241,4 @@ en: image: multiple: 'You can select several images' url: 'The address must start with http:// or https://' + invalid_help: It looks like the form is incomplete. Check the red-colored fields to complete it. diff --git a/config/locales/es.yml b/config/locales/es.yml index 8bde2fb..a6aaf76 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -248,3 +248,4 @@ es: image: multiple: 'Puedes seleccionar varias imágenes' url: 'La dirección debe comenzar con http:// o https://' + invalid_help: Parece que el formulario no está completo. Verifica los campos marcados en rojo para completarlo.