Add mode to keep labeled alt styles until they're all labeled
If you check this box, it'll keep you in a mode where saving an alt style redirects you to the *next* one that needs labeling, until they're all done. Useful for big drops!
This commit is contained in:
parent
d8ff99475e
commit
66438eae1a
4 changed files with 42 additions and 6 deletions
|
@ -41,3 +41,15 @@
|
||||||
|
|
||||||
.field_with_errors
|
.field_with_errors
|
||||||
display: contents
|
display: contents
|
||||||
|
|
||||||
|
.actions
|
||||||
|
display: flex
|
||||||
|
align-items: center
|
||||||
|
gap: 1em
|
||||||
|
|
||||||
|
label
|
||||||
|
display: flex
|
||||||
|
align-items: center
|
||||||
|
gap: .25em
|
||||||
|
font-size: .85em
|
||||||
|
font-style: italic
|
||||||
|
|
|
@ -54,7 +54,7 @@ class AltStylesController < ApplicationController
|
||||||
|
|
||||||
if @alt_style.update(alt_style_params)
|
if @alt_style.update(alt_style_params)
|
||||||
flash[:notice] = "\"#{@alt_style.full_name}\" successfully saved!"
|
flash[:notice] = "\"#{@alt_style.full_name}\" successfully saved!"
|
||||||
redirect_to alt_styles_path
|
redirect_to destination_after_save
|
||||||
else
|
else
|
||||||
render action: :edit, status: :bad_request
|
render action: :edit, status: :bad_request
|
||||||
end
|
end
|
||||||
|
@ -79,4 +79,21 @@ class AltStylesController < ApplicationController
|
||||||
Species.find_by(name: params[:species])
|
Species.find_by(name: params[:species])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destination_after_save
|
||||||
|
if params[:next] == "unlabeled-style"
|
||||||
|
next_unlabeled_style_path
|
||||||
|
else
|
||||||
|
alt_styles_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def next_unlabeled_style_path
|
||||||
|
unlabeled_style = AltStyle.unlabeled.newest.first
|
||||||
|
if unlabeled_style
|
||||||
|
edit_alt_style_path(unlabeled_style, next: "unlabeled-style")
|
||||||
|
else
|
||||||
|
alt_styles_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,8 @@ class AltStyle < ApplicationRecord
|
||||||
scope :by_creation_date, -> {
|
scope :by_creation_date, -> {
|
||||||
order("DATE(created_at) DESC")
|
order("DATE(created_at) DESC")
|
||||||
}
|
}
|
||||||
|
scope :unlabeled, -> { where(series_name: nil) }
|
||||||
|
scope :newest, -> { order(created_at: :desc) }
|
||||||
|
|
||||||
def pet_name
|
def pet_name
|
||||||
I18n.translate('pet_types.human_name', color_human_name: color.human_name,
|
I18n.translate('pet_types.human_name', color_human_name: color.human_name,
|
||||||
|
|
|
@ -28,7 +28,12 @@
|
||||||
- if @alt_style.thumbnail_url?
|
- if @alt_style.thumbnail_url?
|
||||||
= image_tag @alt_style.thumbnail_url
|
= image_tag @alt_style.thumbnail_url
|
||||||
= f.url_field :thumbnail_url
|
= f.url_field :thumbnail_url
|
||||||
|
.actions
|
||||||
= f.submit "Save changes"
|
= f.submit "Save changes"
|
||||||
|
%label{title: "If checked, takes you to the next unlabeled pet style, if any. Useful for labeling in bulk!"}
|
||||||
|
= check_box_tag "next", "unlabeled-style",
|
||||||
|
checked: params[:next] == "unlabeled-style"
|
||||||
|
Then: Go to unlabeled style
|
||||||
|
|
||||||
- content_for :stylesheets do
|
- content_for :stylesheets do
|
||||||
= stylesheet_link_tag "application/breadcrumbs"
|
= stylesheet_link_tag "application/breadcrumbs"
|
||||||
|
|
Loading…
Reference in a new issue