hydra-batch-edit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88b816f49539deda36c4029d5fc68148e23436d7
4
+ data.tar.gz: 138ecb568f0749a34cfa497918004646b6110fd9
5
+ SHA512:
6
+ metadata.gz: 7a270792034acf9c454750ee27b20a7dbcb159919e8a417d8d8dc99d7987311800bbba87a7a5bc7eb26a968cf25c1234c8b10fa92c5f661b36eafcd2a889ae05
7
+ data.tar.gz: 9707ec9d4c52ae144f5a27aec51a6c013acfaf326675db7379fd20012acb595fb2e1c98dfa709f73f372a27f968ef0ffa5441bd14a4615843b0ebb753118460b
@@ -11,8 +11,84 @@ $.fn.batchEdit = (args) ->
11
11
  css_class: "batch_toggle"
12
12
 
13
13
  options = $.extend({}, default_options, window.batch_edits_options)
14
+
15
+ # complete the override by overriding update_state_for
16
+ update_state_for = (check, state, label, form) ->
17
+ check.prop "checked", state
18
+ label.toggleClass "checked", state
19
+
20
+ if state
21
+ form.find("input[name=_method]").val "delete"
22
+ $('span', label).text(options.progress_label)
23
+ else
24
+ form.find("input[name=_method]").val "put"
25
+ $('span', label).text(options.progress_label)
14
26
 
15
- $("[data-behavior='batch-add-form']", $elem).bl_checkbox_submit(options)
27
+ for obj in $("[data-behavior='batch-add-form']", $elem)
28
+ form = $(obj)
29
+ form.children().hide()
30
+ # We're going to use the existing form to actually send our add/removes
31
+ # This works conveneintly because the exact same action href is used
32
+ # for both bookmarks/$doc_id. But let's take out the irrelevant parts
33
+ # of the form to avoid any future confusion.
34
+ form.find("input[type=submit]").remove()
35
+ form.addClass('form-inline')
36
+
37
+ # View needs to set data-doc-id so we know a unique value
38
+ # for making DOM id
39
+ unique_id = form.attr("data-doc-id") || Math.random()
40
+ # if form is currently using method delete to change state,
41
+ # then checkbox is currently checked
42
+ checked = (form.find("input[name=_method][value=delete]").size() != 0)
43
+
44
+ checkbox = $('<input type="checkbox">')
45
+ .addClass( options.css_class )
46
+ .attr("id", options.css_class + "_" + unique_id)
47
+ label = $('<label>')
48
+ .addClass( options.css_class )
49
+ .addClass('checkbox')
50
+ .attr("for", options.css_class + '_' + unique_id)
51
+ .attr("title", form.attr("title") || "")
52
+ span = $('<span>')
53
+
54
+ label.append(checkbox)
55
+ label.append(" ")
56
+ label.append(span)
57
+ update_state_for(checkbox, checked, label, form)
58
+ form.append(label)
59
+
60
+ # TODO make this into a new method
61
+ checkbox.bind 'click', ->
62
+ cb = $(this)
63
+ chkd = not cb.is(":checked")
64
+ form = $(cb.closest('form')[0])
65
+ label = $('label[for="'+$(this).attr('id')+'"]')
66
+ label.attr "disabled", "disabled"
67
+ $('span', label).text(options.progress_label)
68
+ cb.attr "disabled", "disabled"
69
+ ajaxManager.addReq
70
+ queue: "add_doc"
71
+ url: form.attr("action")
72
+ dataType: "json"
73
+ type: form.attr("method").toUpperCase()
74
+ data: form.serialize()
75
+ error: ->
76
+ alert "Error Too Many results Selected"
77
+ update_state_for cb, chkd, label, form
78
+ label.removeAttr "disabled"
79
+ checkbox.removeAttr "disabled"
80
+
81
+ success: (data, status, xhr) ->
82
+ unless xhr.status is 0
83
+ chkd = not chkd
84
+ else
85
+ alert "Error Too Many results Selected"
86
+ update_state_for cb, chkd, label, form
87
+ label.removeAttr "disabled"
88
+ cb.removeAttr "disabled"
89
+
90
+ false
91
+
16
92
 
