Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update status messages on transcription form when the form is updated through ajax. #2210

Merged
merged 1 commit into from
Dec 13, 2023
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
54 changes: 49 additions & 5 deletions concordia/static/js/contribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ function setupPage() {
data.transcriptionStatus == 'not_started')
) {
// If we're in transcribe mode and we don't have the reservation
$('.tx-status-display')
$('.transcription-status-display')
.children()
.attr('hidden', 'hidden')
.filter('.tx-edit-conflict')
.filter('#display-conflict')
.removeAttr('hidden');
}
firstEditorUpdate = false;
Expand All @@ -317,6 +317,21 @@ function setupPage() {
$ocrForm
.find('input[name="supersedes"]')
.val(extra.responseData.id);
$('#transcription-status-display')
.children()
.attr('hidden', 'hidden')
.filter('#display-inprogress')
.removeAttr('hidden');
let messageChildren = $('#transcription-status-message').children();
messageChildren
.attr('hidden', 'hidden')
.filter('#message-inprogress')
.removeAttr('hidden');
messageChildren
.filter('#message-contributors')
.removeAttr('hidden')
.find('#message-contributors-num')
.html(extra.responseData.asset.contributors);
$transcriptionEditor.trigger('update-ui-state');
})
.on('form-submit-failure', function (event, info) {
Expand All @@ -341,12 +356,24 @@ function setupPage() {
method: 'POST',
dataType: 'json',
})
.done(function () {
$('.tx-status-display')
.done(function (data) {
$('#transcription-status-display')
.children()
.attr('hidden', 'hidden')
.filter('.tx-submitted')
.filter('#display-submitted')
.removeAttr('hidden');
let messageChildren = $(
'#transcription-status-message',
).children();
messageChildren
.attr('hidden', 'hidden')
.filter('#message-submitted')
.removeAttr('hidden');
messageChildren
.filter('#message-contributors')
.removeAttr('hidden')
.find('#message-contributors-num')
.html(data.asset.contributors);
$('#successful-submission-modal')
.modal()
.on('hidden.bs.modal', function () {
Expand Down Expand Up @@ -570,6 +597,23 @@ function setupPage() {
.find('textarea[name="text"]')
.val(extra.responseData.text);
$ocrLoading.attr('hidden', 'hidden');
$('#transcription-status-display')
.children()
.attr('hidden', 'hidden')
.filter('#display-inprogress')
.removeAttr('hidden');
let messageChildren = $(
'#transcription-status-message',
).children();
messageChildren
.attr('hidden', 'hidden')
.filter('#message-inprogress')
.removeAttr('hidden');
messageChildren
.filter('#message-contributors')
.removeAttr('hidden')
.find('#message-contributors-num')
.html(extra.responseData.asset.contributors);
$transcriptionEditor.trigger('update-ui-state');
$ocrForm
.find('input[name="supersedes"]')
Expand Down
41 changes: 21 additions & 20 deletions concordia/templates/transcriptions/asset_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,24 +374,24 @@ <h6>Why does <span class="font-italic">By the People</span> have this feature?</

<div id="editor-column" class="d-flex justify-content-between p-3 d-print-block flex-column">
<div class="flex-grow-1 d-flex d-print-block flex-column">
<div class="tx-status-display">
<h2 class="tx-submitted" {% if transcription_status != 'submitted' %}hidden{% endif %}>
<div id="transcription-status-display">
<h2 id="display-submitted" {% if transcription_status != 'submitted' %}hidden{% endif %}>
<span class="fas fa-list"></span>
Needs review
</h2>
<h2 class="tx-completed" {% if transcription_status != 'completed' %}hidden{% endif %}>
<h2 id="display-completed" {% if transcription_status != 'completed' %}hidden{% endif %}>
<span class="fas fa-check"></span>
Completed
</h2>
<h2 class="tx-edit" {% if transcription_status != "not_started" %}hidden{% endif %}>
<h2 id="display-notstarted" {% if transcription_status != "not_started" %}hidden{% endif %}>
<span class="fas fa-edit"></span>
Not started
</h2>
<h2 class="tx-edit" {% if transcription_status != "in_progress" %}hidden{% endif %}>
<h2 id="display-inprogress" {% if transcription_status != "in_progress" %}hidden{% endif %}>
<span class="fas fa-edit"></span>
In progress
</h2>
<span class="tx-edit-conflict" hidden>
<span id="display-conflict" hidden>
<span class="fas fa-exclamation-triangle"></span>
Another user is transcribing this page
</span>
Expand All @@ -401,21 +401,22 @@ <h2 class="tx-edit" {% if transcription_status != "in_progress" %}hidden{% endif
{% csrf_token %}
<input type="hidden" name="supersedes" value="{{ transcription.pk|default:'' }}" />

<span>
{% if transcription_status == 'not_started' %}
<span id="transcription-status-message">
<h2 id="message-contributors" {% if transcription_status == 'not_started' %}hidden{% endif %}>
Registered Contributors: <span id="message-contributors-num" class="font-weight-normal">{{ registered_contributors }}</span>
</h2>
<span id="message-notstarted" {% if transcription_status != 'not_started' %}hidden{% endif %}>
Transcribe this page.
{% else %}
<h2>Registered Contributors: <span class="font-weight-normal">{{ registered_contributors }}</span></h2>
{% if transcription_status == 'in_progress' %}
Someone started this transcription. Can you finish it?
{% elif transcription_status == 'submitted' %}
Check this transcription thoroughly. Accept if correct!
{% elif transcription_status == 'completed' %}
This transcription is finished! You can read and add tags.
{% else %}
Transcription
{% endif %}
{% endif %}
</span>
<span id="message-inprogress" {% if transcription_status != 'in_progress' %}hidden{% endif %}>
Someone started this transcription. Can you finish it?
</span>
<span id="message-submitted" {% if transcription_status != 'submitted' %}hidden{% endif %}>
Check this transcription thoroughly. Accept if correct!
</span>
<span id="message-completed" {% if transcription_status != 'completed' %}hidden{% endif %}>
This transcription is finished! You can read and add tags.
</span>
</span>

{% spaceless %}
Expand Down
4 changes: 4 additions & 0 deletions concordia/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,7 @@ def generate_ocr_transcription(request, *, asset_pk):
"asset": {
"id": transcription.asset.id,
"status": transcription.asset.transcription_status,
"contributors": transcription.asset.get_contributor_count(),
},
},
status=201,
Expand Down Expand Up @@ -1451,6 +1452,7 @@ def save_transcription(request, *, asset_pk):
"asset": {
"id": transcription.asset.id,
"status": transcription.asset.transcription_status,
"contributors": transcription.asset.get_contributor_count(),
},
},
status=201,
Expand Down Expand Up @@ -1501,6 +1503,7 @@ def submit_transcription(request, *, pk):
"asset": {
"id": transcription.asset.id,
"status": transcription.asset.transcription_status,
"contributors": transcription.asset.get_contributor_count(),
},
},
status=200,
Expand Down Expand Up @@ -1557,6 +1560,7 @@ def review_transcription(request, *, pk):
"asset": {
"id": transcription.asset.id,
"status": transcription.asset.transcription_status,
"contributors": transcription.asset.get_contributor_count(),
},
},
status=200,
Expand Down