-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
35 changed files
with
689 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/components/dashboard/show/pending_review_list_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%= render Elements::Tables::TableComponent.new( | ||
id:, label: 'Drafts', show_label: false | ||
) do |component| %> | ||
<% component.with_header( | ||
headers: ['Deposit', 'Collection', 'Owner', 'Last modified'] | ||
) %> | ||
<% works.each do |work| %> | ||
<% component.with_row(values: values_for(work), id: id_for(work)) %> | ||
<% end %> | ||
<% end %> |
40 changes: 40 additions & 0 deletions
40
app/components/dashboard/show/pending_review_list_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dashboard | ||
module Show | ||
# Component for rendering a table on the work show page with works pending review. | ||
class PendingReviewListComponent < ApplicationComponent | ||
def initialize(works:) | ||
@works = works | ||
super() | ||
end | ||
|
||
attr_reader :works | ||
|
||
def id | ||
'pending-review-table' | ||
end | ||
|
||
def id_for(work) | ||
dom_id(work, id) | ||
end | ||
|
||
def values_for(work) | ||
[ | ||
link_to(work.title, link_for(work)), | ||
link_to(work.collection.title, collection_path(druid: work.collection.druid)), | ||
work.user.name, | ||
I18n.l(work.updated_at, format: '%b %d, %Y') | ||
] | ||
end | ||
|
||
private | ||
|
||
def link_for(work) | ||
return wait_works_path(work) unless work.druid | ||
|
||
work_path(druid: work.druid) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Works | ||
module Edit | ||
# Component for rendering a submit button | ||
class SubmitComponent < ApplicationComponent | ||
def initialize(form_id:, work:, collection:, classes: []) | ||
@form_id = form_id | ||
@work = work | ||
@collection = collection | ||
@classes = classes | ||
super() | ||
end | ||
|
||
attr_reader :form_id, :work, :collection, :classes | ||
|
||
def call | ||
render Elements::Forms::SubmitComponent.new(form_id:, label:, classes:) | ||
end | ||
|
||
def label | ||
if collection.review_enabled? && (work.nil? || !helpers.allowed_to?(:review?, work)) | ||
'Submit for review' | ||
else | ||
'Deposit' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%= render Elements::AlertComponent.new(variant: :input) do %> | ||
<div class="h3">Review all details below then approve this deposit or return with comments.</div> | ||
<%= form_with model: review_form, url: review_work_path, method: :put do |form| %> | ||
<div class="form-check mb-3"> | ||
<%= form.radio_button :review_option, 'approve', class: 'form-check-input' %> | ||
<%= form.label :review_option_approve, 'Approve', class: 'form-check-label' %> | ||
</div> | ||
<div class="form-check mb-3"> | ||
<%= form.radio_button :review_option, 'reject', class: 'form-check-input' %> | ||
<%= form.label :review_option_reject, 'Return with comments', class: 'form-check-label' %> | ||
<%= render Elements::Forms::TextareaFieldComponent.new(form:, field_name: :reject_reason, label: 'Reason for returning', hidden_label: true) %> | ||
</div> | ||
|
||
<%= render Elements::Forms::SubmitComponent.new(label: 'Submit') %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Works | ||
module Show | ||
# Component providing a form for submitting a review. | ||
class ReviewComponent < ApplicationComponent | ||
def initialize(work:, review_form:) | ||
@work = work | ||
@review_form = review_form | ||
super() | ||
end | ||
|
||
attr_reader :review_form | ||
|
||
def render? | ||
@work.pending_review? && helpers.allowed_to?(:review?, @work) | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
app/components/works/show/review_rejected_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%= render Elements::AlertComponent.new(variant: :danger) do %> | ||
<p> | ||
The reviewer for this collection has returned the deposit for the following reason(s). | ||
|
||
Please fix the items given below and submit your deposit again for review. | ||
</p> | ||
<blockquote class="blockquote"> | ||
<p><%= review_rejected_reason %></p> | ||
</blockquote> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Works | ||
module Show | ||
# Component for rendering an alert for a rejected review. | ||
class ReviewRejectedComponent < ApplicationComponent | ||
def initialize(work:) | ||
@work = work | ||
super() | ||
end | ||
|
||
delegate :review_rejected_reason, to: :@work | ||
|
||
def render? | ||
@work.rejected_review? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
# Form object for reviewing a work. | ||
class ReviewForm < ApplicationForm | ||
attribute :review_option, :string, default: 'approve' | ||
validates :review_option, inclusion: { in: %w[approve reject] } | ||
|
||
attribute :reject_reason, :string | ||
validates :reject_reason, presence: true, if: -> { review_option == 'reject' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.