17
93
  setState = (obj) ->
18
94
  activate = ->
@@ -85,51 +161,3 @@ $.fn.batchEdit = (args) ->
85
161
 
86
162
  ajaxManager.run()
87
163
 
88
- #override the default blacklight checkbox behavior to queue ajax calls
89
- $("input[type='checkbox']." + default_options.css_class, $elem).click ->
90
- checked = not this["checked"]
91
- checkbox = $(this)
92
- form = $(checkbox.closest('form')[0])
93
- label = $('label[for="'+$(this).attr('id')+'"]')
94
- label.attr "disabled", "disabled"
95
- $('span', label).text(options.progress_label)
96
- checkbox.attr "disabled", "disabled"
97
- ajaxManager.addReq
98
- queue: "add_doc"
99
- url: form.attr("action")
100
- dataType: "json"
101
- type: form.attr("method").toUpperCase()
102
- data: form.serialize()
103
- error: ->
104
- alert "Error Too Many results Selected"
105
- update_state_for checked, checkbox, label, form
106
- label.removeAttr "disabled"
107
- checkbox.removeAttr "disabled"
108
-
109
- success: (data, status, xhr) ->
110
- console.log "got status"
111
- unless xhr.status is 0
112
- checked = not checked
113
- console.log "Updating state2"
114
- update_state_for checked, checkbox, label, form
115
- label.removeAttr "disabled"
116
- checkbox.removeAttr "disabled"
117
- else
118
- alert "Error Too Many results Selected"
119
- update_state_for checked, checkbox, label, form
120
- label.removeAttr "disabled"
121
- checkbox.removeAttr "disabled"
122
-
123
- false
124
-
125
- # complete the override by overriding update_state_for
126
- update_state_for = (state, checkbox, label, form) ->
127
- console.log "in update state ", state
128
- checkbox.attr "checked", state
129
- label.toggleClass "checked", state
130
- if state
131
- form.find("input[name=_method]").val "delete"
132
- $('span', label).text(options.progress_label)
133
- else
134
- form.find("input[name=_method]").val "put"
135
- $('span', label).text(options.progress_label)
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module BatchEdit
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-batch-edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Justin Coyne
@@ -10,70 +9,62 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2013-03-15 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: blacklight
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rails
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: rspec-rails
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  description: Rails engine to do batch editing with hydra-head
@@ -88,6 +79,8 @@ files:
88
79
  - LICENSE
89
80
  - README.textile
90
81
  - Rakefile
82
+ - app/assets/javascripts/batch_edit.js.coffee
83
+ - app/assets/stylesheets/batch_edit.css.scss
91
84
  - app/controllers/batch_edits_controller.rb
92
85
  - app/helpers/batch_edit_helper.rb
93
86
  - app/views/batch_edits/_add_button.html.erb
@@ -116,31 +109,28 @@ files:
116
109
  - spec/support/app/models/solr_document.rb
117
110
  - spec/support/db/migrate/20111101221803_create_searches.rb
118
111
  - spec/support/lib/generators/test_app_generator.rb
119
- - vendor/assets/javascripts/batch_edit.js.coffee
120
- - vendor/assets/stylesheets/batch_edit.css.scss
121
112
  homepage: https://github.com/projecthydra/hydra-batch-edit
122
113
  licenses: []
114
+ metadata: {}
123
115
  post_install_message:
124
116
  rdoc_options: []
125
117
  require_paths:
126
118
  - lib
127
119
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
120
  requirements:
130
- - - ! '>='
121
+ - - '>='
131
122
  - !ruby/object:Gem::Version
132
123
  version: '0'
133
124
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
125
  requirements:
136
- - - ! '>='
126
+ - - '>='
137
127
  - !ruby/object:Gem::Version
138
128
  version: '0'
139
129
  requirements: []
140
130
  rubyforge_project:
141
- rubygems_version: 1.8.24
131
+ rubygems_version: 2.0.0
142
132
  signing_key:
143
- specification_version: 3
133
+ specification_version: 4
144
134
  summary: Rails engine to do batch editing with hydra-head
145
135
  test_files:
146
136
  - spec/.gitignore