rao-resources_controller 0.0.41.pre → 0.0.46.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/concerns/rao/resources_controller/aasm_concern.rb +30 -0
  3. data/app/concerns/rao/resources_controller/batch_actions_concern.rb +5 -1
  4. data/app/views/rao/resources_controller/base/{_after_show_table.haml → _after_show_table.html.haml} +0 -0
  5. data/app/views/rao/resources_controller/base/{_before_index_table.haml → _before_index_table.html.haml} +0 -0
  6. data/app/views/rao/resources_controller/base/{_before_show_table.haml → _before_show_table.html.haml} +0 -0
  7. data/app/views/rao/resources_controller/base/{_form.haml → _form.html.haml} +0 -0
  8. data/app/views/rao/resources_controller/base/_form_buttons.html.haml +5 -0
  9. data/app/views/rao/resources_controller/base/{_form_errors.haml → _form_errors.html.haml} +1 -1
  10. data/app/views/rao/resources_controller/base/{_pagination.haml → _pagination.html.haml} +0 -0
  11. data/app/views/rao/resources_controller/base/{_show.haml → _show.html.haml} +0 -0
  12. data/app/views/rao/resources_controller/base/_show_actions.html.haml +11 -0
  13. data/app/views/rao/resources_controller/base/{_table.haml → _table.html.haml} +0 -0
  14. data/app/views/rao/resources_controller/base/_table_actions.html.haml +12 -0
  15. data/app/views/rao/resources_controller/base/{edit.haml → edit.html.haml} +1 -1
  16. data/app/views/rao/resources_controller/base/{index.haml → index.html.haml} +2 -2
  17. data/app/views/rao/resources_controller/base/{new.haml → new.html.haml} +1 -1
  18. data/app/views/rao/resources_controller/base/{show.haml → show.html.haml} +1 -1
  19. data/config/locales/de.yml +6 -2
  20. data/config/locales/en.yml +6 -2
  21. data/lib/generators/rao/resources_controller/templates/initializer.rb +16 -0
  22. data/lib/rao/resources_controller.rb +3 -0
  23. data/lib/rao/resources_controller/configuration.rb +17 -3
  24. data/{app/concerns → lib}/rao/resources_controller/routing/acts_as_list_concern.rb +0 -0
  25. data/{app/concerns → lib}/rao/resources_controller/routing/acts_as_published_concern.rb +0 -0
  26. metadata +21 -20
  27. data/app/views/rao/resources_controller/base/_form_buttons.haml +0 -5
  28. data/app/views/rao/resources_controller/base/_show_actions.haml +0 -11
  29. data/app/views/rao/resources_controller/base/_table_actions.haml +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcc444b66e4068d44f8b9202c3aebd83a270b13ae4531fa2ec9bc01d0465dbd9
4
- data.tar.gz: b5a80c536bfce97b9b7dad809a92380d19b84b6e5de9b2edde06f2ceb4359c76
3
+ metadata.gz: 744f4aa8b0e61a7dd6f7b37ef153f3e72c2f7b9c72597a3b1f19de98640a3e4a
4
+ data.tar.gz: b0df95591066223fe6b1197b5559792575fa1989f13f5115cb6ffe0733d7ba86
5
5
  SHA512:
6
- metadata.gz: 8852c4c879945143f22b9458b5e7220a3ef912086f8a3980a15da7020179ec73db6f8302d36eb610b8f85d37ffb15cedc79ec550802b31911834f8050539c3af
7
- data.tar.gz: ce38536558dee7755317a8d9a128b63fff4b5f3cd9ce734788ce3fdb0898a02b4e30102998a7bcd229b1598bb1cf2258bf7b3f6e1bb8057bf93f8f65ea09e15c
6
+ metadata.gz: a229dbe1a6b24769674fc01263020fd67f68a0d4e616cd90e96378f689caa8468ab8de05d4dbe2141196bdcc3420adee5048b842057c46717b389d9cc9624172
7
+ data.tar.gz: 966e0aaa556c440e9f31a3951efb6c3fa638259dcaea807b6f59d2fa10c8365ed8ae8b1306de68506af5e06e100e2a6c3120dbec9eb9507cb582ac468af7ad61
@@ -0,0 +1,30 @@
1
+ module Rao
2
+ module ResourcesController
3
+ module AasmConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ before_action :load_resource_for_trigger_event, only: [:trigger_event]
8
+ end
9
+
10
+ def trigger_event
11
+ if @resource.aasm(permitted_params_for_trigger_event[:machine_name].to_sym).fire!(permitted_params_for_trigger_event[:event_name].to_sym)
12
+ flash[:notice] = t('rao.resources_controller.aasm_concern.trigger_event.success', state: @resource.aasm(permitted_params_for_trigger_event[:machine_name].to_sym).current_state, event: permitted_params_for_trigger_event[:event_name])
13
+ else
14
+ flash[:notice] = t('rao.resources_controller.aasm_concern.trigger_event.failure', state: @resource.aasm(permitted_params_for_trigger_event[:machine_name].to_sym).current_state, event: permitted_params_for_trigger_event[:event_name])
15
+ end
16
+ redirect_back(fallback_location: root_path)
17
+ end
18
+
19
+ private
20
+
21
+ def permitted_params_for_trigger_event
22
+ params.permit!
23
+ end
24
+
25
+ def load_resource_for_trigger_event
26
+ load_resource
27
+ end
28
+ end
29
+ end
30
+ end
@@ -9,9 +9,13 @@ module Rao
9
9
  module ResourcesController::BatchActionsConcern
