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...