standard_view 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -10
- data/Rakefile +3 -8
- data/app/helpers/standard_view/application_helper.rb +38 -0
- data/app/helpers/standard_view/badge_helper.rb +22 -0
- data/app/helpers/standard_view/flash_helper.rb +16 -0
- data/app/helpers/standard_view/formatting_helper.rb +21 -0
- data/app/helpers/standard_view/masthead_helper.rb +27 -0
- data/app/helpers/standard_view/navigation_helper.rb +51 -0
- data/app/views/application/_attributes_card.html.erb +32 -0
- data/app/views/application/_flash_messages.html.erb +7 -0
- data/app/views/application/_icon.html.erb +5 -0
- data/app/views/application/_javascripts.html.erb +25 -0
- data/app/views/application/_list_item.html.erb +11 -0
- data/app/views/application/_masthead.html.erb +21 -0
- data/app/views/application/_masthead_brand.html.erb +1 -0
- data/app/views/application/_masthead_nav.html.erb +6 -0
- data/app/views/application/_masthead_nav_items.html.erb +8 -0
- data/app/views/application/_masthead_nav_menu.html.erb +8 -0
- data/app/views/application/_masthead_nav_menu_icon.html.erb +1 -0
- data/app/views/application/_masthead_nav_menu_items.html.erb +10 -0
- data/app/views/application/_stylesheet_font_awesome.html.erb +6 -0
- data/app/views/application/_stylesheets.html.erb +12 -0
- data/app/views/application/index.html.erb +1 -0
- data/app/views/application/show.html.erb +1 -0
- data/app/views/layouts/standard_view/application.html.erb +8 -7
- data/app/views/standard_view/_breadcrumbs.html.erb +48 -0
- data/app/views/standard_view/_index.html.erb +83 -0
- data/app/views/standard_view/_list_item.html.erb +29 -0
- data/app/views/standard_view/_navigation_aside.html.erb +5 -0
- data/app/views/standard_view/_navigation_tabs.html.erb +5 -0
- data/app/views/standard_view/_page_content.html.erb +8 -0
- data/app/views/standard_view/_paginated_collection.html.erb +8 -0
- data/app/views/standard_view/_show.html.erb +48 -0
- data/config/initializers/material.rb +9 -0
- data/config/initializers/simple_form.rb +184 -0
- data/config/initializers/simple_form_bootstrap.rb +457 -0
- data/config/initializers/will_paginate.rb +57 -0
- data/config/locales/en.yml +12 -0
- data/lib/standard_view/engine.rb +11 -0
- data/lib/standard_view/version.rb +3 -1
- data/lib/standard_view.rb +7 -3
- metadata +169 -21
- data/app/assets/config/standard_view_manifest.js +0 -2
- data/app/assets/javascripts/standard_view/application.js +0 -14
- data/app/assets/stylesheets/standard_view/application.css +0 -15
- data/app/controllers/standard_view/application_controller.rb +0 -5
- data/app/jobs/standard_view/application_job.rb +0 -4
- data/app/mailers/standard_view/application_mailer.rb +0 -6
- data/app/models/standard_view/application_record.rb +0 -5
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if content_for?(:navigation_aside) %>
|
2
|
+
<div class="row">
|
3
|
+
<aside class="col-lg-3 mb-3"><%= render "standard_view/navigation_aside" %></aside>
|
4
|
+
<div class="col-lg-9"><%= content_for(:page_content) %></div>
|
5
|
+
</div>
|
6
|
+
<% else %>
|
7
|
+
<%= content_for(:page_content) %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if list.any? %>
|
2
|
+
<nav class="list-group mb-3"><%= render list, cache: true %></nav>
|
3
|
+
<%= will_paginate list, renderer: WillPaginate::ActionView::Bootstrap4LinkRenderer %>
|
4
|
+
<% elsif local_assigns[:is_filtered] %>
|
5
|
+
<div class="alert alert-danger"><%= t(".filtered_out") %></div>
|
6
|
+
<% else %>
|
7
|
+
<div class="alert alert-warning"><%= t(".empty") %></div>
|
8
|
+
<% end %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%# For the good-spirited and impossibly lazy developer, we attempt to jump-start with no code, assuming conventions. %>
|
2
|
+
<% if local_assigns[:material].nil? %>
|
3
|
+
<% record = "#{controller_name.singularize.camelize}".constantize.find(params[:id]) if local_assigns[:record].nil? %>
|
4
|
+
<% material = Material::Base.for(record) %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<%# Title must remain outside the cache block or it will not be assigned properly (since it affects the page layout) %>
|
8
|
+
<% content_for(:title) { material.title } %>
|
9
|
+
|
10
|
+
<% cache material do %>
|
11
|
+
<% if lookup_context.template_exists?("navigation_tabs", controller_name, true) %>
|
12
|
+
<% content_for(:navigation_tabs) { render "navigation_tabs", material: material } %>
|
13
|
+
<% elsif lookup_context.template_exists?("navigation_aside", controller_name, true) %>
|
14
|
+
<% content_for(:navigation_aside) { render "navigation_aside", material: material } %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= content_tag :main, id: "#{material.parameterized_title}-show", class: "container" do %>
|
18
|
+
<header>
|
19
|
+
<%= render "standard_view/breadcrumbs", material: material %>
|
20
|
+
|
21
|
+
<h5 class="text-muted"><%= heading_for_model material %></h5>
|
22
|
+
|
23
|
+
<% content_for(:header_title) { material.header_title } unless content_for?(:header_title) %>
|
24
|
+
<h1 class="mb-3"><%= content_for(:header_title) %></h1>
|
25
|
+
|
26
|
+
<%= content_for(:header_content) if content_for?(:header_content) %>
|
27
|
+
|
28
|
+
<%= render "standard_view/navigation_tabs" if content_for?(:navigation_tabs) %>
|
29
|
+
</header>
|
30
|
+
|
31
|
+
<%= content_tag(:hr) unless content_for?(:navigation_tabs) %>
|
32
|
+
|
33
|
+
<% unless content_for?(:page_content) %>
|
34
|
+
<% content_for(:page_content) do %>
|
35
|
+
<div class="row">
|
36
|
+
<% if lookup_context.template_exists?("content", controller_name, true) %>
|
37
|
+
<div class="col-xl-7 mb-3"><%= render "content", material: material %></div>
|
38
|
+
<div class="col-xl-5"><%= render "attributes_card", material: material %></div>
|
39
|
+
<% else %>
|
40
|
+
<div class="col-12"><%= render "attributes_card", material: material %></div>
|
41
|
+
<% end %>
|
42
|
+
</div>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<%= render "standard_view/page_content" %>
|
47
|
+
<% end %>
|
48
|
+
<% end %>
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simple_form"
|
4
|
+
|
5
|
+
# Uncomment this and change the path if necessary to include your own
|
6
|
+
# components.
|
7
|
+
# See https://github.com/plataformatec/simple_form#custom-components to know
|
8
|
+
# more about custom components.
|
9
|
+
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
10
|
+
#
|
11
|
+
# Use this setup block to configure all options available in SimpleForm.
|
12
|
+
SimpleForm.setup do |config|
|
13
|
+
# Wrappers are used by the form builder to generate a
|
14
|
+
# complete input. You can remove any component from the
|
15
|
+
# wrapper, change the order or even add your own to the
|
16
|
+
# stack. The options given below are used to wrap the
|
17
|
+
# whole input.
|
18
|
+
config.wrappers :default, class: :input,
|
19
|
+
hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
|
20
|
+
## Extensions enabled by default
|
21
|
+
# Any of these extensions can be disabled for a
|
22
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
23
|
+
# You can make any of these extensions optional by
|
24
|
+
# renaming `b.use` to `b.optional`.
|
25
|
+
|
26
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
27
|
+
# and required attributes
|
28
|
+
b.use :html5
|
29
|
+
|
30
|
+
# Calculates placeholders automatically from I18n
|
31
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
32
|
+
b.use :placeholder
|
33
|
+
|
34
|
+
## Optional extensions
|
35
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
36
|
+
# to the input. If so, they will retrieve the values from the model
|
37
|
+
# if any exists. If you want to enable any of those
|
38
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
39
|
+
|
40
|
+
# Calculates maxlength from length validations for string inputs
|
41
|
+
# and/or database column lengths
|
42
|
+
b.optional :maxlength
|
43
|
+
|
44
|
+
# Calculate minlength from length validations for string inputs
|
45
|
+
b.optional :minlength
|
46
|
+
|
47
|
+
# Calculates pattern from format validations for string inputs
|
48
|
+
b.optional :pattern
|
49
|
+
|
50
|
+
# Calculates min and max from length validations for numeric inputs
|
51
|
+
b.optional :min_max
|
52
|
+
|
53
|
+
# Calculates readonly automatically from readonly attributes
|
54
|
+
b.optional :readonly
|
55
|
+
|
56
|
+
## Inputs
|
57
|
+
# b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
|
58
|
+
b.use :label_input
|
59
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
60
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
61
|
+
|
62
|
+
## full_messages_for
|
63
|
+
# If you want to display the full error message for the attribute, you can
|
64
|
+
# use the component :full_error, like:
|
65
|
+
#
|
66
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
67
|
+
end
|
68
|
+
|
69
|
+
# The default wrapper to be used by the FormBuilder.
|
70
|
+
config.default_wrapper = :default
|
71
|
+
|
72
|
+
# Define the way to render check boxes / radio buttons with labels.
|
73
|
+
# Defaults to :nested for bootstrap config.
|
74
|
+
# inline: input + label
|
75
|
+
# nested: label > input
|
76
|
+
config.boolean_style = :nested
|
77
|
+
|
78
|
+
# Default class for buttons
|
79
|
+
config.button_class = 'btn'
|
80
|
+
|
81
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
82
|
+
# :first lists the first message for each field.
|
83
|
+
# Use :to_sentence to list all errors for each field.
|
84
|
+
# config.error_method = :first
|
85
|
+
|
86
|
+
# Default tag used for error notification helper.
|
87
|
+
config.error_notification_tag = :div
|
88
|
+
|
89
|
+
# CSS class to add for error notification helper.
|
90
|
+
config.error_notification_class = 'error_notification'
|
91
|
+
|
92
|
+
# ID to add for error notification helper.
|
93
|
+
# config.error_notification_id = nil
|
94
|
+
|
95
|
+
# Series of attempts to detect a default label method for collection.
|
96
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
97
|
+
|
98
|
+
# Series of attempts to detect a default value method for collection.
|
99
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
100
|
+
|
101
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
102
|
+
# config.collection_wrapper_tag = nil
|
103
|
+
|
104
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
105
|
+
# config.collection_wrapper_class = nil
|
106
|
+
|
107
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
108
|
+
# defaulting to :span.
|
109
|
+
# config.item_wrapper_tag = :span
|
110
|
+
|
111
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
112
|
+
# config.item_wrapper_class = nil
|
113
|
+
|
114
|
+
# How the label text should be generated altogether with the required text.
|
115
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
116
|
+
|
117
|
+
# You can define the class to use on all labels. Default is nil.
|
118
|
+
# config.label_class = nil
|
119
|
+
|
120
|
+
# You can define the default class to be used on forms. Can be overriden
|
121
|
+
# with `html: { :class }`. Defaulting to none.
|
122
|
+
# config.default_form_class = nil
|
123
|
+
|
124
|
+
# You can define which elements should obtain additional classes
|
125
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
126
|
+
|
127
|
+
# Whether attributes are required by default (or not). Default is true.
|
128
|
+
# config.required_by_default = true
|
129
|
+
|
130
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
131
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
132
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
133
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
134
|
+
# change this configuration to true.
|
135
|
+
config.browser_validations = false
|
136
|
+
|
137
|
+
# Collection of methods to detect if a file type was given.
|
138
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ]
|
139
|
+
|
140
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
141
|
+
# to match as key, and the input type that will be used when the field name
|
142
|
+
# matches the regexp as value.
|
143
|
+
# config.input_mappings = { /count/ => :integer }
|
144
|
+
|
145
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
146
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
147
|
+
# config.wrapper_mappings = { string: :prepend }
|
148
|
+
|
149
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
150
|
+
# override default inputs.
|
151
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
152
|
+
|
153
|
+
# Default priority for time_zone inputs.
|
154
|
+
# config.time_zone_priority = nil
|
155
|
+
|
156
|
+
# Default priority for country inputs.
|
157
|
+
# config.country_priority = nil
|
158
|
+
|
159
|
+
# When false, do not use translations for labels.
|
160
|
+
# config.translate_labels = true
|
161
|
+
|
162
|
+
# Automatically discover new inputs in Rails' autoload path.
|
163
|
+
# config.inputs_discovery = true
|
164
|
+
|
165
|
+
# Cache SimpleForm inputs discovery
|
166
|
+
# config.cache_discovery = !Rails.env.development?
|
167
|
+
|
168
|
+
# Default class for inputs
|
169
|
+
# config.input_class = nil
|
170
|
+
|
171
|
+
# Define the default class of the input wrapper of the boolean input.
|
172
|
+
config.boolean_label_class = 'checkbox'
|
173
|
+
|
174
|
+
# Defines if the default input wrapper class should be included in radio
|
175
|
+
# collection wrappers.
|
176
|
+
# config.include_default_input_wrapper_class = true
|
177
|
+
|
178
|
+
# Defines which i18n scope will be used in Simple Form.
|
179
|
+
# config.i18n_scope = 'simple_form'
|
180
|
+
|
181
|
+
# Defines validation classes to the input_field. By default it's nil.
|
182
|
+
# config.input_field_valid_class = 'is-valid'
|
183
|
+
# config.input_field_error_class = 'is-invalid'
|
184
|
+
end
|