diff --git a/app/javascript/controllers/autosave_controller.js b/app/javascript/controllers/autosave_controller.js index fc47154738..4a1db3326f 100644 --- a/app/javascript/controllers/autosave_controller.js +++ b/app/javascript/controllers/autosave_controller.js @@ -13,6 +13,8 @@ export default class extends Controller { static classes = ['goodAlert', 'badAlert'] connect () { + this.visibleClass = 'visible' + this.hiddenClass = 'invisible' this.save = debounce(this.save, this.delayValue).bind(this) } @@ -58,22 +60,50 @@ export default class extends Controller { autosaveAlert () { this.removeBadAlert() - this.alertTarget.innerHTML = 'Autosaving...' + this.alertTargets.forEach(alertTarget => { + alertTarget.innerHTML = 'Autosaving...' + }) + this.revealAlert() } goodAlert () { this.removeBadAlert() - this.alertTarget.innerHTML = 'Saved!' + this.alertTargets.forEach(alertTarget => { + alertTarget.innerHTML = 'Saved!' + }) } removeBadAlert () { - this.alertTarget.classList.add(this.goodAlertClass) - this.alertTarget.classList.remove(this.badAlertClass) + this.alertTargets.forEach(alertTarget => { + alertTarget.classList.add(this.goodAlertClass) + alertTarget.classList.remove(this.badAlertClass) + }) } badAlert (message) { - this.alertTarget.classList.remove(this.goodAlertClass) - this.alertTarget.classList.add(this.badAlertClass) - this.alertTarget.innerHTML = message + this.alertTargets.forEach(alertTarget => { + alertTarget.classList.remove(this.goodAlertClass) + alertTarget.classList.add(this.badAlertClass) + alertTarget.innerHTML = message + }) + } + + hideAlert () { + this.alertTargets.forEach(alertTarget => { + alertTarget.classList.add(this.hiddenClass) + alertTarget.classList.remove(this.visibleClass) + }) + } + + revealAlert (hide = true) { + this.alertTargets.forEach(alertTarget => { + alertTarget.classList.remove(this.hiddenClass) + alertTarget.classList.add(this.visibleClass) + }) + if (hide) { + setTimeout(() => { + this.hideAlert() + }, this.delayValue) + } } } diff --git a/app/views/case_contacts/form/details.html.erb b/app/views/case_contacts/form/details.html.erb index 07942adaf0..6b387fc9f5 100644 --- a/app/views/case_contacts/form/details.html.erb +++ b/app/views/case_contacts/form/details.html.erb @@ -117,8 +117,6 @@ data-casa-nested-form-model-name-value="contact_topic_answer">

Notes

- - <% if @contact_topics.empty? %>

<% if current_user.casa_admin? %> @@ -158,6 +156,12 @@ + + <% org_driving_reimbursement = current_organization.show_driving_reimbursement %> @@ -252,6 +256,12 @@ <% end %> + + <% end %> diff --git a/app/views/shared/_additional_expense_form.html.erb b/app/views/shared/_additional_expense_form.html.erb index 3136f8bd88..0c28565fe0 100644 --- a/app/views/shared/_additional_expense_form.html.erb +++ b/app/views/shared/_additional_expense_form.html.erb @@ -23,6 +23,7 @@ <%= form.text_area(:other_expenses_describe, placeholder: "Enter additional details", class: ["form-control", "expense-describe-input"], + data: { action: "input->autosave#save" }, ) %>