From 8c2928e8339a72ab724395f30ff6decaea9027ef Mon Sep 17 00:00:00 2001 From: f Date: Fri, 14 Dec 2018 10:38:50 -0300 Subject: [PATCH] =?UTF-8?q?mostrar=20un=20mensaje=20mientras=20se=20env?= =?UTF-8?q?=C3=ADa=20el=20form?= 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 fd48b14..41a7f91 100644 --- a/app/assets/javascripts/validation.js +++ b/app/assets/javascripts/validation.js @@ -9,13 +9,17 @@ $(document).on('turbolinks:load', function() { $('.submit-post').click(function(e) { var form = $(this).parents('form.form'); var invalid_help = $('.invalid_help'); + var sending_help = $('.sending_help'); invalid_help.addClass('d-none'); + sending_help.addClass('d-none'); if (form[0].checkValidity() === false) { e.preventDefault(); e.stopPropagation(); invalid_help.removeClass('d-none'); + } else { + sending_help.removeClass('d-none'); } form.addClass('was-validated'); diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 9feade4..b78757b 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -24,6 +24,7 @@ .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') + .sending_help.alert.alert-success.d-none= @site.config.dig('sending_help') || t('posts.sending_help') - if current_user.is_a? Usuaria .form-group = label_tag 'post_author', t('posts.author') @@ -127,5 +128,6 @@ .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') + .sending_help.alert.alert-success.d-none= @site.config.dig('sending_help') || t('posts.sending_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 6c6bb2f..85c58b8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -242,3 +242,4 @@ en: 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. + sending_help: Saving, please wait... diff --git a/config/locales/es.yml b/config/locales/es.yml index a6aaf76..65a7a6d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -249,3 +249,4 @@ es: 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. + sending_help: Guardando, por favor espera...