effective_resources 0.7.11 → 0.7.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/crud_controller.rb +9 -5
- data/app/helpers/effective_resources_helper.rb +39 -5
- data/app/views/application/edit.html.haml +2 -2
- data/app/views/application/index.html.haml +2 -2
- data/app/views/application/new.html.haml +1 -1
- data/app/views/application/show.html.haml +2 -2
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a6b2c73dd66b692135a690dc812d2dba68b4597
|
4
|
+
data.tar.gz: 16f8e2a01244f8b050a803199aec7133babfa717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb8cf1b6bf38f2e8bb5648ff8e7853236925f362631bfcea009839d5e2a8f32e849b1040a514fac477c08190791edbfb1db1aed53e317045927836905b4b1de1
|
7
|
+
data.tar.gz: f12eb117c2ed212cae9a7335c57d92100c1828dcee1f736e3fe0eb8a5151645b028d7240c84721588a0a061bdd9adc90cb1a25458d2304f4a6c81bc394f737a6
|
@@ -9,11 +9,15 @@ module Effective
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def _default_member_actions
|
12
|
-
|
13
|
-
'Save'
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
if defined?(EffectiveBootstrap)
|
13
|
+
{ 'Save': { action: :save }, 'Continue': { action: :save }, 'Add New': { action: :save } }
|
14
|
+
else
|
15
|
+
{
|
16
|
+
'Save' => { action: :save, data: { disable_with: 'Saving...' }},
|
17
|
+
'Continue' => { action: :save, data: { disable_with: 'Saving...' }},
|
18
|
+
'Add New' => { action: :save, data: { disable_with: 'Saving...' }}
|
19
|
+
}
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
@@ -1,17 +1,51 @@
|
|
1
1
|
module EffectiveResourcesHelper
|
2
2
|
|
3
|
-
def
|
3
|
+
def effective_submit(form, options = {}, &block) # effective_bootstrap
|
4
4
|
resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
5
5
|
|
6
6
|
# Apply btn-primary to the first item, only if the class isn't already present
|
7
7
|
actions = if controller.respond_to?(:member_actions_for)
|
8
8
|
controller.member_actions_for(form.object).transform_values.with_index do |opts, index|
|
9
|
-
if opts[:class].
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
opts[:class] = "btn #{index == 0 ? 'btn-primary' : 'btn-secondary'}" if opts[:class].blank?
|
10
|
+
opts
|
11
|
+
end
|
12
|
+
else
|
13
|
+
{}.tap do |actions|
|
14
|
+
actions['Save'] = { class: 'btn btn-primary' }
|
15
|
+
|
16
|
+
if resource.action_path(:index) && EffectiveResources.authorized?(controller, :index, resource.klass)
|
17
|
+
actions['Continue'] = { class: 'btn btn-secondary' }
|
13
18
|
end
|
14
19
|
|
20
|
+
if resource.action_path(:new) && EffectiveResources.authorized?(controller, :new, resource.klass)
|
21
|
+
actions['Add New'] = { class: 'btn btn-secondary' }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
wrapper = (form.layout == :horizontal) ? { class: 'form-group form-actions row' } : { class: 'form-group form-actions' }
|
27
|
+
|
28
|
+
content_tag(:div, wrapper) do
|
29
|
+
buttons = actions.group_by { |_, opts| opts[:class] }.flat_map do |_, grouped|
|
30
|
+
grouped.map { |name, opts| form.save(name, opts) } + ['']
|
31
|
+
end
|
32
|
+
|
33
|
+
if block_given?
|
34
|
+
buttons = [capture(&block), ''] + buttons
|
35
|
+
end
|
36
|
+
|
37
|
+
([icon('spinner'), '', ''] + buttons).join(' ').html_safe
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# effective_form_inputs
|
42
|
+
def simple_form_submit(form, options = {}, &block)
|
43
|
+
resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
44
|
+
|
45
|
+
# Apply btn-primary to the first item, only if the class isn't already present
|
46
|
+
actions = if controller.respond_to?(:member_actions_for)
|
47
|
+
controller.member_actions_for(form.object).transform_values.with_index do |opts, index|
|
48
|
+
opts[:class] = "btn #{index == 0 ? 'btn-primary' : 'btn-default'}" if opts[:class].blank?
|
15
49
|
opts
|
16
50
|
end
|
17
51
|
else
|
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
- if @resource
|
5
5
|
.row
|
6
|
-
.col-
|
6
|
+
.col-8
|
7
7
|
%h1= @page_title
|
8
|
-
.col-
|
8
|
+
.col-4.text-right
|
9
9
|
- resource.member_post_actions.each do |action|
|
10
10
|
- if EffectiveResources.authorized?(controller, action, @resource) && (path = resource.action_path(action, @resource)).present?
|
11
11
|
= link_to action.to_s.titleize, path, class: 'btn btn-sm btn-primary', data: { confirm: "Really #{action} #{@resource}?", method: :post }
|
@@ -1,9 +1,9 @@
|
|
1
1
|
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
2
|
|
3
3
|
.row
|
4
|
-
.col-
|
4
|
+
.col-8
|
5
5
|
%h1= @page_title
|
6
|
-
.col-
|
6
|
+
.col-4.text-right
|
7
7
|
- if EffectiveResources.authorized?(controller, :new, resource.klass) && (path = resource.action_path(:new)).present?
|
8
8
|
= link_to "New #{resource.human_name.titleize}", path, class: 'btn btn-primary'
|
9
9
|
|
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
- if @resource
|
5
5
|
.row
|
6
|
-
.col-
|
6
|
+
.col-8
|
7
7
|
%h1= @page_title
|
8
|
-
.col-
|
8
|
+
.col-4.text-right
|
9
9
|
- resource.member_post_actions.each do |action|
|
10
10
|
- if EffectiveResources.authorized?(controller, action, @resource) && (path = resource.action_path(action, @resource)).present?
|
11
11
|
= link_to action.to_s.titleize, path, class: 'btn btn-sm btn-primary', data: { confirm: "Really #{action} #{@resource}?", method: :post }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|