semantic_ui_views_generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +69 -0
- data/.travis.yml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +89 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/semantic/install_generator.rb +67 -0
- data/lib/generators/semantic/templates/initializers/simple_form.rb +223 -0
- data/lib/generators/semantic/templates/layouts/application.html.erb.tt +36 -0
- data/lib/generators/semantic/templates/layouts/application.html.haml.tt +31 -0
- data/lib/generators/semantic/templates/layouts/application.html.slim.tt +33 -0
- data/lib/generators/semantic/templates/scaffolds/erb/_form.html.erb +21 -0
- data/lib/generators/semantic/templates/scaffolds/erb/edit.html.erb.tt +10 -0
- data/lib/generators/semantic/templates/scaffolds/erb/index.html.erb.tt +34 -0
- data/lib/generators/semantic/templates/scaffolds/erb/new.html.erb.tt +9 -0
- data/lib/generators/semantic/templates/scaffolds/erb/show.html.erb.tt +15 -0
- data/lib/generators/semantic/templates/scaffolds/haml/_form.html.haml +14 -0
- data/lib/generators/semantic/templates/scaffolds/haml/edit.html.haml.tt +10 -0
- data/lib/generators/semantic/templates/scaffolds/haml/index.html.haml.tt +27 -0
- data/lib/generators/semantic/templates/scaffolds/haml/new.html.haml.tt +9 -0
- data/lib/generators/semantic/templates/scaffolds/haml/show.html.haml.tt +15 -0
- data/lib/generators/semantic/templates/scaffolds/slim/_form.html.slim +14 -0
- data/lib/generators/semantic/templates/scaffolds/slim/edit.html.slim.tt +10 -0
- data/lib/generators/semantic/templates/scaffolds/slim/index.html.slim.tt +27 -0
- data/lib/generators/semantic/templates/scaffolds/slim/new.html.slim.tt +9 -0
- data/lib/generators/semantic/templates/scaffolds/slim/show.html.slim.tt +15 -0
- data/lib/generators/semantic/templates/shared/_messages.html.erb +12 -0
- data/lib/generators/semantic/templates/shared/_pagination.html.erb +7 -0
- data/lib/generators/semantic/templates/shared/_pagination.html.haml +4 -0
- data/lib/generators/semantic/templates/shared/_pagination.html.slim +4 -0
- data/lib/generators/semantic/templates/simple_form/_form.html.erb +18 -0
- data/lib/generators/semantic/templates/simple_form/_form.html.haml +13 -0
- data/lib/generators/semantic/templates/simple_form/_form.html.slim +14 -0
- data/lib/semantic_ui_views_generator.rb +6 -0
- data/lib/semantic_ui_views_generator/version.rb +3 -0
- data/semantic_ui_views_generator.gemspec +39 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 449e81ca109162a7e8774a9cac8b2f3590acc99746cd3f1f9d216526d16728eb
|
4
|
+
data.tar.gz: 364364555140d12b5e237d6b6bcb899d38d1a422114094e564b9194d59871267
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aacf03a69049dcd1af5ddf5f5648d79f6cad8eb2b701181f39ede85aab1549c40c537697411cff10ca82eb52783abacb77b28a333777a3a2b9d1845ab183954a
|
7
|
+
data.tar.gz: a11472343f81f2123c07754c266a64d044d529f4b1f1aa6acadcfeb18685545d030b768c7daf73584add744c164c2f557ba4f91b27dcfe5941332002d57ffe0d
|
data/.gitignore
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore OS based config files
|
11
|
+
*.swp
|
12
|
+
*.Thumbs.db
|
13
|
+
*.DS_Store
|
14
|
+
*/.DS_Store
|
15
|
+
.idea/*
|
16
|
+
.backup/*
|
17
|
+
|
18
|
+
# Ignore Rails generated caching files
|
19
|
+
.sass-cache/
|
20
|
+
.bundle/*
|
21
|
+
vendor/bundle/
|
22
|
+
vendor/cache/
|
23
|
+
cache/*
|
24
|
+
dump.rdb
|
25
|
+
coverage/*
|
26
|
+
|
27
|
+
|
28
|
+
# Ignore basic notes, docs, etc
|
29
|
+
docs/*
|
30
|
+
|
31
|
+
# Ignore Generated files, that should be build when pushing to production
|
32
|
+
public/assets/
|
33
|
+
public/javascripts/*.js
|
34
|
+
public/packs
|
35
|
+
public/stylesheets/*.css
|
36
|
+
/node_modules
|
37
|
+
|
38
|
+
# Ignore the default SQLite database.
|
39
|
+
/db/*.sqlite3
|
40
|
+
/db/*.sqlite3-journal
|
41
|
+
db/database.sqlite.yml
|
42
|
+
db/database.oracle.yml
|
43
|
+
db/data/seed.rb
|
44
|
+
db/scheme.rb
|
45
|
+
|
46
|
+
# Ignore all logfiles and tempfiles.
|
47
|
+
/log/*
|
48
|
+
/tmp/*
|
49
|
+
!/log/.keep
|
50
|
+
!/tmp/.keep
|
51
|
+
|
52
|
+
# Ignore uploaded files in development
|
53
|
+
/storage/*
|
54
|
+
!/storage/.keep
|
55
|
+
|
56
|
+
# Node / Yarn package files
|
57
|
+
node_modules/
|
58
|
+
yarn-error.log
|
59
|
+
|
60
|
+
/public/assets
|
61
|
+
.byebug_history
|
62
|
+
|
63
|
+
# Ignore master key for decrypting credentials and more.
|
64
|
+
/config/master.key
|
65
|
+
|
66
|
+
# Ignore application based files
|
67
|
+
.idea
|
68
|
+
.vagrant
|
69
|
+
*.gem
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in semantic_ui_views_generator.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'railties', '>= 5.0'
|
9
|
+
gem 'semantic-ui-sass', github: 'doabit/semantic-ui-sass'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/doabit/semantic-ui-sass
|
3
|
+
revision: 6c8e8dabb46b50fb5e01a4766a63c362501f0dc8
|
4
|
+
specs:
|
5
|
+
semantic-ui-sass (2.4.0.1)
|
6
|
+
sass (>= 3.2)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: .
|
10
|
+
specs:
|
11
|
+
semantic_ui_views_generator (0.1.0)
|
12
|
+
railties (>= 5.0)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
actionpack (5.2.3)
|
18
|
+
actionview (= 5.2.3)
|
19
|
+
activesupport (= 5.2.3)
|
20
|
+
rack (~> 2.0)
|
21
|
+
rack-test (>= 0.6.3)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
+
actionview (5.2.3)
|
25
|
+
activesupport (= 5.2.3)
|
26
|
+
builder (~> 3.1)
|
27
|
+
erubi (~> 1.4)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
30
|
+
activesupport (5.2.3)
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
|
+
i18n (>= 0.7, < 2)
|
33
|
+
minitest (~> 5.1)
|
34
|
+
tzinfo (~> 1.1)
|
35
|
+
builder (3.2.3)
|
36
|
+
concurrent-ruby (1.1.5)
|
37
|
+
crass (1.0.4)
|
38
|
+
erubi (1.8.0)
|
39
|
+
ffi (1.10.0)
|
40
|
+
i18n (1.6.0)
|
41
|
+
concurrent-ruby (~> 1.0)
|
42
|
+
loofah (2.2.3)
|
43
|
+
crass (~> 1.0.2)
|
44
|
+
nokogiri (>= 1.5.9)
|
45
|
+
method_source (0.9.2)
|
46
|
+
mini_portile2 (2.4.0)
|
47
|
+
minitest (5.11.3)
|
48
|
+
nokogiri (1.10.3)
|
49
|
+
mini_portile2 (~> 2.4.0)
|
50
|
+
rack (2.0.7)
|
51
|
+
rack-test (1.1.0)
|
52
|
+
rack (>= 1.0, < 3)
|
53
|
+
rails-dom-testing (2.0.3)
|
54
|
+
activesupport (>= 4.2.0)
|
55
|
+
nokogiri (>= 1.6)
|
56
|
+
rails-html-sanitizer (1.0.4)
|
57
|
+
loofah (~> 2.2, >= 2.2.2)
|
58
|
+
railties (5.2.3)
|
59
|
+
actionpack (= 5.2.3)
|
60
|
+
activesupport (= 5.2.3)
|
61
|
+
method_source
|
62
|
+
rake (>= 0.8.7)
|
63
|
+
thor (>= 0.19.0, < 2.0)
|
64
|
+
rake (12.3.2)
|
65
|
+
rb-fsevent (0.10.3)
|
66
|
+
rb-inotify (0.10.0)
|
67
|
+
ffi (~> 1.0)
|
68
|
+
sass (3.7.4)
|
69
|
+
sass-listen (~> 4.0.0)
|
70
|
+
sass-listen (4.0.0)
|
71
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
72
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
73
|
+
thor (0.20.3)
|
74
|
+
thread_safe (0.3.6)
|
75
|
+
tzinfo (1.2.5)
|
76
|
+
thread_safe (~> 0.1)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
ruby
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
bundler (>= 1.17)
|
83
|
+
railties (>= 5.0)
|
84
|
+
rake (>= 10.0)
|
85
|
+
semantic-ui-sass!
|
86
|
+
semantic_ui_views_generator!
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Brandon Hicks
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# SemanticViewsGenerator
|
2
|
+
|
3
|
+
![](https://ruby-gem-downloads-badge.herokuapp.com/semantic_views_generator?type=total) [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) [![Gem Version](https://badge.fury.io/rb/semantic_views_generator.svg)](https://badge.fury.io/rb/semantic_views_generator)
|
4
|
+
|
5
|
+
This gem is used for generating semantic based scaffold views for your Rails application. They can be Erb, Slim, or HAML. You can include pagination (using Pagy), simple_form (for the form components), and if you'd like you can utilize the meta-tags gems to all dynamic page titles when switching between your view components.
|
6
|
+
|
7
|
+
This is more or less a sister project of the [bootstrap_views_generator](https://github.com/tarellel/bootstrap_views_generator) gem, but for those who prefer to use Semantic UI.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'semantic_ui_views_generator', group: :development
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install semantic_ui_views_generator
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```shell
|
28
|
+
Usage:
|
29
|
+
rails g semantic:install [options]
|
30
|
+
|
31
|
+
Options:
|
32
|
+
Options:
|
33
|
+
-t, [--template-engine=TEMPLATE_ENGINE] # Indicates when to generate template engine
|
34
|
+
# Default: erb
|
35
|
+
--simpleform # Indicates if simpleform will be used (when used will generate a Semantic Ui based simple_form initialzer)
|
36
|
+
# Default: false
|
37
|
+
--pagination # Specify if you want to add pagination to the index pages
|
38
|
+
# Defaults: false (requires Pagy to use pagination)
|
39
|
+
--metatags # If you want the pages titles to use the metatags gem function for the page title
|
40
|
+
# Default: false
|
41
|
+
```
|
42
|
+
|
43
|
+
## Options
|
44
|
+
|
45
|
+
##### Template Engines
|
46
|
+
|
47
|
+
Supported Template Engines
|
48
|
+
|
49
|
+
* ERB
|
50
|
+
* HAML
|
51
|
+
* Slim
|
52
|
+
|
53
|
+
**HAML**
|
54
|
+
|
55
|
+
Make sure you have haml added to your your Gemfile
|
56
|
+
```ruby
|
57
|
+
gem 'haml-rails'
|
58
|
+
|
59
|
+
# generate haml views
|
60
|
+
rails g semantic:install --template_engine=haml
|
61
|
+
```
|
62
|
+
|
63
|
+
**Slim**
|
64
|
+
Make sure you have Slim added to your Gemfile
|
65
|
+
```ruby
|
66
|
+
gem 'slim-rails'
|
67
|
+
|
68
|
+
# generate Slim views
|
69
|
+
rails g semantic:install --template_engine=slim
|
70
|
+
```
|
71
|
+
|
72
|
+
#### Pagination
|
73
|
+
|
74
|
+
Ensure you have [Pagy](https://github.com/ddnexus/pagy) gem installed
|
75
|
+
```ruby
|
76
|
+
gem 'pagy'
|
77
|
+
```
|
78
|
+
|
79
|
+
|
80
|
+
#### Meta-Tags
|
81
|
+
Ensure you have the [meta-tags](https://github.com/kpumuk/meta-tags) gem installed
|
82
|
+
```ruby
|
83
|
+
gem 'meta-tags'
|
84
|
+
```
|
85
|
+
|
86
|
+
### Examples
|
87
|
+
|
88
|
+
Generate semantic views with pagination enabled
|
89
|
+
```shell
|
90
|
+
rails g semantic:install --pagination
|
91
|
+
```
|
92
|
+
|
93
|
+
Generate semantic views with slim and using simple_form
|
94
|
+
```shell
|
95
|
+
rails g semantic:install --template_engine=slim --simpleform
|
96
|
+
```
|
97
|
+
|
98
|
+
### Extras
|
99
|
+
|
100
|
+
* If you like to use the [meta-tags](https://github.com/kpumuk/meta-tags) gem to add page titles based on the views.
|
101
|
+
* Pagination defaults to using [Pagy](https://github.com/ddnexus/pagy) on the index pages.
|
102
|
+
* With [simple_form](https://github.com/plataformatec/simple_form) it generates a `config/initialzers/simple_form.rb` file for your simple_form formatting.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "semantic_ui_views_generator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Semantic
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
desc 'Overwrite Rails scaffold templates with Semantic UI based templates'
|
7
|
+
source_root ::File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
class_option :template_engine, type: :string, default: 'erb', aliases: '-t', desc: 'Set template engine to generate the views with'
|
10
|
+
# Boolean flags that can be flagged by adding to the generator call ie: --pagination or --metag_tags
|
11
|
+
class_option :metatags, type: :boolean, default: false, aliases: "-m", desc: 'If views will assign pages title using metatags gem'
|
12
|
+
class_option :pagination, type: :boolean, default: false, aliases: '-p', desc: 'Toggle if pagination will be used with the index view/controller (based off of Pagy)'
|
13
|
+
class_option :simpleform, type: :boolean, default: false, aliases: '-sf', desc: 'Enable SimpleForms for the form generating'
|
14
|
+
|
15
|
+
def copy_scaffold_views
|
16
|
+
%w[edit index show new].each do |file|
|
17
|
+
template "scaffolds/#{options[:template_engine]}/#{file}.html.#{options[:template_engine]}", "lib/templates/#{options[:template_engine]}/scaffold/#{file}.html.#{options[:template_engine]}", force: true
|
18
|
+
end
|
19
|
+
copy_file "scaffolds/#{options[:template_engine]}/_form.html.#{options[:template_engine]}", "lib/templates/#{options[:template_engine]}/scaffold/_form.html.#{options[:template_engine]}", force: true
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_layout
|
23
|
+
template "layouts/application.html.#{options[:template_engine]}.tt", "app/views/layouts/application.html.#{options[:template_engine]}", force: true
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy_flash_messages
|
27
|
+
copy_file 'shared/_messages.html.erb', 'app/views/shared/_messages.html.erb', force: true
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_shared_pagination
|
31
|
+
if options[:pagination]
|
32
|
+
copy_file "shared/_pagination.html.#{options[:template_engine]}", "app/views/shared/_pagination.html.#{options[:template_engine]}", force: true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def copy_simpleforms
|
37
|
+
if options[:simpleform]
|
38
|
+
copy_file 'initialzers/simple_form.rb', 'config/initialzers/simple_form.rb', force: true
|
39
|
+
|
40
|
+
copy_file "simple_form/_form.html.#{options[:template_engine]}", "lib/templates/#{options[:template_engine]}/scaffold/_form.html.#{options[:template_engine]}", force: true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def inject_helpers
|
45
|
+
helper_str = <<-HELPER
|
46
|
+
|
47
|
+
# For generating SemanitcUI based flash[:notices]
|
48
|
+
def flash_class(level)
|
49
|
+
case level
|
50
|
+
when 'success'
|
51
|
+
'positive'
|
52
|
+
when 'error'
|
53
|
+
'negative'
|
54
|
+
when 'alert'
|
55
|
+
'negative'
|
56
|
+
when 'notice'
|
57
|
+
'info'
|
58
|
+
else
|
59
|
+
'info'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
HELPER
|
63
|
+
inject_into_file 'app/helpers/application_helper.rb', helper_str, after: "module ApplicationHelper\n", force: true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
## src: https://pranavsingh.me/semantic-ui-simple-form-wrapper/
|
2
|
+
# Use this setup block to configure all options available in SimpleForm.
|
3
|
+
SimpleForm.setup do |config|
|
4
|
+
# Wrappers are used by the form builder to generate a
|
5
|
+
# complete input. You can remove any component from the
|
6
|
+
# wrapper, change the order or even add your own to the
|
7
|
+
# stack. The options given below are used to wrap the
|
8
|
+
# whole input.
|
9
|
+
config.wrappers :default, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
10
|
+
## Extensions enabled by default
|
11
|
+
# Any of these extensions can be disabled for a
|
12
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
13
|
+
# You can make any of these extensions optional by
|
14
|
+
# renaming `b.use` to `b.optional`.
|
15
|
+
|
16
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
17
|
+
# and required attributes
|
18
|
+
b.use :html5
|
19
|
+
|
20
|
+
# Calculates placeholders automatically from I18n
|
21
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
22
|
+
b.use :placeholder
|
23
|
+
|
24
|
+
## Optional extensions
|
25
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
26
|
+
# to the input. If so, they will retrieve the values from the model
|
27
|
+
# if any exists. If you want to enable any of those
|
28
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
29
|
+
|
30
|
+
# Calculates maxlength from length validations for string inputs
|
31
|
+
# and/or database column lengths
|
32
|
+
b.optional :maxlength
|
33
|
+
|
34
|
+
# Calculate minlength from length validations for string inputs
|
35
|
+
b.optional :minlength
|
36
|
+
|
37
|
+
# Calculates pattern from format validations for string inputs
|
38
|
+
b.optional :pattern
|
39
|
+
|
40
|
+
# Calculates min and max from length validations for numeric inputs
|
41
|
+
b.optional :min_max
|
42
|
+
|
43
|
+
# Calculates readonly automatically from readonly attributes
|
44
|
+
b.optional :readonly
|
45
|
+
|
46
|
+
## Inputs
|
47
|
+
b.use :label_input
|
48
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
49
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Custom Semantic Wrapper
|
53
|
+
# Values are similar to the default wrapper above, with different classes
|
54
|
+
config.wrappers :semantic, tag: 'div', class: "field", error_class: 'error', hint_class: 'with_hint' do |b|
|
55
|
+
b.use :html5
|
56
|
+
b.use :placeholder
|
57
|
+
b.optional :maxlength
|
58
|
+
b.optional :pattern
|
59
|
+
b.optional :min_max
|
60
|
+
b.use :label_input
|
61
|
+
b.use :hint, wrap_with: { tag: 'div', class: 'hint' }
|
62
|
+
b.use :error, wrap_with: { tag: 'div', class: 'ui red pointing above label error' }
|
63
|
+
end
|
64
|
+
|
65
|
+
config.wrappers :ui_checkbox, tag: 'div', class: "field", error_class: 'error', hint_class: 'with_hint' do |b|
|
66
|
+
b.use :html5
|
67
|
+
b.wrapper tag: 'div', class: 'ui checkbox' do |input|
|
68
|
+
input.use :label_input
|
69
|
+
input.use :hint, wrap_with: { tag: 'div', class: 'hint' }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
config.wrappers :ui_slider_checkbox, tag: 'div', class: "field", error_class: 'error', hint_class: 'with_hint' do |b|
|
74
|
+
b.use :html5
|
75
|
+
b.wrapper tag: 'div', class: 'ui slider checkbox' do |input|
|
76
|
+
input.use :label_input
|
77
|
+
input.use :hint, wrap_with: { tag: 'div', class: 'hint' }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
config.wrappers :ui_toggle_checkbox, tag: 'div', class: "field", error_class: 'error', hint_class: 'with_hint' do |b|
|
82
|
+
b.use :html5
|
83
|
+
b.wrapper tag: 'div', class: 'ui toggle checkbox' do |input|
|
84
|
+
input.use :label_input
|
85
|
+
input.use :hint, wrap_with: { tag: 'div', class: 'hint' }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
config.wrappers :ui_left_labled_input, tag: 'div', class: "field", error_class: 'error', hint_class: 'with_hint' do |b|
|
90
|
+
b.use :html5
|
91
|
+
b.use :label
|
92
|
+
|
93
|
+
b.wrapper tag: 'div', class: 'ui left labeled input' do |input|
|
94
|
+
input.use :input
|
95
|
+
input.use :hint, wrap_with: { tag: 'div', class: 'hint' }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
config.wrappers :ui_right_labled_input, tag: 'div', class: "field", error_class: 'error', hint_class: 'with_hint' do |b|
|
100
|
+
b.use :html5
|
101
|
+
b.use :label
|
102
|
+
|
103
|
+
b.wrapper tag: 'div', class: 'ui right labeled input' do |input|
|
104
|
+
input.use :input
|
105
|
+
input.use :hint, wrap_with: { tag: 'div', class: 'hint' }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# The default wrapper to be used by the FormBuilder.
|
110
|
+
# config.default_wrapper = :default
|
111
|
+
config.default_wrapper = :semantic
|
112
|
+
|
113
|
+
# Define the way to render check boxes / radio buttons with labels.
|
114
|
+
# Defaults to :nested for semanticui config.
|
115
|
+
# inline: input + label
|
116
|
+
# nested: label > input
|
117
|
+
config.boolean_style = :inline
|
118
|
+
|
119
|
+
# Default class for buttons
|
120
|
+
config.button_class = 'ui primary submit button'
|
121
|
+
|
122
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
123
|
+
# :first lists the first message for each field.
|
124
|
+
# Use :to_sentence to list all errors for each field.
|
125
|
+
config.error_method = :first
|
126
|
+
|
127
|
+
# Default tag used for error notification helper.
|
128
|
+
config.error_notification_tag = :div
|
129
|
+
|
130
|
+
# CSS class to add for error notification helper.
|
131
|
+
config.error_notification_class = 'alert alert-error'
|
132
|
+
|
133
|
+
# ID to add for error notification helper.
|
134
|
+
# config.error_notification_id = nil
|
135
|
+
|
136
|
+
# Series of attempts to detect a default label method for collection.
|
137
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
138
|
+
|
139
|
+
# Series of attempts to detect a default value method for collection.
|
140
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
141
|
+
|
142
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
143
|
+
# config.collection_wrapper_tag = :div
|
144
|
+
|
145
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
146
|
+
# config.collection_wrapper_class = "field"
|
147
|
+
|
148
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
149
|
+
# defaulting to :span. Please note that when using :boolean_style = :nested,
|
150
|
+
# SimpleForm will force this option to be a label.
|
151
|
+
config.item_wrapper_tag = :div
|
152
|
+
|
153
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
154
|
+
config.item_wrapper_class = 'ui checkbox'
|
155
|
+
|
156
|
+
# How the label text should be generated altogether with the required text.
|
157
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
158
|
+
config.label_text = lambda { |label, required, explicit_label| "#{label}" }
|
159
|
+
# Semantic UI has its own astrick
|
160
|
+
|
161
|
+
# You can define the class to use on all labels. Default is nil.
|
162
|
+
# config.label_class = nil
|
163
|
+
|
164
|
+
# You can define the class to use on all forms. Default is simple_form.
|
165
|
+
config.default_form_class = 'ui form'
|
166
|
+
|
167
|
+
# You can define which elements should obtain additional classes
|
168
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
169
|
+
|
170
|
+
# Whether attributes are required by default (or not). Default is true.
|
171
|
+
# config.required_by_default = true
|
172
|
+
|
173
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
174
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
175
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
176
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
177
|
+
# change this configuration to true.
|
178
|
+
config.browser_validations = false
|
179
|
+
|
180
|
+
# Collection of methods to detect if a file type was given.
|
181
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
182
|
+
|
183
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
184
|
+
# to match as key, and the input type that will be used when the field name
|
185
|
+
# matches the regexp as value.
|
186
|
+
# config.input_mappings = { /count/ => :integer }
|
187
|
+
|
188
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
189
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
190
|
+
# config.wrapper_mappings = { string: :prepend }
|
191
|
+
|
192
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
193
|
+
# override default inputs.
|
194
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
195
|
+
|
196
|
+
# Default priority for time_zone inputs.
|
197
|
+
# config.time_zone_priority = nil
|
198
|
+
|
199
|
+
# Default priority for country inputs.
|
200
|
+
# config.country_priority = nil
|
201
|
+
|
202
|
+
# When false, do not use translations for labels.
|
203
|
+
# config.translate_labels = true
|
204
|
+
|
205
|
+
# Automatically discover new inputs in Rails' autoload path.
|
206
|
+
# config.inputs_discovery = true
|
207
|
+
|
208
|
+
# Cache SimpleForm inputs discovery
|
209
|
+
# config.cache_discovery = !Rails.env.development?
|
210
|
+
|
211
|
+
# Default class for inputs
|
212
|
+
# config.input_class = nil
|
213
|
+
|
214
|
+
# Define the default class of the input wrapper of the boolean input.
|
215
|
+
config.boolean_label_class = 'checkbox'
|
216
|
+
|
217
|
+
# Defines if the default input wrapper class should be included in radio
|
218
|
+
# collection wrappers.
|
219
|
+
# config.include_default_input_wrapper_class = true
|
220
|
+
|
221
|
+
# Defines which i18n scope will be used in Simple Form.
|
222
|
+
# config.i18n_scope = 'simple_form'
|
223
|
+
end
|