hydra-batch-edit 0.0.7 → 0.1.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.
- data/.gitignore +1 -0
- data/lib/hydra/batch_edit/version.rb +1 -1
- data/vendor/assets/javascripts/batch_edit.js.coffee +21 -14
- metadata +2 -2
data/.gitignore
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
$
|
2
|
-
|
1
|
+
$ = jQuery
|
2
|
+
|
3
|
+
$.fn.batchEdit = (args) ->
|
4
|
+
$elem = this
|
5
|
+
$("[data-behavior='batch-tools']", $elem).removeClass('hidden')
|
3
6
|
|
4
7
|
window.batch_edits_options = {} if typeof window.batch_edits_options is "undefined"
|
5
|
-
default_options =
|
8
|
+
default_options =
|
6
9
|
checked_label: "Selected",
|
7
10
|
unchecked_label: "Select",
|
8
|
-
css_class: "batch_toggle"
|
11
|
+
css_class: "batch_toggle"
|
9
12
|
|
10
13
|
options = $.extend({}, default_options, window.batch_edits_options)
|
11
14
|
|
12
|
-
$("[data-behavior='batch-add-form']").bl_checkbox_submit(options)
|
15
|
+
$("[data-behavior='batch-add-form']", $elem).bl_checkbox_submit(options)
|
13
16
|
|
14
17
|
setState = (obj) ->
|
15
18
|
activate = ->
|
@@ -37,16 +40,16 @@ $ ->
|
|
37
40
|
setState(obj)
|
38
41
|
|
39
42
|
#set initial state
|
40
|
-
setState($("[data-behavior='batch-edit-activate']"))
|
43
|
+
setState($("[data-behavior='batch-edit-activate']", $elem))
|
41
44
|
|
42
|
-
$("[data-behavior='batch-edit-activate']").click (e) ->
|
45
|
+
$("[data-behavior='batch-edit-activate']", $elem).click (e) ->
|
43
46
|
e.preventDefault()
|
44
47
|
toggleState($(this))
|
45
48
|
$.ajax({
|
46
49
|
type: 'POST',
|
47
50
|
url: '/batch_edits/state',
|
48
51
|
data: {_method:'PUT', state: $(this).attr('data-state')},
|
49
|
-
})
|
52
|
+
})
|
50
53
|
# TODO check-all
|
51
54
|
|
52
55
|
# ajax manager to queue ajax calls so all adds or removes are done in sequence
|
@@ -83,12 +86,13 @@ $ ->
|
|
83
86
|
ajaxManager.run()
|
84
87
|
|
85
88
|
#override the default blacklight checkbox behavior to queue ajax calls
|
86
|
-
$("input[type='checkbox'].
|
89
|
+
$("input[type='checkbox']." + default_options.css_class, $elem).click ->
|
87
90
|
checked = not this["checked"]
|
88
91
|
checkbox = $(this)
|
89
|
-
form = $(checkbox.
|
90
|
-
label = $(
|
91
|
-
label.
|
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)
|
92
96
|
checkbox.attr "disabled", "disabled"
|
93
97
|
ajaxManager.addReq
|
94
98
|
queue: "add_doc"
|
@@ -103,8 +107,10 @@ $ ->
|
|
103
107
|
checkbox.removeAttr "disabled"
|
104
108
|
|
105
109
|
success: (data, status, xhr) ->
|
110
|
+
console.log "got status"
|
106
111
|
unless xhr.status is 0
|
107
112
|
checked = not checked
|
113
|
+
console.log "Updating state2"
|
108
114
|
update_state_for checked, checkbox, label, form
|
109
115
|
label.removeAttr "disabled"
|
110
116
|
checkbox.removeAttr "disabled"
|
@@ -118,11 +124,12 @@ $ ->
|
|
118
124
|
|
119
125
|
# complete the override by overriding update_state_for
|
120
126
|
update_state_for = (state, checkbox, label, form) ->
|
127
|
+
console.log "in update state ", state
|
121
128
|
checkbox.attr "checked", state
|
122
129
|
label.toggleClass "checked", state
|
123
130
|
if state
|
124
131
|
form.find("input[name=_method]").val "delete"
|
125
|
-
label.text
|
132
|
+
$('span', label).text(options.progress_label)
|
126
133
|
else
|
127
134
|
form.find("input[name=_method]").val "put"
|
128
|
-
label.text
|
135
|
+
$('span', label).text(options.progress_label)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-batch-edit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: blacklight
|