effective_resources 0.7.10 → 0.7.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e44162d953de99661aac288c2e8669aa08a5087
|
4
|
+
data.tar.gz: 596ef36a05b5da9e203b63ca8d7238f07adc8d7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43c8affec3f9c374ce8b360ca99af890f4ae15396f2fa0c9a4a7129ac707056e56b21a121dbdea040721f1c5519821fe003b49c13570c102ca7dd476b16fffd3
|
7
|
+
data.tar.gz: c349c0453fb2839f3c38ccad102dc247cdac31dae701c1ed3c8359a02c13d784e3ce2d42b995bf62802d2eaca76003dcbe84668319390b1b7e65068b83b21ab7
|
@@ -37,7 +37,7 @@ module EffectiveResourcesHelper
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# I think this is a bug. I can't override default button class when passing my own class: variable. it merges them.
|
40
|
-
if (btn_class = SimpleForm.button_class).present?
|
40
|
+
if defined?(SimpleForm) && (btn_class = SimpleForm.button_class).present?
|
41
41
|
buttons = buttons.map { |button| button.sub(btn_class, '') }
|
42
42
|
end
|
43
43
|
|
@@ -85,54 +85,7 @@ module EffectiveResourcesHelper
|
|
85
85
|
].compact.join
|
86
86
|
end
|
87
87
|
|
88
|
-
### Icon Helpers for actions_column or elsewhere
|
89
|
-
def show_icon_to(path, options = {})
|
90
|
-
glyphicon_to('eye-open', path, {title: 'Show'}.merge(options))
|
91
|
-
end
|
92
|
-
|
93
|
-
def edit_icon_to(path, options = {})
|
94
|
-
glyphicon_to('edit', path, {title: 'Edit'}.merge(options))
|
95
|
-
end
|
96
|
-
|
97
|
-
def destroy_icon_to(path, options = {})
|
98
|
-
defaults = {title: 'Destroy', data: {method: :delete, confirm: 'Delete this item?'}}
|
99
|
-
glyphicon_to('trash', path, defaults.merge(options))
|
100
|
-
end
|
101
|
-
|
102
|
-
def settings_icon_to(path, options = {})
|
103
|
-
glyphicon_to('cog', path, {title: 'Settings'}.merge(options))
|
104
|
-
end
|
105
|
-
|
106
|
-
def ok_icon_to(path, options = {})
|
107
|
-
glyphicon_to('ok', path, {title: 'OK'}.merge(options))
|
108
|
-
end
|
109
|
-
|
110
|
-
def approve_icon_to(path, options = {})
|
111
|
-
glyphicon_to('ok', path, {title: 'Approve'}.merge(options))
|
112
|
-
end
|
113
|
-
|
114
|
-
def remove_icon_to(path, options = {})
|
115
|
-
glyphicon_to('remove', path, {title: 'Remove'}.merge(options))
|
116
|
-
end
|
117
|
-
|
118
|
-
def glyphicon_tag(icon, options = {})
|
119
|
-
if icon.to_s.start_with?('glyphicon-')
|
120
|
-
content_tag(:span, '', {class: "glyphicon #{icon}"}.merge(options))
|
121
|
-
else
|
122
|
-
content_tag(:span, '', {class: "glyphicon glyphicon-#{icon}"}.merge(options))
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def glyphicon_to(icon, path, options = {})
|
127
|
-
content_tag(:a, options.merge(href: path)) do
|
128
|
-
glyphicon_tag(icon)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
alias_method :bootstrap_icon_to, :glyphicon_to
|
132
|
-
alias_method :glyph_icon_to, :glyphicon_to
|
133
|
-
|
134
88
|
### Tableize attributes
|
135
|
-
|
136
89
|
# This is used by effective_orders, effective_logging, effective_trash and effective_mergery
|
137
90
|
def tableize_hash(obj, table: 'table', th: true, sub_table: 'table', sub_th: true, flatten: true)
|
138
91
|
case obj
|
@@ -22,31 +22,31 @@ module Effective
|
|
22
22
|
case sql_type
|
23
23
|
when :belongs_to
|
24
24
|
relation
|
25
|
-
.order("#{is_null(sql_column)} ASC")
|
25
|
+
.order(Arel.sql("#{is_null(sql_column)} ASC"))
|
26
26
|
.order(order_by_associated_conditions(association, sort: sort, direction: direction, limit: limit))
|
27
27
|
when :belongs_to_polymorphic
|
28
28
|
relation
|
29
|
-
.order("#{sql_column}_type #{sql_direction}")
|
30
|
-
.order("#{sql_column}_id #{sql_direction}")
|
29
|
+
.order(Arel.sql("#{sql_column}_type #{sql_direction}"))
|
30
|
+
.order(Arel.sql("#{sql_column}_id #{sql_direction}"))
|
31
31
|
when :has_and_belongs_to_many, :has_many, :has_one
|
32
32
|
relation
|
33
33
|
.order(order_by_associated_conditions(association, sort: sort, direction: direction, limit: limit))
|
34
|
-
.order("#{sql_column(klass.primary_key)} #{sql_direction}")
|
34
|
+
.order(Arel.sql("#{sql_column(klass.primary_key)} #{sql_direction}"))
|
35
35
|
when :effective_addresses
|
36
36
|
relation
|
37
37
|
.order(order_by_associated_conditions(associated(:addresses), sort: sort, direction: direction, limit: limit))
|
38
|
-
.order("#{sql_column(klass.primary_key)} #{sql_direction}")
|
38
|
+
.order(Arel.sql("#{sql_column(klass.primary_key)} #{sql_direction}"))
|
39
39
|
when :effective_roles
|
40
|
-
relation.order("#{sql_column(:roles_mask)} #{sql_direction}")
|
40
|
+
relation.order(Arel.sql("#{sql_column(:roles_mask)} #{sql_direction}"))
|
41
41
|
when :string, :text
|
42
42
|
relation
|
43
|
-
.order(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column}='' ASC, #{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s)
|
43
|
+
.order(Arel.sql(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column}='' ASC, #{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s))
|
44
44
|
when :time
|
45
45
|
relation
|
46
|
-
.order(("ISNULL(#{sql_column}), " if mysql?).to_s + "EXTRACT(hour from #{sql_column}) #{sql_direction}, EXTRACT(minute from #{sql_column}) #{sql_direction}" + (" NULLS LAST" if postgres?).to_s)
|
46
|
+
.order(Arel.sql(("ISNULL(#{sql_column}), " if mysql?).to_s + "EXTRACT(hour from #{sql_column}) #{sql_direction}, EXTRACT(minute from #{sql_column}) #{sql_direction}" + (" NULLS LAST" if postgres?).to_s))
|
47
47
|
else
|
48
48
|
relation
|
49
|
-
.order(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s)
|
49
|
+
.order(Arel.sql(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s))
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
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.11
|
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-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- app/assets/javascripts/effective_resources/effective_ujs.js
|
38
38
|
- app/controllers/concerns/effective/crud_controller.rb
|
39
39
|
- app/controllers/concerns/effective/flash_messages.rb
|
40
|
-
- app/helpers/effective_bootstrap3_helper.rb
|
41
40
|
- app/helpers/effective_resources_helper.rb
|
42
41
|
- app/models/effective/access_denied.rb
|
43
42
|
- app/models/effective/attribute.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module EffectiveBootstrap3Helper
|
2
|
-
|
3
|
-
# An effective Bootstrap3 menu DSL
|
4
|
-
# Automatically puts in the 'active' class based on request path
|
5
|
-
|
6
|
-
# %ul.nav.navbar-nav.navbar-right
|
7
|
-
# = nav_link_to 'Sign In', new_user_session_path
|
8
|
-
# = nav_dropdown 'Settings' do
|
9
|
-
# = nav_link_to 'Account Settings', user_settings_path
|
10
|
-
# %li.divider
|
11
|
-
# = nav_link_to 'Sign In', new_user_session_path, method: :delete
|
12
|
-
def nav_link_to(label, path, opts = {})
|
13
|
-
content_tag(:li, class: ('active' if request.fullpath.include?(path))) do
|
14
|
-
link_to(label, path, opts)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def nav_dropdown(label, link_class: [], list_class: [], &block)
|
19
|
-
raise 'expected a block' unless block_given?
|
20
|
-
|
21
|
-
content_tag(:li, class: 'dropdown') do
|
22
|
-
content_tag(:a, class: 'dropdown-toggle', href: '#', 'data-toggle': 'dropdown', role: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false') do
|
23
|
-
label.html_safe + content_tag(:span, '', class: 'caret')
|
24
|
-
end + content_tag(:ul, class: 'dropdown-menu') { yield }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# An effective Bootstrap3 tabpanel DSL
|
29
|
-
# Inserts both the tablist and the tabpanel
|
30
|
-
|
31
|
-
# = tabs do
|
32
|
-
# = tab 'Imports' do
|
33
|
-
# %p Imports
|
34
|
-
|
35
|
-
# = tab 'Exports' do
|
36
|
-
# %p Exports
|
37
|
-
|
38
|
-
# If you pass active 'label' it will make that tab active. Otherwise first.
|
39
|
-
def tabs(active: nil, panel: {}, list: {}, content: {}, &block)
|
40
|
-
raise 'expected a block' unless block_given?
|
41
|
-
|
42
|
-
@_tab_mode = :panel
|
43
|
-
@_tab_active = (active || :first)
|
44
|
-
|
45
|
-
content_tag(:div, {role: 'tabpanel'}.merge(panel)) do
|
46
|
-
content_tag(:ul, {class: 'nav nav-tabs', role: 'tablist'}.merge(list)) { yield } # Yield to tab the first time
|
47
|
-
end + content_tag(:div, {class: 'tab-content'}.merge(content)) do
|
48
|
-
@_tab_mode = :content
|
49
|
-
@_tab_active = (active || :first)
|
50
|
-
yield # Yield tot ab the second time
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def tab(label, controls = nil, &block)
|
55
|
-
controls ||= label.to_s.parameterize.gsub('_', '-')
|
56
|
-
controls = controls[1..-1] if controls[0] == '#'
|
57
|
-
|
58
|
-
active = (@_tab_active == :first || @_tab_active == label)
|
59
|
-
|
60
|
-
@_tab_active = nil if @_tab_active == :first
|
61
|
-
|
62
|
-
if @_tab_mode == :panel # Inserting the label into the tabpanel top
|
63
|
-
content_tag(:li, role: 'presentation', class: ('active' if active)) do
|
64
|
-
content_tag(:a, href: '#' + controls, 'aria-controls': controls, 'data-toggle': 'tab', role: 'tab') do
|
65
|
-
label
|
66
|
-
end
|
67
|
-
end
|
68
|
-
else # Inserting the content into the tab itself
|
69
|
-
content_tag(:div, id: controls, class: "tab-pane#{' active' if active}", role: 'tabpanel') do
|
70
|
-
yield
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|