10
10
  def destroy_many
11
11
  @collection = load_collection_scope.where(id: params[:ids])
12
+ count = @collection.count
12
13
  @collection.destroy_all
13
14
 
14
- respond_with @collection, location: after_destroy_many_location, notice: t('.success', count: @collection.count)
15
+ default_message = t('.success', inflections.merge(count: count))
16
+ respond_with @collection,
17
+ location: after_destroy_many_location,
18
+ notice: t('rao.resources_controller.batch_actions_concern.destroy_many.success', inflections.merge(count: count, default: default_message))
15
19
  end
16
20
 
17
21
  private
@@ -0,0 +1,5 @@
1
+ = form.button :submit, class: 'btn btn-success' do
2
+ = fa_icon :check
3
+ = t('.submit', model_name: form.object.model_name.human)
4
+ = link_to(((action_name == 'new' || form.object.new_record?) ? collection_path : resource_path(form.object)), class: 'btn btn-link') do
5
+ = t('.cancel')
@@ -1,5 +1,5 @@
1
1
  - if resource.errors.any?
2
- = bootstrap_alert(context: :danger, class: 'error-explanation') do
2
+ .alert.alert-danger.error-explanation
3
3
  .error-heading= t('errors.template.header', count: resource.errors.count, model: resource.class.model_name.human)
4
4
  %ul
5
5
  - resource.errors.full_messages.each do |msg|
@@ -0,0 +1,11 @@
1
+ .btn-group
2
+ = link_to(edit_resource_path(resource), class: 'btn btn-secondary') do
3
+ %i.fas.fa-edit
4
+ = t('.edit')
5
+
6
+ = link_to(resource_path(resource), class: 'btn btn-danger', method: :delete, data: { confirm: t('.destroy_confirmation') }) do
7
+ %i.fas.fa-trash
8
+ = t('.destroy')
9
+
10
+ = link_to(collection_path, class: 'btn btn-link') do
11
+ = t('.back')
@@ -0,0 +1,12 @@
1
+ = table.column :actions, title: '' do |resource|
2
+ - capture_haml do
3
+ .btn-group
4
+ = link_to(resource_path(resource), class: 'btn btn-sm btn-primary') do
5
+ %i.fas.fa-eye
6
+ = t('.show')
7
+ = link_to(edit_resource_path(resource), class: 'btn btn-sm btn-secondary') do
8
+ %i.fas.fa-edit
9
+ = t('.edit')
10
+ = link_to(resource_path(resource), class: 'btn btn-sm btn-danger', method: :delete, data: { confirm: t('.destroy_confirmation') }) do
11
+ %i.fas.fa-trash
12
+ = t('.destroy')
@@ -1,6 +1,6 @@
1
1
  %h1= t('.title', inflections)
2
2
 
3
- = bootstrap_form_for(@resource, url: resource_path(@resource)) do |f|
3
+ = simple_form_for(@resource, url: resource_path(@resource)) do |f|
4
4
  = render 'form_errors', resource: f.object
5
5
  = render 'form', form: f
6
6
  = render 'form_buttons', form: f
@@ -2,8 +2,8 @@
2
2
  %span
3
3
  = resource_class.model_name.human(count: :other)
4
4
  .pull-right
5
- = bootstrap_button(to: new_resource_path, context: :success) do
6
- = fa_icon(:plus)
5
+ = link_to(new_resource_path, class: 'btn btn-success') do
6
+ %i.fas.fa-plus
7
7
  = t('.new')
8
8
 
9
9
  = render 'before_index_table', collection: @collection
@@ -1,6 +1,6 @@
1
1
  %h1= t('.title', inflections)
2
2
 
3
- = bootstrap_form_for(@resource, url: collection_path) do |f|
3
+ = simple_form_for(@resource, url: collection_path) do |f|
4
4
  = render 'form_errors', resource: f.object
5
5
  = render 'form', form: f
