From 2e39b624f2dcdc7ca8ee080959dced4ee68439d6 Mon Sep 17 00:00:00 2001 From: Josh Stegmaier <104993387+joshuastegmaier@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:05:22 -0400 Subject: [PATCH] Removed automatic unlocking of buttons on the transcription form to fix the bug causing the save button to be unlocked when it shouldn't be (#2506) --- concordia/static/js/src/contribute.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/concordia/static/js/src/contribute.js b/concordia/static/js/src/contribute.js index 30f9c8942..c7cb6a92b 100644 --- a/concordia/static/js/src/contribute.js +++ b/concordia/static/js/src/contribute.js @@ -14,17 +14,17 @@ function unlockControls($container) { if (!$container) { return; } - // Unlocks all of the controls in the provided jQuery element + // Unlocks all of the controls except buttons in the provided jQuery element $container.find('input, textarea').removeAttr('readonly'); $container.find('input:checkbox').removeAttr('disabled'); - // We exclude the rollback/forward buttons because the logic - // is handled in the template (both on first load and - // when updated via AJAX). - $container - .find('button') - .not('#rollback-transcription-button') - .not('#rollforward-transcription-button') - .removeAttr('disabled'); + + // Though we lock all buttons in lockControls, we don't automatically + // unlock most of them. Which buttons should be locked or unlocked + // is more complicated logic handled by the update-ui-state + // listener on the transcription form and the form + // results handlers. + // The only buttons unlocked here are ones that should always be unlocked. + $container.find('button#open-guide').removeAttr('disabled'); } $(document).on('keydown', function (event) { @@ -266,9 +266,9 @@ function setupPage() { $textarea.removeAttr('readonly'); $textarea.attr('placeholder', editorPlaceholderText); } - if (data.transcriptionId && !data.unsavedChanges) { - // We have a transcription ID and it's not stale, so we can submit the transcription for review: + // We have a transcription ID and it's not stale, + // so we can submit the transcription for review and disable the save button: $saveButton.attr('disabled', 'disabled'); $submitButton.removeAttr('disabled'); // We only want to do this the first time the editor ui is updated (i.e., on first load)