From 8f95177c25fb475b586bc602ec9c6b58f794b32d Mon Sep 17 00:00:00 2001 From: Mariam05 Date: Thu, 23 May 2024 15:29:18 -0400 Subject: [PATCH] LTI-371: show indication that update, cancel requests are loading --- app/javascript/packs/edit.js | 13 +++++++++++++ app/views/rooms/_form.html.erb | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/javascript/packs/edit.js b/app/javascript/packs/edit.js index 4399fbcf..332456e3 100644 --- a/app/javascript/packs/edit.js +++ b/app/javascript/packs/edit.js @@ -120,4 +120,17 @@ $(document).on('turbolinks:load', function () { checkSharedCodeCheckboxStatus(); + // Show loading indicator when 'Update' or 'Cancel' buttons are pressed + const updateButton = $('#form-update-btn'); + updateButton.on('click', (event) => { + event.preventDefault(); + updateButton.attr('value', 'Loading...'); + $('#edit-form').trigger('submit'); + }) + + const cancelButton = $(this.getElementsByName('cancel')); + cancelButton.on('click', (event) => { + cancelButton.text('Loading...'); + }) + }); diff --git a/app/views/rooms/_form.html.erb b/app/views/rooms/_form.html.erb index b8cd85bb..a62f5b49 100644 --- a/app/views/rooms/_form.html.erb +++ b/app/views/rooms/_form.html.erb @@ -13,7 +13,7 @@ # with BigBlueButton; if not, see . %> -<%= form_with(model: room, local: true, class: "form fill", :url => room_path(@room, :launch_nonce => @launch_nonce) ) do |form| %> +<%= form_with(model: room, local: true, class: "form fill", :url => room_path(@room, :launch_nonce => @launch_nonce), name: 'edit-form', id: 'edit-form' ) do |form| %> <% if room.errors.any? %>

<%= pluralize(room.errors.count, "error") %> prohibited this room from being saved:

@@ -167,7 +167,7 @@
- <%= form.submit t('default.room.update'), class: "btn-primary m-1 ml-0" %> + <%= form.submit t('default.room.update'), class: "btn-primary m-1 ml-0", id: 'form-update-btn' %> <%= form.button t('default.room.cancel'), class: "btn-secondary m-1", name: "cancel" %>