record_collection 0.4.0 → 0.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5e3294ffdbde01e5cf34236fb973cbf916f4987
4
- data.tar.gz: 687dc343a29876feddba4db109df1574284c57b6
3
+ metadata.gz: 27a961f9360e4b6b15247645a561d95d9175ffd2
4
+ data.tar.gz: b759cd45c821a2cdb7883c12571409c893a81356
5
5
  SHA512:
6
- metadata.gz: d56f38fa061aa4639af785b31277e83ea54161edaf04afaced21b874bf91cdb7bb9717daa29b6a4a850516b26e3cf5c95ba424bb3ed2c86536292dc275cf8175
7
- data.tar.gz: 888b1a5a779ea182d20677c37481067465bd4aecc2d8811616c4583cebc071555e0f9519867e16707b2900c61589c3cc4bdfb4e4f94694243e8ff27084701608
6
+ metadata.gz: 19531f61ada3020a7623c0636c6a65e1f88190690ec7da23aa2035d79edd80ea60c5a829fa2999232c042f84e3068787cc78ad583a6fbb010943178a6505c3a0
7
+ data.tar.gz: 4b8f4546f36ab1e8e934b895904b5540ca689ed97a464cd80589824b80780bf68a3436dc3d2adfc45f5adfcd85736ff38e72354d9a1134ec758884d03982795d
data/README.md CHANGED
@@ -32,20 +32,20 @@ This call behaves exactly as the normal resources :... call,
32
32
  but adds:
33
33
  ```ruby
34
34
  collection do
35
- get :batch_edit
36
- post :batch_update
35
+ get :collection_edit
36
+ post :collection_update
37
37
  end
38
38
  ```
39
39
  So the route definition in `config/routes.rb` defined as:
40
40
  ```ruby
41
- batch_resources :employees, except: [:new]
41
+ collection_resources :employees, except: [:new]
42
42
  ```
43
43
  is exactly the same as:
44
44
  ```ruby
45
45
  resources :employees, except: [:new] do
46
46
  collection do
47
- get :batch_edit
48
- post :batch_update
47
+ get :collection_edit
48
+ post :collection_update
49
49
  end
50
50
  end
51
51
  ```