6
6
  = render 'form_buttons', form: f
@@ -1,4 +1,4 @@
1
- %h1= @resource.try_all(:human, :title, :name, :to_s)
1
+ %h1= Rao::ResourcesController::Configuration.label_for_resource_proc.call(@resource)
2
2
 
3
3
  = render 'before_show_table', resource: @resource
4
4
 
@@ -43,5 +43,9 @@ de:
43
43
  title: "%{resource_name} erstellen"
44
44
  show_actions:
45
45
  back: "Zurück"
46
- delete: "Löschen"
47
- edit: "Bearbeiten"
46
+ destroy: "Löschen"
47
+ destroy_confirmation: "Sind Sie sicher?"
48
+ edit: "Bearbeiten"
49
+ batch_actions_concern:
50
+ destroy_many:
51
+ success: "%{count} %{collection_name} wurden gelöscht."
@@ -43,5 +43,9 @@ en:
43
43
  title: "New %{resource_name}"
44
44
  show_actions:
45
45
  back: "Back"
46
- delete: "Delete"
47
- edit: "Edit"
46
+ destroy: "Delete"
47
+ destroy_confirmation: "Are you sure?"
48
+ edit: "Edit"
49
+ batch_actions_concern:
50
+ destroy_many:
51
+ success: "Deleted %{count} %{collection_name}."
@@ -12,4 +12,20 @@ Rao::ResourcesController.configure do |config|
12
12
  # default: config.pagination_per_page_default = 25
13
13
  #
14
14
  config.pagination_per_page_default = 25
15
+
16
+ # Configures how a label will be created for resources.
17
+ #
18
+ # default: config.label_for_resource_proc = lambda do |resource|
19
+ # [:human, :title, :name, :to_s].each do |method_name|
20
+ # next unless resource.respond_to?(method_name)
21
+ # return resource.send(method_name)
22
+ # end
23
+ # end
24
+ #
25
+ config.label_for_resource_proc = lambda do |resource|
26
+ [:human, :title, :name, :to_s].each do |method_name|
27
+ next unless resource.respond_to?(method_name)
28
+ return resource.send(method_name)
29
+ end
30
+ end
15
31
  end
@@ -2,6 +2,9 @@ require "rao/resources_controller/configuration"
2
2
  require "rao/resources_controller/version"
3
3
  require "rao/resources_controller/engine"
4
4
 
5
+ require "rao/resources_controller/routing/acts_as_list_concern"
6
+ require "rao/resources_controller/routing/acts_as_published_concern"
7
+
5
8
  module Rao
6
9
  module ResourcesController
7
10
  extend Configuration
@@ -5,8 +5,22 @@ module Rao
5
5
  yield self
6
6
  end
7
7
 
8
- mattr_accessor(:resources_controller_base_class_name) { "::ApplicationController" }
9
- mattr_accessor(:pagination_per_page_default) { 25 }
8
+ mattr_accessor(:resources_controller_base_class_name) do
9
+ "::ApplicationController"
10
+ end
11
+
12
+ mattr_accessor(:pagination_per_page_default) do
13
+ 25
14
+ end
15
+
16
+ mattr_accessor(:label_for_resource_proc) do
17
+ lambda do |resource|
18
+ [:human, :title, :name, :to_s].each do |method_name|
19
+ next unless resource.respond_to?(method_name)
20
+ return resource.send(method_name)
21
+ end
22
+ end
23
+ end
10
24
  end
11
25
  end
12
- end
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rao-resources_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.41.pre
4
+ version: 0.0.46.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-24 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -147,6 +147,7 @@ files:
147
147
  - README.md
148
148
  - Rakefile
149
149
  - app/concerns/rao/controller/autosubmit_concern.rb
150
+ - app/concerns/rao/resources_controller/aasm_concern.rb
150
151
  - app/concerns/rao/resources_controller/acts_as_list_concern.rb
151
152
  - app/concerns/rao/resources_controller/acts_as_published_concern.rb
152
153
  - app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
@@ -159,26 +160,24 @@ files:
159
160
  - app/concerns/rao/resources_controller/resources_concern.rb
160
161
  - app/concerns/rao/resources_controller/rest_actions_concern.rb
161
162
  - app/concerns/rao/resources_controller/rest_resource_urls_concern.rb
162
- - app/concerns/rao/resources_controller/routing/acts_as_list_concern.rb
163
- - app/concerns/rao/resources_controller/routing/acts_as_published_concern.rb
164
163
  - app/concerns/rao/resources_controller/sorting_concern.rb
165
164
  - app/concerns/rao/resources_controller/will_paginate_concern.rb
166
165
  - app/controllers/rao/resources_controller/base.rb
