five-two-nw-olivander 0.1.2.43.a → 0.1.2.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/olivander/components/resource_show_component.html.haml +7 -1
- data/app/controllers/concerns/olivander/resources/auto_form_attributes.rb +7 -7
- data/app/datatables/olivander/datatable.rb +3 -5
- data/app/views/application/_resource_form_actions.html.haml +1 -1
- data/app/views/application/show.html.haml +2 -0
- data/app/views/layouts/olivander/adminlte/_login_flashes.html.haml +4 -0
- data/lib/olivander/version.rb +1 -1
- metadata +4 -28
- data/app/assets/javascripts/controllers/refresh_datatable_controller.js +0 -9
- data/app/controllers/concerns/olivander/resources/model_registrar.rb +0 -49
- data/app/controllers/concerns/olivander/resources/model_registry.rb +0 -201
- data/app/javascript/controllers/refresh_datatable_controller.js +0 -11
- data/lib/generators/olivander/active_record/migration/templates/create_table_migration.rb.tt +0 -28
- data/lib/generators/olivander/active_record/model/templates/model.rb.tt +0 -32
- data/lib/generators/olivander/active_record/model/templates/module.rb.tt +0 -7
- data/lib/generators/olivander/active_record_generator.rb +0 -21
- data/lib/generators/olivander/controller/templates/controller.rb.tt +0 -8
- data/lib/generators/olivander/controller_generator.rb +0 -7
- data/lib/generators/olivander/datatable/templates/datatable.rb.tt +0 -0
- data/lib/generators/olivander/datatable_generator.rb +0 -13
- data/lib/generators/olivander/install/USAGE +0 -8
- data/lib/generators/olivander/install/install_generator.rb +0 -28
- data/lib/generators/olivander/install/templates/context_builder.rb +0 -3
- data/lib/generators/olivander/install/templates/effective_datatables.rb +0 -51
- data/lib/generators/olivander/install/templates/effective_resources.rb +0 -57
- data/lib/generators/olivander/install/templates/favicon-dev.ico +0 -0
- data/lib/generators/olivander/install/templates/favicon.ico +0 -0
- data/lib/generators/olivander/install/templates/logo.png +0 -0
- data/lib/generators/olivander/install/templates/lograge.rb +0 -32
- data/lib/generators/olivander/install/templates/route_builder.rb +0 -3
- data/lib/generators/olivander/scaffold/USAGE +0 -8
- data/lib/generators/olivander/scaffold_generator.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16cf7a76d584d994ebe2a9288a075ace5c102267db5f9f9a1421419649a1e2d4
|
4
|
+
data.tar.gz: 70cf5157b16b6ba71d3b9419fa7be32313fb2649f3f0f18a895a935968ac20b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 733bf715caa8743fedbaac361989ac3a666fa0a5de69d13d30e4172a4a7b3950528bfd22ea617d412148757f2c96fcfb9a84e8561f4014812e724146856376b6
|
7
|
+
data.tar.gz: 61153f2f1bf784b231420905d8de974d09f68a188ed12fe59ef1c8690a38a742ee345754673e426acdc8d8d002a9b8293170b3c8bb05869eddf5454681be78ca
|
@@ -22,7 +22,13 @@
|
|
22
22
|
- icon_class = val ? 'fa-check text-success' : 'fa-times text-danger'
|
23
23
|
%i.fa{ class: icon_class }
|
24
24
|
- when :association
|
25
|
-
|
25
|
+
- if val.present?
|
26
|
+
- if val.is_a?(ActiveRecord::Associations::CollectionProxy)
|
27
|
+
%ul
|
28
|
+
- val.each do |val1|
|
29
|
+
%li= link_to val1
|
30
|
+
- else
|
31
|
+
= link_to val if val.present?
|
26
32
|
- else
|
27
33
|
= val
|
28
34
|
- (section.columns-slice.size).times do
|
@@ -49,14 +49,14 @@ module Olivander
|
|
49
49
|
sym = att.name.to_sym
|
50
50
|
type = att.type
|
51
51
|
next unless inc == sym
|
52
|
+
resource_field sym, type
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
|
55
|
+
reflections.map{ |x| x[1] }
|
56
|
+
.filter{ |x| x.foreign_key == inc || x.name == inc }
|
57
|
+
.each do |r|
|
58
|
+
sym = r.name
|
59
|
+
type = :association
|
60
60
|
resource_field sym, type
|
61
61
|
end
|
62
62
|
end
|
@@ -64,14 +64,12 @@ module Olivander
|
|
64
64
|
label = field_label_for(klazz, key)
|
65
65
|
sym = key.gsub('_id', '')
|
66
66
|
visible = show.include?(key) || !(default_hidden.include?(key) || hide.include?(key))
|
67
|
-
if
|
68
|
-
|
69
|
-
elsif link_path.present? && sym == 'name'
|
70
|
-
link_col sym, link_path, :id, visible: visible
|
67
|
+
if %w[id name first_name last_name display_name title].include?(sym)
|
68
|
+
col sym, visible: visible, action: :show
|
71
69
|
elsif sym.include?('.')
|
72
70
|
col sym, visible: visible, label: label
|
73
71
|
else
|
74
|
-
col sym, visible: visible, label: label
|
72
|
+
col sym, visible: visible, label: label
|
75
73
|
end
|
76
74
|
end
|
77
75
|
actions_col
|
@@ -7,7 +7,7 @@
|
|
7
7
|
= resource_form_action_label(@resource, a.sym)
|
8
8
|
|
9
9
|
- if a.turbo_frame.blank?
|
10
|
-
= link_to({ controller: a.controller, action: a.action }, method: a.verb, class: 'btn btn-tool') do
|
10
|
+
= link_to({ controller: a.controller, action: a.action }, method: a.verb, class: 'btn btn-tool', data: { confirm: 'are you sure?' }) do
|
11
11
|
= yield cf_sym
|
12
12
|
- else
|
13
13
|
= link_to({ controller: a.controller, action: a.action }, class: 'btn btn-tool', data: { turbo: true, turbo_method: a.verb, turbo_frame: a.turbo_frame }) do
|
@@ -12,7 +12,9 @@
|
|
12
12
|
.card-tools
|
13
13
|
= resource_form_actions(@context.route_builder, @resource, for_action: action_name.to_sym)
|
14
14
|
.card-body
|
15
|
+
= render_optional_partial 'show_inside_before'
|
15
16
|
= render Olivander::Components::ResourceShowComponent.new(@resource, [])
|
17
|
+
= render_optional_partial 'show_inside_after'
|
16
18
|
.card-footer.text-right
|
17
19
|
= link_to 'Cancel', @_effective_resource.action_path(:index), class: 'btn btn-secondary'
|
18
20
|
|
data/lib/olivander/version.rb
CHANGED
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.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|
@@ -190,7 +190,6 @@ files:
|
|
190
190
|
- app/assets/javascripts/adminlte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css
|
191
191
|
- app/assets/javascripts/adminlte/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js
|
192
192
|
- app/assets/javascripts/adminlte/select2_defaults.coffee
|
193
|
-
- app/assets/javascripts/controllers/refresh_datatable_controller.js
|
194
193
|
- app/assets/stylesheets/adminlte.css
|
195
194
|
- app/assets/stylesheets/fa-fix.scss
|
196
195
|
- app/assets/stylesheets/olivander/application.css
|
@@ -210,14 +209,11 @@ files:
|
|
210
209
|
- app/components/olivander/components/table_portlet_component.rb
|
211
210
|
- app/components/olivander/components/table_portlet_component/table_component.html.haml
|
212
211
|
- app/controllers/concerns/olivander/resources/auto_form_attributes.rb
|
213
|
-
- app/controllers/concerns/olivander/resources/model_registrar.rb
|
214
|
-
- app/controllers/concerns/olivander/resources/model_registry.rb
|
215
212
|
- app/controllers/concerns/olivander/resources/route_builder.rb
|
216
213
|
- app/controllers/olivander/application_controller.rb
|
217
214
|
- app/datatables/olivander/datatable.rb
|
218
215
|
- app/helpers/olivander/application_helper.rb
|
219
216
|
- app/inputs/date_time_input.rb
|
220
|
-
- app/javascript/controllers/refresh_datatable_controller.js
|
221
217
|
- app/jobs/olivander/application_job.rb
|
222
218
|
- app/mailers/olivander/application_mailer.rb
|
223
219
|
- app/models/olivander/application_record.rb
|
@@ -245,26 +241,6 @@ files:
|
|
245
241
|
- config/locales/simple_form.en.yml
|
246
242
|
- config/routes.rb
|
247
243
|
- lib/five-two-nw-olivander.rb
|
248
|
-
- lib/generators/olivander/active_record/migration/templates/create_table_migration.rb.tt
|
249
|
-
- lib/generators/olivander/active_record/model/templates/model.rb.tt
|
250
|
-
- lib/generators/olivander/active_record/model/templates/module.rb.tt
|
251
|
-
- lib/generators/olivander/active_record_generator.rb
|
252
|
-
- lib/generators/olivander/controller/templates/controller.rb.tt
|
253
|
-
- lib/generators/olivander/controller_generator.rb
|
254
|
-
- lib/generators/olivander/datatable/templates/datatable.rb.tt
|
255
|
-
- lib/generators/olivander/datatable_generator.rb
|
256
|
-
- lib/generators/olivander/install/USAGE
|
257
|
-
- lib/generators/olivander/install/install_generator.rb
|
258
|
-
- lib/generators/olivander/install/templates/context_builder.rb
|
259
|
-
- lib/generators/olivander/install/templates/effective_datatables.rb
|
260
|
-
- lib/generators/olivander/install/templates/effective_resources.rb
|
261
|
-
- lib/generators/olivander/install/templates/favicon-dev.ico
|
262
|
-
- lib/generators/olivander/install/templates/favicon.ico
|
263
|
-
- lib/generators/olivander/install/templates/logo.png
|
264
|
-
- lib/generators/olivander/install/templates/lograge.rb
|
265
|
-
- lib/generators/olivander/install/templates/route_builder.rb
|
266
|
-
- lib/generators/olivander/scaffold/USAGE
|
267
|
-
- lib/generators/olivander/scaffold_generator.rb
|
268
244
|
- lib/olivander.rb
|
269
245
|
- lib/olivander/application_context.rb
|
270
246
|
- lib/olivander/engine.rb
|
@@ -294,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
270
|
version: '0'
|
295
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
296
272
|
requirements:
|
297
|
-
- - "
|
273
|
+
- - ">="
|
298
274
|
- !ruby/object:Gem::Version
|
299
|
-
version:
|
275
|
+
version: '0'
|
300
276
|
requirements: []
|
301
277
|
rubygems_version: 3.1.6
|
302
278
|
signing_key:
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'olivander/resources/model_registry'
|
2
|
-
|
3
|
-
module Olivander
|
4
|
-
module Resources
|
5
|
-
module ModelRegistrar
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
def this_is_included_method
|
10
|
-
puts 'hi'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class_methods do
|
15
|
-
def register_model(model = self, context: :default, using: self, &block)
|
16
|
-
Rails.logger.debug "###################"
|
17
|
-
Rails.logger.debug "registering model #{model.name} in context #{context} using #{using&.name} at #{self.name}"
|
18
|
-
using.register_model(model, context: context, &block) && return unless using == self
|
19
|
-
|
20
|
-
::Olivander::Resources::ModelRegistry.global_registry.register(model, &block)
|
21
|
-
Rails.logger.debug "###################\n"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class TestRegistrant
|
27
|
-
end
|
28
|
-
|
29
|
-
class TestRegistrar
|
30
|
-
include ModelRegistrar
|
31
|
-
end
|
32
|
-
|
33
|
-
class TestRegistrar2
|
34
|
-
include ModelRegistrar
|
35
|
-
|
36
|
-
# register_model do
|
37
|
-
# puts 'hello'
|
38
|
-
# field_layout :show do :all end
|
39
|
-
# end
|
40
|
-
# register_model Olivander::Resources::TestRegistrant, context: :foo do
|
41
|
-
# puts 'this is the other thing'
|
42
|
-
# field_layout do [[1, :id]] end
|
43
|
-
# end
|
44
|
-
# register_model context: :bar, using: TestRegistrar do
|
45
|
-
# puts 'and lastly...'
|
46
|
-
# end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,201 +0,0 @@
|
|
1
|
-
module Olivander
|
2
|
-
module Resources
|
3
|
-
module ModelRegistry
|
4
|
-
mattr_accessor :global_registry
|
5
|
-
|
6
|
-
module Registry
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
class_methods do
|
10
|
-
attr_accessor :_registry_hash
|
11
|
-
attr_accessor :_registering
|
12
|
-
|
13
|
-
def register(model, &block)
|
14
|
-
self._registry_hash ||= {}
|
15
|
-
self._registering = ensure_registry_for(model)
|
16
|
-
instance_exec(&block)
|
17
|
-
_registering.make_datatable_classes
|
18
|
-
self._registering = nil
|
19
|
-
# Rails.logger.debug _registry_hash
|
20
|
-
end
|
21
|
-
|
22
|
-
def entry_for(model)
|
23
|
-
_registry_hash[model]
|
24
|
-
end
|
25
|
-
|
26
|
-
def ensure_registry_for(model)
|
27
|
-
_registry_hash[model] ||= RegisteredModel.new(model)
|
28
|
-
end
|
29
|
-
|
30
|
-
def field_layout(layouts = [:show, :form])
|
31
|
-
layouts = [*layouts] # ensure it's an array
|
32
|
-
field_layout = block_given? ? yield : :all
|
33
|
-
layouts.each do |layout|
|
34
|
-
Rails.logger.debug "setting layout for #{_registering}[#{layout}]"
|
35
|
-
_registering.add_layout(layout, field_layout)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def add_datatable(view = nil, &block)
|
40
|
-
_registering.add_datatable(view, DatatableDef.new(_registering, &block))
|
41
|
-
end
|
42
|
-
|
43
|
-
def render_fields(field_list, with_format: :string)
|
44
|
-
_registering.render_fields(field_list, with_format)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class DatatableDef
|
50
|
-
attr_accessor :model, :blocks, :datatable_class, :block
|
51
|
-
|
52
|
-
def initialize(model, &block)
|
53
|
-
Rails.logger.info "making new datatable"
|
54
|
-
Rails.logger.info block.source
|
55
|
-
self.model = model
|
56
|
-
self.blocks = {}
|
57
|
-
|
58
|
-
# instance_exec(&block) if block_given?
|
59
|
-
self.block = block
|
60
|
-
end
|
61
|
-
|
62
|
-
def datatable(sym)
|
63
|
-
blocks[:datatable] = Proc.new{ datatable do model.send(sym) end }
|
64
|
-
end
|
65
|
-
|
66
|
-
def collection(sym)
|
67
|
-
blocks[:collection] = Proc.new{ collection do model.send(sym) end }
|
68
|
-
end
|
69
|
-
|
70
|
-
def filters(sym)
|
71
|
-
blocks[:filters] = Proc.new{ model.send(sym) }
|
72
|
-
end
|
73
|
-
|
74
|
-
def charts(sym)
|
75
|
-
blocks[:charts] = Proc.new{ model.send(sym) }
|
76
|
-
end
|
77
|
-
|
78
|
-
def make_class(key)
|
79
|
-
# return datatable_class unless datatable_class.nil?
|
80
|
-
# ensure_blocks
|
81
|
-
|
82
|
-
name_key = key == :index ? '' : key
|
83
|
-
name = [model.name.demodulize, name_key, 'Datatable'].join
|
84
|
-
blocks = self.blocks
|
85
|
-
block = self.block
|
86
|
-
klass = Class.new(Olivander::Datatable) do
|
87
|
-
puts 'stuff'
|
88
|
-
# blocks.values.each do |block|
|
89
|
-
# puts 'this is a block'
|
90
|
-
# puts block.source
|
91
|
-
# instance_eval(block.source)
|
92
|
-
# binding.pry
|
93
|
-
# instance_exec(&block)
|
94
|
-
# end
|
95
|
-
# collection do
|
96
|
-
# Erp::Rate.all
|
97
|
-
# end
|
98
|
-
instance_exec(&block)
|
99
|
-
end
|
100
|
-
module_name = model.name.deconstantize
|
101
|
-
constantized_module = module_name.constantize
|
102
|
-
constantized_module.send(:remove_const, name) if constantized_module.const_defined?(name)
|
103
|
-
self.datatable_class = constantized_module.const_set(name, klass)
|
104
|
-
end
|
105
|
-
|
106
|
-
def ensure_blocks
|
107
|
-
blocks[:collection] ||= Proc.new{
|
108
|
-
model.all
|
109
|
-
}
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
class RegisteredModel
|
114
|
-
attr_accessor :fields, :layouts, :datatables, :name, :model
|
115
|
-
|
116
|
-
def initialize(model)
|
117
|
-
self.model = model
|
118
|
-
set_fields
|
119
|
-
self.layouts = {}
|
120
|
-
self.datatables = {}
|
121
|
-
self.name = model.name
|
122
|
-
end
|
123
|
-
|
124
|
-
def to_s
|
125
|
-
name
|
126
|
-
end
|
127
|
-
|
128
|
-
def inspect
|
129
|
-
name
|
130
|
-
end
|
131
|
-
|
132
|
-
def add_layout(key, layout)
|
133
|
-
layout = [[2, fields]] if layout == :all
|
134
|
-
layouts[key] = layout
|
135
|
-
end
|
136
|
-
|
137
|
-
def layout(key)
|
138
|
-
layouts[key] || add_layout(key, :all)
|
139
|
-
end
|
140
|
-
|
141
|
-
def add_datatable(key, datatable_def)
|
142
|
-
Rails.logger.info "adding datatable #{key}"
|
143
|
-
datatables[key || :index] = datatable_def
|
144
|
-
# binding.pry
|
145
|
-
end
|
146
|
-
|
147
|
-
def datatable(key)
|
148
|
-
datatables[key] || add_datatable(key, DatatableDef.new(self))
|
149
|
-
end
|
150
|
-
|
151
|
-
def make_datatable_classes
|
152
|
-
datatables.each do |key, dt_def|
|
153
|
-
dt_def.make_class(key)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def render_fields(field_list, with_format)
|
158
|
-
field_list.each do |field|
|
159
|
-
fields[field].render_as = with_format
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
private
|
164
|
-
|
165
|
-
def set_fields
|
166
|
-
self.fields = {}
|
167
|
-
|
168
|
-
if model.respond_to?(:columns)
|
169
|
-
model.columns.map{ |x| RegisteredField.new(x) }.each do |field|
|
170
|
-
fields[field.key] = field
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
class RegisteredField
|
177
|
-
attr_accessor :key, :ar_def, :dt_def, :render_as
|
178
|
-
|
179
|
-
def to_s
|
180
|
-
key
|
181
|
-
end
|
182
|
-
|
183
|
-
def inspect
|
184
|
-
key
|
185
|
-
end
|
186
|
-
|
187
|
-
def initialize(ar_def)
|
188
|
-
self.key = ar_def.name.to_sym
|
189
|
-
self.ar_def = ar_def
|
190
|
-
self.render_as = ar_def.type
|
191
|
-
self.dt_def = {}
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
class DefaultModelRegistry
|
196
|
-
include Registry
|
197
|
-
::Olivander::Resources::ModelRegistry.global_registry = Olivander::Resources::ModelRegistry::DefaultModelRegistry
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
2
|
-
|
3
|
-
console.log('this code was executed')
|
4
|
-
|
5
|
-
// Connects to data-controller="refresh-datatable"
|
6
|
-
export default class extends Controller {
|
7
|
-
connect() {
|
8
|
-
console.log('the refresh datatable controller was initialized')
|
9
|
-
console.log('this happened')
|
10
|
-
}
|
11
|
-
}
|
data/lib/generators/olivander/active_record/migration/templates/create_table_migration.rb.tt
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
-
def change
|
3
|
-
create_table :<%= table_name %><%= primary_key_type %> do |t|
|
4
|
-
t.references :tenancy, index: true, foreign_key: true
|
5
|
-
<% attributes.each do |attribute| -%>
|
6
|
-
<% foreign_key_type ||= nil -%>
|
7
|
-
<% if attribute.password_digest? -%>
|
8
|
-
t.string :password_digest<%= attribute.inject_options %>
|
9
|
-
<% elsif attribute.token? -%>
|
10
|
-
t.string :<%= attribute.name %><%= attribute.inject_options %>
|
11
|
-
<% elsif attribute.reference? -%>
|
12
|
-
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
13
|
-
<% elsif !attribute.virtual? -%>
|
14
|
-
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
15
|
-
<% end -%>
|
16
|
-
<% end -%>
|
17
|
-
<% if options[:timestamps] %>
|
18
|
-
t.audits
|
19
|
-
<% end -%>
|
20
|
-
end
|
21
|
-
<% attributes.select(&:token?).each do |attribute| -%>
|
22
|
-
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
|
23
|
-
<% end -%>
|
24
|
-
<% attributes_with_index.each do |attribute| -%>
|
25
|
-
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
26
|
-
<% end -%>
|
27
|
-
end
|
28
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
<% module_namespacing do -%>
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# Model class for <%= plural_table_name %> table
|
5
|
-
class <%= class_name %> < <%= parent_class_name.classify %>
|
6
|
-
include HagridChassis::MultiTenant
|
7
|
-
include HagridChassis::Audited
|
8
|
-
|
9
|
-
<% attributes.select(&:reference?).each do |attribute| -%>
|
10
|
-
belongs_to :<%= attribute.name %><%= ", polymorphic: true" if attribute.polymorphic? %>
|
11
|
-
<% end -%>
|
12
|
-
<% attributes.select(&:rich_text?).each do |attribute| -%>
|
13
|
-
has_rich_text :<%= attribute.name %>
|
14
|
-
<% end -%>
|
15
|
-
<% attributes.select(&:attachment?).each do |attribute| -%>
|
16
|
-
has_one_attached :<%= attribute.name %>
|
17
|
-
<% end -%>
|
18
|
-
<% attributes.select(&:attachments?).each do |attribute| -%>
|
19
|
-
has_many_attached :<%= attribute.name %>
|
20
|
-
<% end -%>
|
21
|
-
<% attributes.select(&:token?).each do |attribute| -%>
|
22
|
-
has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
|
23
|
-
<% end -%>
|
24
|
-
<% if attributes.any?(&:password_digest?) -%>
|
25
|
-
has_secure_password
|
26
|
-
<% end -%>
|
27
|
-
|
28
|
-
effective_resource do
|
29
|
-
<% attributes.each do |attribute| -%><%= " #{attribute.name} :#{attribute.type}\n" unless attribute.type == :references %><% end -%>
|
30
|
-
end
|
31
|
-
end
|
32
|
-
<% end -%>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "rails/generators/active_record/model/model_generator"
|
2
|
-
|
3
|
-
module Olivander
|
4
|
-
class ActiveRecordGenerator < ActiveRecord::Generators::ModelGenerator
|
5
|
-
desc "This will generate ActiveRecord files using Olivander templates"
|
6
|
-
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
7
|
-
|
8
|
-
# redefine the source path so we can isolate our templates
|
9
|
-
# note that ActiveRecords's generator defines a path like:
|
10
|
-
# ../../migration/templates/create_table_migration.rb
|
11
|
-
# so we have to put two dummy path positions to counter-act
|
12
|
-
# the ../.. and of course append .tt for thor to treat the file
|
13
|
-
# as a template
|
14
|
-
source_root File.expand_path('active_record/model/templates', __dir__)
|
15
|
-
|
16
|
-
def create_migration_file
|
17
|
-
self.attributes = shell.base.attributes
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
File without changes
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Olivander
|
2
|
-
class DatatableGenerator < Rails::Generators::NamedBase
|
3
|
-
include Rails::Generators::ResourceHelpers
|
4
|
-
|
5
|
-
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
6
|
-
|
7
|
-
source_root File.expand_path('datatable/templates', __dir__)
|
8
|
-
|
9
|
-
def create_datatable
|
10
|
-
template "datatable.rb", File.join("app/datatables", controller_file_path, "../#{file_name}_datatable.rb")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Olivander
|
2
|
-
class InstallGenerator < Rails::Generators::Base
|
3
|
-
source_root File.expand_path('templates', __dir__)
|
4
|
-
|
5
|
-
def effective_datatables
|
6
|
-
template 'effective_datatables.rb', 'config/initializers/effective_datatables.rb'
|
7
|
-
template 'effective_resources.rb', 'config/initializers/effective_resources.rb'
|
8
|
-
end
|
9
|
-
|
10
|
-
def lograge
|
11
|
-
template 'lograge.rb', 'config/initializers/lograge.rb'
|
12
|
-
end
|
13
|
-
|
14
|
-
def olivander_base_classes
|
15
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
16
|
-
" include ::Olivander::ApplicationController\n"
|
17
|
-
end
|
18
|
-
inject_into_class "app/models/application_record.rb", "ApplicationRecord" do
|
19
|
-
" include ::Olivander::ApplicationRecord\n"
|
20
|
-
end
|
21
|
-
template 'logo.png', 'public/images/logo.png'
|
22
|
-
template 'favicon.ico', 'public/images/favicon.ico'
|
23
|
-
template 'favicon-dev.ico', 'public/images/favicon-dev.ico'
|
24
|
-
template 'route_builder.rb', 'app/services/route_builder.rb'
|
25
|
-
template 'context_builder.rb', 'app_services/context_builder.rb'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
EffectiveDatatables.setup do |config|
|
2
|
-
# Authorization Method
|
3
|
-
#
|
4
|
-
# This method is called by all controller actions with the appropriate action and resource
|
5
|
-
# If it raises an exception or returns false, an Effective::AccessDenied Error will be raised
|
6
|
-
#
|
7
|
-
# Use via Proc:
|
8
|
-
# Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCan
|
9
|
-
# Proc.new { |controller, action, resource| can?(action, resource) } # CanCan with skip_authorization_check
|
10
|
-
# Proc.new { |controller, action, resource| authorize "#{action}?", resource } # Pundit
|
11
|
-
# Proc.new { |controller, action, resource| current_user.is?(:admin) } # Custom logic
|
12
|
-
#
|
13
|
-
# Use via Boolean:
|
14
|
-
# config.authorization_method = true # Always authorized
|
15
|
-
# config.authorization_method = false # Always unauthorized
|
16
|
-
#
|
17
|
-
# Use via Method (probably in your application_controller.rb):
|
18
|
-
# config.authorization_method = :my_authorization_method
|
19
|
-
# def my_authorization_method(resource, action)
|
20
|
-
# true
|
21
|
-
# end
|
22
|
-
config.authorization_method = Proc.new { |controller, action, resource|
|
23
|
-
controller.can?(action, resource)
|
24
|
-
}
|
25
|
-
|
26
|
-
# Default number of entries shown per page
|
27
|
-
# Valid options are: 5, 10, 25, 50, 100, 250, 500, :all
|
28
|
-
config.default_length = 10
|
29
|
-
|
30
|
-
# Default class used on the <table> tag
|
31
|
-
config.html_class = 'table table-hover table-striped'
|
32
|
-
|
33
|
-
# Log search/sort information to the console
|
34
|
-
config.debug = false
|
35
|
-
|
36
|
-
# Use a cookie to save and restore state from previous page visits.
|
37
|
-
config.save_state = true
|
38
|
-
|
39
|
-
# Configure the _effective_dt cookie.
|
40
|
-
config.cookie_max_size = 1500 # String size. Final byte size is about 1.5 times bigger, after rails signs it
|
41
|
-
config.cookie_domain = :all # Should usually be :all
|
42
|
-
config.cookie_tld_length = nil # Leave nil to autodetect, or set to probably 2
|
43
|
-
|
44
|
-
# Date formatting
|
45
|
-
config.format_datetime = '%F %H:%M'
|
46
|
-
config.format_date = '%m/%d/%Y'
|
47
|
-
config.format_time = '%H:%M'
|
48
|
-
|
49
|
-
# Enable the Download button which serves a CSV of your collection
|
50
|
-
config.download = false
|
51
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
EffectiveResources.setup do |config|
|
2
|
-
# Authorization Method
|
3
|
-
#
|
4
|
-
# This method is called by all controller actions with the appropriate action and resource
|
5
|
-
# If it raises an exception or returns false, an Effective::AccessDenied Error will be raised
|
6
|
-
#
|
7
|
-
# Use via Proc:
|
8
|
-
# Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCan
|
9
|
-
# Proc.new { |controller, action, resource| can?(action, resource) } # CanCan with skip_authorization_check
|
10
|
-
# Proc.new { |controller, action, resource| authorize "#{action}?", resource } # Pundit
|
11
|
-
# Proc.new { |controller, action, resource| current_user.is?(:admin) } # Custom logic
|
12
|
-
#
|
13
|
-
# Use via Boolean:
|
14
|
-
# config.authorization_method = true # Always authorized
|
15
|
-
# config.authorization_method = false # Always unauthorized
|
16
|
-
#
|
17
|
-
# Use via Method (probably in your application_controller.rb):
|
18
|
-
# config.authorization_method = :my_authorization_method
|
19
|
-
# def my_authorization_method(resource, action)
|
20
|
-
# true
|
21
|
-
# end
|
22
|
-
# config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
|
23
|
-
config.authorization_method = Proc.new { |controller, action, resource|
|
24
|
-
authorize!(action, resource)
|
25
|
-
}
|
26
|
-
|
27
|
-
# Default Submits
|
28
|
-
#
|
29
|
-
# These default submit actions will be added to each controller
|
30
|
-
# and rendered when calling effective_submit(f)
|
31
|
-
# based on the controller, and its `submits` if any.
|
32
|
-
#
|
33
|
-
# Supported values: 'Save', 'Continue', and 'Add New'
|
34
|
-
config.default_submits = ['Save', 'Continue', 'Add New']
|
35
|
-
|
36
|
-
# Mailer Settings
|
37
|
-
#
|
38
|
-
# The default mailer settings for all effective gems
|
39
|
-
#
|
40
|
-
# Configure the parent class responsible to send e-mails.
|
41
|
-
# config.parent_mailer = '::ApplicationMailer'
|
42
|
-
|
43
|
-
# Default deliver method
|
44
|
-
# config.deliver_method = :deliver_later
|
45
|
-
|
46
|
-
# Default layout
|
47
|
-
# config.mailer_layout = 'effective_mailer_layout'
|
48
|
-
|
49
|
-
# Customize the Subject
|
50
|
-
# config.mailer_subject = Proc.new { |action, subject, resource, opts = {}| subject }
|
51
|
-
|
52
|
-
# Default From
|
53
|
-
config.mailer_sender = '"Info" <info@example.com>'
|
54
|
-
|
55
|
-
# Send Admin correspondence To
|
56
|
-
config.mailer_admin = '"Admin" <admin@example.com>'
|
57
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'colorized_string'
|
2
|
-
|
3
|
-
class ColorKeyValue < Lograge::Formatters::KeyValue
|
4
|
-
FIELDS_COLORS = {
|
5
|
-
method: :white,
|
6
|
-
path: :white,
|
7
|
-
format: :red,
|
8
|
-
controller: :green,
|
9
|
-
action: :green,
|
10
|
-
status: :yellow,
|
11
|
-
duration: :magenta,
|
12
|
-
view: :magenta,
|
13
|
-
db: :magenta,
|
14
|
-
time: :cyan,
|
15
|
-
ip: :red,
|
16
|
-
host: :red,
|
17
|
-
params: :green,
|
18
|
-
unpermitted_params: {color: :black, background: :red},
|
19
|
-
}
|
20
|
-
|
21
|
-
def format(key, value)
|
22
|
-
line = super(key, value)
|
23
|
-
|
24
|
-
color = FIELDS_COLORS[key] || :default
|
25
|
-
ColorizedString[line].colorize(color)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
Rails.application.configure do
|
30
|
-
config.lograge.enabled = true
|
31
|
-
config.lograge.formatter = ColorKeyValue.new
|
32
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Olivander
|
2
|
-
class ScaffoldGenerator < Rails::Generators::NamedBase
|
3
|
-
include Rails::Generators::ResourceHelpers
|
4
|
-
|
5
|
-
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
6
|
-
|
7
|
-
source_root File.expand_path('templates/scaffold', __dir__)
|
8
|
-
|
9
|
-
hook_for :orm, as: :model, required: true do |instance, controller|
|
10
|
-
instance.invoke controller, [ instance.name ], instance.options.merge({ test_framework: false })
|
11
|
-
end
|
12
|
-
|
13
|
-
hook_for :datatable, as: :boolean, default: true
|
14
|
-
|
15
|
-
hook_for :resource_controller do |instance, controller|
|
16
|
-
instance.invoke controller, [ instance.name.pluralize ], instance.options.merge({ helper: false, test_framework: false, assets: false })
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_views
|
20
|
-
# template "views/_form.html.haml", File.join("app/views", controller_file_path, '_form.html.haml')
|
21
|
-
# template "views/_model.html.haml", File.join("app/views", controller_file_path, "_#{file_name}.html.haml")
|
22
|
-
end
|
23
|
-
|
24
|
-
hook_for :resource_route, in: :rails
|
25
|
-
end
|
26
|
-
end
|