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 %>, };