@@ -74,26 +74,26 @@ See the [active_attr](https://github.com/cgriego/active_attr) gem for
74
74
  attribute definitions.
75
75
 
76
76
  ## Defining your controllers
77
- If you already used the specification `batch_resources :employees` in
77
+ If you already used the specification `collection_resources :employees` in
78
78
  your [config/routes.rb](spec/dummy/config/routes.rb) file you can add
79
79
  the actions in your controller typically looking like:
80
80
  ```ruby
81
81
  class EmployeesController < ApplicationController
82
82
  # your standard actions here
83
83
 
84
- # GET /employees/batch_edit?ids[]=1&ids[]=3&...
85
- def batch_edit
84
+ # GET /employees/collection_edit?ids[]=1&ids[]=3&...
85
+ def collection_edit
86
86
  @collection = Employee::Collection.find(params[:ids])
87
87
  redirect_to employees_path, alert: 'No employees selected' if @collection.empty?
88
88
  end
89
89
 
90
- # POST /employees/batch_update
91
- def batch_update
90
+ # POST /employees/collection_update
91
+ def collection_update
92
92
  @collection = Employee::Collection.find(params[:ids])
93
93
  if @collection.update params[:collection]
94
94
  redirect_to employees_path, notice: 'Collection is updated'
95
95
  else
96
- render 'batch_edit'
96
+ render 'collection_edit'
97
97
  end
98
98
  end
99
99
  end
@@ -104,7 +104,7 @@ model types.
104
104
 
105
105
  ## Creating your views
106
106
  The
107
- [app/views/employess/batch_edit.html.slim](spec/dummy/app/views/employees/batch_edit.html.slim) view is a tricky one.
107
+ [app/views/employess/collection_edit.html.slim](spec/dummy/app/views/employees/collection_edit.html.slim) view is a tricky one.
108
108
  Since we are working on a collection of record, and want to edit those
109
109
  attributes we just want a normal form for editing the attributes,
110
110
  treating the collection as the record itself. The problem however is
@@ -123,10 +123,10 @@ the standard [form_helpers](http://guides.rubyonrails.org/form_helpers.html)<br>
123
123
  * `optional_text_field`
124
124
  * `optional_input` ([simple_form](https://github.com/plataformatec/simple_form))
125
125
 
126
- The form you create typically looks like [app/views/employees/batch_edit.html.slim](spec/dummy/app/views/employees/batch_edit.html.slim):
126
+ The form you create typically looks like [app/views/employees/collection_edit.html.slim](spec/dummy/app/views/employees/collection_edit.html.slim):
127
127
  ```slim
128
128
  h1 Edit multiple employees
129
- = form_for @collection, url: [:batch_update, @collection.record_class] do |f|
129
+ = form_for @collection, url: [:collection_update, @collection.record_class] do |f|
130
130
  = f.collection_ids
131
131
  .form-inputs= f.optional_text_field :section
132
132
  .form-inputs= f.optional_boolean :admin
@@ -141,7 +141,7 @@ better understanding of how the optional fields work.
141
141
 
142
142
  ## Selecting records from the index using checkboxes (multi_select)
143
143
  The idea behind working with collections is that you end up as a `GET` request at:
144
- `+controller+/batch_edit?ids[]=2&ids[]=3` etc. How you achieve this
144
+ `+controller+/collection_edit?ids[]=2&ids[]=3` etc. How you achieve this
145
145
  is totally up to yourself, but this gem provides you with a nice
146
146
  standard way of selecting records from the index page. To filter records
147
147
  to a specific subset the [ransack](https://github.com/activerecord-hackery/ransack)
@@ -4,18 +4,18 @@ module ActionDispatch::Routing
4
4
  # This call behaves exactly as the normal resources :... call,
5
5
  # but adds:
6
6
  # collection do
7
- # get :batch_edit
8
- # post :batch_update
7
+ # get :collection_edit
8
+ # post :collection_update
9
9
  # end
10
- def batch_resources(*resources, &blk)
11
- batch_blk = Proc.new do
10
+ def collection_resources(*resources, &blk)
11
+ collection_blk = Proc.new do
12
12
  collection do
13
- get :batch_edit
14
- match :batch_update, via: [:post, :patch, :put]
13
+ get :collection_edit
14
+ match :collection_update, via: [:post, :patch, :put]
15
15
  end
16
16
  blk.call if blk
17
17
  end
18
- resources(*resources, &batch_blk)
18
+ resources(*resources, &collection_blk)
19
19
  end
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module RecordCollection
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -45,17 +45,17 @@ class EmployeesController < ApplicationController
45
45
  redirect_to employees_url, notice: 'Employee was successfully destroyed.'
46
46
  end
47
47
 
48
- def batch_edit
48
+ def collection_edit
49
49
  @collection = Employee::Collection.find(params[:ids])
50
50
  redirect_to employees_path, alert: 'No employees selected' if @collection.empty?
51
51
  end
52
52
 
53
- def batch_update
53
+ def collection_update
54
54
  @collection = Employee::Collection.find(params[:ids])
55
55
  if @collection.update params[:collection]
56
56
  redirect_to employees_path, notice: 'Collection is updated'
57
57
  else
58
- render 'batch_edit'
58
+ render 'collection_edit'
59
59
  end
60
60
  end
61
61
 
@@ -1,5 +1,5 @@
1
1
  h1 Edit multiple employees
2
- = form_for @collection, url: [:batch_update, @collection.record_class] do |f|
2
+ = form_for @collection, url: [:collection_update, @collection.record_class] do |f|
3
3
  = render 'form_errors', target: @collection
4
4
  .form-inputs= f.optional_text_field :section
5
5
  .form-inputs= f.optional_boolean :admin
@@ -20,6 +20,6 @@ table.with-selection
20
20
  td= link_to 'Edit', edit_employee_path(employee)
21
21
  td= link_to 'Destroy', employee, method: :delete, data: {confirm: 'Are you sure?' }
22
22
  br
23
- button.actions-button onclick="window.location = Routes.batch_edit_employees_path({ids: MultiSelect.selected_ids()})" Actions
23
+ button.actions-button onclick="window.location = Routes.collection_edit_employees_path({ids: MultiSelect.selected_ids()})" Actions
24
24
 
25
25
  = link_to 'New Employee', new_employee_path
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- batch_resources :employees
2
+ collection_resources :employees
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin ter Kuile
@@ -343,7 +343,7 @@ files:
343
343
  - spec/dummy/app/models/project.rb
344
344
  - spec/dummy/app/views/application/_form_errors.html.slim
345
345
  - spec/dummy/app/views/employees/_form.html.erb
346
- - spec/dummy/app/views/employees/batch_edit.html.slim
346
+ - spec/dummy/app/views/employees/collection_edit.html.slim
347
347
  - spec/dummy/app/views/employees/edit.html.erb
348
348
  - spec/dummy/app/views/employees/index.html.slim
349
349
  - spec/dummy/app/views/employees/new.html.erb
@@ -435,7 +435,7 @@ test_files:
435
435
  - spec/dummy/app/models/project.rb
436
436
  - spec/dummy/app/views/application/_form_errors.html.slim
437
437
  - spec/dummy/app/views/employees/_form.html.erb
438
- - spec/dummy/app/views/employees/batch_edit.html.slim
438
+ - spec/dummy/app/views/employees/collection_edit.html.slim
439
439
  - spec/dummy/app/views/employees/edit.html.erb
440
440
  - spec/dummy/app/views/employees/index.html.slim
441
441
  - spec/dummy/app/views/employees/new.html.erb