Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web-app/django/VIM/templates/instruments/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h5>Instrument Information</h5>
required />
<div class="form-text">
At least the first two digits are required.
<a href="https://en.wikipedia.org/wiki/Hornbostel%E2%80%93Sachs"
<a href="https://github.com/DDMAL/UMIL/wiki/HBS-FAQ:-How-can-I-determine-an-instruments-Hornbostel%E2%80%90Sachs-number%3F"
target="_blank"
rel="noopener">
Learn more <i class="bi bi-box-arrow-up-right"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h5 class="modal-title" id="addNameModalLabel">
</a>
</small>
</div>

</div>
</div>
<!-- Row for 'Publish' button -->
<div class="row mt-3">
Expand Down
21 changes: 20 additions & 1 deletion web-app/frontend/src/instruments/helpers/AddNameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Modal } from 'bootstrap';
export class AddNameManager {
private nameRowManager: NameRowManager;
private nameValidator: NameValidator;
private isPublishing = false;

constructor(nameRowManager: NameRowManager, nameValidator: NameValidator) {
this.nameRowManager = nameRowManager;
Expand Down Expand Up @@ -38,7 +39,7 @@ export class AddNameManager {
document
.getElementById('confirmPublishBtn')
?.addEventListener('click', () => {
this.submitNames();
void this.submitNames();
});
}

Expand Down Expand Up @@ -158,6 +159,18 @@ export class AddNameManager {
* Submits name entries to the backend API
*/
private async submitNames(): Promise<void> {
if (this.isPublishing) return;
this.isPublishing = true;

const confirmBtn = document.getElementById(
'confirmPublishBtn',
) as HTMLButtonElement | null;
const previousLabel = confirmBtn?.textContent ?? '';
if (confirmBtn) {
confirmBtn.disabled = true;
confirmBtn.textContent = 'Saving…';
}

const umilId = document
.getElementById('instrumentUmilIdInModal')
?.textContent?.trim();
Expand Down Expand Up @@ -193,6 +206,12 @@ export class AddNameManager {
}
} catch (error) {
alert('An error occurred while publishing: ' + (error as Error).message);
} finally {
this.isPublishing = false;
if (confirmBtn) {
confirmBtn.disabled = false;
confirmBtn.textContent = previousLabel || 'Confirm';
}
}
}

Expand Down
Loading