167
- - app/views/rao/resources_controller/base/_after_show_table.haml
168
- - app/views/rao/resources_controller/base/_before_index_table.haml
169
- - app/views/rao/resources_controller/base/_before_show_table.haml
170
- - app/views/rao/resources_controller/base/_form.haml
171
- - app/views/rao/resources_controller/base/_form_buttons.haml
172
- - app/views/rao/resources_controller/base/_form_errors.haml
173
- - app/views/rao/resources_controller/base/_pagination.haml
174
- - app/views/rao/resources_controller/base/_show.haml
175
- - app/views/rao/resources_controller/base/_show_actions.haml
176
- - app/views/rao/resources_controller/base/_table.haml
177
- - app/views/rao/resources_controller/base/_table_actions.haml
178
- - app/views/rao/resources_controller/base/edit.haml
179
- - app/views/rao/resources_controller/base/index.haml
180
- - app/views/rao/resources_controller/base/new.haml
181
- - app/views/rao/resources_controller/base/show.haml
166
+ - app/views/rao/resources_controller/base/_after_show_table.html.haml
167
+ - app/views/rao/resources_controller/base/_before_index_table.html.haml
168
+ - app/views/rao/resources_controller/base/_before_show_table.html.haml
169
+ - app/views/rao/resources_controller/base/_form.html.haml
170
+ - app/views/rao/resources_controller/base/_form_buttons.html.haml
171
+ - app/views/rao/resources_controller/base/_form_errors.html.haml
172
+ - app/views/rao/resources_controller/base/_pagination.html.haml
173
+ - app/views/rao/resources_controller/base/_show.html.haml
174
+ - app/views/rao/resources_controller/base/_show_actions.html.haml
175
+ - app/views/rao/resources_controller/base/_table.html.haml
176
+ - app/views/rao/resources_controller/base/_table_actions.html.haml
177
+ - app/views/rao/resources_controller/base/edit.html.haml
178
+ - app/views/rao/resources_controller/base/index.html.haml
179
+ - app/views/rao/resources_controller/base/new.html.haml
180
+ - app/views/rao/resources_controller/base/show.html.haml
182
181
  - config/initializers/include_routing_concerns.rb
183
182
  - config/locales/de.yml
184
183
  - config/locales/en.yml
@@ -188,6 +187,8 @@ files:
188
187
  - lib/rao/resources_controller.rb
189
188
  - lib/rao/resources_controller/configuration.rb
190
189
  - lib/rao/resources_controller/engine.rb
190
+ - lib/rao/resources_controller/routing/acts_as_list_concern.rb
191
+ - lib/rao/resources_controller/routing/acts_as_published_concern.rb
191
192
  - lib/rao/resources_controller/version.rb
192
193
  - lib/tasks/rao-resources_controller_tasks.rake
193
194
  homepage: https://github.com/rails-add_ons
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
210
  - !ruby/object:Gem::Version
210
211
  version: 1.3.1
211
212
  requirements: []
212
- rubygems_version: 3.1.2
213
+ rubygems_version: 3.1.4
213
214
  signing_key:
214
215
  specification_version: 4
215
216
  summary: Resources Controllers for Ruby on Rails.
@@ -1,5 +0,0 @@
1
- = form.button :submit, class: 'btn btn-success' do
2
- = fa_icon :check
3
- = t('.submit', model_name: form.object.model_name.human)
4
- = bootstrap_button(to: ((action_name == 'new' || form.object.new_record?) ? collection_path : resource_path(form.object)), context: :link) do
5
- = t('.cancel')
@@ -1,11 +0,0 @@
1
- = bootstrap_button_group do
2
- = bootstrap_button(to: edit_resource_path(resource), context: :secondary) do
3
- = fa_icon(:pencil)
4
- = t('.edit')
5
-
6
- = bootstrap_button(to: resource_path(resource), context: :danger, method: :delete, data: { confirm: 'Are you sure?' }) do
7
- = fa_icon :trash
8
- = t('.destroy')
9
-
10
- = bootstrap_button(to: collection_path, context: :link) do
11
- = t('.back')
@@ -1,12 +0,0 @@
1
- = table.column :actions do |resource|
2
- - capture_haml do
3
- = bootstrap_button_group do
4
- = bootstrap_button(to: resource_path(resource), context: :primary, size: :small) do
5
- = fa_icon :eye
6
- = t('.show')
7
- = bootstrap_button(to: edit_resource_path(resource), context: :secondary, size: :small) do
8
- = fa_icon :pencil
9
- = t('.edit')
10
- = bootstrap_button(to: resource_path(resource), context: :danger, size: :small, method: :delete, data: { confirm: 'Are you sure?' }) do
11
- = fa_icon :trash
12
- = t('.destroy')