five-two-nw-olivander 0.1.2.23 → 0.1.2.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e1ff112f4d4b249ab0810df0cec13e2dceddddafcaf228de4caa4d7009fbba5
4
- data.tar.gz: 471a085a13daf8ab6468d95999663351a07f761636fd559081dae664b459d11f
3
+ metadata.gz: 9898ba669152317001f7f33540a9367bb177c57ab66a7141599e2d813334c505
4
+ data.tar.gz: f39570a4bd11aedbf8f30dd60fbde534263b080297bfd057dafc3ae8ff2fbe9f
5
5
  SHA512:
6
- metadata.gz: a4aa345359703da27fcbf09077638bba6c8e229ca43b9792b5da97725af1439da746784496152796bc3a2e603bf4a85cf6efc199746130c09d391d98b2f65d07
7
- data.tar.gz: 5fab915b6c4e2cd4fd5a4560ee3cb44b3198d52fc16f78fb47fe8c05a3f21724e6f00a2d84cff83d37468e497022951a0076c803d0fb62759e3069f1ff8d847c
6
+ metadata.gz: 442950a337255b5c53805f09f58eed5bd0cc2185f55977cedad2f2000783c5d04dfc9624f0b89cbdb9520446ee3c73914b5bd788f03a6af38f99273b893abfe7
7
+ data.tar.gz: 8afccfa400c2512f2beab92b60e2758017f9fbce51d240f05b4d2128b3e89dea80eb81d9d551ce68d574efabe9060f72fc6419c21af94acf0fe5b9e2ef34e282
@@ -84,5 +84,34 @@ module Olivander
84
84
 
85
85
  sym.to_s.titleize
86
86
  end
87
+
88
+ def is_dev_environment?
89
+ sidebar_context_suffix != 'production'
90
+ end
91
+
92
+ def sidebar_context_name
93
+ [@context.name, sidebar_context_suffix&.upcase].reject(&:blank?).join(' ')
94
+ end
95
+
96
+ def sidebar_context_suffix
97
+ suffix = nil
98
+ suffix ||= ENV['CLIENT_ENVIRONMENT']
99
+ parts = request.host.split('.')
100
+ suffix ||= parts.first.split('-').last.downcase if request.host.include?('-')
101
+ suffix ||= 'local' if %w[localhost test].include?(parts.last.downcase)
102
+ suffix ||= 'production'
103
+ suffix
104
+ end
105
+
106
+ def sidebar_background_class
107
+ @context.sidebar_background_class ||
108
+ ENV['SIDEBAR_BACKGROUND_CLASS'] ||
109
+ (is_dev_environment? ? 'bg-danger' : 'bg-info')
110
+ end
111
+
112
+ def favicon_link
113
+ favicon_path = is_dev_environment? ? '/images/favicon-dev.png' : '/images/favicon.ico'
114
+ favicon_link_tag(image_path(favicon_path))
115
+ end
87
116
  end
88
117
  end
@@ -0,0 +1,43 @@
1
+ class CustomFormBuilder < SimpleForm::FormBuilder
2
+ def initialize(*)
3
+ Rails.logger.warn "instantiating this class"
4
+ super
5
+ end
6
+
7
+ def association(association, options = {}, &block)
8
+ Rails.logger.warn "making an association"
9
+ resolve_custom_input_association(association, options)
10
+ super(association, options, &block)
11
+ end
12
+
13
+ def resolve_custom_input_association(association, options)
14
+ return if options[:as].present?
15
+
16
+ [
17
+ "#{object.class.name.demodulize}#{association.to_s.titleize}", "#{association.to_s.titleize}"
18
+ ].each do |key|
19
+ Rails.logger.debug "trying for #{key}"
20
+ next unless attempt_mapping_with_custom_namespace("#{key}Input").present?
21
+
22
+ options[:as] = key.to_sym
23
+ break
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def fetch_association_collection(reflection, options)
30
+ Rails.logger.warn "we got into here"
31
+
32
+ options_method = "options_for_#{reflection.name}".to_sym
33
+ if object.respond_to?(options_method) then
34
+ Rails.logger.info "using specific method"
35
+ options.fetch(:collection) do
36
+ object.send(options_method)
37
+ end
38
+ else
39
+ Rails.logger.info "doing it old school"
40
+ super(reflection, options)
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,5 @@
1
1
  - read_only = action_name != 'edit'
2
- = simple_form_for(@resource) do |f|
2
+ = simple_form_for(@resource, builder: CustomFormBuilder) do |f|
3
3
  .card.card-primary
4
4
  .card-header
5
5
  %h3.card-title= @resource
@@ -1,3 +1,4 @@
1
- json.items @resources do |resource|
2
- json.id resource.id
3
- end
1
+ resource = (@_effective_resource || Effective::Resource.new(controller_path))
2
+ @resources = instance_variable_get('@' + resource.plural_name)
3
+
4
+ json.array! @resources
@@ -2,6 +2,7 @@
2
2
  %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
3
3
  %title= page_title
4
4
  %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/
