time_wrapper 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/time_wrapper.rb +3 -22
- data/lib/time_wrapper/locale/locale.rb +4 -0
- data/lib/time_wrapper/simple_form_wrapper.rb +16 -0
- data/lib/time_wrapper/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0f4e500679f51a1675806f08b22beb3bcaed4d
|
4
|
+
data.tar.gz: 777554b442955594d7b87c6c9650f9b380cf3775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b96801d84744f866f6f7558866f4dfef9717448a4dc3fd8c991315403ba66fea00819d0db8d50ebf375da18d4b3286bd7cfb4bcdd2c3d0e3a159eda3e78e1b2e
|
7
|
+
data.tar.gz: 3024e38c32caa38fde8eb063eda7137a3b99b573ea8c185ca87386628151af83ff8bfb3e19ec3a80a4fcca913c23592195d8262bc0259823a21d3aa02df52c9a
|
data/README.md
CHANGED
@@ -48,6 +48,12 @@ Given a datetime field named `time` use the following in simple form:
|
|
48
48
|
<%= f.input :time, as: :string, wrapper: :time %>
|
49
49
|
```
|
50
50
|
|
51
|
+
To get proper setter and getters, as well as basic format validation (you probably want to add your own) use the following in you model:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
time_attribute :time
|
55
|
+
```
|
56
|
+
|
51
57
|
## Generate stylesheets
|
52
58
|
|
53
59
|
If you want to customize the stylesheets.
|
data/lib/time_wrapper.rb
CHANGED
@@ -1,33 +1,14 @@
|
|
1
1
|
require "time_wrapper/version"
|
2
2
|
|
3
3
|
require "time_wrapper/orm/active_record"
|
4
|
+
require "time_wrapper/locale/locale"
|
5
|
+
require "time_wrapper/simple_form_wrapper"
|
4
6
|
|
5
7
|
module TimeWrapper
|
6
8
|
module Rails
|
7
9
|
class Engine < ::Rails::Engine
|
8
|
-
|
9
|
-
::SimpleForm.setup do |config|
|
10
|
-
config.wrappers :time, tag: 'div', class: 'form-group', error_class: 'has-danger' do |b|
|
11
|
-
b.use :html5
|
12
|
-
b.use :placeholder
|
13
|
-
b.use :label, class: 'form-control-label'
|
14
|
-
b.wrapper tag: 'div', class: 'input-group time timepicker' do |input|
|
15
|
-
input.use :input, class: 'form-control', autocomplete: :off
|
16
|
-
input.wrapper tag: 'span', class: 'input-group-addon' do |addon|
|
17
|
-
addon.wrapper tag: 'i', class: "fa fa-clock-o" do |_|
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
b.use :error, wrap_with: { tag: 'small', class: 'text-help text-muted' }
|
22
|
-
b.use :hint, wrap_with: { tag: 'p', class: 'text-help text-muted' }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
10
|
+
|
26
11
|
end
|
27
12
|
end
|
28
13
|
end
|
29
14
|
|
30
|
-
ActiveSupport.on_load(:i18n) do
|
31
|
-
I18n.load_path << "#{File.dirname(__FILE__)}/time_wrapper/locale/en.yml"
|
32
|
-
I18n.load_path << "#{File.dirname(__FILE__)}/time_wrapper/locale/da.yml"
|
33
|
-
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
::SimpleForm.setup do |config|
|
2
|
+
config.wrappers :time, tag: 'div', class: 'form-group', error_class: 'has-danger' do |b|
|
3
|
+
b.use :html5
|
4
|
+
b.use :placeholder
|
5
|
+
b.use :label, class: 'form-control-label'
|
6
|
+
b.wrapper tag: 'div', class: 'input-group time timepicker' do |input|
|
7
|
+
input.use :input, class: 'form-control', autocomplete: :off
|
8
|
+
input.wrapper tag: 'span', class: 'input-group-addon' do |addon|
|
9
|
+
addon.wrapper tag: 'i', class: "fa fa-clock-o" do |_|
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
b.use :error, wrap_with: { tag: 'small', class: 'text-help text-muted' }
|
14
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'text-help text-muted' }
|
15
|
+
end
|
16
|
+
end
|
data/lib/time_wrapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thies Pierdola
|
@@ -146,7 +146,9 @@ files:
|
|
146
146
|
- lib/time_wrapper.rb
|
147
147
|
- lib/time_wrapper/locale/da.yml
|
148
148
|
- lib/time_wrapper/locale/en.yml
|
149
|
+
- lib/time_wrapper/locale/locale.rb
|
149
150
|
- lib/time_wrapper/orm/active_record.rb
|
151
|
+
- lib/time_wrapper/simple_form_wrapper.rb
|
150
152
|
- lib/time_wrapper/time_attribute.rb
|
151
153
|
- lib/time_wrapper/version.rb
|
152
154
|
- time_wrapper.gemspec
|