sufia 6.0.0.beta1 → 6.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -2
- data/Gemfile +10 -1
- data/History.md +21 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/orcid.png +0 -0
- data/app/assets/javascripts/sufia.js +1 -1
- data/app/assets/javascripts/sufia/batch_edit.js +36 -54
- data/app/assets/javascripts/sufia/edit_metadata.js +10 -11
- data/app/assets/javascripts/sufia/permissions.js +2 -26
- data/app/assets/stylesheets/sufia.css.scss +10 -2
- data/app/assets/stylesheets/sufia/_batch-edit.scss +8 -6
- data/app/assets/stylesheets/sufia/_dashboard.scss +10 -0
- data/app/assets/stylesheets/sufia/_settings.scss +1 -0
- data/app/assets/stylesheets/sufia/_styles.scss +5 -3
- data/app/controllers/batch_controller.rb +9 -6
- data/app/controllers/batch_edits_controller.rb +2 -2
- data/app/controllers/collections_controller.rb +19 -3
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +30 -29
- data/app/controllers/concerns/sufia/breadcrumbs.rb +8 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +19 -7
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +14 -2
- data/app/controllers/single_use_links_viewer_controller.rb +5 -1
- data/app/forms/sufia/forms/batch_edit_form.rb +6 -0
- data/app/forms/sufia/forms/collection_edit_form.rb +17 -0
- data/app/forms/sufia/forms/generic_file_edit_form.rb +16 -0
- data/app/helpers/generic_file_helper.rb +3 -47
- data/app/helpers/sufia/permissions_helper.rb +29 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +11 -0
- data/app/inputs/multi_value_with_help_input.rb +8 -0
- data/app/inputs/select_with_help_input.rb +3 -0
- data/app/inputs/select_with_modal_help_input.rb +36 -0
- data/app/inputs/with_help_icon.rb +32 -0
- data/app/models/concerns/sufia/solr_document_behavior.rb +1 -1
- data/app/presenters/sufia/collection_presenter.rb +29 -0
- data/app/presenters/sufia/generic_file_presenter.rb +14 -0
- data/app/presenters/sufia/presenter_renderer.rb +53 -0
- data/app/views/batch/_metadata.html.erb +10 -44
- data/app/views/batch/_more_metadata.html.erb +3 -2
- data/app/views/batch/edit.html.erb +2 -2
- data/app/views/batch_edits/edit.html.erb +13 -17
- data/app/views/collections/_form.html.erb +5 -5
- data/app/views/collections/_show_descriptions.html.erb +8 -10
- data/app/views/collections/edit.html.erb +8 -9
- data/app/views/collections/edit_fields/_description.html.erb +1 -2
- data/app/views/dashboard/_index_partials/_stats.html.erb +3 -3
- data/app/views/generic_files/_descriptions.html.erb +5 -8
- data/app/views/generic_files/_permission_form.html.erb +8 -17
- data/app/views/generic_files/_show_descriptions.html.erb +3 -4
- data/app/views/generic_files/edit.html.erb +1 -2
- data/app/views/generic_files/jq_upload.json.jbuilder +8 -0
- data/app/views/records/edit_fields/_default.html.erb +5 -10
- data/app/views/records/edit_fields/_description.html.erb +5 -10
- data/app/views/records/edit_fields/_resource_type.html.erb +2 -5
- data/app/views/records/edit_fields/_rights.html.erb +3 -9
- data/app/views/single_use_links_viewer/show.html.erb +10 -16
- data/app/views/users/_profile.html.erb +1 -2
- data/app/views/users/_user_info.html.erb +20 -3
- data/app/views/users/edit.html.erb +11 -2
- data/app/views/users/show.html.erb +1 -1
- data/config/locales/sufia.en.yml +46 -26
- data/config/routes.rb +1 -1
- data/lib/generators/sufia/install_generator.rb +4 -0
- data/lib/sufia.rb +4 -0
- data/lib/sufia/form_builder.rb +16 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/generic_file/actor_spec.rb +1 -2
- data/spec/controllers/batch_controller_spec.rb +16 -48
- data/spec/controllers/batch_edits_controller_spec.rb +27 -16
- data/spec/controllers/collections_controller_spec.rb +81 -61
- data/spec/controllers/generic_files_controller_spec.rb +17 -2
- data/spec/controllers/users_controller_spec.rb +13 -3
- data/spec/features/collection_spec.rb +93 -88
- data/spec/features/users_spec.rb +1 -1
- data/spec/forms/collection_edit_form_spec.rb +20 -0
- data/spec/forms/generic_file_edit_form_spec.rb +26 -0
- data/spec/helpers/generic_file_helper_spec.rb +33 -7
- data/spec/helpers/permissions_helper_spec.rb +21 -0
- data/spec/inputs/multi_value_with_help_input_spec.rb +25 -0
- data/spec/inputs/select_with_modal_help_input_spec.rb +21 -0
- data/spec/jobs/batch_update_job_spec.rb +11 -14
- data/spec/lib/sufia/breadcrumbs_spec.rb +46 -8
- data/spec/models/generic_file_spec.rb +0 -13
- data/spec/models/user_spec.rb +23 -0
- data/spec/presenters/presenter_renderer_spec.rb +19 -0
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +12 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/input_support.rb +12 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/batch/edit.html.erb_spec.rb +13 -23
- data/spec/views/batch_edits/edit.html.erb_spec.rb +19 -0
- data/spec/views/collections/_form.html.erb_spec.rb +26 -28
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +15 -9
- data/spec/views/dashboard/index_spec.rb +2 -2
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +23 -0
- data/spec/views/generic_file/edit.html.erb_spec.rb +5 -0
- data/spec/views/generic_file/show.html.erb_spec.rb +5 -0
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +1 -1
- data/sufia-models/app/jobs/batch_update_job.rb +5 -5
- data/sufia-models/app/models/batch.rb +7 -3
- data/sufia-models/app/models/concerns/sufia/collection.rb +7 -25
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -1
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +2 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +4 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/user.rb +24 -17
- data/sufia-models/app/models/sufia/orcid_validator.rb +8 -0
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +13 -0
- data/sufia-models/app/services/sufia/indexing_service.rb +15 -0
- data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +30 -0
- data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +3 -47
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +11 -31
- data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +19 -0
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +2 -31
- data/sufia-models/lib/generators/sufia/models/templates/config/redis.yml +3 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +3 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +5 -0
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +2 -33
- data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +31 -0
- data/sufia-models/lib/sufia/models/engine.rb +1 -0
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +5 -5
- data/sufia.gemspec +2 -3
- metadata +49 -39
- data/app/assets/javascripts/sufia/multiForm.js +0 -67
- data/app/helpers/records_helper.rb +0 -4
- data/app/helpers/sufia/records_helper_behavior.rb +0 -68
- data/app/views/batch_edits/update_edit.js.erb +0 -5
- data/app/views/collections/_edit_descriptions.html.erb +0 -18
- data/app/views/collections/edit_fields/_title.html.erb +0 -3
- data/app/views/generic_files/_field_form.html.erb +0 -20
- data/app/views/records/_edit_field.html.erb +0 -22
- data/app/views/records/edit_fields/_suffix.html.erb +0 -10
- data/app/views/records/edit_fields/_type.html.erb +0 -8
- data/app/views/users/_social_media_info.html.erb +0 -20
- data/spec/helpers/records_helper_spec.rb +0 -102
- data/spec/models/generic_file/web_form_spec.rb +0 -35
- data/sufia-models/app/models/concerns/sufia/generic_file/accessible_attributes.rb +0 -87
- data/sufia-models/app/models/concerns/sufia/generic_file/web_form.rb +0 -62
@@ -14,7 +14,23 @@ class CollectionsController < ApplicationController
|
|
14
14
|
|
15
15
|
layout "sufia-one-column"
|
16
16
|
|
17
|
-
|
17
|
+
def show
|
18
|
+
super
|
19
|
+
@presenter = presenter
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def presenter
|
25
|
+
Sufia::CollectionPresenter.new(@collection)
|
26
|
+
end
|
27
|
+
|
28
|
+
def collection_params
|
29
|
+
params.require(:collection).permit(:title, :description, :members, part_of: [],
|
30
|
+
contributor: [], creator: [], publisher: [], date_created: [], subject: [],
|
31
|
+
language: [], rights: [], resource_type: [], identifier: [], based_near: [],
|
32
|
+
tag: [], related_url: [])
|
33
|
+
end
|
18
34
|
|
19
35
|
def query_collection_members
|
20
36
|
flash[:notice]=nil if flash[:notice] == "Select something first"
|
@@ -33,9 +49,9 @@ class CollectionsController < ApplicationController
|
|
33
49
|
format.json { render json: {id: id}, status: :destroyed, location: @collection }
|
34
50
|
end
|
35
51
|
end
|
36
|
-
|
52
|
+
|
37
53
|
def initialize_fields_for_edit
|
38
|
-
@collection
|
54
|
+
@form = Sufia::Forms::CollectionEditForm.new(@collection)
|
39
55
|
end
|
40
56
|
|
41
57
|
def _prefixes
|
@@ -12,7 +12,7 @@ module Sufia
|
|
12
12
|
super
|
13
13
|
@generic_file = ::GenericFile.new
|
14
14
|
@generic_file.depositor = current_user.user_key
|
15
|
-
@terms =
|
15
|
+
@terms = terms - [:title, :format, :resource_type]
|
16
16
|
|
17
17
|
h = {}
|
18
18
|
@names = []
|
@@ -21,7 +21,7 @@ module Sufia
|
|
21
21
|
# For each of the files in the batch, set the attributes to be the concatination of all the attributes
|
22
22
|
batch.each do |doc_id|
|
23
23
|
gf = ::GenericFile.load_instance_from_solr(doc_id)
|
24
|
-
|
24
|
+
terms.each do |key|
|
25
25
|
h[key] ||= []
|
26
26
|
h[key] = (h[key] + gf.send(key)).uniq
|
27
27
|
end
|
@@ -35,7 +35,11 @@ module Sufia
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def after_update
|
38
|
-
|
38
|
+
|
39
|
+
respond_to do |format|
|
40
|
+
format.json { head :no_content }
|
41
|
+
format.html { redirect_to_return_controller }
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
41
45
|
def after_destroy_collection
|
@@ -43,49 +47,46 @@ module Sufia
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def update_document(obj)
|
46
|
-
|
50
|
+
obj.attributes = generic_file_params
|
47
51
|
obj.date_modified = Time.now.ctime
|
48
52
|
obj.visibility = params[:visibility]
|
49
53
|
end
|
50
54
|
|
51
55
|
def update
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
super
|
58
|
-
elsif type == "delete_all"
|
59
|
-
batch.each do |doc_id|
|
60
|
-
gf = ::GenericFile.find(doc_id)
|
61
|
-
gf.destroy
|
62
|
-
end
|
63
|
-
after_update
|
64
|
-
end
|
65
|
-
|
66
|
-
# reset the batch around if we are doing ajax calls
|
67
|
-
if request.xhr?
|
68
|
-
self.batch = batch_sav.dup
|
69
|
-
@key = params["key"]
|
70
|
-
if @key != "permissions"
|
71
|
-
@vals = params["generic_file"][@key]
|
72
|
-
else
|
73
|
-
@vals = [""]
|
74
|
-
end
|
75
|
-
render :update_edit
|
56
|
+
case params["update_type"]
|
57
|
+
when "update"
|
58
|
+
super
|
59
|
+
when "delete_all"
|
60
|
+
destroy_batch
|
76
61
|
end
|
77
62
|
end
|
78
63
|
|
79
64
|
protected
|
80
65
|
|
66
|
+
def destroy_batch
|
67
|
+
batch.each do |doc_id|
|
68
|
+
gf = ::GenericFile.find(doc_id)
|
69
|
+
gf.destroy
|
70
|
+
end
|
71
|
+
after_update
|
72
|
+
end
|
73
|
+
|
81
74
|
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
82
75
|
def initialize_fields(attributes, file)
|
83
|
-
|
76
|
+
terms.each do |key|
|
84
77
|
# if value is empty, we create an one element array to loop over for output
|
85
78
|
file[key] = attributes[key].empty? ? [''] : attributes[key]
|
86
79
|
end
|
87
80
|
end
|
88
81
|
|
82
|
+
def terms
|
83
|
+
Forms::BatchEditForm.terms
|
84
|
+
end
|
85
|
+
|
86
|
+
def generic_file_params
|
87
|
+
Forms::BatchEditForm.model_attributes(params[:generic_file])
|
88
|
+
end
|
89
|
+
|
89
90
|
def redirect_to_return_controller
|
90
91
|
if params[:return_controller]
|
91
92
|
redirect_to sufia.url_for(controller: params[:return_controller], only_path: true)
|
@@ -20,11 +20,10 @@
|
|
20
20
|
case request.referer
|
21
21
|
when /catalog/
|
22
22
|
add_breadcrumb I18n.t('sufia.bread_crumb.search_results'), request.referer
|
23
|
-
when /dashboard/
|
24
|
-
default_trail
|
25
|
-
add_breadcrumb_for_controller
|
26
23
|
else
|
27
24
|
default_trail
|
25
|
+
add_breadcrumb_for_controller
|
26
|
+
add_breadcrumb_for_action
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
@@ -37,5 +36,11 @@
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
39
|
+
def add_breadcrumb_for_action
|
40
|
+
if /edit|stats/ =~ action_name && controller_name == "generic_files"
|
41
|
+
add_breadcrumb I18n.t("sufia.generic_file.browse_view"), sufia.generic_file_path(Sufia::Noid.noidify params["id"])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
40
45
|
end
|
41
46
|
end
|
@@ -50,9 +50,9 @@ module Sufia
|
|
50
50
|
|
51
51
|
# routed to /files/:id/edit
|
52
52
|
def edit
|
53
|
-
@
|
53
|
+
@form = edit_form
|
54
54
|
@groups = current_user.groups
|
55
|
-
@version_list =
|
55
|
+
@version_list = version_list
|
56
56
|
end
|
57
57
|
|
58
58
|
# routed to /files/:id/stats
|
@@ -103,6 +103,7 @@ module Sufia
|
|
103
103
|
respond_to do |format|
|
104
104
|
format.html {
|
105
105
|
@events = @generic_file.events(100)
|
106
|
+
@presenter = presenter
|
106
107
|
@audit_status = audit_service.human_readable_audit_status
|
107
108
|
}
|
108
109
|
format.endnote { render text: @generic_file.export_as_endnote }
|
@@ -140,6 +141,18 @@ module Sufia
|
|
140
141
|
|
141
142
|
protected
|
142
143
|
|
144
|
+
def presenter
|
145
|
+
Sufia::GenericFilePresenter.new(@generic_file)
|
146
|
+
end
|
147
|
+
|
148
|
+
def version_list
|
149
|
+
Sufia::VersionListPresenter.new(@generic_file.content.versions.all)
|
150
|
+
end
|
151
|
+
|
152
|
+
def edit_form
|
153
|
+
Sufia::Forms::GenericFileEditForm.new(@generic_file)
|
154
|
+
end
|
155
|
+
|
143
156
|
def audit_service
|
144
157
|
Sufia::GenericFileAuditService.new(@generic_file)
|
145
158
|
end
|
@@ -162,7 +175,8 @@ module Sufia
|
|
162
175
|
|
163
176
|
# this is provided so that implementing application can override this behavior and map params to different attributes
|
164
177
|
def update_metadata
|
165
|
-
|
178
|
+
file_attributes = Sufia::Forms::GenericFileEditForm.model_attributes(params[:generic_file])
|
179
|
+
actor.update_metadata(file_attributes, params[:visibility])
|
166
180
|
end
|
167
181
|
|
168
182
|
def update_visibility
|
@@ -185,12 +199,10 @@ module Sufia
|
|
185
199
|
if actor.create_content(file, file.original_filename, datastream_id)
|
186
200
|
respond_to do |format|
|
187
201
|
format.html {
|
188
|
-
render json:
|
189
|
-
content_type: 'text/html',
|
190
|
-
layout: false
|
202
|
+
render 'jq_upload', formats: 'json', content_type: 'text/html'
|
191
203
|
}
|
192
204
|
format.json {
|
193
|
-
render
|
205
|
+
render 'jq_upload'
|
194
206
|
}
|
195
207
|
end
|
196
208
|
else
|
@@ -48,8 +48,8 @@ module Sufia::UsersControllerBehavior
|
|
48
48
|
# Process changes from profile form
|
49
49
|
def update
|
50
50
|
if params[:user]
|
51
|
-
@user.
|
52
|
-
@user.populate_attributes if
|
51
|
+
@user.attributes = user_params
|
52
|
+
@user.populate_attributes if update_directory?
|
53
53
|
end
|
54
54
|
|
55
55
|
unless @user.save
|
@@ -65,6 +65,10 @@ module Sufia::UsersControllerBehavior
|
|
65
65
|
redirect_to sufia.profile_path(@user.to_param), notice: "Your profile has been updated"
|
66
66
|
end
|
67
67
|
|
68
|
+
def update_directory?
|
69
|
+
['1', 'true'].include? params[:user][:update_directory]
|
70
|
+
end
|
71
|
+
|
68
72
|
def toggle_trophy
|
69
73
|
unless current_user.can? :edit, params[:file_id]
|
70
74
|
redirect_to root_path, alert: "You do not have permissions to the file"
|
@@ -103,6 +107,14 @@ module Sufia::UsersControllerBehavior
|
|
103
107
|
|
104
108
|
protected
|
105
109
|
|
110
|
+
def user_params
|
111
|
+
params.require(:user).permit(:email, :login, :display_name, :address, :admin_area,
|
112
|
+
:department, :title, :office, :chat_id, :website, :affiliation,
|
113
|
+
:telephone, :avatar, :group_list, :groups_last_update, :facebook_handle,
|
114
|
+
:twitter_handle, :googleplus_handle, :linkedin_handle, :remove_avatar, :orcid)
|
115
|
+
end
|
116
|
+
|
117
|
+
|
106
118
|
# You can override base_query to return a list of arguments
|
107
119
|
def base_query
|
108
120
|
[nil]
|
@@ -39,7 +39,7 @@ class SingleUseLinksViewerController < ApplicationController
|
|
39
39
|
raise not_found_exception unless single_use_link.path == sufia.polymorphic_path(@asset)
|
40
40
|
|
41
41
|
#show the file
|
42
|
-
@
|
42
|
+
@presenter = presenter
|
43
43
|
|
44
44
|
# create a dowload link that is single use for the user since we do not just want to show metadata we want to access it too
|
45
45
|
@su = single_use_link.create_for_path sufia.download_path(id: @asset)
|
@@ -48,6 +48,10 @@ class SingleUseLinksViewerController < ApplicationController
|
|
48
48
|
|
49
49
|
protected
|
50
50
|
|
51
|
+
def presenter
|
52
|
+
Sufia::GenericFilePresenter.new(@asset)
|
53
|
+
end
|
54
|
+
|
51
55
|
def authorize_download!
|
52
56
|
authorize! :read, asset
|
53
57
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Sufia
|
2
|
+
module Forms
|
3
|
+
class CollectionEditForm
|
4
|
+
include HydraEditor::Form
|
5
|
+
self.model_class = ::Collection
|
6
|
+
self.terms = [:resource_type, :title, :creator, :contributor, :description, :tag, :rights,
|
7
|
+
:publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url]
|
8
|
+
|
9
|
+
# Test to see if the given field is required
|
10
|
+
# @param [Symbol] key a field
|
11
|
+
# @return [Boolean] is it required or not
|
12
|
+
def required?(key)
|
13
|
+
model_class.validators_on(key).any?{|v| v.kind_of? ActiveModel::Validations::PresenceValidator}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Sufia
|
2
|
+
module Forms
|
3
|
+
class GenericFileEditForm < GenericFilePresenter
|
4
|
+
include HydraEditor::Form
|
5
|
+
self.required_fields = [:title, :creator, :tag, :rights]
|
6
|
+
|
7
|
+
# This is required so that fields_for will draw a nested form.
|
8
|
+
# See ActionView::Helpers#nested_attributes_association?
|
9
|
+
# https://github.com/rails/rails/blob/a04c0619617118433db6e01b67d5d082eaaa0189/actionview/lib/action_view/helpers/form_helper.rb#L1890
|
10
|
+
def permissions_attributes= attributes
|
11
|
+
model.permissions_attributes= attributes
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -4,20 +4,9 @@ module GenericFileHelper
|
|
4
4
|
gf.to_s
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def render_show_field_partial(key, locals)
|
12
|
-
render_show_field_partial_with_action('generic_files', key, locals)
|
13
|
-
end
|
14
|
-
|
15
|
-
def render_edit_field_partial(key, locals)
|
16
|
-
render_edit_field_partial_with_action('generic_files', key, locals)
|
17
|
-
end
|
18
|
-
|
19
|
-
def render_batch_edit_field_partial(key, locals)
|
20
|
-
render_edit_field_partial_with_action('batch_edit', key, locals)
|
7
|
+
def present_terms(presenter, terms=:all, &block)
|
8
|
+
terms = presenter.terms if terms == :all
|
9
|
+
Sufia::PresenterRenderer.new(presenter, self).fields(terms, &block)
|
21
10
|
end
|
22
11
|
|
23
12
|
def render_download_icon title = nil
|
@@ -40,39 +29,6 @@ module GenericFileHelper
|
|
40
29
|
|
41
30
|
private
|
42
31
|
|
43
|
-
def render_edit_field_partial_with_action(action, key, locals)
|
44
|
-
["#{action}/edit_fields/#{key}", "#{action}/edit_fields/default"].each do |str|
|
45
|
-
# XXX rather than handling this logic through exceptions, maybe there's a Rails internals method
|
46
|
-
# for determining if a partial template exists..
|
47
|
-
begin
|
48
|
-
return render partial: str, locals: locals.merge({ key: key })
|
49
|
-
rescue ActionView::MissingTemplate
|
50
|
-
nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def render_show_field_partial_with_action(action, key, locals)
|
56
|
-
["#{action}/show_fields/#{key}", "#{action}/show_fields/default"].each do |str|
|
57
|
-
# XXX rather than handling this logic through exceptions, maybe there's a Rails internals method
|
58
|
-
# for determining if a partial template exists..
|
59
|
-
begin
|
60
|
-
return render partial: str, locals: locals.merge({ key: key })
|
61
|
-
rescue ActionView::MissingTemplate
|
62
|
-
nil
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def more_or_less_button(key, html_class, symbol)
|
68
|
-
# TODO, there could be more than one element with this id on the page, but the fuctionality doesn't work without it.
|
69
|
-
content_tag('button', class: "#{html_class} btn", id: "additional_#{key}_submit", name: "additional_#{key}") do
|
70
|
-
(symbol + content_tag('span', class: 'sr-only') do
|
71
|
-
"add another #{key.to_s}"
|
72
|
-
end).html_safe
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
32
|
def download_image_tag title = nil
|
77
33
|
if title.nil?
|
78
34
|
image_tag "default.png", { alt: "No preview available", class: "img-responsive" }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Sufia
|
2
|
+
module PermissionsHelper
|
3
|
+
|
4
|
+
def visibility_help
|
5
|
+
help_link('generic_files/visibility', 'Visibility', 'Useage information for visibility')
|
6
|
+
end
|
7
|
+
|
8
|
+
def share_with_help
|
9
|
+
help_link('generic_files/share_with', 'Share With', 'Useage information for sharing')
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def help_link(file, title, aria_label)
|
15
|
+
link_to help_icon, '#', rel: 'popover', :'data-content' => capture_content(file),
|
16
|
+
:'data-original-title' => title, :'aria-label' => aria_label
|
17
|
+
end
|
18
|
+
|
19
|
+
def capture_content(file)
|
20
|
+
capture do
|
21
|
+
render file
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def help_icon
|
26
|
+
content_tag 'i', '', :'aria-hidden' => true, class: 'help-icon'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module Sufia
|
2
2
|
module SufiaHelperBehavior
|
3
|
+
def orcid_label(style_class='')
|
4
|
+
"#{image_tag 'orcid.png', { alt: t('sufia.user_profile.orcid.alt'), class: style_class }} #{t('sufia.user_profile.orcid.label')}".html_safe
|
5
|
+
end
|
6
|
+
|
3
7
|
def error_messages_for(object)
|
4
8
|
if object.try(:errors) and object.errors.full_messages.any?
|
5
9
|
content_tag(:div, class: 'alert alert-block alert-error validation-errors') do
|
@@ -164,6 +168,13 @@ module Sufia
|
|
164
168
|
end
|
165
169
|
end
|
166
170
|
|
171
|
+
def user_display_name_and_key(user_key)
|
172
|
+
user = ::User.find_by_user_key(user_key)
|
173
|
+
return user_key if user.nil?
|
174
|
+
|
175
|
+
user.respond_to?(:name) ? "#{user.name} (#{user_key})" : user_key
|
176
|
+
end
|
177
|
+
|
167
178
|
private
|
168
179
|
|
169
180
|
def search_action_for_dashboard
|