five-two-nw-olivander 0.2.0.6 → 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: ec1b83147e32bcad39702fd0a0a42a71a819e6f16ccc04ce2bf736a72cf8ba14
4
- data.tar.gz: 0fa90392ac13ae2161024e59def15f555c7f38e8ebf036bf4787bd0f91a72602
3
+ metadata.gz: 2b23f7bab4f40d25ff84742a1e66c4d8d658c19697d4c3a02eb95a31ea5b6c3c
4
+ data.tar.gz: 14147a7fa4bd820a3dfc6b42ff22e5046a64a61de5e53cf387c8fd78c2938f1f
5
5
  SHA512:
6
- metadata.gz: 93c448ec29561ffd681659106967a9149d17a877c123c737f05d98f408643e698fef4930f3cf0e310caa59acc675e0ae095c6dc9fc878d94c13ee0c46ebb3838
7
- data.tar.gz: 63b5b466d541df95458ed0f7474aab9da06dba1803fa5a6118b1882e12391414824bdba931d9931ed065ccabbfdeedad945fb368063f758727f9cb0aeedd7716
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
@@ -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,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = '0.2.0.6'.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.6
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-21 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