effective_resources 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -1
- data/app/helpers/effective_bootstrap3_helper.rb +73 -0
- data/app/models/effective/attribute.rb +8 -1
- data/lib/effective_resources/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fde8a7116e90e55e54e43b683dac085b29af3dae
|
4
|
+
data.tar.gz: 187aa06eba950381a7162ff8f4f7ad3d47456414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6caec9e92919a827a1722c299bc6822bd8cc92ba911ac6a6f3d0c7005302cbd249b9a47ad3b8d862e07fc86b580b373486166a0fb287a7a5dd7bcdde7a0c398c
|
7
|
+
data.tar.gz: 3a0756a8dcb1d1d7267152f80714a87fe22817cc22656dee89eef7c6c05729f69fae4a9bb9c2077ead73e89ffa3363f7ec1407d8d00a9afe13766e6240ad44ed
|
data/README.md
CHANGED
@@ -76,7 +76,55 @@ Implements the 7 RESTful actions: `index`, `new`, `create`, `show`, `edit`, `upd
|
|
76
76
|
- Does the right thing with member and collection actions
|
77
77
|
- Intelligently redirects based on commit message
|
78
78
|
|
79
|
-
## Helpers
|
79
|
+
## Bootstrap3 Helpers
|
80
|
+
|
81
|
+
### nav_link_to
|
82
|
+
|
83
|
+
Use `nav_link_to` and `nav_dropdown` to create bootstrap3 menus.
|
84
|
+
|
85
|
+
The helper automatically assigns the `active` class based on the request path.
|
86
|
+
|
87
|
+
```haml
|
88
|
+
%nav.navbar.navbar-default
|
89
|
+
.container
|
90
|
+
.navbar-header
|
91
|
+
= link_to(image_tag('logo.png', alt: 'Logo'), '/', class: 'navbar-brand')
|
92
|
+
%button.navbar-toggle.collapsed{data: {toggle: 'collapse', target: '.navbar-collapse', 'aria-expanded': false}}
|
93
|
+
%span.icon-bar
|
94
|
+
%span.icon-bar
|
95
|
+
%span.icon-bar
|
96
|
+
.collapse.navbar-collapse
|
97
|
+
%ul.nav.navbar-nav.navbar-right
|
98
|
+
- if current_user.present?
|
99
|
+
- if can?(:index, Things)
|
100
|
+
= nav_link_to 'Things', things_path
|
101
|
+
|
102
|
+
= nav_dropdown 'Settings' do
|
103
|
+
= nav_link_to 'Account Settings', user_settings_path
|
104
|
+
%li.divider
|
105
|
+
= nav_link_to 'Sign Out', destroy_user_session_path, method: :delete
|
106
|
+
- else
|
107
|
+
= nav_link_to 'Sign In', new_user_session_path
|
108
|
+
```
|
109
|
+
|
110
|
+
### tabs
|
111
|
+
|
112
|
+
Use `tabs do` and `tabs` to create bootstrap3 tabs.
|
113
|
+
|
114
|
+
The helper inserts both the tablist and the tabpanel, and assigns the `active` class.
|
115
|
+
|
116
|
+
```haml
|
117
|
+
= tabs do
|
118
|
+
= tab 'Imports' do
|
119
|
+
%p Imports
|
120
|
+
|
121
|
+
= tab 'Exports' do
|
122
|
+
%p Exports
|
123
|
+
```
|
124
|
+
|
125
|
+
You can also call `tabs(active: 'Exports') do` to set the active tab.
|
126
|
+
|
127
|
+
## Simple Form Helpers
|
80
128
|
|
81
129
|
### simple_form_submit
|
82
130
|
|
@@ -0,0 +1,73 @@
|
|
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, &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') do
|
46
|
+
content_tag(:ul, class: 'nav nav-tabs', role: 'tablist') { yield } # Yield to tab the first time
|
47
|
+
end + content_tag(:div, class: 'tab-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, &block)
|
55
|
+
controls = label.to_s.downcase.to_param
|
56
|
+
active = (@_tab_active == :first || @_tab_active == label)
|
57
|
+
|
58
|
+
@_tab_active = nil if @_tab_active == :first
|
59
|
+
|
60
|
+
if @_tab_mode == :panel # Inserting the label into the tabpanel top
|
61
|
+
content_tag(:li, role: 'presentation', class: ('active' if active)) do
|
62
|
+
content_tag(:a, href: '#' + controls, 'aria-controls': controls, 'data-toggle': 'tab', role: 'tab') do
|
63
|
+
label
|
64
|
+
end
|
65
|
+
end
|
66
|
+
else # Inserting the content into the tab itself
|
67
|
+
content_tag(:div, id: controls, class: "tab-pane#{' active' if active}", role: 'tabpanel') do
|
68
|
+
yield
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -71,7 +71,14 @@ module Effective
|
|
71
71
|
[true, 'true', 't', '1'].include?(value)
|
72
72
|
when :date, :datetime
|
73
73
|
if (digits = value.to_s.scan(/(\d+)/).flatten).present?
|
74
|
-
date =
|
74
|
+
date = if digits.first.length == 4 # 2017-01-10
|
75
|
+
Time.zone.local(*digits)
|
76
|
+
else # 01/10/2016
|
77
|
+
year = digits.find { |d| d.length == 4}
|
78
|
+
digits = [year] + (digits - [year])
|
79
|
+
Time.zone.local(*digits)
|
80
|
+
end
|
81
|
+
|
75
82
|
name.to_s.start_with?('end_') ? date.end_of_day : date
|
76
83
|
end
|
77
84
|
when :time
|
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.2
|
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: 2017-11
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -37,6 +37,7 @@ 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
|
40
41
|
- app/helpers/effective_resources_helper.rb
|
41
42
|
- app/models/effective/access_denied.rb
|
42
43
|
- app/models/effective/attribute.rb
|