5
+ = favicon_link
5
6
  = csrf_meta_tags
6
7
  = csp_meta_tag
7
8
  %link{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback' }
@@ -1,9 +1,9 @@
1
1
  / Main Sidebar Container
2
2
  %aside.main-sidebar.sidebar-dark-primary.elevation-4{ data: { controller: 'left-nav' }}
3
3
  / Brand Logo
4
- %a.brand-link.bg-info{:href => "/"}
4
+ %a.brand-link{ href: "/", class: sidebar_background_class }
5
5
  %img.brand-image.img-circle.elevation-3{:alt => @context.logo.alt, :src => @context.logo.url, :style => "opacity: .8"}/
6
- %span.brand-text.font-weight-light= @context.name
6
+ %span.brand-text.font-weight-light= sidebar_context_name
7
7
  / Sidebar
8
8
  .sidebar
9
9
  / Sidebar user panel (optional)
@@ -70,16 +70,49 @@ SimpleForm.setup do |config|
70
70
  config.wrappers :checkbox, class: "form-check",
71
71
  hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
72
72
  b.use :html5
73
- b.use :placeholder
74
- b.optional :maxlength
75
- b.optional :minlength
76
- b.optional :pattern
77
- b.optional :min_max
78
73
  b.optional :readonly
79
- b.use :input, class: 'form-check-input'
80
- b.use :label #, class: 'form-control'
81
- b.use :hint, wrap_with: { tag: :span, class: :hint }
82
- b.use :error, wrap_with: { tag: :span, class: "text-danger" }
74
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
75
+ ba.use :label_text
76
+ end
77
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
78
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
79
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
80
+ end
81
+
82
+ # vertical input for boolean
83
+ config.wrappers :vertical_boolean, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
84
+ b.use :html5
85
+ b.optional :readonly
86
+ b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb|
87
+ bb.use :input, class: 'form-check-input' #, error_class: 'is-invalid', valid_class: 'is-valid'
88
+ bb.use :label, class: 'form-check-label'
89
+ bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
90
+ bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
91
+ end
92
+ end
93
+
94
+ # vertical input for radio buttons and check boxes
95
+ config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
96
+ b.use :html5
97
+ b.optional :readonly
98
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
99
+ ba.use :label_text
100
+ end
101
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
102
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
103
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
104
+ end
105
+
106
+ # vertical input for inline radio buttons and check boxes
107
+ config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
108
+ b.use :html5
109
+ b.optional :readonly
110
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
111
+ ba.use :label_text
112
+ end
113
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
114
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
115
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
83
116
  end
84
117
 
85
118
  config.wrappers :switch, class: "custom-control custom-switch",
@@ -170,10 +203,24 @@ SimpleForm.setup do |config|
170
203
  # Custom wrappers for input types. This should be a hash containing an input
171
204
  # type as key and the wrapper that will be used for all inputs with specified type.
172
205
  # config.wrapper_mappings = { string: :prepend }
206
+ config.wrapper_mappings = {
207
+ boolean: :vertical_boolean,
208
+ check_boxes: :check_box,
209
+ # date: :horizontal_multi_select,
210
+ # datetime: :horizontal_multi_select,
211
+ # file: :horizontal_file,
212
+ # radio_buttons: :horizontal_collection,
213
+ # range: :horizontal_range,
214
+ # time: :horizontal_multi_select
215
+ }
173
216
 
174
217
  # Namespaces where SimpleForm should look for custom input classes that
175
218
  # override default inputs.
176
- # config.custom_inputs_namespaces << "CustomInputs"
219
+ Dir.glob('app/inputs/**/')
220
+ .map{ |x| x.gsub('app/inputs/', '').split('/').reject(&:blank?).join('/').camelize }
221
+ .reject(&:blank?).each do |d|
222
+ config.custom_inputs_namespaces << d
223
+ end
177
224
 
178
225
  # Default priority for time_zone inputs.
179
226
  # config.time_zone_priority = nil
@@ -1,6 +1,6 @@
1
1
  module Olivander
2
2
  class ApplicationContext
3
- attr_accessor :name, :logo, :company, :menu_items, :route_builder, :sign_out_path
3
+ attr_accessor :name, :logo, :company, :menu_items, :route_builder, :sign_out_path, :sidebar_background_class
4
4
 
5
5
  def self.default
6
6
  ctx = ApplicationContext.new
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = "0.1.2.23"
2
+ VERSION = '0.1.2.24'.freeze
3
3
  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.23
4
+ version: 0.1.2.24
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-24 00:00:00.000000000 Z
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick
@@ -194,6 +194,7 @@ files:
194
194
  - app/controllers/olivander/application_controller.rb
195
195
  - app/datatables/olivander/datatable.rb
196
196
  - app/helpers/olivander/application_helper.rb
197
+ - app/inputs/custom_form_builder.rb
197
198
  - app/inputs/date_time_input.rb
198
199
  - app/jobs/olivander/application_job.rb
199
200
  - app/mailers/olivander/application_mailer.rb