worthwhile 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/WORTHWHILE_VERSION +1 -1
- data/app/datastreams/worthwhile/generic_work_rdf_properties.rb +1 -1
- data/app/helpers/curate/collections_helper.rb +0 -23
- data/app/helpers/worthwhile/collections_helper.rb +33 -0
- data/app/views/curate/collections/_form_to_add_member.html.erb +2 -8
- data/lib/worthwhile/version.rb +1 -1
- data/spec/helpers/worthwhile/collections_helper_spec.rb +14 -0
- data/worthwhile-models/app/models/concerns/worthwhile/generic_file_base.rb +1 -1
- data/worthwhile-models/app/models/concerns/worthwhile/solr_document_behavior.rb +5 -3
- data/worthwhile-models/lib/worthwhile/models/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f92a3d35183f9fecc6d40669f3947b604746570
|
4
|
+
data.tar.gz: 9f11fc3e4e3df7ccdea248f3bd77393590a9487b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 553879425a72f231b43b5ffe8410fba8d65d2b11dee4a576f42ffc9bebe8693249d097eec384fe4d65d8c0b2c6537645ec89c2afdd5fb7882caa46f7105f3875
|
7
|
+
data.tar.gz: 33cb788b8e54d4c743588047bc9ceeab335d16c2a88d2f9c74320f0bc5303591ee5a457b203f4f3191c0be8f21fc89ce3b700d649950960396d3a54ae1df9b56
|
data/WORTHWHILE_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -7,27 +7,4 @@ module Curate::CollectionsHelper
|
|
7
7
|
}
|
8
8
|
end
|
9
9
|
|
10
|
-
def available_collections(item = nil)
|
11
|
-
if item.present?
|
12
|
-
collection_options.reject {|n| n == item}
|
13
|
-
else
|
14
|
-
collection_options
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def collection_options
|
21
|
-
@collection_options ||= current_users_collections
|
22
|
-
end
|
23
|
-
|
24
|
-
# Defaults to returning a list of all collections.
|
25
|
-
# If you have implement User.collections, the results of that will be used.
|
26
|
-
def current_users_collections
|
27
|
-
if current_user.respond_to?(:collections)
|
28
|
-
current_user.collections.to_a
|
29
|
-
else
|
30
|
-
Collection.all
|
31
|
-
end
|
32
|
-
end
|
33
10
|
end
|
@@ -27,4 +27,37 @@ module Worthwhile::CollectionsHelper
|
|
27
27
|
content_tag :span, '', class: "glyphicon glyphicon-#{type}"
|
28
28
|
end
|
29
29
|
|
30
|
+
def collection_options_for_select(exclude_item = nil)
|
31
|
+
options_for_select(available_collections(exclude_item))
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
# return a list of collections for the current user with the exception of the passed in collection
|
36
|
+
def available_collections(exclude_item)
|
37
|
+
if exclude_item
|
38
|
+
collection_options.reject {|n| n.last == exclude_item.id}
|
39
|
+
else
|
40
|
+
collection_options
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def collection_options
|
46
|
+
@collection_options ||= current_users_collections
|
47
|
+
end
|
48
|
+
|
49
|
+
# Defaults to returning a list of all collections.
|
50
|
+
# If you have implement User.collections, the results of that will be used.
|
51
|
+
def current_users_collections
|
52
|
+
if current_user.respond_to?(:collections)
|
53
|
+
current_user.collections.map { |c| [c.title.join(', '), c.id] }
|
54
|
+
else
|
55
|
+
query = ActiveFedora::SolrService.construct_query_for_rel(has_model: Collection.to_class_uri)
|
56
|
+
ActiveFedora::SolrService.query(query, fl: 'desc_metadata__title_tesim id',
|
57
|
+
rows: 1000).map do |r|
|
58
|
+
[r['desc_metadata__title_tesim'].join(', '), r['id']]
|
59
|
+
end.sort { |a, b| a.first <=> b.first }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
30
63
|
end
|
@@ -8,14 +8,8 @@
|
|
8
8
|
|
9
9
|
<div class="form-group collection_id">
|
10
10
|
<div class="controls">
|
11
|
-
|
12
|
-
|
13
|
-
<% if collections.any? -%>
|
14
|
-
<% options << '<optgroup label="Your Collections">'.html_safe %>
|
15
|
-
<% options << options_from_collection_for_select(collections, "pid", "title") %>
|
16
|
-
<% options << '</optgroup>'.html_safe %>
|
17
|
-
<% end %>
|
18
|
-
<%= select_tag :id, options, prompt: 'Make a Selection', class: 'form-control', :'aria-labelledby' => select_label_id %>
|
11
|
+
<%= select_tag :id, collection_options_for_select(collectible), prompt: 'Make a Selection',
|
12
|
+
class: 'form-control', :'aria-labelledby' => select_label_id %>
|
19
13
|
</div>
|
20
14
|
</div>
|
21
15
|
|
data/lib/worthwhile/version.rb
CHANGED
@@ -16,4 +16,18 @@ describe Worthwhile::CollectionsHelper do
|
|
16
16
|
batch_document_ids: [ '456' ])
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
describe "#collection_options_for_select" do
|
21
|
+
before do
|
22
|
+
allow(helper).to receive(:current_user).and_return(User.new)
|
23
|
+
end
|
24
|
+
let!(:collection1) { Collection.create!(pid: 'test:123', title: 'One') }
|
25
|
+
let!(:collection2) { Collection.create!(pid: 'test:456', title: 'Two') }
|
26
|
+
let!(:collection3) { Collection.create!(pid: 'test:789', title: 'Thre') }
|
27
|
+
subject { helper.collection_options_for_select(collection2) }
|
28
|
+
|
29
|
+
it "should exclude the passed in collection" do
|
30
|
+
expect(subject).to eq "<option value=\"#{collection1.id}\">#{collection1.title}</option>\n<option value=\"#{collection3.id}\">#{collection3.title}</option>"
|
31
|
+
end
|
32
|
+
end
|
19
33
|
end
|
@@ -12,7 +12,7 @@ module Worthwhile
|
|
12
12
|
include Sufia::GenericFile::Metadata
|
13
13
|
include Sufia::GenericFile::Versions
|
14
14
|
include Sufia::Permissions::Readable
|
15
|
-
include CurationConcern::VersionedContent
|
15
|
+
include ::CurationConcern::VersionedContent
|
16
16
|
|
17
17
|
included do
|
18
18
|
belongs_to :batch, property: :is_part_of, class_name: 'ActiveFedora::Base'
|
@@ -27,8 +27,10 @@ module Worthwhile
|
|
27
27
|
# @example
|
28
28
|
# link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>
|
29
29
|
def to_model
|
30
|
-
|
31
|
-
|
30
|
+
@model ||= begin
|
31
|
+
m = ActiveFedora::Base.load_instance_from_solr(id, self)
|
32
|
+
m.class == ActiveFedora::Base ? self : m
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
def collection?
|
@@ -48,7 +50,7 @@ module Worthwhile
|
|
48
50
|
Array(self[Solrizer.solr_name('human_readable_type', :stored_searchable)]).first
|
49
51
|
end
|
50
52
|
|
51
|
-
def representative
|
53
|
+
def representative
|
52
54
|
Array(self[Solrizer.solr_name('representative', :stored_searchable)]).first
|
53
55
|
end
|
54
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worthwhile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hydra-head
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.
|
75
|
+
version: 0.1.2
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.1.
|
82
|
+
version: 0.1.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sufia-models
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|