effective_resources 0.7.11 → 0.7.12

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: 2e44162d953de99661aac288c2e8669aa08a5087
4
- data.tar.gz: 596ef36a05b5da9e203b63ca8d7238f07adc8d7f
3
+ metadata.gz: 9a6b2c73dd66b692135a690dc812d2dba68b4597
4
+ data.tar.gz: 16f8e2a01244f8b050a803199aec7133babfa717
5
5
  SHA512:
6
- metadata.gz: 43c8affec3f9c374ce8b360ca99af890f4ae15396f2fa0c9a4a7129ac707056e56b21a121dbdea040721f1c5519821fe003b49c13570c102ca7dd476b16fffd3
7
- data.tar.gz: c349c0453fb2839f3c38ccad102dc247cdac31dae701c1ed3c8359a02c13d784e3ce2d42b995bf62802d2eaca76003dcbe84668319390b1b7e65068b83b21ab7
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' => { action: :save, data: { disable_with: 'Saving...' }},
14
- 'Continue' => { action: :save, data: { disable_with: 'Saving...' }},
15
- 'Add New' => { action: :save, data: { disable_with: 'Saving...' }}
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 simple_form_submit(form, options = {}, &block)
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].present?
10
- opts
11
- else
12
- opts[:class] = "btn #{index == 0 ? 'btn-primary' : 'btn-default'}"
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-xs-8
6
+ .col-8
7
7
  %h1= @page_title
8
- .col-xs-4.text-right
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-xs-8
4
+ .col-8
5
5
  %h1= @page_title
6
- .col-xs-4.text-right
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,7 +3,7 @@
3
3
 
4
4
  - if @resource
5
5
  .row
6
- .col-xs-8
6
+ .col-8
7
7
  %h1= @page_title
8
8
 
9
9
  = render_resource_form(resource)
@@ -3,9 +3,9 @@
3
3
 
4
4
  - if @resource
5
5
  .row
6
- .col-xs-8
6
+ .col-8
7
7
  %h1= @page_title
8
- .col-xs-4.text-right
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,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '0.7.11'.freeze
2
+ VERSION = '0.7.12'.freeze
3
3
  end
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.11
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-02-20 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails