From 5a531c98ae71edecde10080ac44964df230c21a1 Mon Sep 17 00:00:00 2001 From: ivanscinote <138504771+ivanscinote@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:34:36 +0200 Subject: [PATCH] Add callback to clear form errors at create wopi files [SCI-8927] (#5877) * Add callback to clear form errors at create wopi files [SCI-8927] --- app/assets/javascripts/assets/wopi/create_wopi_file.js | 5 +++++ app/assets/javascripts/sitewide/constants.js.erb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/assets/wopi/create_wopi_file.js b/app/assets/javascripts/assets/wopi/create_wopi_file.js index f99eac947..88db1b051 100644 --- a/app/assets/javascripts/assets/wopi/create_wopi_file.js +++ b/app/assets/javascripts/assets/wopi/create_wopi_file.js @@ -41,6 +41,11 @@ function initCreateWopiFileModal() { msg = I18n.t('assets.create_wopi_file.errors.not_found'); } renderFormError(undefined, element, msg); + }) + .on('input', '#new-wopi-file-name', function() { + if (this.value.length <= GLOBAL_CONSTANTS.FILENAME_MAX_LENGTH) { + $(this).closest('form').clearFormErrors(); + } }); } diff --git a/app/assets/javascripts/sitewide/constants.js.erb b/app/assets/javascripts/sitewide/constants.js.erb index 315b504ac..e3a67d903 100644 --- a/app/assets/javascripts/sitewide/constants.js.erb +++ b/app/assets/javascripts/sitewide/constants.js.erb @@ -10,5 +10,6 @@ const GLOBAL_CONSTANTS = { REPOSITORY_CHECKLIST_ITEMS_PER_COLUMN: <%= Constants::REPOSITORY_CHECKLIST_ITEMS_PER_COLUMN %>, REPOSITORY_STOCK_UNIT_ITEMS_PER_COLUMN: <%= Constants::REPOSITORY_STOCK_UNIT_ITEMS_PER_COLUMN %>, HAS_UNSAVED_DATA_CLASS_NAME: 'has-unsaved-data', - DEFAULT_ELEMENTS_PER_PAGE: <%= Constants::DEFAULT_ELEMENTS_PER_PAGE %> + DEFAULT_ELEMENTS_PER_PAGE: <%= Constants::DEFAULT_ELEMENTS_PER_PAGE %>, + FILENAME_MAX_LENGTH: <%= Constants::FILENAME_MAX_LENGTH %>, };