sufia 7.3.0.rc3 → 7.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.eslintrc +6 -5
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -8
- data/README.md +10 -5
- data/app/actors/sufia/actors/attach_members_actor.rb +70 -0
- data/app/actors/sufia/apply_permission_template_actor.rb +4 -4
- data/app/actors/sufia/default_admin_set_actor.rb +10 -7
- data/app/assets/javascripts/sufia.js +3 -1
- data/app/assets/javascripts/sufia/app.js +7 -18
- data/app/assets/javascripts/sufia/autocomplete.es6 +56 -57
- data/app/assets/javascripts/sufia/autocomplete/language.es6 +1 -2
- data/app/assets/javascripts/sufia/autocomplete/location.es6 +1 -1
- data/app/assets/javascripts/sufia/autocomplete/subject.es6 +1 -3
- data/app/assets/javascripts/sufia/autocomplete/work.es6 +31 -22
- data/app/assets/javascripts/sufia/{editor.js → content_blocks.js} +0 -0
- data/app/assets/javascripts/sufia/editor.es6 +47 -0
- data/app/assets/javascripts/sufia/editor/admin_set_widget.es6 +39 -0
- data/app/assets/javascripts/sufia/notifications.es6 +13 -13
- data/app/assets/javascripts/sufia/permissions/control.es6 +3 -3
- data/app/assets/javascripts/sufia/permissions/group_controls.es6 +2 -2
- data/app/assets/javascripts/sufia/permissions/user_controls.es6 +3 -3
- data/app/assets/javascripts/sufia/relationships.js +4 -2
- data/app/assets/javascripts/sufia/relationships/control.es6 +83 -0
- data/app/assets/javascripts/sufia/relationships/registry.es6 +60 -0
- data/app/assets/javascripts/sufia/relationships/registry_entry.es6 +38 -0
- data/app/assets/javascripts/sufia/relationships/work.es6 +7 -0
- data/app/assets/javascripts/sufia/save_work/required_fields.es6 +1 -1
- data/app/assets/javascripts/sufia/save_work/save_work_control.es6 +19 -11
- data/app/assets/javascripts/sufia/save_work/visibility_component.es6 +19 -10
- data/app/assets/javascripts/sufia/select_work_type.es6 +8 -6
- data/app/controllers/concerns/sufia/batch_uploads_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/works_controller_behavior.rb +7 -0
- data/app/controllers/sufia/admin/admin_sets_controller.rb +5 -2
- data/app/forms/sufia/forms/batch_edit_form.rb +2 -1
- data/app/forms/sufia/forms/work_form.rb +19 -17
- data/app/models/concerns/sufia/admin_set_behavior.rb +38 -0
- data/app/presenters/sufia/admin_set_options_presenter.rb +51 -0
- data/app/presenters/sufia/admin_set_presenter.rb +11 -0
- data/app/search_builders/sufia/find_works_search_builder.rb +1 -0
- data/app/services/sufia/actor_factory.rb +1 -0
- data/app/services/sufia/admin_set_create_service.rb +9 -9
- data/app/services/sufia/admin_set_service.rb +0 -28
- data/app/services/sufia/workflow/abstract_notification.rb +14 -1
- data/app/services/sufia/workflow/changes_required_notification.rb +2 -2
- data/app/services/sufia/workflow/deposited_notification.rb +1 -1
- data/app/services/sufia/workflow/pending_review_notification.rb +1 -1
- data/app/views/curation_concerns/base/_find_work_widget.html.erb +10 -16
- data/app/views/curation_concerns/base/_form.html.erb +5 -1
- data/app/views/curation_concerns/base/_form_child_work_relationships.html.erb +22 -32
- data/app/views/curation_concerns/base/_form_relationships.html.erb +4 -7
- data/app/views/curation_concerns/base/_guts4form.html.erb +7 -1
- data/app/views/sufia/admin/admin_sets/_form_participants.html.erb +3 -3
- data/app/views/sufia/admin/admin_sets/show.html.erb +10 -2
- data/config/initializers/monkey_patch_admin_set.rb +2 -0
- data/config/locales/sufia.en.yml +2 -0
- data/db/migrate/20170317141521_permission_template_change_column_workflow_name.rb +5 -0
- data/lib/generators/sufia/templates/workflow.json.erb +1 -0
- data/lib/sufia/version.rb +1 -1
- data/lib/tasks/migrate.rake +1 -1
- data/spec/actors/sufia/actors/attach_members_actor_spec.rb +68 -0
- data/spec/actors/sufia/apply_permission_template_actor_spec.rb +7 -3
- data/spec/actors/sufia/default_admin_set_actor_spec.rb +1 -1
- data/spec/controllers/sufia/admin/admin_sets_controller_spec.rb +21 -6
- data/spec/controllers/sufia/admin/permission_templates_controller_spec.rb +1 -1
- data/spec/controllers/sufia/batch_uploads_controller_spec.rb +24 -2
- data/spec/factories/permission_templates.rb +1 -0
- data/spec/factories/workflows.rb +1 -1
- data/spec/forms/curation_concerns/generic_work_form_spec.rb +5 -2
- data/spec/forms/sufia/forms/batch_edit_form_spec.rb +1 -1
- data/spec/forms/sufia/forms/work_form_spec.rb +32 -19
- data/spec/javascripts/autocomplete_spec.js.coffee +12 -33
- data/spec/javascripts/helpers/test_fixtures.js.coffee +10 -1
- data/spec/javascripts/relationships_control_spec.js.coffee +27 -0
- data/spec/javascripts/save_work_spec.js +9 -6
- data/spec/javascripts/visibility_component_spec.js +17 -8
- data/spec/models/admin_set_spec.rb +69 -0
- data/spec/presenters/sufia/admin_set_options_presenter_spec.rb +73 -0
- data/spec/presenters/sufia/admin_set_presenter_spec.rb +31 -2
- data/spec/services/sufia/actor_factory_spec.rb +2 -0
- data/spec/services/sufia/admin_set_create_service_spec.rb +4 -2
- data/spec/services/sufia/admin_set_service_spec.rb +0 -72
- data/spec/services/sufia/workflow/changes_required_notification_spec.rb +1 -1
- data/spec/services/sufia/workflow/deposited_notification_spec.rb +1 -1
- data/spec/services/sufia/workflow/pending_review_notification_spec.rb +1 -1
- data/spec/views/curation_concerns/base/_find_work_widget.html.erb_spec.rb +1 -2
- data/spec/views/curation_concerns/base/_form_child_work_relationships.html.erb_spec.rb +27 -62
- data/spec/views/curation_concerns/base/_form_relationships.html.erb_spec.rb +4 -2
- data/spec/views/sufia/admin/admin_sets/_form_participants.html.erb_spec.rb +1 -1
- data/spec/views/sufia/admin/admin_sets/_form_visibility.html.erb_spec.rb +3 -1
- data/spec/views/sufia/admin/admin_sets/show.html.erb_spec.rb +59 -0
- data/sufia.gemspec +3 -2
- data/template.rb +1 -1
- metadata +34 -19
- data/app/assets/javascripts/sufia/relationships/table.es6 +0 -206
- data/app/assets/javascripts/sufia/relationships/table_row.es6 +0 -79
- data/app/views/curation_concerns/base/_form_parent_work_relationships.html.erb +0 -43
- data/app/views/records/edit_fields/_in_works_ids.html.erb +0 -59
- data/spec/javascripts/helpers/test_responses.js +0 -13
- data/spec/javascripts/relationships_table_spec.js.coffee +0 -83
- data/spec/views/curation_concerns/base/_form_parent_work_relationships.html.erb_spec.rb +0 -114
- data/spec/views/records/edit_fields/_in_works_ids.html.erb_spec.rb +0 -113
@@ -7,7 +7,7 @@ export class RequiredFields {
|
|
7
7
|
}
|
8
8
|
|
9
9
|
get areComplete() {
|
10
|
-
return this.requiredFields.filter((n, elem) => { return this.isValuePresent(elem) } ).length
|
10
|
+
return this.requiredFields.filter((n, elem) => { return this.isValuePresent(elem) } ).length === 0
|
11
11
|
}
|
12
12
|
|
13
13
|
isValuePresent(elem) {
|
@@ -2,7 +2,7 @@ import { RequiredFields } from './required_fields'
|
|
2
2
|
import { ChecklistItem } from './checklist_item'
|
3
3
|
import { UploadedFiles } from './uploaded_files'
|
4
4
|
import { DepositAgreement } from './deposit_agreement'
|
5
|
-
import
|
5
|
+
import VisibilityComponent from './visibility_component'
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Polyfill String.prototype.startsWith()
|
@@ -14,16 +14,18 @@ if (!String.prototype.startsWith) {
|
|
14
14
|
};
|
15
15
|
}
|
16
16
|
|
17
|
-
export class SaveWorkControl {
|
17
|
+
export default class SaveWorkControl {
|
18
18
|
/**
|
19
19
|
* Initialize the save controls
|
20
20
|
* @param {jQuery} element the jquery selector for the save panel
|
21
|
+
* @param {AdminSetWidget} adminSetWidget the control for the adminSet dropdown
|
21
22
|
*/
|
22
|
-
constructor(element) {
|
23
|
-
if (element.
|
23
|
+
constructor(element, adminSetWidget) {
|
24
|
+
if (element.length < 1) {
|
24
25
|
return
|
25
26
|
}
|
26
27
|
this.element = element
|
28
|
+
this.adminSetWidget = adminSetWidget
|
27
29
|
this.form = element.closest('form')
|
28
30
|
element.data('save_work_control', this)
|
29
31
|
this.activate();
|
@@ -82,20 +84,26 @@ export class SaveWorkControl {
|
|
82
84
|
}
|
83
85
|
this.requiredFields = new RequiredFields(this.form, () => this.formStateChanged())
|
84
86
|
this.uploads = new UploadedFiles(this.form, () => this.formStateChanged())
|
85
|
-
|
86
87
|
this.saveButton = this.element.find(':submit')
|
87
|
-
|
88
88
|
this.depositAgreement = new DepositAgreement(this.form, () => this.formStateChanged())
|
89
|
-
|
90
89
|
this.requiredMetadata = new ChecklistItem(this.element.find('#required-metadata'))
|
91
90
|
this.requiredFiles = new ChecklistItem(this.element.find('#required-files'))
|
92
|
-
new VisibilityComponent(this.element.find('.visibility'))
|
91
|
+
new VisibilityComponent(this.element.find('.visibility'), this.adminSetWidget)
|
92
|
+
this.preventSubmit()
|
93
|
+
this.watchMultivaluedFields()
|
94
|
+
this.formChanged()
|
95
|
+
}
|
96
|
+
|
97
|
+
preventSubmit() {
|
93
98
|
this.preventSubmitUnlessValid()
|
94
99
|
this.preventSubmitIfAlreadyInProgress()
|
95
100
|
this.preventSubmitIfUploading()
|
96
|
-
|
97
|
-
|
98
|
-
|
101
|
+
}
|
102
|
+
|
103
|
+
// If someone adds or removes a field on a multivalue input, fire a formChanged event.
|
104
|
+
watchMultivaluedFields() {
|
105
|
+
$('.multi_value.form-group', this.form).bind('managed_field:add', () => this.formChanged())
|
106
|
+
$('.multi_value.form-group', this.form).bind('managed_field:remove', () => this.formChanged())
|
99
107
|
}
|
100
108
|
|
101
109
|
// Called when a file has been uploaded, the deposit agreement is clicked or a form field has had text entered.
|
@@ -1,6 +1,12 @@
|
|
1
|
-
export class VisibilityComponent {
|
2
|
-
|
1
|
+
export default class VisibilityComponent {
|
2
|
+
/**
|
3
|
+
* Initialize the save controls
|
4
|
+
* @param {jQuery} element the jquery selector for the visibility component
|
5
|
+
* @param {AdminSetWidget} adminSetWidget the control for the adminSet dropdown
|
6
|
+
*/
|
7
|
+
constructor(element, adminSetWidget) {
|
3
8
|
this.element = element
|
9
|
+
this.adminSetWidget = adminSetWidget
|
4
10
|
this.form = element.closest('form')
|
5
11
|
$('.collapse').collapse({ toggle: false })
|
6
12
|
element.find("[type='radio']").on('change', () => { this.showForm() })
|
@@ -35,21 +41,24 @@ export class VisibilityComponent {
|
|
35
41
|
|
36
42
|
// Limit visibility options based on selected AdminSet (if enabled)
|
37
43
|
limitByAdminSet() {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
if(this.adminSetWidget) {
|
45
|
+
this.adminSetWidget.on('change', (data) => this.restrictToVisibility(data))
|
46
|
+
if (this.adminSetWidget.isEmpty()) {
|
47
|
+
console.error("No data was passed from the admin set. Perhaps there are no selectable options?")
|
48
|
+
return
|
49
|
+
}
|
50
|
+
this.restrictToVisibility(this.adminSetWidget.data())
|
42
51
|
}
|
43
52
|
}
|
44
53
|
|
45
54
|
// Restrict visibility and/or release date to match the AdminSet requirements (if any)
|
46
|
-
restrictToVisibility(
|
55
|
+
restrictToVisibility(data) {
|
47
56
|
// visibility requirement is in HTML5 'data-visibility' attr
|
48
|
-
let visibility =
|
57
|
+
let visibility = data['visibility']
|
49
58
|
// release date requirement is in HTML5 'data-release-date' attr
|
50
|
-
let release_date =
|
59
|
+
let release_date = data['releaseDate']
|
51
60
|
// if release_date is flexible (i.e. before date), then 'data-release-before-date' attr will be true
|
52
|
-
let release_before =
|
61
|
+
let release_before = data['releaseBeforeDate']
|
53
62
|
|
54
63
|
// Restrictions require either a visibility requirement or a release_date requirement (or both)
|
55
64
|
if(visibility || release_date) {
|
@@ -6,17 +6,17 @@ export default class SelectWorkType {
|
|
6
6
|
constructor(element) {
|
7
7
|
this.$element = element;
|
8
8
|
this.target = element.data('target')
|
9
|
-
this.modal = $(this.target)
|
9
|
+
this.modal = $(this.target)
|
10
10
|
this.form = this.modal.find('form.new-work-select')
|
11
11
|
|
12
12
|
// launch the modal.
|
13
|
-
element.on('click', (e) => {
|
14
|
-
e.preventDefault()
|
15
|
-
this.modal.modal()
|
13
|
+
element.on('click', (e) => {
|
14
|
+
e.preventDefault()
|
15
|
+
this.modal.modal()
|
16
16
|
// ensure the type is set for the last clicked element
|
17
17
|
this.type = element.data('create-type')
|
18
18
|
// add custom routing logic when the modal is shown
|
19
|
-
this.form.on('submit', this.routingLogic.bind(this))
|
19
|
+
this.form.on('submit', this.routingLogic.bind(this))
|
20
20
|
});
|
21
21
|
|
22
22
|
// remove the routing logic when the modal is hidden
|
@@ -27,7 +27,9 @@ export default class SelectWorkType {
|
|
27
27
|
|
28
28
|
// when the form is submitted route to the correct location
|
29
29
|
routingLogic(e) {
|
30
|
-
e.preventDefault()
|
30
|
+
e.preventDefault()
|
31
|
+
if (this.destination() === undefined)
|
32
|
+
return false
|
31
33
|
// get the destination from the data attribute of the selected radio button
|
32
34
|
window.location.href = this.destination()
|
33
35
|
}
|
@@ -55,7 +55,7 @@ module Sufia
|
|
55
55
|
# ActionController::Parameters are not serializable, so cast to a hash
|
56
56
|
BatchCreateJob.perform_later(current_user,
|
57
57
|
params[:title].permit!.to_h,
|
58
|
-
params
|
58
|
+
params.fetch(:resource_type, {}).permit!.to_h,
|
59
59
|
params[:uploaded_files],
|
60
60
|
attributes_for_actor.to_h.merge!(model: klass),
|
61
61
|
log)
|
@@ -19,7 +19,14 @@ module Sufia
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def new
|
22
|
+
# TODO: move these lines to the work form builder in Hyrax
|
22
23
|
curation_concern.depositor = current_user.user_key
|
24
|
+
|
25
|
+
# admin_set_id is required on the client, otherwise simple_form renders a blank option.
|
26
|
+
# however it isn't a required field for someone to submit via json.
|
27
|
+
# Set the first admin_set they have access to.
|
28
|
+
admin_set = Sufia::AdminSetService.new(self).search_results(:deposit).first
|
29
|
+
curation_concern.admin_set_id = admin_set && admin_set.id
|
23
30
|
super
|
24
31
|
end
|
25
32
|
|
@@ -64,8 +64,11 @@ module Sufia
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def destroy
|
67
|
-
@admin_set.destroy
|
68
|
-
|
67
|
+
if @admin_set.destroy
|
68
|
+
redirect_to sufia.admin_admin_sets_path, notice: t(:'sufia.admin.admin_sets.delete.notification')
|
69
|
+
else
|
70
|
+
redirect_to sufia.admin_admin_set_path(@admin_set), alert: @admin_set.errors.full_messages.to_sentence
|
71
|
+
end
|
69
72
|
end
|
70
73
|
|
71
74
|
# for the AdminSetService
|
@@ -27,7 +27,8 @@ module Sufia
|
|
27
27
|
def self.build_permitted_params
|
28
28
|
super + [:visibility_during_embargo, :embargo_release_date,
|
29
29
|
:visibility_after_embargo, :visibility_during_lease,
|
30
|
-
:lease_expiration_date, :visibility_after_lease, :visibility]
|
30
|
+
:lease_expiration_date, :visibility_after_lease, :visibility] -
|
31
|
+
[{ work_members_attributes: [:id, :_destroy] }]
|
31
32
|
end
|
32
33
|
|
33
34
|
private
|
@@ -37,22 +37,8 @@ module Sufia::Forms
|
|
37
37
|
:collection_ids, :in_works_ids, :admin_set_id]
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
def ordered_fileset_members
|
43
|
-
model.ordered_members.to_a.select { |m| m.model_name.singular.to_sym == :file_set }
|
44
|
-
end
|
45
|
-
|
46
|
-
# The ordered_members which are not FileSet types
|
47
|
-
# @return [Array] All of the non file sets in the ordered_members
|
48
|
-
def ordered_work_members
|
49
|
-
model.ordered_members.to_a.select { |m| m.model_name.singular.to_sym != :file_set }
|
50
|
-
end
|
51
|
-
|
52
|
-
# The in_work items
|
53
|
-
# @return [Array] All of the works that this work is a member of
|
54
|
-
def in_work_members
|
55
|
-
model.in_works.to_a
|
40
|
+
def work_members
|
41
|
+
model.members.to_a.reject { |m| m.is_a? FileSet }
|
56
42
|
end
|
57
43
|
|
58
44
|
def self.multiple?(term)
|
@@ -60,8 +46,24 @@ module Sufia::Forms
|
|
60
46
|
super
|
61
47
|
end
|
62
48
|
|
49
|
+
def self.sanitize_params(form_params)
|
50
|
+
admin_set_id = form_params[:admin_set_id]
|
51
|
+
if admin_set_id && Sipity::Workflow.find_by!(name: Sufia::PermissionTemplate.find_by!(admin_set_id: admin_set_id).workflow_name).allows_access_grant?
|
52
|
+
return super
|
53
|
+
end
|
54
|
+
params_without_permissions = permitted_params.reject { |arg| arg.respond_to?(:key?) && arg.key?(:permissions_attributes) }
|
55
|
+
form_params.permit(*params_without_permissions)
|
56
|
+
end
|
57
|
+
|
63
58
|
def self.build_permitted_params
|
64
|
-
super + [:on_behalf_of,
|
59
|
+
super + [:on_behalf_of,
|
60
|
+
{ collection_ids: [] },
|
61
|
+
{ work_members_attributes: [:id, :_destroy] }]
|
65
62
|
end
|
63
|
+
|
64
|
+
# This is required so that fields_for will draw a nested form.
|
65
|
+
# See ActionView::Helpers#nested_attributes_association?
|
66
|
+
# https://github.com/rails/rails/blob/v5.0.2/actionview/lib/action_view/helpers/form_helper.rb#L1890
|
67
|
+
delegate :work_members_attributes=, to: :model
|
66
68
|
end
|
67
69
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Sufia
|
2
|
+
module AdminSetBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
DEFAULT_ID = 'admin_set/default'.freeze
|
7
|
+
DEFAULT_WORKFLOW_NAME = 'default'.freeze
|
8
|
+
|
9
|
+
def self.default_set?(id)
|
10
|
+
id == DEFAULT_ID
|
11
|
+
end
|
12
|
+
|
13
|
+
before_destroy :check_if_not_default_set, :check_if_empty
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def check_if_empty
|
19
|
+
return true if members.empty?
|
20
|
+
errors[:base] << I18n.t('sufia.admin.admin_sets.delete.error_not_empty')
|
21
|
+
if Rails.version < '5.0.0'
|
22
|
+
false
|
23
|
+
else
|
24
|
+
throw :abort
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_if_not_default_set
|
29
|
+
return true unless AdminSet.default_set?(id)
|
30
|
+
errors[:base] << I18n.t('sufia.admin.admin_sets.delete.error_default_set')
|
31
|
+
if Rails.version < '5.0.0'
|
32
|
+
false
|
33
|
+
else
|
34
|
+
throw :abort
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Sufia
|
2
|
+
# Presents the options for the AdminSet widget on the create/edit form
|
3
|
+
class AdminSetOptionsPresenter
|
4
|
+
def initialize(service)
|
5
|
+
@service = service
|
6
|
+
end
|
7
|
+
|
8
|
+
# Return AdminSet selectbox options based on access type
|
9
|
+
# @param [Symbol] access :deposit, :read, or :edit
|
10
|
+
def select_options(access = :deposit)
|
11
|
+
@service.search_results(access).map do |admin_set|
|
12
|
+
[admin_set.to_s, admin_set.id, data_attributes(admin_set)]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# Create a hash of HTML5 'data' attributes. These attributes are added to select_options and
|
19
|
+
# later utilized by Javascript to limit new Work options based on AdminSet selected
|
20
|
+
def data_attributes(admin_set)
|
21
|
+
# Get permission template associated with this AdminSet (if any)
|
22
|
+
permission_template = PermissionTemplate.find_by(admin_set_id: admin_set.id)
|
23
|
+
|
24
|
+
# Only add data attributes if permission template exists
|
25
|
+
return {} unless permission_template
|
26
|
+
attributes_for(permission_template: permission_template)
|
27
|
+
end
|
28
|
+
|
29
|
+
# all PermissionTemplate release & visibility data attributes (if not blank or false)
|
30
|
+
def attributes_for(permission_template:)
|
31
|
+
{}.tap do |attrs|
|
32
|
+
attrs['data-sharing'] = sharing?(permission_template: permission_template)
|
33
|
+
attrs['data-release-date'] = permission_template.release_date unless permission_template.release_date.blank?
|
34
|
+
attrs['data-release-before-date'] = true if permission_template.release_before_date?
|
35
|
+
attrs['data-visibility'] = permission_template.visibility unless permission_template.visibility.blank?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Does the workflow for the currently selected permission template allow sharing?
|
40
|
+
def sharing?(permission_template:)
|
41
|
+
wf = workflow(permission_template: permission_template)
|
42
|
+
return false unless wf
|
43
|
+
wf.allows_access_grant?
|
44
|
+
end
|
45
|
+
|
46
|
+
def workflow(permission_template:)
|
47
|
+
return unless permission_template.workflow_name
|
48
|
+
Sipity::Workflow.find_by!(name: permission_template.workflow_name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -3,5 +3,16 @@ module Sufia
|
|
3
3
|
def total_items
|
4
4
|
ActiveFedora::SolrService.count("{!field f=isPartOf_ssim}#{id}")
|
5
5
|
end
|
6
|
+
|
7
|
+
# AdminSet cannot be deleted if default set or non-empty
|
8
|
+
def disable_delete?
|
9
|
+
AdminSet.default_set?(id) || total_items > 0
|
10
|
+
end
|
11
|
+
|
12
|
+
# Message to display if deletion is disabled
|
13
|
+
def disabled_message
|
14
|
+
return I18n.t('sufia.admin.admin_sets.delete.error_default_set') if AdminSet.default_set?(id)
|
15
|
+
return I18n.t('sufia.admin.admin_sets.delete.error_not_empty') if total_items > 0
|
16
|
+
end
|
6
17
|
end
|
7
18
|
end
|
@@ -5,6 +5,7 @@ class Sufia::FindWorksSearchBuilder < Sufia::SearchBuilder
|
|
5
5
|
|
6
6
|
self.default_processor_chain += [:filter_on_title, :show_only_resources_deposited_by_current_user, :show_only_other_works, :show_only_works_not_child, :show_only_works_not_parent]
|
7
7
|
|
8
|
+
# Excludes the id that is part of the params
|
8
9
|
def initialize(context)
|
9
10
|
super(context)
|
10
11
|
@id = context.params[:id]
|
@@ -8,6 +8,7 @@ module Sufia
|
|
8
8
|
CurationConcerns::Actors::AddToWorkActor,
|
9
9
|
CurationConcerns::Actors::AssignRepresentativeActor,
|
10
10
|
CurationConcerns::Actors::AttachFilesActor,
|
11
|
+
Sufia::Actors::AttachMembersActor,
|
11
12
|
CurationConcerns::Actors::ApplyOrderActor,
|
12
13
|
InterpretVisibilityActor,
|
13
14
|
DefaultAdminSetActor,
|
@@ -1,29 +1,28 @@
|
|
1
1
|
module Sufia
|
2
2
|
# Creates AdminSets
|
3
3
|
class AdminSetCreateService
|
4
|
-
DEFAULT_ID = 'admin_sets/default'.freeze
|
5
|
-
|
6
4
|
def self.create_default!
|
7
|
-
return if AdminSet.exists?(DEFAULT_ID)
|
8
|
-
admin_set = AdminSet.new(id: DEFAULT_ID, title: ['Default Admin Set'])
|
5
|
+
return if AdminSet.exists?(AdminSet::DEFAULT_ID)
|
6
|
+
admin_set = AdminSet.new(id: AdminSet::DEFAULT_ID, title: ['Default Admin Set'])
|
9
7
|
begin
|
10
|
-
new(admin_set, nil).create
|
8
|
+
new(admin_set, nil, AdminSet::DEFAULT_WORKFLOW_NAME).create
|
11
9
|
rescue ActiveFedora::IllegalOperation
|
12
10
|
# It is possible that another thread created the AdminSet just before this method
|
13
11
|
# was called, so ActiveFedora will raise IllegalOperation. In this case we can safely
|
14
12
|
# ignore the error.
|
15
|
-
Rails.logger.error("AdminSet ID=#{DEFAULT_ID} may or may not have been created due to threading issues.")
|
13
|
+
Rails.logger.error("AdminSet ID=#{AdminSet::DEFAULT_ID} may or may not have been created due to threading issues.")
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
19
17
|
# @param admin_set [AdminSet] the admin set to operate on
|
20
18
|
# @param creating_user [User] the user who created the admin set.
|
21
|
-
def initialize(admin_set, creating_user)
|
19
|
+
def initialize(admin_set, creating_user, workflow_name)
|
22
20
|
@admin_set = admin_set
|
23
21
|
@creating_user = creating_user
|
22
|
+
@workflow_name = workflow_name
|
24
23
|
end
|
25
24
|
|
26
|
-
attr_reader :creating_user, :admin_set
|
25
|
+
attr_reader :creating_user, :admin_set, :workflow_name
|
27
26
|
|
28
27
|
# Creates an admin set, setting the creator and the default access controls.
|
29
28
|
# @return [TrueClass, FalseClass] true if it was successful
|
@@ -43,7 +42,8 @@ module Sufia
|
|
43
42
|
|
44
43
|
def create_permission_template
|
45
44
|
PermissionTemplate.create!(admin_set_id: admin_set.id,
|
46
|
-
access_grants_attributes: access_grants_attributes
|
45
|
+
access_grants_attributes: access_grants_attributes,
|
46
|
+
workflow_name: workflow_name)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -20,33 +20,5 @@ module Sufia
|
|
20
20
|
[doc, counts[doc.id]]
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
# Return AdminSet selectbox options based on access type
|
25
|
-
# @param [Symbol] access :read or :edit
|
26
|
-
def select_options(access = :read)
|
27
|
-
search_results(access).map do |admin_set|
|
28
|
-
[admin_set.to_s, admin_set.id, data_attributes(admin_set)]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Create a hash of HTML5 'data' attributes. These attributes are added to select_options and
|
35
|
-
# later utilized by Javascript to limit new Work options based on AdminSet selected
|
36
|
-
def data_attributes(admin_set)
|
37
|
-
attrs = {}
|
38
|
-
# Get permission template associated with this AdminSet (if any)
|
39
|
-
permission_template = PermissionTemplate.find_by(admin_set_id: admin_set.id)
|
40
|
-
|
41
|
-
# Only add data attributes if permission template exists
|
42
|
-
if permission_template
|
43
|
-
# Save all PermissionTemplate release & visibility data attributes (if not blank or false)
|
44
|
-
attrs['data-release-date'] = permission_template.release_date unless permission_template.release_date.blank?
|
45
|
-
attrs['data-release-before-date'] = true if permission_template.release_before_date?
|
46
|
-
attrs['data-visibility'] = permission_template.visibility unless permission_template.visibility.blank?
|
47
|
-
end
|
48
|
-
|
49
|
-
attrs
|
50
|
-
end
|
51
23
|
end
|
52
24
|
end
|