five-two-nw-olivander 0.2.0.5 → 0.2.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8143b2faef8f3a4a66f49a4de75815c3e4f31cb92cae9f66017cb5bb928e7f7
4
- data.tar.gz: 5d03f6db29f5435a04c83d1be27ae67b81922aa267b4203dc507b73cfafe1963
3
+ metadata.gz: 2b23f7bab4f40d25ff84742a1e66c4d8d658c19697d4c3a02eb95a31ea5b6c3c
4
+ data.tar.gz: 14147a7fa4bd820a3dfc6b42ff22e5046a64a61de5e53cf387c8fd78c2938f1f
5
5
  SHA512:
6
- metadata.gz: 11dcfc173f945d1100f793d7b749842e0e4b5be5ea1e010ae40ad1044366f8766a0368d7bd0c641561863c5437127686638cd107d0b86d9f281dc7be31c192ad
7
- data.tar.gz: b241c425f3bff5e26e9409584a242e7f3952eb0b0f9edbd833f8a855d0893f446d39688e69e0127c845eb46bf96c2f8cdc2466c412356574bad57316088b0e4a
6
+ metadata.gz: e25a94a5a33cd5a66b0f10c45b514d0652a693abd91daea7c3150d388b82ac394ab5bb34ac99299debeea5b2c2979ba52e8355132d0d970051ef176549f1127d
7
+ data.tar.gz: 19fc5469c3f3643a499c94558388187ab98170f2b1d5fc620ddf5941692c0e6f42f2fef05332c46878787a13b9006eca6c21200bcdbd7e0a61a018194e7122f9
@@ -15,7 +15,11 @@ export default class extends Controller {
15
15
  dataType: 'json',
16
16
  processResults: function(data) {
17
17
  return { results: data.map(function(map) {
18
- return { id: map.id, text: map.text || map.name || map.description };
18
+ return {
19
+ id: map.id,
20
+ text: map.text || map.name || map.description,
21
+ children: map.children
22
+ };
19
23
  }) };
20
24
  }
21
25
  }
@@ -6,6 +6,7 @@ module Olivander
6
6
  included do
7
7
  include Effective::CrudController
8
8
  layout 'olivander/adminlte/main'
9
+ before_action :fix_date_params
9
10
 
10
11
  def index
11
12
  if request.format == :json && params[:_type].present? && params[:_type] == 'query'
@@ -17,6 +18,25 @@ module Olivander
17
18
 
18
19
  def index_search
19
20
  self.resources ||= resource_scope.all if resource_scope.respond_to?(:all)
21
+ index_term_search if params[:term].present?
22
+ index_param_search
23
+ if resources.order_values.size.zero? && resources.model.implicit_order_column.present?
24
+ self.resources = resources.order(resources.model.implicit_order_column.to_sym)
25
+ end
26
+ self.resources = self.resources.limit(25)
27
+ end
28
+
29
+ def index_param_search
30
+ params.each do |param|
31
+ effective_resource.klass.columns.each do |col|
32
+ next unless col.name == param[0] #&& !param[1].blank?
33
+
34
+ self.resources = self.resources.where(param[0].to_sym => param[1])
35
+ end
36
+ end
37
+ end
38
+
39
+ def index_term_search
20
40
  if resource_scope.respond_to?(:search_for)
21
41
  self.resources = self.resources.search_for(params[:term])
22
42
  else
@@ -31,7 +51,6 @@ module Olivander
31
51
  self.resources = self.resources.where(clauses) if clauses.present? && clauses.length.positive?
32
52
  self.resources = self.resources.order(orders) if orders.length.positive?
33
53
  end
34
- self.resources = self.resources.limit(25)
35
54
  end
36
55
 
37
56
  def permitted_params
@@ -93,6 +112,73 @@ module Olivander
93
112
  end
94
113
  end
95
114
  end
