Skip to content

Commit

Permalink
2313 - Abandon subject without losing transcription
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNigel23 committed Jul 23, 2024
1 parent a48a707 commit 70814ee
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
18 changes: 15 additions & 3 deletions app/controllers/transcribe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def active?
end

def display_page
rollback_article_categories(params[:rollback_delete_ids], params[:rollback_unset_ids])

@collection = page.collection unless @collection
@auto_fullscreen = cookies[:auto_fullscreen] || 'no';
@layout_mode = cookies[:transcribe_layout_mode] || @collection.default_orientation
Expand Down Expand Up @@ -128,6 +130,7 @@ def needs_review

def save_transcription
old_link_count = @page.page_article_links.where(text_type: 'transcription').count
old_article_ids = @page.articles.pluck(:id)

@quality_sampling = QualitySampling.find(params[:quality_sampling_id]) if params[:quality_sampling_id].present?

Expand All @@ -148,7 +151,7 @@ def save_transcription
save_to_needs_review = params[:save_to_needs_review] || params[:done_to_needs_review]
save_to_transcribed = params[:save_to_transcribed] || params[:done_to_transcribed]
approve_to_transcribed = params[:approve_to_transcribed]

if params['save'] || save_to_incomplete || save_to_needs_review || save_to_transcribed || approve_to_transcribed
message = log_transcript_attempt
# leave the status alone if it's needs review, but otherwise set it to transcribed
Expand Down Expand Up @@ -240,7 +243,7 @@ def save_transcription

next_page_id = @page.last? || save_button_clicked ? @page.id : @page.lower_item.id
redirect_to action: 'assign_categories', page_id: @page.id,
collection_id: @collection, next_page_id: next_page_id
collection_id: @collection, next_page_id: next_page_id, old_article_ids: old_article_ids
end
else
log_transcript_error(message)
Expand Down Expand Up @@ -304,6 +307,7 @@ def assign_categories
# no reason to check articles if subjects disabled
unless @page.collection.subjects_disabled
@unassigned_articles = []
@new_article_ids = @page.articles.where.not(id: params[:old_article_ids]).pluck(:id)

# Separate translationa and transcription links
left, right = @page.page_article_links.partition { |x| x.text_type == 'translation' }
Expand Down Expand Up @@ -337,6 +341,8 @@ def help

def save_translation
old_link_count = @page.page_article_links.where(text_type: 'translation').count
old_article_ids = @page.articles.pluck(:id)

@page.attributes = page_params

#check to see if the page is marked blank
Expand Down Expand Up @@ -382,7 +388,8 @@ def save_translation
end
end

redirect_to :action => 'assign_categories', page_id: @page.id, collection_id: @collection, :text_type => 'translation'
redirect_to action: 'assign_categories', page_id: @page.id,
collection_id: @collection, text_type: 'translation', old_article_ids: old_article_ids
else
log_translation_error(message)
render :action => 'translate'
Expand Down Expand Up @@ -608,6 +615,11 @@ def record_translation_deed

private

def rollback_article_categories(destroy_ids, unset_ids)
Article.where(id: destroy_ids, provenance: nil).destroy_all if destroy_ids
Article.where(id: unset_ids).update(categories: []) if unset_ids
end

def page_params
params.require(:page).permit(:source_text, :source_translation, :title)
end
Expand Down
18 changes: 13 additions & 5 deletions app/views/transcribe/assign_categories.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
ruby:
if @text_type == 'translation'
cancel_path = collection_translate_page_path(@collection.owner, @collection, @work, @page.id,
rollback_unset_ids: @unassigned_articles.pluck(:id), rollback_delete_ids: @new_article_ids)
continue_path = collection_translate_page_path(@collection.owner, @collection, @work, @next_page_id)
else
cancel_path = collection_transcribe_page_path(@collection.owner, @collection, @work, @page.id,
rollback_unset_ids: @unassigned_articles.pluck(:id), rollback_delete_ids: @new_article_ids)
continue_path = collection_transcribe_page_path(@collection.owner, @collection, @work, @next_page_id)
end

=render({ :partial => '/shared/page_tabs', :locals => { :selected => 3, :page_id => @page.id }})

.headline
Expand All @@ -21,8 +32,5 @@ p.big =t('.uncategorized_subjects_mentioned')
option(data-level=level value=c.id selected=selected aria-label=t('.options') *language_attrs(@collection)) =c.title

span.legend
-if @text_type == 'translation'
-next_path = collection_translate_page_path(@collection.owner, @collection, @work, @page.id)
-else
-next_path = collection_transcribe_page_path(@collection.owner, @collection, @work, @page.id)
=link_to t('.continue'), next_path, class: 'button outline round'
=link_to t('.cancel'), cancel_path, class: 'button outline round', style: 'margin: 0 0.5rem';
=link_to t('.continue'), continue_path, class: 'button outline round', style: 'margin: 0 0.5rem';
1 change: 1 addition & 0 deletions config/locales/transcribe/transcribe-de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ de:
transcribe:
assign_categories:
assign_categories: Kategorien zuweisen
cancel: Stornieren
continue: Weitermachen
manage_categories: Kategorien verwalten
options: Optionen
Expand Down
1 change: 1 addition & 0 deletions config/locales/transcribe/transcribe-en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ en:
transcribe:
assign_categories:
assign_categories: Assign categories
cancel: Cancel
continue: Continue
manage_categories: Manage Categories
options: options
Expand Down
1 change: 1 addition & 0 deletions config/locales/transcribe/transcribe-es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ es:
transcribe:
assign_categories:
assign_categories: Asignar categorías
cancel: Cancelar
continue: Continuar
manage_categories: Administrar Categorías
options: Opciones
Expand Down
1 change: 1 addition & 0 deletions config/locales/transcribe/transcribe-fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ fr:
transcribe:
assign_categories:
assign_categories: Attribuer des catégories
cancel: Annuler
continue: Continuer
manage_categories: Gérer les catégories
options: options
Expand Down
1 change: 1 addition & 0 deletions config/locales/transcribe/transcribe-pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pt:
transcribe:
assign_categories:
assign_categories: Atribuir categorias
cancel: Cancelar
continue: Continuar
manage_categories: Controlar Categorias
options: opções
Expand Down

0 comments on commit 70814ee

Please sign in to comment.