Skip to content

Commit 9658a71

Browse files
authored
Merge pull request #19 from jayshepherd/patch-1
Grammar and small copy changes for README
2 parents fbf536b + 6f76699 commit 9658a71

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

README.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Plugin for ActiveAdmin. Provides batch Update and Delete for scoped_collection (
1010

1111
# Description
1212

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.
1414

1515
# Install
1616

@@ -40,9 +40,9 @@ Also include CSS in "app/assets/stylesheets/active_admin.css.scss"
4040

4141
# Usage
4242

43-
Usually you need two standart actions: Delete and Update.
43+
Usually you need two standard actions: Delete and Update.
4444

45-
For example you 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:
4646

4747
```ruby
4848
scoped_collection_action :scoped_collection_destroy
@@ -62,11 +62,11 @@ ActiveAdmin.register Post do
6262
end
6363
```
6464

65-
Important thing. Visit Posts page with your browser. And you will see no changes. Now perform 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.
6666

6767
### Update action
6868

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:
7070

7171
```ruby
7272
scoped_collection_action :scoped_collection_update, form: -> do
@@ -90,9 +90,9 @@ Parameter "form" is a proc object which returns Hash. It defines what fields you
9090

9191
# Custom Actions
9292

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.
9494

95-
In ActiveAdmin resource
95+
In ActiveAdmin resource:
9696

9797
```ruby
9898
ActiveAdmin.register Phone do
@@ -108,7 +108,7 @@ ActiveAdmin.register Phone do
108108
end
109109
```
110110

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.
112112

113113

114114
# Details and Settings
@@ -118,21 +118,22 @@ This simple code will create new button "Erase date" in sidebar. After clicking
118118

119119
Sidebar visibility by default depends on several things.
120120

121-
First you must set
121+
First you must set:
122122

123123
```ruby
124124
config.batch_actions = true
125125
```
126126

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.
128128

129129
```ruby
130130
scoped_collection_action :something_here
131131
```
132132

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.
134136

135-
And the last one. By default we dont allow perform actions on all the records. We want protect you from accidental deleting.
136137
Sidebar with buttons will appear only after you perform filtering or scopes on resource records.
137138

138139
And lastly you can manage sidebar visibility by resource config:
@@ -148,9 +149,9 @@ config.scoped_collection_actions_if = -> { params[:scope] }
148149
### Can I use my handler on update/delete action?
149150

150151
You can pass block to default actions update and delete.
151-
And do custom redirect after it. Use render(location: 'something') instead of redirect_to().
152+
And do custom redirect after it. Use `render` (location: 'something') instead of `redirect_to()`.
152153

153-
This example renders form which allows to change "name" field. And after it do redirect to dashboard page.
154+
This example renders form which allows to change `name` field. And after it do redirect to dashboard page.
154155

155156
```ruby
156157
scoped_collection_action :scoped_collection_update,
@@ -164,9 +165,10 @@ This example renders form which allows to change "name" field. And after it do r
164165
```
165166

166167

167-
### How can I rename button ?
168+
### How can I rename button?
169+
170+
Every scoped_collection_action has option `:title`.
168171

169-
Every scoped_collection_action has option :title.
170172
Example:
171173

172174
```ruby
@@ -178,7 +180,7 @@ Example:
178180

179181
### How can I modify modal dialog title?
180182

181-
Similar to button title. Use option :confirm
183+
Similar to button title. Use option `:confirm`
182184

183185
```ruby
184186
scoped_collection_action :scoped_collection_destroy, confirm: 'Delete all phones?'
@@ -187,7 +189,7 @@ Similar to button title. Use option :confirm
187189

188190
### Can I replace you pop-up form with my own?
189191

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.
191193

192194

193195
```ruby
@@ -200,15 +202,14 @@ Now in HTML page, you have button:
200202
<button class="my_popup" data="{&quot;auth_token&quot;:&quot;2a+KLu5u9McQENspCiep0DGZI6D09fCVXAN9inrwRG0=&quot;,&quot;batch_action&quot;:&quot;my_pop_action&quot;,&quot;confirm&quot;:&quot;Are you sure?&quot;}">My pop action</button>
201203
```
202204

203-
But without handler. Clicking on the button does nothing.
205+
Without handler, clicking on the button does nothing.
204206

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.
208210

209211
One thing is important - how you will send data to server. Generally it should be:
210212

211-
212213
POST request
213214

214215
URL: /admin/collection_path/batch_action
@@ -234,7 +235,7 @@ batch_action = "my_pop_action"
234235
```authenticity_token``` and ```batch_action``` you can get from data-attribute of the Button.
235236

236237

237-
Example in JavaScript
238+
Example in JavaScript:
238239

239240
```javascript
240241
url = window.location.pathname + '/batch_action' + window.location.search
@@ -248,9 +249,9 @@ Example in JavaScript
248249
window.location.reload()
249250
```
250251

251-
### How notify user about success and error operations ?
252+
### How notify user about success and error operations?
252253

253-
We recommend to use Rails Flash messages.
254+
We recommend using Rails Flash messages.
254255

255256
Example with updating phone diagonal attribute. In this case model Phone has validation:
256257

0 commit comments

Comments
 (0)