sufia 7.0.0.beta4 → 7.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/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +1 -2
- data/.travis.yml +1 -0
- data/Gemfile +18 -9
- data/README.md +23 -3
- data/app/assets/javascripts/sufia.js +4 -1
- data/app/assets/javascripts/sufia/app.js +15 -3
- data/app/assets/javascripts/sufia/autocomplete.es6 +51 -0
- data/app/assets/javascripts/sufia/autocomplete/language.es6 +25 -0
- data/app/assets/javascripts/sufia/autocomplete/location.es6 +24 -0
- data/app/assets/javascripts/sufia/autocomplete/subject.es6 +26 -0
- data/app/assets/javascripts/sufia/batch_edit.js +8 -5
- data/app/assets/javascripts/sufia/permissions/control.es6 +7 -3
- data/app/assets/javascripts/sufia/save_work/required_fields.es6 +10 -4
- data/app/assets/javascripts/sufia/save_work/save_work_control.es6 +14 -4
- data/app/assets/stylesheets/sufia/_fixedsticky.scss +23 -21
- data/app/assets/stylesheets/sufia/_form-progress.scss +16 -7
- data/app/assets/stylesheets/sufia/_header.scss +2 -1
- data/app/assets/stylesheets/sufia/_settings.scss +4 -0
- data/app/controllers/api/items_controller.rb +2 -2
- data/app/controllers/api/zotero_controller.rb +1 -1
- data/app/controllers/citations_controller.rb +0 -2
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +7 -7
- data/app/controllers/concerns/sufia/batch_uploads_controller_behavior.rb +9 -3
- data/app/controllers/concerns/sufia/singular_subresource_controller.rb +6 -1
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -3
- data/app/controllers/concerns/sufia/works_controller_behavior.rb +11 -4
- data/app/controllers/my/highlights_controller.rb +1 -1
- data/app/forms/sufia/forms/batch_edit_form.rb +10 -6
- data/app/forms/sufia/forms/batch_upload_form.rb +2 -2
- data/app/forms/sufia/forms/collection_form.rb +4 -0
- data/app/forms/sufia/forms/work_form.rb +4 -0
- data/app/helpers/sufia/blacklight_override.rb +0 -20
- data/app/helpers/sufia/collections_helper.rb +12 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +84 -56
- data/app/jobs/batch_create_job.rb +18 -2
- data/app/jobs/content_depositor_change_event_job.rb +13 -6
- data/app/jobs/create_work_job.rb +6 -2
- data/app/models/batch_upload_item.rb +15 -0
- data/app/models/concerns/sufia/ability.rb +7 -4
- data/app/models/concerns/sufia/user.rb +0 -11
- data/app/models/concerns/sufia/work_behavior.rb +1 -0
- data/app/models/concerns/sufia/works/featured.rb +23 -0
- data/app/models/file_download_stat.rb +9 -12
- data/app/models/file_view_stat.rb +5 -15
- data/app/models/proxy_deposit_request.rb +11 -7
- data/app/models/sufia/statistic.rb +65 -0
- data/app/models/work_view_stat.rb +5 -16
- data/app/presenters/file_usage.rb +3 -4
- data/app/presenters/sufia/file_set_presenter.rb +1 -3
- data/app/presenters/sufia/trophy_presenter.rb +28 -0
- data/app/presenters/sufia/user_profile_presenter.rb +1 -1
- data/app/presenters/work_usage.rb +5 -4
- data/app/search_builders/deposit_search_builder.rb +4 -3
- data/app/search_builders/parent_collection_search_builder.rb +1 -1
- data/app/services/sufia/collection_member_service.rb +1 -1
- data/app/services/sufia/user_stat_importer.rb +11 -6
- data/app/views/_controls.html.erb +11 -9
- data/app/views/batch_edits/edit.html.erb +8 -2
- data/app/views/catalog/_index_list_default.html.erb +2 -1
- data/app/views/curation_concerns/base/_form_metadata.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_progress.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_relationships.html.erb +1 -1
- data/app/views/curation_concerns/base/_guts4form.html.erb +6 -2
- data/app/views/curation_concerns/base/_items.html.erb +1 -1
- data/app/views/curation_concerns/base/edit.html.erb +1 -1
- data/app/views/curation_concerns/base/new.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/_permission.html.erb +5 -1
- data/app/views/curation_concerns/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/show.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +1 -1
- data/app/views/{error → errors}/404.html.erb +0 -0
- data/app/views/records/edit_fields/_based_near.html.erb +8 -0
- data/app/views/records/edit_fields/_language.html.erb +8 -0
- data/app/views/records/edit_fields/_subject.html.erb +8 -0
- data/app/views/stats/work.html.erb +1 -1
- data/app/views/sufia/batch_uploads/_form.html.erb +1 -1
- data/app/views/sufia/homepage/_home_header.html.erb +1 -1
- data/app/views/sufia/homepage/_sortable_featured.html.erb +1 -1
- data/app/views/transfers/new.html.erb +3 -1
- data/app/views/users/_contributions.html.erb +1 -1
- data/config/locales/sufia.en.yml +3 -2
- data/config/routes.rb +0 -7
- data/lib/generators/sufia/install_generator.rb +0 -24
- data/lib/generators/sufia/templates/catalog_controller.rb +4 -3
- data/lib/generators/sufia/templates/config/sufia.rb +4 -2
- data/lib/generators/sufia/upgrade700_generator.rb +7 -9
- data/lib/generators/sufia/work_generator.rb +56 -0
- data/lib/sufia.rb +4 -1
- data/lib/sufia/arkivo/actor.rb +1 -1
- data/lib/sufia/configuration.rb +15 -3
- data/lib/sufia/engine.rb +1 -10
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/api/items_controller_spec.rb +20 -7
- data/spec/controllers/sufia/batch_uploads_controller_spec.rb +4 -3
- data/spec/controllers/transfers_controller_spec.rb +3 -11
- data/spec/controllers/users_controller_spec.rb +2 -1
- data/spec/features/batch_edit_spec.rb +17 -2
- data/spec/forms/sufia/forms/batch_edit_form_spec.rb +2 -0
- data/spec/forms/sufia/forms/batch_upload_form_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +36 -26
- data/spec/helpers/{generic_work_helper_spec.rb → sufia/collections_helper_spec.rb} +1 -1
- data/spec/helpers/sufia_helper_spec.rb +70 -32
- data/spec/javascripts/autocomplete_spec.js.coffee +7 -7
- data/spec/javascripts/save_work_spec.js +20 -20
- data/spec/lib/sufia/configuration_spec.rb +30 -0
- data/spec/lib/sufia/user_stat_importer_spec.rb +21 -36
- data/spec/models/file_download_stat_spec.rb +8 -8
- data/spec/models/file_view_stat_spec.rb +8 -8
- data/spec/models/generic_work_spec.rb +24 -0
- data/spec/models/proxy_deposit_request_spec.rb +2 -4
- data/spec/models/sufia/ability_spec.rb +7 -13
- data/spec/models/user_spec.rb +0 -14
- data/spec/models/work_view_stat_spec.rb +22 -8
- data/spec/presenters/sufia/file_usage_spec.rb +0 -4
- data/spec/presenters/sufia/trophy_presenter_spec.rb +46 -0
- data/spec/presenters/sufia/user_profile_presenter_spec.rb +4 -1
- data/spec/presenters/sufia/work_usage_spec.rb +8 -17
- data/spec/routing/route_spec.rb +0 -6
- data/spec/spec_helper.rb +8 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -0
- data/spec/views/batch_edits/edit.html.erb_spec.rb +8 -2
- data/spec/views/catalog/_index_list_default.html.erb_spec.rb +8 -6
- data/spec/views/curation_concerns/base/_form.html.erb_spec.rb +3 -0
- data/spec/views/curation_concerns/file_sets/_permission.html.erb_spec.rb +16 -0
- data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +0 -2
- data/spec/views/records/edit_fields/_based_near.html.erb_spec.rb +20 -0
- data/spec/views/records/edit_fields/_language.html.erb_spec.rb +20 -0
- data/spec/views/records/edit_fields/_subject.html.erb_spec.rb +20 -0
- data/spec/views/{homepage → sufia/homepage}/_announcement.html.erb_spec.rb +0 -0
- data/spec/views/{homepage → sufia/homepage}/_featured_works.html.erb_spec.rb +0 -0
- data/spec/views/{homepage → sufia/homepage}/_home_header.html.erb_spec.rb +0 -0
- data/spec/views/sufia/homepage/_sortable_featured.html.erb_spec.rb +21 -0
- data/spec/views/users/edit.html.erb_spec.rb +5 -5
- data/spec/views/users/show.html.erb_spec.rb +5 -3
- data/sufia.gemspec +4 -3
- data/tasks/noid.rake +2 -2
- data/tasks/sufia-dev.rake +1 -1
- metadata +73 -68
- data/app/assets/javascripts/sufia/edit_metadata.js +0 -87
- data/app/controllers/authorities_controller.rb +0 -19
- data/app/helpers/generic_work_helper.rb +0 -10
- data/app/helpers/sufia_url_helper.rb +0 -14
- data/app/models/concerns/sufia/file_stat_utils.rb +0 -33
- data/app/models/concerns/sufia/work_stat_utils.rb +0 -33
- data/app/models/geo_names_resource.rb +0 -18
- data/app/models/local_authority.rb +0 -101
- data/app/models/local_authority_entry.rb +0 -3
- data/app/models/subject_local_authority_entry.rb +0 -2
- data/app/views/curation_concerns/generic_works/_generic_work.html.erb +0 -3
- data/app/views/error/401.html.erb +0 -18
- data/app/views/error/500.html.erb +0 -9
- data/app/views/error/single_use_error.html.erb +0 -19
- data/lib/generators/sufia/geonames_username_config_generator.rb +0 -20
- data/spec/controllers/authorities_controller_spec.rb +0 -18
- data/spec/fixtures/cities15000.tsv +0 -149
- data/spec/fixtures/genreForms.nt +0 -471
- data/spec/fixtures/lexvo.rdf +0 -3108
- data/spec/helpers/sufia_url_helper_spec.rb +0 -18
- data/spec/models/geo_names_resource_spec.rb +0 -30
- data/spec/models/local_authority_spec.rb +0 -108
- data/vendor/assets/javascripts/almond.js +0 -430
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac6f239c006772685658115ca65e17cefcb60838
|
4
|
+
data.tar.gz: 61e9010739cf96f205a4288ac9868ea881d06800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24f73b89ad7008c00580a7505a51ac0ebf506807eab9212d1f0fd0c21d3364f21d86827a7f53e3a35d207edacdaaf68ddd6f6c6b7062eafb831c1dbb9d629223
|
7
|
+
data.tar.gz: 399cc1c453ec1430f577b73889d30a6b259074708096cd974173e171a8a3880b25c79f6fcaf9fded7ff5374c6a2404a1b814029fe121922b12fa4fd2490d421a
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -8,6 +8,7 @@ Metrics/ClassLength:
|
|
8
8
|
Exclude:
|
9
9
|
- 'lib/generators/sufia/templates/catalog_controller.rb'
|
10
10
|
- 'lib/generators/sufia/install_generator.rb'
|
11
|
+
- 'lib/sufia/configuration.rb'
|
11
12
|
- 'app/services/sufia/user_stat_importer.rb'
|
12
13
|
|
13
14
|
Metrics/ParameterLists:
|
@@ -24,7 +25,6 @@ Metrics/MethodLength:
|
|
24
25
|
- 'lib/generators/sufia/templates/migrations/create_local_authorities.rb'
|
25
26
|
- 'app/helpers/sufia/citations_behaviors/formatters/endnote_formatter.rb'
|
26
27
|
- 'app/models/concerns/sufia/solr_document/export.rb'
|
27
|
-
- 'app/models/local_authority.rb'
|
28
28
|
- 'lib/generators/sufia/install_generator.rb'
|
29
29
|
- 'lib/sufia/arkivo/metadata_munger.rb'
|
30
30
|
|
@@ -40,7 +40,6 @@ Style/PredicateName:
|
|
40
40
|
Rails/Output:
|
41
41
|
Exclude:
|
42
42
|
- 'lib/generators/**/*'
|
43
|
-
- 'app/services/sufia/user_stat_importer.rb'
|
44
43
|
|
45
44
|
Rails/HasAndBelongsToMany:
|
46
45
|
Exclude:
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -10,10 +10,10 @@ group :development, :test do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# BEGIN ENGINE_CART BLOCK
|
13
|
-
# engine_cart: 0.
|
14
|
-
# engine_cart stanza: 0.
|
13
|
+
# engine_cart: 0.10.0
|
14
|
+
# engine_cart stanza: 0.10.0
|
15
15
|
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
|
16
|
-
file = File.expand_path(
|
16
|
+
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
17
17
|
if File.exist?(file)
|
18
18
|
begin
|
19
19
|
eval_gemfile file
|
@@ -24,13 +24,22 @@ if File.exist?(file)
|
|
24
24
|
else
|
25
25
|
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
|
26
26
|
|
27
|
-
|
27
|
+
if ENV['RAILS_VERSION']
|
28
|
+
if ENV['RAILS_VERSION'] == 'edge'
|
29
|
+
gem 'rails', github: 'rails/rails'
|
30
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
31
|
+
else
|
32
|
+
gem 'rails', ENV['RAILS_VERSION']
|
33
|
+
end
|
34
|
+
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
gem '
|
32
|
-
|
33
|
-
gem '
|
36
|
+
case ENV['RAILS_VERSION']
|
37
|
+
when /^4.2/
|
38
|
+
gem 'responders', '~> 2.0'
|
39
|
+
gem 'sass-rails', '>= 5.0'
|
40
|
+
gem 'coffee-rails', '~> 4.1.0'
|
41
|
+
when /^4.[01]/
|
42
|
+
gem 'sass-rails', '< 5.0'
|
34
43
|
end
|
35
44
|
end
|
36
45
|
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# Sufia
|
2
2
|
|
3
|
-
[![Version](https://badge.fury.io/rb/sufia.png)](http://badge.fury.io/rb/sufia)
|
3
|
+
Code: [![Version](https://badge.fury.io/rb/sufia.png)](http://badge.fury.io/rb/sufia)
|
4
4
|
[![Build Status](https://travis-ci.org/projecthydra/sufia.png?branch=master)](https://travis-ci.org/projecthydra/sufia)
|
5
5
|
[![Dependency Status](https://gemnasium.com/projecthydra/sufia.png)](https://gemnasium.com/projecthydra/sufia)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/projecthydra/sufia/badge.svg)](https://coveralls.io/r/projecthydra/sufia)
|
7
7
|
[![Documentation Status](https://inch-ci.org/github/projecthydra/sufia.svg?branch=master)](https://inch-ci.org/github/projecthydra/sufia)
|
8
8
|
[![Code Climate](https://codeclimate.com/github/projecthydra/sufia/badges/gpa.svg)](https://codeclimate.com/github/projecthydra/sufia)
|
9
|
-
|
10
|
-
[![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
|
9
|
+
|
10
|
+
Docs: [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
|
11
11
|
[![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./.github/CONTRIBUTING.md)
|
12
12
|
[![API Docs](http://img.shields.io/badge/API-docs-blue.svg)](http://rubydoc.info/gems/sufia)
|
13
13
|
|
14
|
+
Jump in: [![Slack Status](http://slack.projecthydra.org/badge.svg)](http://slack.projecthydra.org/) [![Ready Tickets](https://badge.waffle.io/projecthydra/sufia.png?label=ready&milestone=7.0.0&title=Ready)](https://waffle.io/projecthydra/sufia?milestone=7.0.0)
|
15
|
+
|
14
16
|
# Table of Contents
|
15
17
|
|
16
18
|
* [What is Sufia?](#what-is-sufia)
|
@@ -26,6 +28,7 @@
|
|
26
28
|
* [Rails](#rails)
|
27
29
|
* [Sufia's Ruby\-related dependencies](#sufias-ruby-related-dependencies)
|
28
30
|
* [Install Sufia](#install-sufia)
|
31
|
+
* [Generate a primary work type](#generate-a-primary-work-type)
|
29
32
|
* [Database tables and indexes](#database-tables-and-indexes)
|
30
33
|
* [Start Redis](#start-redis)
|
31
34
|
* [Start Solr](#start-solr)
|
@@ -75,6 +78,7 @@ Sufia has the following features:
|
|
75
78
|
* Dynamically configurable featured works and researchers on homepage
|
76
79
|
* Proxy deposit and transfers of ownership
|
77
80
|
* Integration with Zotero for automatic population of user content
|
81
|
+
* Suggested values from controlled vocabularies provided by [Questioning Authority](https://github.com/projecthydra-labs/questioning_authority)
|
78
82
|
|
79
83
|
See [Sufia's documentation site](http://sufia.io/) for more non-technical documentation.
|
80
84
|
|
@@ -164,6 +168,22 @@ Install Sufia into your app using its built-in install generator. This step adds
|
|
164
168
|
rails generate sufia:install -f
|
165
169
|
```
|
166
170
|
|
171
|
+
## Generate a primary work type
|
172
|
+
|
173
|
+
While earlier versions of Sufia came with a pre-defined object model, Sufia 7.0 and greater allow you to specify your primary work type by using tooling provided by the CurationConcerns gem. Work on the 7.x series will include adding support for users to generate an arbitrary number of work types, not **just** a primary work type. At this time we do *not* recommend generating multiple work types.
|
174
|
+
|
175
|
+
Pass a (CamelCased) model name to Sufia's work generator to get started, e.g.:
|
176
|
+
|
177
|
+
```
|
178
|
+
rails generate sufia:work Work
|
179
|
+
```
|
180
|
+
|
181
|
+
or
|
182
|
+
|
183
|
+
```
|
184
|
+
rails generate sufia:work MovingImage
|
185
|
+
```
|
186
|
+
|
167
187
|
## Database tables and indexes
|
168
188
|
|
169
189
|
Now that Sufia's required database migrations have been generated into your app, you'll need to load them into your application's database.
|
@@ -34,7 +34,6 @@
|
|
34
34
|
//= require sufia/featured_works
|
35
35
|
//= require sufia/featured_researcher
|
36
36
|
//= require sufia/batch_select_all
|
37
|
-
//= require sufia/edit_metadata
|
38
37
|
//= require sufia/single_use_link
|
39
38
|
//= require sufia/search
|
40
39
|
//= require sufia/editor
|
@@ -53,6 +52,10 @@
|
|
53
52
|
//= require sufia/save_work
|
54
53
|
//= require sufia/permissions
|
55
54
|
//= require sufia/notifications
|
55
|
+
//= require sufia/autocomplete
|
56
|
+
//= require sufia/autocomplete/location
|
57
|
+
//= require sufia/autocomplete/subject
|
58
|
+
//= require sufia/autocomplete/language
|
56
59
|
|
57
60
|
//= require curation_concerns/collections
|
58
61
|
//= require hydra-editor/hydra-editor
|
@@ -2,6 +2,7 @@
|
|
2
2
|
// code should be called from here.
|
3
3
|
Sufia = {
|
4
4
|
initialize: function () {
|
5
|
+
this.autocomplete();
|
5
6
|
this.saveWorkControl();
|
6
7
|
this.saveWorkFixed();
|
7
8
|
this.popovers();
|
@@ -10,9 +11,20 @@ Sufia = {
|
|
10
11
|
this.transfers();
|
11
12
|
},
|
12
13
|
|
14
|
+
autocomplete: function () {
|
15
|
+
var ac = require('sufia/autocomplete');
|
16
|
+
var autocomplete = new ac.Autocomplete()
|
17
|
+
$('.multi_value.form-group').manage_fields({
|
18
|
+
add: function(e, element) {
|
19
|
+
autocomplete.fieldAdded(element)
|
20
|
+
}
|
21
|
+
});
|
22
|
+
autocomplete.setup();
|
23
|
+
},
|
24
|
+
|
13
25
|
saveWorkControl: function () {
|
14
26
|
var sw = require('sufia/save_work/save_work_control');
|
15
|
-
new sw.SaveWorkControl($("#form-progress"))
|
27
|
+
var control = new sw.SaveWorkControl($("#form-progress"))
|
16
28
|
},
|
17
29
|
|
18
30
|
saveWorkFixed: function () {
|
@@ -31,8 +43,8 @@ Sufia = {
|
|
31
43
|
|
32
44
|
permissions: function () {
|
33
45
|
var perm = require('sufia/permissions/control');
|
34
|
-
new perm.PermissionsControl($("#share"), '
|
35
|
-
new perm.PermissionsControl($("#permission"), '
|
46
|
+
new perm.PermissionsControl($("#share"), 'tmpl-work-grant');
|
47
|
+
new perm.PermissionsControl($("#permission"), 'tmpl-file-set-grant');
|
36
48
|
},
|
37
49
|
|
38
50
|
notifications: function () {
|
@@ -0,0 +1,51 @@
|
|
1
|
+
export class Autocomplete {
|
2
|
+
constructor() {
|
3
|
+
}
|
4
|
+
|
5
|
+
// This is the initial setup for the form.
|
6
|
+
setup() {
|
7
|
+
$('[data-autocomplete]').each((index, value) => {
|
8
|
+
let selector = $(value)
|
9
|
+
switch (selector.data('autocomplete')) {
|
10
|
+
case "subject":
|
11
|
+
this.autocompleteSubject(selector);
|
12
|
+
break;
|
13
|
+
case "language":
|
14
|
+
this.autocompleteLanguage(selector);
|
15
|
+
break;
|
16
|
+
case "based_near":
|
17
|
+
this.autocompleteLocation(selector);
|
18
|
+
break;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
}
|
22
|
+
|
23
|
+
// attach an auto complete based on the field
|
24
|
+
fieldAdded(cloneElem) {
|
25
|
+
var $cloneElem = $(cloneElem);
|
26
|
+
// FIXME this code (comparing the id) depends on a bug. Each input has an id and
|
27
|
+
// the id is duplicated when you press the plus button. This is not valid html.
|
28
|
+
if (/_based_near$/.test($cloneElem.attr("id"))) {
|
29
|
+
this.autocompleteLocation($cloneElem);
|
30
|
+
} else if (/_language$/.test($cloneElem.attr("id"))) {
|
31
|
+
this.autocompleteLanguage($cloneElem);
|
32
|
+
} else if (/_subject$/.test($cloneElem.attr("id"))) {
|
33
|
+
this.autocompleteSubject($cloneElem);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
autocompleteLocation(field) {
|
38
|
+
var loc = require('sufia/autocomplete/location');
|
39
|
+
new loc.Location(field, field.data('autocomplete-url'))
|
40
|
+
}
|
41
|
+
|
42
|
+
autocompleteSubject(field) {
|
43
|
+
var subj = require('sufia/autocomplete/subject');
|
44
|
+
new subj.Subject(field, field.data('autocomplete-url'))
|
45
|
+
}
|
46
|
+
|
47
|
+
autocompleteLanguage(field) {
|
48
|
+
var lang = require('sufia/autocomplete/language');
|
49
|
+
new lang.Language(field, field.data('autocomplete-url'))
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
export class Language {
|
2
|
+
constructor(element, url) {
|
3
|
+
this.url = url
|
4
|
+
element.autocomplete(this.options());
|
5
|
+
}
|
6
|
+
|
7
|
+
options() {
|
8
|
+
return {
|
9
|
+
minLength: 2,
|
10
|
+
source: (request, response) => {
|
11
|
+
$.getJSON(this.url, {
|
12
|
+
q: request.term
|
13
|
+
}, response );
|
14
|
+
},
|
15
|
+
focus: function() {
|
16
|
+
// prevent value inserted on focus
|
17
|
+
return false;
|
18
|
+
},
|
19
|
+
complete: function(event) {
|
20
|
+
$('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
|
21
|
+
}
|
22
|
+
};
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export class Location {
|
2
|
+
constructor(element, url) {
|
3
|
+
this.url = url
|
4
|
+
element.autocomplete(this.options());
|
5
|
+
}
|
6
|
+
|
7
|
+
options() {
|
8
|
+
return {
|
9
|
+
minLength: 2,
|
10
|
+
source: ( request, response ) => {
|
11
|
+
$.getJSON(this.url, {
|
12
|
+
q: request.term
|
13
|
+
}, response );
|
14
|
+
},
|
15
|
+
focus: function() {
|
16
|
+
// prevent value inserted on focus
|
17
|
+
return false;
|
18
|
+
},
|
19
|
+
complete: function(event) {
|
20
|
+
$('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
|
21
|
+
}
|
22
|
+
};
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export class Subject {
|
2
|
+
constructor(element, url) {
|
3
|
+
this.url = url
|
4
|
+
element.autocomplete(this.options());
|
5
|
+
}
|
6
|
+
|
7
|
+
options() {
|
8
|
+
return {
|
9
|
+
minLength: 2,
|
10
|
+
source: ( request, response ) => {
|
11
|
+
$.getJSON(this.url, {
|
12
|
+
q: request.term
|
13
|
+
}, response );
|
14
|
+
},
|
15
|
+
focus: function() {
|
16
|
+
// prevent value inserted on focus
|
17
|
+
return false;
|
18
|
+
},
|
19
|
+
complete: function(event) {
|
20
|
+
$('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
|
21
|
+
}
|
22
|
+
};
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
|
@@ -87,7 +87,7 @@ function batch_edit_init () {
|
|
87
87
|
|
88
88
|
for (key in Object.keys(adata)) {
|
89
89
|
curKey = Object.keys(adata)[key];
|
90
|
-
if (curKey.slice(0, 12) ==
|
90
|
+
if (curKey.slice(0, 12) == req.key) {
|
91
91
|
data[curKey] = adata[curKey];
|
92
92
|
form.push(req.form);
|
93
93
|
}
|
@@ -100,10 +100,8 @@ function batch_edit_init () {
|
|
100
100
|
};
|
101
101
|
}());
|
102
102
|
|
103
|
-
|
104
103
|
ajaxManager.run();
|
105
104
|
|
106
|
-
|
107
105
|
function after_ajax(form) {
|
108
106
|
form.enableForm();
|
109
107
|
}
|
@@ -145,6 +143,7 @@ function batch_edit_init () {
|
|
145
143
|
|
146
144
|
ajaxManager.addReq({
|
147
145
|
form: form_id,
|
146
|
+
key: form.data('model'),
|
148
147
|
queue: "add_doc",
|
149
148
|
url: form.attr("action"),
|
150
149
|
dataType: "json",
|
@@ -165,8 +164,12 @@ function batch_edit_init () {
|
|
165
164
|
}
|
166
165
|
|
167
166
|
Blacklight.onLoad(function() {
|
168
|
-
// set up global batch edit options to override the ones in the gem
|
169
|
-
window.batch_edits_options = { checked_label: "",
|
167
|
+
// set up global batch edit options to override the ones in the hydra-batch-edit gem
|
168
|
+
window.batch_edits_options = { checked_label: "",
|
169
|
+
unchecked_label: "",
|
170
|
+
progress_label: "",
|
171
|
+
status_label: "",
|
172
|
+
css_class: "batch_toggle" };
|
170
173
|
batch_edit_init();
|
171
174
|
|
172
175
|
}); //end of Blacklight.onload
|
@@ -6,17 +6,21 @@ export class PermissionsControl {
|
|
6
6
|
/**
|
7
7
|
* Initialize the save controls
|
8
8
|
* @param {jQuery} element the jquery selector for the permissions container
|
9
|
-
* @param {String} object_name the name of the object to create
|
10
9
|
* @param {String} template_id the identifier of the template for the added elements
|
11
10
|
*/
|
12
|
-
constructor(element,
|
11
|
+
constructor(element, template_id) {
|
13
12
|
if (element.size() == 0) {
|
14
13
|
return
|
15
14
|
}
|
16
15
|
this.element = element
|
17
16
|
|
18
|
-
this.registry = new Registry(this.element, object_name, template_id)
|
17
|
+
this.registry = new Registry(this.element, this.object_name(), template_id)
|
19
18
|
this.user_controls = new UserControls(this.element, this.registry)
|
20
19
|
this.group_controls = new GroupControls(this.element, this.registry)
|
21
20
|
}
|
21
|
+
|
22
|
+
// retrieve object_name the name of the object to create
|
23
|
+
object_name() {
|
24
|
+
return this.element.data('param-key')
|
25
|
+
}
|
22
26
|
}
|
@@ -2,12 +2,18 @@ export class RequiredFields {
|
|
2
2
|
// Monitors the form and runs the callback if any of the required fields change
|
3
3
|
constructor(form, callback) {
|
4
4
|
this.form = form
|
5
|
-
|
6
|
-
this.
|
7
|
-
this.requiredFields.change(callback)
|
5
|
+
this.callback = callback
|
6
|
+
this.reload()
|
8
7
|
}
|
9
8
|
|
10
|
-
get areComplete(){
|
9
|
+
get areComplete() {
|
11
10
|
return this.requiredFields.filter((n, elem) => { return $(elem).val().length < 1 } ).length == 0
|
12
11
|
}
|
12
|
+
|
13
|
+
// Reassign requiredFields because fields may have been added or removed.
|
14
|
+
reload() {
|
15
|
+
// ":input" matches all input, select or textarea fields.
|
16
|
+
this.requiredFields = this.form.find(':input[required]')
|
17
|
+
this.requiredFields.change(this.callback)
|
18
|
+
}
|
13
19
|
}
|
@@ -26,6 +26,7 @@ export class SaveWorkControl {
|
|
26
26
|
this.element = element
|
27
27
|
this.form = element.closest('form')
|
28
28
|
element.data('save_work_control', this)
|
29
|
+
this.activate();
|
29
30
|
}
|
30
31
|
|
31
32
|
/**
|
@@ -56,24 +57,33 @@ export class SaveWorkControl {
|
|
56
57
|
if (!this.form) {
|
57
58
|
return
|
58
59
|
}
|
59
|
-
this.requiredFields = new RequiredFields(this.form, () => this.
|
60
|
-
this.uploads = new UploadedFiles(this.form, () => this.
|
60
|
+
this.requiredFields = new RequiredFields(this.form, () => this.formStateChanged())
|
61
|
+
this.uploads = new UploadedFiles(this.form, () => this.formStateChanged())
|
61
62
|
|
62
63
|
this.saveButton = this.element.find(':submit')
|
63
64
|
|
64
|
-
this.depositAgreement = new DepositAgreement(this.form, () => this.
|
65
|
+
this.depositAgreement = new DepositAgreement(this.form, () => this.formStateChanged())
|
65
66
|
|
66
67
|
this.requiredMetadata = new ChecklistItem(this.element.find('#required-metadata'))
|
67
68
|
this.requiredFiles = new ChecklistItem(this.element.find('#required-files'))
|
68
69
|
new VisibilityComponent(this.element.find('.visibility'))
|
69
70
|
this.preventSubmitUnlessValid()
|
71
|
+
$('.multi_value.form-group', this.form).bind('managed_field:add', () => this.formChanged())
|
72
|
+
$('.multi_value.form-group', this.form).bind('managed_field:remove', () => this.formChanged())
|
70
73
|
this.formChanged()
|
71
74
|
}
|
72
75
|
|
73
|
-
|
76
|
+
// Called when a file has been uploaded, the deposit agreement is clicked or a form field has had text entered.
|
77
|
+
formStateChanged() {
|
74
78
|
this.saveButton.prop("disabled", !this.isValid());
|
75
79
|
}
|
76
80
|
|
81
|
+
// called when a new field has been added to the form.
|
82
|
+
formChanged() {
|
83
|
+
this.requiredFields.reload();
|
84
|
+
this.formStateChanged();
|
85
|
+
}
|
86
|
+
|
77
87
|
isValid() {
|
78
88
|
// avoid short circuit evaluation. The checkboxes should be independent.
|
79
89
|
let metadataValid = this.validateMetadata()
|