sufia 7.3.0.rc3 → 7.3.0
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/.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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1796e607d146678e8569583b7ac12eb043543d6e
|
|
4
|
+
data.tar.gz: '01839aa30ae6849f657879ab9fc31762b8e9f619'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecab36e574a7eebfeeb6b9590eafc351ca283a245f843842c898df8afa01b4ada033c5cdba77d8d96d9c58f01cafa87570cab22f8a6a0df759eeb6fc76b97247
|
|
7
|
+
data.tar.gz: 72724cf04ec14999a11b496cc361bd50916f2c5ee6750019be25982772e06b87ba82808bf200a759f430564a7f8de74aeced9fd18b630604bad17c323d4cf33f
|
data/.codeclimate.yml
CHANGED
data/.eslintrc
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
parserOptions:
|
|
2
|
+
sourceType: module
|
|
3
|
+
ecmaFeatures:
|
|
4
|
+
jsx: true
|
|
4
5
|
|
|
5
6
|
env:
|
|
6
7
|
amd: true
|
|
@@ -61,7 +62,7 @@ rules:
|
|
|
61
62
|
no-empty-pattern: 2
|
|
62
63
|
no-eq-null: 2
|
|
63
64
|
no-eval: 2
|
|
64
|
-
no-extend-native:
|
|
65
|
+
no-extend-native: 1
|
|
65
66
|
no-extra-bind: 2
|
|
66
67
|
no-fallthrough: 2
|
|
67
68
|
no-floating-decimal: 0
|
|
@@ -78,7 +79,7 @@ rules:
|
|
|
78
79
|
no-native-reassign: 2
|
|
79
80
|
no-new-func: 2
|
|
80
81
|
no-new-wrappers: 2
|
|
81
|
-
no-new:
|
|
82
|
+
no-new: 1
|
|
82
83
|
no-octal-escape: 2
|
|
83
84
|
no-octal: 2
|
|
84
85
|
no-proto: 2
|
data/.rubocop.yml
CHANGED
|
@@ -22,7 +22,6 @@ Metrics/LineLength:
|
|
|
22
22
|
Metrics/AbcSize:
|
|
23
23
|
Max: 30
|
|
24
24
|
Exclude:
|
|
25
|
-
- 'app/controllers/concerns/sufia/admin/depositor_stats.rb'
|
|
26
25
|
- 'app/controllers/concerns/sufia/my_controller_behavior.rb'
|
|
27
26
|
- 'app/services/sufia/user_stat_importer.rb'
|
|
28
27
|
- 'lib/sufia/arkivo/metadata_munger.rb'
|
data/.rubocop_todo.yml
CHANGED
|
@@ -22,8 +22,6 @@ Metrics/ModuleLength:
|
|
|
22
22
|
|
|
23
23
|
Metrics/MethodLength:
|
|
24
24
|
Exclude:
|
|
25
|
-
- 'lib/generators/sufia/templates/migrations/create_local_authorities.rb'
|
|
26
|
-
- 'app/helpers/sufia/citations_behaviors/formatters/endnote_formatter.rb'
|
|
27
25
|
- 'app/models/concerns/sufia/solr_document/export.rb'
|
|
28
26
|
- 'app/controllers/concerns/sufia/my_controller_behavior.rb'
|
|
29
27
|
- 'lib/generators/sufia/install_generator.rb'
|
|
@@ -42,11 +40,6 @@ Rails/Output:
|
|
|
42
40
|
Exclude:
|
|
43
41
|
- 'lib/generators/**/*'
|
|
44
42
|
|
|
45
|
-
Rails/HasAndBelongsToMany:
|
|
46
|
-
Exclude:
|
|
47
|
-
- 'app/models/domain_term.rb'
|
|
48
|
-
- 'app/models/local_authority.rb'
|
|
49
|
-
|
|
50
43
|
RSpec/NamedSubject:
|
|
51
44
|
Enabled: false
|
|
52
45
|
|
|
@@ -54,7 +47,6 @@ RSpec/ExampleLength:
|
|
|
54
47
|
Max: 7
|
|
55
48
|
Exclude:
|
|
56
49
|
- 'spec/controllers/api/items_controller_spec.rb'
|
|
57
|
-
- 'spec/controllers/authorities_controller_spec.rb'
|
|
58
50
|
- 'spec/controllers/collections_controller_spec.rb'
|
|
59
51
|
- 'spec/controllers/curation_concerns/file_sets_controller_spec.rb'
|
|
60
52
|
- 'spec/controllers/my/highlights_controller_spec.rb'
|
data/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Docs: [](./LICENSE)
|
|
14
14
|
|
|
15
15
|
Jump in: [](http://slack.projecthydra.org/)
|
|
16
|
-
[](https://waffle.io/projecthydra/sufia)
|
|
17
17
|
|
|
18
18
|
# Table of Contents
|
|
19
19
|
|
|
@@ -31,6 +31,7 @@ Jump in: [](http://slack
|
|
|
31
31
|
* [Creating a Sufia\-based app](#creating-a-sufia-based-app)
|
|
32
32
|
* [Generate a primary work type](#generate-a-primary-work-type)
|
|
33
33
|
* [Start servers](#start-servers)
|
|
34
|
+
* [Add Default Admin Set](#add-default-admin-set)
|
|
34
35
|
* [Managing a Sufia\-based app](#managing-a-sufia-based-app)
|
|
35
36
|
* [License](#license)
|
|
36
37
|
* [Contributing](#contributing)
|
|
@@ -66,7 +67,7 @@ After installing the Prerequisites:
|
|
|
66
67
|
|
|
67
68
|
## Prerequisites
|
|
68
69
|
|
|
69
|
-
Sufia 7
|
|
70
|
+
Sufia 7 requires the following software to work:
|
|
70
71
|
|
|
71
72
|
1. [Solr](http://lucene.apache.org/solr/) version >= 5.x (tested up to 6.4.1)
|
|
72
73
|
1. [Fedora Commons](http://www.fedora-commons.org/) digital repository version >= 4.5.1 (tested up to 4.7.1)
|
|
@@ -135,9 +136,9 @@ Generating a new Rails application using Sufia's template above takes cares of a
|
|
|
135
136
|
* Loading all of Sufia's database migrations into your application's database
|
|
136
137
|
* Loading Sufia's default workflows into your application's database
|
|
137
138
|
|
|
138
|
-
## Generate a
|
|
139
|
+
## Generate a work type
|
|
139
140
|
|
|
140
|
-
While earlier versions of Sufia came with a pre-defined object model, Sufia 7
|
|
141
|
+
While earlier versions of Sufia came with a pre-defined object model, Sufia 7 allows you to generate an arbitrary number of work types. Let's start by generating one.
|
|
141
142
|
|
|
142
143
|
Pass a (CamelCased) model name to Sufia's work generator to get started, e.g.:
|
|
143
144
|
|
|
@@ -169,7 +170,11 @@ After Fedora and Solr are running, create the default administrative set by runn
|
|
|
169
170
|
rake sufia:default_admin_set:create
|
|
170
171
|
```
|
|
171
172
|
|
|
172
|
-
You will want to run this command the first time this code is deployed to a new environment as well.
|
|
173
|
+
You will want to run this command the first time this code is deployed to a new environment as well. Note it depends on loading workflows, which is run by the install template but also needs to be run in a new environment:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
rake curation_concerns:workflow:load
|
|
177
|
+
```
|
|
173
178
|
|
|
174
179
|
# Managing a Sufia-based app
|
|
175
180
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Sufia
|
|
2
|
+
module Actors
|
|
3
|
+
# Attach or remove child works to/from this work. This decodes parameters
|
|
4
|
+
# that follow the rails nested parameters conventions:
|
|
5
|
+
# e.g.
|
|
6
|
+
# 'work_members_attributes' => {
|
|
7
|
+
# '0' => { 'id' = '12312412'},
|
|
8
|
+
# '1' => { 'id' = '99981228', '_destroy' => 'true' }
|
|
9
|
+
# }
|
|
10
|
+
#
|
|
11
|
+
# The goal of this actor is to mutate the ordered_members with as few writes
|
|
12
|
+
# as possible, because changing ordered_members is slow. This class only
|
|
13
|
+
# writes changes, not the full ordered list.
|
|
14
|
+
#
|
|
15
|
+
# TODO: Perhaps this can subsume AttachFilesActor
|
|
16
|
+
class AttachMembersActor < CurationConcerns::Actors::AbstractActor
|
|
17
|
+
def update(attributes)
|
|
18
|
+
attributes_collection = attributes.delete(:work_members_attributes)
|
|
19
|
+
assign_nested_attributes_for_collection(attributes_collection) &&
|
|
20
|
+
next_actor.update(attributes)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# Attaches any unattached members. Deletes those that are marked _delete
|
|
26
|
+
# @param [Hash<Hash>] a collection of members
|
|
27
|
+
def assign_nested_attributes_for_collection(attributes_collection)
|
|
28
|
+
return true unless attributes_collection
|
|
29
|
+
attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes }
|
|
30
|
+
# checking for existing works to avoid rewriting/loading works that are
|
|
31
|
+
# already attached
|
|
32
|
+
existing_works = curation_concern.member_ids
|
|
33
|
+
attributes_collection.each do |attributes|
|
|
34
|
+
next if attributes['id'].blank?
|
|
35
|
+
if existing_works.include?(attributes['id'])
|
|
36
|
+
remove(attributes['id']) if has_destroy_flag?(attributes)
|
|
37
|
+
else
|
|
38
|
+
add(attributes['id'])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def ability
|
|
44
|
+
@ability ||= ::Ability.new(user)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Adds the item to the ordered members so that it displays in the items
|
|
48
|
+
# along side the FileSets on the show page
|
|
49
|
+
def add(id)
|
|
50
|
+
member = ActiveFedora::Base.find(id)
|
|
51
|
+
return unless ability.can?(:edit, member)
|
|
52
|
+
curation_concern.ordered_members << member
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Remove the object from the members set and the ordered members list
|
|
56
|
+
def remove(id)
|
|
57
|
+
member = ActiveFedora::Base.find(id)
|
|
58
|
+
curation_concern.ordered_members.delete(member)
|
|
59
|
+
curation_concern.members.delete(member)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Determines if a hash contains a truthy _destroy key.
|
|
63
|
+
# rubocop:disable Style/PredicateName
|
|
64
|
+
def has_destroy_flag?(hash)
|
|
65
|
+
ActiveFedora::Type::Boolean.new.cast(hash['_destroy'])
|
|
66
|
+
end
|
|
67
|
+
# rubocop:enable Style/PredicateName
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -10,10 +10,10 @@ module Sufia
|
|
|
10
10
|
def add_edit_users(attributes)
|
|
11
11
|
return unless attributes[:admin_set_id].present?
|
|
12
12
|
template = Sufia::PermissionTemplate.find_by!(admin_set_id: attributes[:admin_set_id])
|
|
13
|
-
curation_concern.edit_users
|
|
14
|
-
curation_concern.edit_groups
|
|
15
|
-
curation_concern.read_users
|
|
16
|
-
curation_concern.read_groups
|
|
13
|
+
curation_concern.edit_users += template.access_grants.where(agent_type: 'user', access: 'manage').pluck(:agent_id)
|
|
14
|
+
curation_concern.edit_groups += template.access_grants.where(agent_type: 'group', access: 'manage').pluck(:agent_id)
|
|
15
|
+
curation_concern.read_users += template.access_grants.where(agent_type: 'user', access: 'view').pluck(:agent_id)
|
|
16
|
+
curation_concern.read_groups += template.access_grants.where(agent_type: 'group', access: 'view').pluck(:agent_id)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -25,25 +25,28 @@ module Sufia
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def ensure_permission_template!(admin_set_id:)
|
|
28
|
-
Sufia::PermissionTemplate.
|
|
28
|
+
Sufia::PermissionTemplate.find_by(admin_set_id: admin_set_id) || create_permission_template!(admin_set_id: admin_set_id)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
DEFAULT_ID = 'admin_set/default'.freeze
|
|
32
|
-
|
|
33
31
|
def default_admin_set_id
|
|
34
32
|
create_default_admin_set unless default_exists?
|
|
35
|
-
DEFAULT_ID
|
|
33
|
+
AdminSet::DEFAULT_ID
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
def default_exists?
|
|
39
|
-
AdminSet.exists?(DEFAULT_ID)
|
|
37
|
+
AdminSet.exists?(AdminSet::DEFAULT_ID)
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
# Creates the default AdminSet and an associated PermissionTemplate with workflow
|
|
43
41
|
def create_default_admin_set
|
|
44
|
-
AdminSet.create!(id: DEFAULT_ID, title: ['Default Admin Set']).tap do |_as|
|
|
45
|
-
|
|
42
|
+
AdminSet.create!(id: AdminSet::DEFAULT_ID, title: ['Default Admin Set']).tap do |_as|
|
|
43
|
+
create_permission_template!(admin_set_id: AdminSet::DEFAULT_ID)
|
|
46
44
|
end
|
|
47
45
|
end
|
|
46
|
+
|
|
47
|
+
# Creates a Sufia::PermissionTemplate for the given AdminSet
|
|
48
|
+
def create_permission_template!(admin_set_id:)
|
|
49
|
+
Sufia::PermissionTemplate.create!(admin_set_id: admin_set_id, workflow_name: AdminSet::DEFAULT_WORKFLOW_NAME)
|
|
50
|
+
end
|
|
48
51
|
end
|
|
49
52
|
end
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
//= require sufia/batch_select_all
|
|
39
39
|
//= require sufia/browse_everything
|
|
40
40
|
//= require sufia/search
|
|
41
|
-
//= require sufia/
|
|
41
|
+
//= require sufia/content_blocks
|
|
42
42
|
//= require sufia/ga_events
|
|
43
43
|
//= require sufia/select_submit
|
|
44
44
|
//= require sufia/tabs
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
//= require sufia/admin/admin_set_controls
|
|
56
56
|
//= require sufia/admin/admin_set/participants
|
|
57
57
|
//= require sufia/admin/admin_set/visibility
|
|
58
|
+
//= require sufia/editor
|
|
59
|
+
//= require sufia/editor/admin_set_widget
|
|
58
60
|
//= require sufia/save_work
|
|
59
61
|
//= require sufia/permissions
|
|
60
62
|
//= require sufia/notifications
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
Sufia = {
|
|
4
4
|
initialize: function () {
|
|
5
5
|
this.autocomplete();
|
|
6
|
-
this.saveWorkControl();
|
|
7
|
-
this.saveWorkFixed();
|
|
8
6
|
this.popovers();
|
|
9
7
|
this.permissions();
|
|
10
8
|
this.notifications();
|
|
11
9
|
this.transfers();
|
|
12
|
-
this.
|
|
10
|
+
this.editor();
|
|
13
11
|
this.fileManager();
|
|
14
12
|
this.selectWorkType();
|
|
15
13
|
this.datatable();
|
|
@@ -40,16 +38,14 @@ Sufia = {
|
|
|
40
38
|
autocomplete.setup();
|
|
41
39
|
},
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
|
|
41
|
+
editor: function () {
|
|
42
|
+
var element = $("[data-behavior='work-form']")
|
|
43
|
+
if (element.length > 0) {
|
|
44
|
+
var Editor = require('sufia/editor');
|
|
45
|
+
new Editor(element)
|
|
46
|
+
}
|
|
46
47
|
},
|
|
47
48
|
|
|
48
|
-
saveWorkFixed: function () {
|
|
49
|
-
// Setting test to false to skip native and go right to polyfill
|
|
50
|
-
FixedSticky.tests.sticky = false;
|
|
51
|
-
$('#savewidget').fixedsticky();
|
|
52
|
-
},
|
|
53
49
|
|
|
54
50
|
// initialize popover helpers
|
|
55
51
|
popovers: function () {
|
|
@@ -82,13 +78,6 @@ Sufia = {
|
|
|
82
78
|
$("#proxy_deposit_request_transfer_to").userSearch();
|
|
83
79
|
},
|
|
84
80
|
|
|
85
|
-
relationshipsTable: function () {
|
|
86
|
-
var rel = require('sufia/relationships/table');
|
|
87
|
-
$('table.relationships-ajax-enabled').each(function () {
|
|
88
|
-
new rel.RelationshipsTable($(this));
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
|
|
92
81
|
selectWorkType: function () {
|
|
93
82
|
var selectWork = require('sufia/select_work_type');
|
|
94
83
|
$("[data-behavior=select-work]").each(function () {
|
|
@@ -1,66 +1,65 @@
|
|
|
1
|
+
import Location from 'sufia/autocomplete/location'
|
|
2
|
+
import Subject from 'sufia/autocomplete/subject'
|
|
3
|
+
import Language from 'sufia/autocomplete/language'
|
|
4
|
+
import Work from 'sufia/autocomplete/work'
|
|
5
|
+
|
|
6
|
+
|
|
1
7
|
export class Autocomplete {
|
|
2
|
-
|
|
3
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
}
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
}
|
|
11
|
+
// This is the initial setup for the form.
|
|
12
|
+
setup() {
|
|
13
|
+
$('[data-autocomplete]').each((index, value) => {
|
|
14
|
+
let selector = $(value)
|
|
15
|
+
switch (selector.data('autocomplete')) {
|
|
16
|
+
case "subject":
|
|
17
|
+
this.autocompleteSubject(selector);
|
|
18
|
+
break;
|
|
19
|
+
case "language":
|
|
20
|
+
this.autocompleteLanguage(selector);
|
|
21
|
+
break;
|
|
22
|
+
case "based_near":
|
|
23
|
+
this.autocompleteLocation(selector);
|
|
24
|
+
break;
|
|
25
|
+
case "work":
|
|
26
|
+
this.autocompleteWork(selector);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
// attach an auto complete based on the field
|
|
33
|
+
fieldAdded(cloneElem) {
|
|
34
|
+
var $cloneElem = $(cloneElem);
|
|
35
|
+
// FIXME this code (comparing the id) depends on a bug. Each input has an id and
|
|
36
|
+
// the id is duplicated when you press the plus button. This is not valid html.
|
|
37
|
+
if (/_based_near$/.test($cloneElem.attr("id"))) {
|
|
38
|
+
this.autocompleteLocation($cloneElem);
|
|
39
|
+
} else if (/_language$/.test($cloneElem.attr("id"))) {
|
|
40
|
+
this.autocompleteLanguage($cloneElem);
|
|
41
|
+
} else if (/_subject$/.test($cloneElem.attr("id"))) {
|
|
42
|
+
this.autocompleteSubject($cloneElem);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
|
-
}
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
+
autocompleteLocation(field) {
|
|
47
|
+
new Location(field, field.data('autocomplete-url'))
|
|
48
|
+
}
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
50
|
+
autocompleteSubject(field) {
|
|
51
|
+
new Subject(field, field.data('autocomplete-url'))
|
|
52
|
+
}
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
54
|
+
autocompleteLanguage(field) {
|
|
55
|
+
new Language(field, field.data('autocomplete-url'))
|
|
56
|
+
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
}
|
|
58
|
+
autocompleteWork(field, excludeWorkId) {
|
|
59
|
+
new Work(
|
|
60
|
+
field,
|
|
61
|
+
field.data('autocomplete-url'),
|
|
62
|
+
field.data('exclude-work')
|
|
63
|
+
)
|
|
64
|
+
}
|
|
66
65
|
}
|