You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-26Lines changed: 27 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Plugin for ActiveAdmin. Provides batch Update and Delete for scoped_collection (
10
10
11
11
# Description
12
12
13
-
This gem give you ability to perform various batch actions on any filtered(or scoped) resource. Action applies to all records across all pages. It is similar to ActiveAdmin batch action, but affects not only checked records. Usefull if you want to delete or update a lot of records in one click.
13
+
This gem give you ability to perform various batch actions on any filtered(or scoped) resource. Action applies to all records across all pages. It is similar to ActiveAdmin batch action, but affects all filtered records. This is usefull if you want to delete or update a lot of records in one click.
14
14
15
15
# Install
16
16
@@ -40,9 +40,9 @@ Also include CSS in "app/assets/stylesheets/active_admin.css.scss"
40
40
41
41
# Usage
42
42
43
-
Usually you need two standart actions: Delete and Update.
43
+
Usually you need two standard actions: Delete and Update.
44
44
45
-
For exampleyou have resource Posts. And you want to have delete action. So you one line:
45
+
For example, if you have resource Posts and you want to have a delete action, add:
Important thing. Visit Posts page with your browser. And you will see no changes. Nowperform any filter with Filters sidebar. Only after that you will see delete button. It will be in sidebar under Filters.
65
+
**Important**: Visit Posts page with your browser and you will see no changes. Now, perform any filter with the Filters sidebar. Only after you filter will you see a delete button. It will be in sidebar under Filters.
66
66
67
67
### Update action
68
68
69
-
Update is second standart action. It is more complex. It has "form" hash wrapped in Proc.
69
+
Update is second standard action and is more complex. It has "form" hash wrapped in Proc:
@@ -90,9 +90,9 @@ Parameter "form" is a proc object which returns Hash. It defines what fields you
90
90
91
91
# Custom Actions
92
92
93
-
Example. We have Phone resource. It has column "manufactured_at". And we need action which will erase this date.
93
+
Example: We have Phone resource and it has column "manufactured_at". We need an action which will erase this date.
94
94
95
-
In ActiveAdmin resource
95
+
In ActiveAdmin resource:
96
96
97
97
```ruby
98
98
ActiveAdmin.register Phonedo
@@ -108,7 +108,7 @@ ActiveAdmin.register Phone do
108
108
end
109
109
```
110
110
111
-
This simple code will create new button "Erase date" in sidebar. After clicking this button, user will see confirm message "Are you sure?". After confirming all filtered records will be updated.
111
+
This simple code will create a new button "Erase date" in sidebar. After clicking this button, the user will see confirm message "Are you sure?". After confirming, all filtered records will be updated.
112
112
113
113
114
114
# Details and Settings
@@ -118,21 +118,22 @@ This simple code will create new button "Erase date" in sidebar. After clicking
118
118
119
119
Sidebar visibility by default depends on several things.
120
120
121
-
First you must set
121
+
First you must set:
122
122
123
123
```ruby
124
124
config.batch_actions =true
125
125
```
126
126
127
-
Actually inside of this Gem we use "batch_actions". So without them Collection Actions wouldn't work.
127
+
Actually, inside of this Gem we use "batch_actions". So without them Collection Actions wouldn't work.
128
128
129
129
```ruby
130
130
scoped_collection_action :something_here
131
131
```
132
132
133
-
You resource should have some collection actions. If it doesn't have any - sidebar will not appear.
133
+
You resource should have some collection actions. If it doesn't have any, the sidebar will not appear.
134
+
135
+
By default we dont allow perform actions on **all** the records. We want protect you from accidental deleting.
134
136
135
-
And the last one. By default we dont allow perform actions on all the records. We want protect you from accidental deleting.
136
137
Sidebar with buttons will appear only after you perform filtering or scopes on resource records.
137
138
138
139
And lastly you can manage sidebar visibility by resource config:
@@ -164,9 +165,10 @@ This example renders form which allows to change "name" field. And after it do r
164
165
```
165
166
166
167
167
-
### How can I rename button ?
168
+
### How can I rename button?
169
+
170
+
Every scoped_collection_action has option `:title`.
168
171
169
-
Every scoped_collection_action has option :title.
170
172
Example:
171
173
172
174
```ruby
@@ -178,7 +180,7 @@ Example:
178
180
179
181
### How can I modify modal dialog title?
180
182
181
-
Similar to button title. Use option :confirm
183
+
Similar to button title. Use option `:confirm`
182
184
183
185
```ruby
184
186
scoped_collection_action :scoped_collection_destroy, confirm:'Delete all phones?'
@@ -187,7 +189,7 @@ Similar to button title. Use option :confirm
187
189
188
190
### Can I replace you pop-up form with my own?
189
191
190
-
Yes. But also you must take care of mandatory parameters passed to server.
192
+
Yes. But also you must take care of mandatory parameters passed to the server.
191
193
192
194
193
195
```ruby
@@ -200,15 +202,14 @@ Now in HTML page, you have button:
200
202
<buttonclass="my_popup"data="{"auth_token":"2a+KLu5u9McQENspCiep0DGZI6D09fCVXAN9inrwRG0=","batch_action":"my_pop_action","confirm":"Are you sure?"}">My pop action</button>
201
203
```
202
204
203
-
But without handler. Clicking on the button does nothing.
205
+
Without handler, clicking on the button does nothing.
204
206
205
-
You can render form in any way you want.
206
-
It can be some popup(Fancybox, Simplemodal, etc.), or some inline collapsible form.
207
-
It can even be a separate full-page.
207
+
You can render the form in any way you want:
208
+
-It can be some popup(Fancybox, Simplemodal, etc.), or some inline collapsible form.
209
+
-It can even be a separate full-page.
208
210
209
211
One thing is important - how you will send data to server. Generally it should be:
0 commit comments