tao_form 0.1.0 → 0.1.1
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 +4 -4
- data/config/initializers/simple_form.rb +160 -0
- data/config/initializers/simple_form/bottom_hints_component.rb +20 -0
- data/config/locales/simple_form/en.yml +31 -0
- data/config/locales/simple_form/zh-CN.yml +31 -0
- data/config/locales/tao_form/components/date_picker/en.yml +5 -0
- data/config/locales/tao_form/components/date_picker/zh-CN.yml +5 -0
- data/config/locales/tao_form/components/datetime/en.yml +5 -0
- data/config/locales/tao_form/components/datetime/zh-CN.yml +5 -0
- data/config/locales/tao_form/components/moment_picker/en.yml +31 -0
- data/config/locales/tao_form/components/moment_picker/zh-CN.yml +31 -0
- data/config/locales/tao_form/components/month_picker/en.yml +5 -0
- data/config/locales/tao_form/components/month_picker/zh-CN.yml +5 -0
- data/config/locales/tao_form/components/select/en.yml +17 -0
- data/config/locales/tao_form/components/select/zh-CN.yml +17 -0
- data/config/locales/tao_form/components/time_picker/en.yml +5 -0
- data/config/locales/tao_form/components/time_picker/zh-CN.yml +5 -0
- data/lib/tao_form/version.rb +1 -1
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea29e938c2248a053c8aa926f55540b96a4291a0
|
4
|
+
data.tar.gz: da944d10585f0ee0a08b3aa52c6b9c4ebf5568a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a5af2571bbe2b022e24115a4e8d8d57f3d8c3e9027cd9c209d3e72661212a278192ce4d1b6fb9e9f6a333a20c90359e88adca9686743fe2767a3f224f884d63
|
7
|
+
data.tar.gz: 044b0b65398c21acd4a98305264ff8833d3f7a0edf9759f49512b88265423081a9e13f5c9c0bac0c678b80c67a5bd9d6a9701e8836677d72f74d68cf002aa889
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
2
|
+
SimpleForm.setup do |config|
|
3
|
+
# Wrappers are used by the form builder to generate a
|
4
|
+
# complete input. You can remove any component from the
|
5
|
+
# wrapper, change the order or even add your own to the
|
6
|
+
# stack. The options given below are used to wrap the
|
7
|
+
# whole input.
|
8
|
+
config.wrappers :tao_desktop, class: 'form-input',
|
9
|
+
hint_class: 'input-with-hint', error_class: 'input-with-errors' do |b|
|
10
|
+
|
11
|
+
b.use :html5
|
12
|
+
b.use :placeholder
|
13
|
+
b.optional :maxlength
|
14
|
+
b.optional :pattern
|
15
|
+
b.optional :min_max
|
16
|
+
b.optional :readonly
|
17
|
+
|
18
|
+
b.use :label, class: 'input-label'
|
19
|
+
b.wrapper tag: :div, class: 'input-content' do |content|
|
20
|
+
content.use :input
|
21
|
+
content.use :error, wrap_with: { tag: :div, class: :error }
|
22
|
+
content.use :bottom_hint, wrap_with: {tag: :div, class: 'bottom-hint'}
|
23
|
+
end
|
24
|
+
|
25
|
+
b.use :hint, wrap_with: { tag: :div, class: :hint }
|
26
|
+
end
|
27
|
+
|
28
|
+
config.wrappers :tao_mobile, class: 'form-input',
|
29
|
+
hint_class: 'input-with-hint', error_class: 'input-with-errors' do |b|
|
30
|
+
|
31
|
+
b.use :html5
|
32
|
+
b.use :placeholder
|
33
|
+
b.optional :maxlength
|
34
|
+
b.optional :pattern
|
35
|
+
b.optional :min_max
|
36
|
+
b.optional :readonly
|
37
|
+
|
38
|
+
b.wrapper tag: :div, class: 'input-content' do |content|
|
39
|
+
content.use :label, class: 'input-label'
|
40
|
+
content.use :input
|
41
|
+
end
|
42
|
+
|
43
|
+
b.use :error, wrap_with: { tag: :div, class: :error }
|
44
|
+
b.use :hint, wrap_with: { tag: :div, class: :hint }
|
45
|
+
b.use :bottom_hint, wrap_with: {tag: :div, class: 'bottom-hint'}
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# The default wrapper to be used by the FormBuilder.
|
50
|
+
config.default_wrapper = :tao_desktop
|
51
|
+
|
52
|
+
# Define the way to render check boxes / radio buttons with labels.
|
53
|
+
# Defaults to :nested for bootstrap config.
|
54
|
+
# inline: input + label
|
55
|
+
# nested: label > input
|
56
|
+
config.boolean_style = :nested
|
57
|
+
|
58
|
+
# Default class for buttons
|
59
|
+
config.button_class = 'button'
|
60
|
+
|
61
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
62
|
+
# :first lists the first message for each field.
|
63
|
+
# Use :to_sentence to list all errors for each field.
|
64
|
+
# config.error_method = :first
|
65
|
+
|
66
|
+
# Default tag used for error notification helper.
|
67
|
+
config.error_notification_tag = :div
|
68
|
+
|
69
|
+
# CSS class to add for error notification helper.
|
70
|
+
config.error_notification_class = 'error_notification'
|
71
|
+
|
72
|
+
# ID to add for error notification helper.
|
73
|
+
# config.error_notification_id = nil
|
74
|
+
|
75
|
+
# Series of attempts to detect a default label method for collection.
|
76
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
77
|
+
|
78
|
+
# Series of attempts to detect a default value method for collection.
|
79
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
80
|
+
|
81
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
82
|
+
# config.collection_wrapper_tag = nil
|
83
|
+
|
84
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
85
|
+
# config.collection_wrapper_class = nil
|
86
|
+
|
87
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
88
|
+
# defaulting to :span.
|
89
|
+
# config.item_wrapper_tag = :span
|
90
|
+
|
91
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
92
|
+
# config.item_wrapper_class = nil
|
93
|
+
|
94
|
+
# How the label text should be generated altogether with the required text.
|
95
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
96
|
+
|
97
|
+
# You can define the class to use on all labels. Default is nil.
|
98
|
+
# config.label_class = nil
|
99
|
+
|
100
|
+
# You can define the default class to be used on forms. Can be overriden
|
101
|
+
# with `html: { :class }`. Defaulting to none.
|
102
|
+
# config.default_form_class = nil
|
103
|
+
|
104
|
+
# You can define which elements should obtain additional classes
|
105
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
106
|
+
|
107
|
+
# Whether attributes are required by default (or not). Default is true.
|
108
|
+
# config.required_by_default = true
|
109
|
+
|
110
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
111
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
112
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
113
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
114
|
+
# change this configuration to true.
|
115
|
+
config.browser_validations = false
|
116
|
+
|
117
|
+
# Collection of methods to detect if a file type was given.
|
118
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
119
|
+
|
120
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
121
|
+
# to match as key, and the input type that will be used when the field name
|
122
|
+
# matches the regexp as value.
|
123
|
+
# config.input_mappings = { /count/ => :integer }
|
124
|
+
|
125
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
126
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
127
|
+
# config.wrapper_mappings = { string: :prepend }
|
128
|
+
|
129
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
130
|
+
# override default inputs.
|
131
|
+
config.custom_inputs_namespaces << "TaoForm::Inputs"
|
132
|
+
|
133
|
+
# Default priority for time_zone inputs.
|
134
|
+
# config.time_zone_priority = nil
|
135
|
+
|
136
|
+
# Default priority for country inputs.
|
137
|
+
# config.country_priority = nil
|
138
|
+
|
139
|
+
# When false, do not use translations for labels.
|
140
|
+
# config.translate_labels = true
|
141
|
+
|
142
|
+
# Automatically discover new inputs in Rails' autoload path.
|
143
|
+
# config.inputs_discovery = true
|
144
|
+
|
145
|
+
# Cache SimpleForm inputs discovery
|
146
|
+
# config.cache_discovery = !Rails.env.development?
|
147
|
+
|
148
|
+
# Default class for inputs
|
149
|
+
config.input_class = 'input-field'
|
150
|
+
|
151
|
+
# Define the default class of the input wrapper of the boolean input.
|
152
|
+
config.boolean_label_class = 'checkbox'
|
153
|
+
|
154
|
+
# Defines if the default input wrapper class should be included in radio
|
155
|
+
# collection wrappers.
|
156
|
+
# config.include_default_input_wrapper_class = true
|
157
|
+
|
158
|
+
# Defines which i18n scope will be used in Simple Form.
|
159
|
+
# config.i18n_scope = 'simple_form'
|
160
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SimpleForm
|
2
|
+
module Components
|
3
|
+
# Needs to be enabled in order to do automatic lookups
|
4
|
+
module BottomHints
|
5
|
+
# Name of the component method
|
6
|
+
def bottom_hint(wrapper_options = nil)
|
7
|
+
@bottom_hint ||= begin
|
8
|
+
options[:bottom_hint].to_s.html_safe if options[:bottom_hint].present?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Used when the validation_hint is optional
|
13
|
+
def has_validation_hint?
|
14
|
+
bottom_hint.present?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
SimpleForm::Inputs::Base.send(:include, SimpleForm::Components::BottomHints)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
en:
|
2
|
+
simple_form:
|
3
|
+
yes: 'Yes'
|
4
|
+
no: 'No'
|
5
|
+
required:
|
6
|
+
text: 'required'
|
7
|
+
mark: '*'
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
|
+
# When using html, text and mark won't be used.
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
11
|
+
error_notification:
|
12
|
+
default_message: "Please review the problems below:"
|
13
|
+
# Examples
|
14
|
+
# labels:
|
15
|
+
# defaults:
|
16
|
+
# password: 'Password'
|
17
|
+
# user:
|
18
|
+
# new:
|
19
|
+
# email: 'E-mail to sign in.'
|
20
|
+
# edit:
|
21
|
+
# email: 'E-mail.'
|
22
|
+
# hints:
|
23
|
+
# defaults:
|
24
|
+
# username: 'User name to sign in.'
|
25
|
+
# password: 'No special characters, please.'
|
26
|
+
# include_blanks:
|
27
|
+
# defaults:
|
28
|
+
# age: 'Rather not say'
|
29
|
+
# prompts:
|
30
|
+
# defaults:
|
31
|
+
# age: 'Select your age'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
en:
|
2
|
+
simple_form:
|
3
|
+
yes: 是
|
4
|
+
no: 否
|
5
|
+
required:
|
6
|
+
text: 必填
|
7
|
+
mark: '*'
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
|
+
# When using html, text and mark won't be used.
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
11
|
+
error_notification:
|
12
|
+
default_message: "请检查下面的错误:"
|
13
|
+
# Examples
|
14
|
+
# labels:
|
15
|
+
# defaults:
|
16
|
+
# password: 'Password'
|
17
|
+
# user:
|
18
|
+
# new:
|
19
|
+
# email: 'E-mail to sign in.'
|
20
|
+
# edit:
|
21
|
+
# email: 'E-mail.'
|
22
|
+
# hints:
|
23
|
+
# defaults:
|
24
|
+
# username: 'User name to sign in.'
|
25
|
+
# password: 'No special characters, please.'
|
26
|
+
# include_blanks:
|
27
|
+
# defaults:
|
28
|
+
# age: 'Rather not say'
|
29
|
+
# prompts:
|
30
|
+
# defaults:
|
31
|
+
# age: 'Select your age'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
zh-CN:
|
2
|
+
tao_form:
|
3
|
+
components:
|
4
|
+
moment_picker:
|
5
|
+
close: Close
|
6
|
+
|
7
|
+
result:
|
8
|
+
clear_option: Clear Selected
|
9
|
+
segment_list:
|
10
|
+
year: Year
|
11
|
+
month: Month
|
12
|
+
date: Date
|
13
|
+
hour: Hour
|
14
|
+
minute: Minute
|
15
|
+
clear_value: Clear value
|
16
|
+
segments:
|
17
|
+
year_segment:
|
18
|
+
label: '%{year}'
|
19
|
+
prev_years: Previous couple of years
|
20
|
+
next_years: Next couple of years
|
21
|
+
month_segment:
|
22
|
+
prev_year: Previous year
|
23
|
+
next_year: Next year
|
24
|
+
date_segment:
|
25
|
+
prev_month: Previous month
|
26
|
+
next_month: Next month
|
27
|
+
label: '%{date}'
|
28
|
+
hour_segment:
|
29
|
+
label: '%{hour}'
|
30
|
+
minute_segment:
|
31
|
+
label: '%{minute}'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
zh-CN:
|
2
|
+
tao_form:
|
3
|
+
components:
|
4
|
+
moment_picker:
|
5
|
+
close: 关闭
|
6
|
+
|
7
|
+
result:
|
8
|
+
clear_option: 清除当前选择
|
9
|
+
segment_list:
|
10
|
+
year: 年
|
11
|
+
month: 月
|
12
|
+
date: 日
|
13
|
+
hour: 时
|
14
|
+
minute: 分
|
15
|
+
clear_value: 清除当前值
|
16
|
+
segments:
|
17
|
+
year_segment:
|
18
|
+
label: '%{year}年'
|
19
|
+
prev_years: 前几年
|
20
|
+
next_years: 后几年
|
21
|
+
month_segment:
|
22
|
+
prev_year: 上一年
|
23
|
+
next_year: 下一年
|
24
|
+
date_segment:
|
25
|
+
prev_month: 上个月
|
26
|
+
next_month: 下个月
|
27
|
+
label: '%{date}日'
|
28
|
+
hour_segment:
|
29
|
+
label: '%{hour}点'
|
30
|
+
minute_segment:
|
31
|
+
label: '%{minute}分'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
zh-CN:
|
2
|
+
tao_form:
|
3
|
+
components:
|
4
|
+
select:
|
5
|
+
placeholder: Please Select
|
6
|
+
ok: OK
|
7
|
+
list:
|
8
|
+
search_placeholder: Search Options
|
9
|
+
no_option: No option
|
10
|
+
loading: Loading...
|
11
|
+
tips: '<span class="size"></span> more options are hidden, please search for them.'
|
12
|
+
remote_no_option: Please search for options
|
13
|
+
search_not_found: No option Found
|
14
|
+
result:
|
15
|
+
clear_selected: Clear Selected
|
16
|
+
multiple_result:
|
17
|
+
add: Add
|
@@ -0,0 +1,17 @@
|
|
1
|
+
zh-CN:
|
2
|
+
tao_form:
|
3
|
+
components:
|
4
|
+
select:
|
5
|
+
placeholder: 请选择
|
6
|
+
ok: 确定
|
7
|
+
list:
|
8
|
+
search_placeholder: 搜索选项
|
9
|
+
no_option: 没有选项
|
10
|
+
remote_no_option: 请输入关键字查找选项
|
11
|
+
search_not_found: 没有找到匹配的选项
|
12
|
+
loading: 正在加载...
|
13
|
+
tips: 有 <span class="size"></span> 个选项没有显示,请使用更精确的搜索条件
|
14
|
+
result:
|
15
|
+
clear_selected: 清除已选择
|
16
|
+
multiple_result:
|
17
|
+
add: 添加
|
data/lib/tao_form/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tao_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- your name
|
@@ -104,6 +104,22 @@ files:
|
|
104
104
|
- LICENSE
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
|
+
- config/initializers/simple_form.rb
|
108
|
+
- config/initializers/simple_form/bottom_hints_component.rb
|
109
|
+
- config/locales/simple_form/en.yml
|
110
|
+
- config/locales/simple_form/zh-CN.yml
|
111
|
+
- config/locales/tao_form/components/date_picker/en.yml
|
112
|
+
- config/locales/tao_form/components/date_picker/zh-CN.yml
|
113
|
+
- config/locales/tao_form/components/datetime/en.yml
|
114
|
+
- config/locales/tao_form/components/datetime/zh-CN.yml
|
115
|
+
- config/locales/tao_form/components/moment_picker/en.yml
|
116
|
+
- config/locales/tao_form/components/moment_picker/zh-CN.yml
|
117
|
+
- config/locales/tao_form/components/month_picker/en.yml
|
118
|
+
- config/locales/tao_form/components/month_picker/zh-CN.yml
|
119
|
+
- config/locales/tao_form/components/select/en.yml
|
120
|
+
- config/locales/tao_form/components/select/zh-CN.yml
|
121
|
+
- config/locales/tao_form/components/time_picker/en.yml
|
122
|
+
- config/locales/tao_form/components/time_picker/zh-CN.yml
|
107
123
|
- lib/assets/icons/arrow-down.svg
|
108
124
|
- lib/assets/icons/arrow-left.svg
|
109
125
|
- lib/assets/icons/arrow-right.svg
|