five-two-nw-olivander 0.1.2 → 0.1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/olivander/datatable.rb +18 -0
- data/app/views/application/edit.html.haml +11 -0
- data/app/views/application/index.html.haml +24 -0
- data/app/views/application/new.html.haml +11 -0
- data/app/views/application/show.html.haml +14 -0
- data/config/initializers/simple_form.rb +176 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/lib/five-two-nw-olivander.rb +1 -0
- data/lib/olivander/version.rb +1 -1
- data/lib/templates/erb/scaffold/_form.html.erb +15 -0
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44fe284f2bfe724fd9afc389fe29459b92d7358bd2db4bbcc834c575b4defb89
|
4
|
+
data.tar.gz: 19de553ddc1641dea2af0b12e41a9c9c4459470972205227d106d6cc61f5660e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29b8d4a75d6680a5283562bcd52e746a74c21cff1b9f0ed6982d6132c05cafc28659343a5f9ed6d18de437c36bb08a9966ba21cf6cd873c98028137785b59358
|
7
|
+
data.tar.gz: b698a84298b468c808c630332a19e90f8061b4f8ef232324a8c890e15fa5c0cd5c6d2adbc0408085dcfce1e2334a69d98a811f4ab8f4d405eda5eea55392ceb6
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Olivander
|
2
|
+
class Datatable < Effective::Datatable
|
3
|
+
def link_col(field, path, path_args)
|
4
|
+
dsl_tool.col(field) do |r|
|
5
|
+
args = [].tap do |arr|
|
6
|
+
if path_args.is_a? Array
|
7
|
+
path_args.each do |arg|
|
8
|
+
arr << r.send(arg)
|
9
|
+
end
|
10
|
+
else
|
11
|
+
arr << r.send(path_args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
link_to r.send(field), send(path, args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
|
+
- @resource = instance_variable_get('@' + resource.name) if resource.name
|
3
|
+
|
4
|
+
- if @resource
|
5
|
+
.row
|
6
|
+
.col-8
|
7
|
+
%h1= @page_title
|
8
|
+
.col-4.text-right
|
9
|
+
= render_resource_buttons(@resource, edit: false)
|
10
|
+
|
11
|
+
= render_resource_form(@resource)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
|
+
|
3
|
+
.row
|
4
|
+
.col-12
|
5
|
+
.card
|
6
|
+
.card-header
|
7
|
+
%h1= @page_title
|
8
|
+
.card-body
|
9
|
+
- if @datatable
|
10
|
+
= render_datatable(@datatable)
|
11
|
+
|
12
|
+
- elsif instance_variable_get('@' + resource.plural_name).respond_to?(:to_partial_path)
|
13
|
+
= render instance_variable_get('@' + resource.plural_name)
|
14
|
+
|
15
|
+
- elsif instance_variable_get('@' + resource.name).respond_to?(:to_partial_path)
|
16
|
+
= render instance_variable_get('@' + resource.name)
|
17
|
+
|
18
|
+
- elsif Rails.env.development?
|
19
|
+
%p effective_resources index view is not sure what to render.
|
20
|
+
%p Define an @datatable, @#{resource.try(:plural_name) || 'a plural'}, or @#{resource.try(:name) || 'a singular'}.
|
21
|
+
%p or include Effective::CrudController in your controller
|
22
|
+
.card-footer
|
23
|
+
= render_resource_buttons(resource.klass, (action ||= :index) => false)
|
24
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
|
+
- @resource = instance_variable_get('@' + resource.name) if resource.name
|
3
|
+
|
4
|
+
- if @resource
|
5
|
+
.row
|
6
|
+
.col-8
|
7
|
+
%h1= @page_title
|
8
|
+
.col-4.text-right
|
9
|
+
= render_resource_buttons(@resource)
|
10
|
+
|
11
|
+
= render_resource_form(@resource)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
|
+
- @resource = instance_variable_get('@' + resource.name) if resource.name
|
3
|
+
|
4
|
+
- if @resource
|
5
|
+
.row
|
6
|
+
.col-8
|
7
|
+
%h1= @page_title
|
8
|
+
.col-4.text-right
|
9
|
+
= render_resource_buttons(@resource, show: false)
|
10
|
+
|
11
|
+
= render_resource_partial(@resource)
|
12
|
+
|
13
|
+
.form-actions
|
14
|
+
= link_to 'Continue', (resource.action_path(:index) || root_path), class: 'btn btn-primary'
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Uncomment this and change the path if necessary to include your own
|
4
|
+
# components.
|
5
|
+
# See https://github.com/heartcombo/simple_form#custom-components to know
|
6
|
+
# more about custom components.
|
7
|
+
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
8
|
+
#
|
9
|
+
# Use this setup block to configure all options available in SimpleForm.
|
10
|
+
SimpleForm.setup do |config|
|
11
|
+
# Wrappers are used by the form builder to generate a
|
12
|
+
# complete input. You can remove any component from the
|
13
|
+
# wrapper, change the order or even add your own to the
|
14
|
+
# stack. The options given below are used to wrap the
|
15
|
+
# whole input.
|
16
|
+
config.wrappers :default, class: :input,
|
17
|
+
hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
|
18
|
+
## Extensions enabled by default
|
19
|
+
# Any of these extensions can be disabled for a
|
20
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
21
|
+
# You can make any of these extensions optional by
|
22
|
+
# renaming `b.use` to `b.optional`.
|
23
|
+
|
24
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
25
|
+
# and required attributes
|
26
|
+
b.use :html5
|
27
|
+
|
28
|
+
# Calculates placeholders automatically from I18n
|
29
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
30
|
+
b.use :placeholder
|
31
|
+
|
32
|
+
## Optional extensions
|
33
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
34
|
+
# to the input. If so, they will retrieve the values from the model
|
35
|
+
# if any exists. If you want to enable any of those
|
36
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
37
|
+
|
38
|
+
# Calculates maxlength from length validations for string inputs
|
39
|
+
# and/or database column lengths
|
40
|
+
b.optional :maxlength
|
41
|
+
|
42
|
+
# Calculate minlength from length validations for string inputs
|
43
|
+
b.optional :minlength
|
44
|
+
|
45
|
+
# Calculates pattern from format validations for string inputs
|
46
|
+
b.optional :pattern
|
47
|
+
|
48
|
+
# Calculates min and max from length validations for numeric inputs
|
49
|
+
b.optional :min_max
|
50
|
+
|
51
|
+
# Calculates readonly automatically from readonly attributes
|
52
|
+
b.optional :readonly
|
53
|
+
|
54
|
+
## Inputs
|
55
|
+
# b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
|
56
|
+
b.use :label_input
|
57
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
58
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
59
|
+
|
60
|
+
## full_messages_for
|
61
|
+
# If you want to display the full error message for the attribute, you can
|
62
|
+
# use the component :full_error, like:
|
63
|
+
#
|
64
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
65
|
+
end
|
66
|
+
|
67
|
+
# The default wrapper to be used by the FormBuilder.
|
68
|
+
config.default_wrapper = :default
|
69
|
+
|
70
|
+
# Define the way to render check boxes / radio buttons with labels.
|
71
|
+
# Defaults to :nested for bootstrap config.
|
72
|
+
# inline: input + label
|
73
|
+
# nested: label > input
|
74
|
+
config.boolean_style = :nested
|
75
|
+
|
76
|
+
# Default class for buttons
|
77
|
+
config.button_class = 'btn'
|
78
|
+
|
79
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
80
|
+
# :first lists the first message for each field.
|
81
|
+
# Use :to_sentence to list all errors for each field.
|
82
|
+
# config.error_method = :first
|
83
|
+
|
84
|
+
# Default tag used for error notification helper.
|
85
|
+
config.error_notification_tag = :div
|
86
|
+
|
87
|
+
# CSS class to add for error notification helper.
|
88
|
+
config.error_notification_class = 'error_notification'
|
89
|
+
|
90
|
+
# Series of attempts to detect a default label method for collection.
|
91
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
92
|
+
|
93
|
+
# Series of attempts to detect a default value method for collection.
|
94
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
95
|
+
|
96
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
97
|
+
# config.collection_wrapper_tag = nil
|
98
|
+
|
99
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
100
|
+
# config.collection_wrapper_class = nil
|
101
|
+
|
102
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
103
|
+
# defaulting to :span.
|
104
|
+
# config.item_wrapper_tag = :span
|
105
|
+
|
106
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
107
|
+
# config.item_wrapper_class = nil
|
108
|
+
|
109
|
+
# How the label text should be generated altogether with the required text.
|
110
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
111
|
+
|
112
|
+
# You can define the class to use on all labels. Default is nil.
|
113
|
+
# config.label_class = nil
|
114
|
+
|
115
|
+
# You can define the default class to be used on forms. Can be overriden
|
116
|
+
# with `html: { :class }`. Defaulting to none.
|
117
|
+
# config.default_form_class = nil
|
118
|
+
|
119
|
+
# You can define which elements should obtain additional classes
|
120
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
121
|
+
|
122
|
+
# Whether attributes are required by default (or not). Default is true.
|
123
|
+
# config.required_by_default = true
|
124
|
+
|
125
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
126
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
127
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
128
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
129
|
+
# change this configuration to true.
|
130
|
+
config.browser_validations = false
|
131
|
+
|
132
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
133
|
+
# to match as key, and the input type that will be used when the field name
|
134
|
+
# matches the regexp as value.
|
135
|
+
# config.input_mappings = { /count/ => :integer }
|
136
|
+
|
137
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
138
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
139
|
+
# config.wrapper_mappings = { string: :prepend }
|
140
|
+
|
141
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
142
|
+
# override default inputs.
|
143
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
144
|
+
|
145
|
+
# Default priority for time_zone inputs.
|
146
|
+
# config.time_zone_priority = nil
|
147
|
+
|
148
|
+
# Default priority for country inputs.
|
149
|
+
# config.country_priority = nil
|
150
|
+
|
151
|
+
# When false, do not use translations for labels.
|
152
|
+
# config.translate_labels = true
|
153
|
+
|
154
|
+
# Automatically discover new inputs in Rails' autoload path.
|
155
|
+
# config.inputs_discovery = true
|
156
|
+
|
157
|
+
# Cache SimpleForm inputs discovery
|
158
|
+
# config.cache_discovery = !Rails.env.development?
|
159
|
+
|
160
|
+
# Default class for inputs
|
161
|
+
# config.input_class = nil
|
162
|
+
|
163
|
+
# Define the default class of the input wrapper of the boolean input.
|
164
|
+
config.boolean_label_class = 'checkbox'
|
165
|
+
|
166
|
+
# Defines if the default input wrapper class should be included in radio
|
167
|
+
# collection wrappers.
|
168
|
+
# config.include_default_input_wrapper_class = true
|
169
|
+
|
170
|
+
# Defines which i18n scope will be used in Simple Form.
|
171
|
+
# config.i18n_scope = 'simple_form'
|
172
|
+
|
173
|
+
# Defines validation classes to the input_field. By default it's nil.
|
174
|
+
# config.input_field_valid_class = 'is-valid'
|
175
|
+
# config.input_field_error_class = 'is-invalid'
|
176
|
+
end
|
@@ -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'
|
data/lib/olivander/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<%# frozen_string_literal: true %>
|
2
|
+
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
3
|
+
<%%= f.error_notification %>
|
4
|
+
<%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%- attributes.each do |attribute| -%>
|
8
|
+
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
|
9
|
+
<%- end -%>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class="form-actions">
|
13
|
+
<%%= f.button :submit %>
|
14
|
+
</div>
|
15
|
+
<%% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: five-two-nw-olivander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.2
|
4
|
+
version: 0.1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.2.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simple_form
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.1'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: view_component
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,11 +176,16 @@ files:
|
|
162
176
|
- app/controllers/olivander/resources/crud_controller.rb
|
163
177
|
- app/controllers/olivander/resources/default_crud_chain.rb
|
164
178
|
- app/controllers/olivander/test_controller.rb
|
179
|
+
- app/datatables/olivander/datatable.rb
|
165
180
|
- app/datatables/test_datatable.rb
|
166
181
|
- app/helpers/olivander/application_helper.rb
|
167
182
|
- app/jobs/olivander/application_job.rb
|
168
183
|
- app/mailers/olivander/application_mailer.rb
|
169
184
|
- app/models/olivander/application_record.rb
|
185
|
+
- app/views/application/edit.html.haml
|
186
|
+
- app/views/application/index.html.haml
|
187
|
+
- app/views/application/new.html.haml
|
188
|
+
- app/views/application/show.html.haml
|
170
189
|
- app/views/layouts/olivander/adminlte/_content.html.haml
|
171
190
|
- app/views/layouts/olivander/adminlte/_content_kanban.html.haml
|
172
191
|
- app/views/layouts/olivander/adminlte/_control_sidebar.html.haml
|
@@ -180,6 +199,8 @@ files:
|
|
180
199
|
- app/views/layouts/olivander/adminlte/main.html.haml
|
181
200
|
- app/views/layouts/olivander/application.html.haml
|
182
201
|
- config/initializers/effective_datatables.rb.old
|
202
|
+
- config/initializers/simple_form.rb
|
203
|
+
- config/locales/simple_form.en.yml
|
183
204
|
- config/routes.rb
|
184
205
|
- lib/five-two-nw-olivander.rb
|
185
206
|
- lib/olivander.rb
|
@@ -189,6 +210,7 @@ files:
|
|
189
210
|
- lib/olivander/menus/menu_item.rb
|
190
211
|
- lib/olivander/version.rb
|
191
212
|
- lib/tasks/olivander_tasks.rake
|
213
|
+
- lib/templates/erb/scaffold/_form.html.erb
|
192
214
|
homepage: https://rubygems.org/gems/olivander
|
193
215
|
licenses:
|
194
216
|
- MIT
|