115
+
116
+ def respond_with_error(resource, action)
117
+ return if response.body.present?
118
+
119
+ flash.delete(:success)
120
+ flash.now[:danger] ||= resource_flash(:danger, resource, action)
121
+
122
+ respond_to do |format|
123
+ case action_name.to_sym
124
+ when :create
125
+ format.html { render :new }
126
+ when :update
127
+ format.html { render :edit }
128
+ when :destroy
129
+ format.html do
130
+ redirect_flash
131
+ redirect_to(resource_redirect_path(resource, action))
132
+ end
133
+ else
134
+ if template_present?(action)
135
+ format.html { render(action, locals: { action: action }) }
136
+ elsif request.referer.to_s.end_with?('/edit')
137
+ format.html { render :edit }
138
+ elsif request.referer.to_s.end_with?('/new')
139
+ format.html { render :new }
140
+ else
141
+ format.html do
142
+ redirect_flash
143
+ redirect_to(resource_redirect_path(resource, action))
144
+ end
145
+ end
146
+ end
147
+
148
+ format.js do
149
+ view = template_present?(action) ? action : :member_action
150
+ render(view, locals: { action: action }) # action.js.erb
151
+ end
152
+
153
+ format.turbo_stream do
154
+ end
155
+ end
156
+ end
157
+
158
+ def date_params
159
+ []
160
+ end
161
+
162
+ def fix_date_params
163
+ recurse_and_fix_date_params(params)
164
+ end
165
+
166
+ def recurse_and_fix_date_params(params)
167
+ params.keys.each do |k|
168
+ if params[k].is_a? ActionController::Parameters
169
+ recurse_and_fix_date_params(params[k])
170
+ else
171
+ params[k] = rearrange_date_param(params[k]) if date_params.include?(k.to_sym)
172
+ end
173
+ end
174
+ end
175
+
176
+ def rearrange_date_param(value)
177
+ return nil if value.blank?
178
+
179
+ parts = value.split('/')
180
+ "#{parts[2]}-#{parts[0]}-#{parts[1]}"
181
+ end
96
182
  end
97
183
  end
98
184
  end
@@ -3,8 +3,8 @@
3
3
  = render partial: 'layouts/olivander/adminlte/head'
4
4
  %body.hold-transition.login-page
5
5
  .login-box
6
- -# .login-logo
7
- -# %img.brand-image.img-circle.elevation-3{:alt => Olivander::CurrentContext.application_context.logo.alt, :src => Olivander::CurrentContext.application_context.logo.url, :style => "opacity: .8"}
6
+ - unless Olivander::CurrentContext.application_context.login_logo.url.blank?
7
+ %img{ alt: Olivander::CurrentContext.application_context.login_logo.alt, src: Olivander::CurrentContext.application_context.login_logo.url, style: "max-width: 100%; opacity: 1.0" }
8
8
  .card
9
9
  .card-header.text-center{ class: sidebar_background_class }
10
10
  %a.h1{ href: '/' }
@@ -125,7 +125,7 @@ SimpleForm.setup do |config|
125
125
  b.optional :min_max
126
126
  b.optional :readonly
127
127
  b.use :input, class: 'custom-control-input'
128
- #b.use :label, class: 'custom-control-label'
128
+ b.use :label, class: 'custom-control-label'
129
129
  b.use :hint, wrap_with: { tag: :span, class: :hint }
130
130
  b.use :error, wrap_with: { tag: :span, class: "text-danger" }
131
131
  end
@@ -1,10 +1,11 @@
1
1
  module Olivander
2
2
  class ApplicationContext
3
- attr_accessor :name, :logo, :company, :menu_items, :route_builder, :sign_out_path, :sidebar_background_class
3
+ attr_accessor :name, :logo, :login_logo, :company, :menu_items, :route_builder, :sign_out_path, :sidebar_background_class
4
4
 
5
5
  def initialize(**kwargs)
6
6
  self.name = kwargs[:name] || ENV['OLIVANDER_APP_NAME'] || 'Application Name'
7
7
  self.logo = kwargs[:logo] || Logo.new(url: kwargs[:logo_url], alt: kwargs[:logo_alt])
8
+ self.login_logo = kwargs[:login_logo] || LoginLogo.new(url: kwargs[:login_logo_url], alt: kwargs[:login_logo_alt])
8
9
  self.company = kwargs[:company] || Company.new(name: kwargs[:company_name], url: kwargs[:company_url])
9
10
  self.sign_out_path = kwargs[:sign_out_path] || '/sign_out'
10
11
  self.menu_items = kwargs[:menu_items] || []
@@ -41,6 +42,15 @@ module Olivander
41
42
  end
42
43
  end
43
44
 
45
+ class LoginLogo
46
+ attr_accessor :url, :alt
47
+
48
+ def initialize(**kwargs)
49
+ self.url = kwargs[:url] || ENV['OLIVANDER_LOGIN_LOGO_URL'] || '/images/olivander_login_logo.png'
50
+ self.alt = kwargs[:alt] || ENV['OLIVANDER_LOGIN_LOGO_ALT'] || 'Login Logo Image'
51
+ end
52
+ end
53
+
44
54
  class Company
45
55
  attr_accessor :name, :url
46
56
 
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = '0.2.0.5'.freeze
2
+ VERSION = '0.2.0.7'.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.2.0.5
4
+ version: 0.2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2024-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick