-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from curationexperts/refactoring-agencies
refactoring partnering services
- Loading branch information
Showing
10 changed files
with
53 additions
and
43 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
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 @@ | ||
# services/partners_service.rb | ||
module Hyrax | ||
class PartnersService < Hyrax::QaSelectService | ||
def initialize | ||
super('partnering_agencies') | ||
end | ||
|
||
def include_current_value(value, _index, render_options, html_options) | ||
unless value.blank? || active?(value) | ||
html_options[:class] << ' force-select' | ||
render_options += [[label(value), value]] | ||
end | ||
[render_options, html_options] | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<%= f.input :partnering_agency, as: :select, | ||
collection: PartnersService.select_all_options, | ||
<% partnering_service = Hyrax::PartnersService.new %> | ||
<%= f.input :partnering_agency, as: :multi_value_select, | ||
collection: partnering_service.select_all_options, | ||
include_blank: true, | ||
input_html: { class: 'form-control' } | ||
%> | ||
item_helper: partnering_service.method(:include_current_value), | ||
input_html: { class: 'form-control' } %> |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
# Load DSL and set up stages | ||
require "capistrano/setup" | ||
|
||
|
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,17 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Hyrax::PartnersService do | ||
before do | ||
# Configure QA to use fixtures | ||
qa_fixtures = { local_path: File.expand_path('config/authorities') } | ||
allow(Qa::Authorities::Local).to receive(:config).and_return(qa_fixtures) | ||
end | ||
|
||
let(:service) { described_class.new } | ||
|
||
describe "#select_all_options" do | ||
it "has a select list" do | ||
expect(service.select_all_options).to include(["Does not apply (no collaborating organization)", "Does not apply (no collaborating organization)"]) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.