five-two-nw-olivander 0.1.2.30 → 0.1.2.31
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 +4 -4
- data/app/assets/stylesheets/adminlte.css +7 -1
- data/app/components/olivander/components/portlet_component.html.haml +1 -1
- data/app/components/olivander/components/portlet_component.rb +1 -1
- data/app/components/olivander/components/table_portlet_component/table_component.html.haml +18 -0
- data/app/components/olivander/components/table_portlet_component.html.haml +25 -0
- data/app/components/olivander/components/table_portlet_component.rb +59 -0
- data/app/controllers/concerns/olivander/resources/auto_form_attributes.rb +14 -12
- data/app/helpers/olivander/application_helper.rb +18 -0
- data/lib/olivander/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b9f0ff95753e126cb4de1106d1cad6f079b4bdd53fd7fe1329b1cd00556ef2c
|
|
4
|
+
data.tar.gz: c0ef254479699aced86f0ae096ad4b013becf8c96aff80ec510906107aaf6d46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f9297fdacf15c8a833c226deb411c6394e4c8ec125c6515d4127b5dea867048d15e2478ea6f911ca2b6855c887a444886180d4ac9356b94eb7855b301b17823
|
|
7
|
+
data.tar.gz: a8fdfaf8efbd4eaeb2dfef11060f10b3bbf90bd8f1249d734aa64c1a44238e8f9aec7af4093d8ec161a3b041ebdfbab1a6405a29ec0e94c83035ca8412011bab
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Olivander
|
|
4
4
|
module Components
|
|
5
5
|
class PortletComponent < ViewComponent::Base
|
|
6
|
-
def initialize(title, background: nil, header_background: 'bg-
|
|
6
|
+
def initialize(title, background: nil, header_background: 'bg-secondary', turbo_frame: nil, src: nil, loading: nil)
|
|
7
7
|
super
|
|
8
8
|
@title = title
|
|
9
9
|
@background = background
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
- if @item_iteration.first?
|
|
2
|
+
%table.table.table-striped.table-hover.table-fixed_header/
|
|
3
|
+
- if @headers
|
|
4
|
+
%thead
|
|
5
|
+
%tr
|
|
6
|
+
- @builder.field_blocks.each do |field_block|
|
|
7
|
+
%th{ class: field_block.alignment }
|
|
8
|
+
- if field_block.key.present?
|
|
9
|
+
= I18n.t(['activerecord.attributes', @item.class.name.underscore, field_block.key].join('.'))
|
|
10
|
+
%tbody/
|
|
11
|
+
%tr
|
|
12
|
+
- @builder.field_blocks.each do |field_block|
|
|
13
|
+
%td{ class: field_block.alignment }
|
|
14
|
+
= capture do
|
|
15
|
+
- instance_exec(@item, &field_block.block)
|
|
16
|
+
- if @item_iteration.last?
|
|
17
|
+
</tbody>
|
|
18
|
+
</table>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
- if @turbo_frame.present?
|
|
2
|
+
<turbo-frame id="#{@turbo_frame}">
|
|
3
|
+
|
|
4
|
+
.card{ class: @background }
|
|
5
|
+
.card-header{ class: @header_background }
|
|
6
|
+
%h3.card-title= @title
|
|
7
|
+
.card-tools
|
|
8
|
+
- if header_tools?
|
|
9
|
+
= header_tools
|
|
10
|
+
-# %button.btn.btn-tool{ type: :button, 'data-card-widget': :collapse }
|
|
11
|
+
-# %i.fas.fa-minus
|
|
12
|
+
-# %button.btn.btn-tool{ type: :button, 'data-card-widget': :maximize }
|
|
13
|
+
-# %i.fas.fa-expand
|
|
14
|
+
.card-body
|
|
15
|
+
- if @collection&.size&.positive?
|
|
16
|
+
%div{style: @max_height.present? ? "max-height: #{@max_height}; overflow-y: auto; overflow-x: hidden" : ""}
|
|
17
|
+
= render Olivander::Components::TablePortletComponent::TableComponent.with_collection(@collection, builder: @builder, headers: @headers)
|
|
18
|
+
- else
|
|
19
|
+
No #{@title.downcase} to display.
|
|
20
|
+
- if footer_buttons?
|
|
21
|
+
.card-footer.text-right
|
|
22
|
+
= footer_buttons
|
|
23
|
+
|
|
24
|
+
- if @turbo_frame.present?
|
|
25
|
+
</turbo-frame>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Olivander
|
|
4
|
+
module Components
|
|
5
|
+
class TablePortletComponent < ViewComponent::Base
|
|
6
|
+
renders_one :header_tools
|
|
7
|
+
renders_one :footer_buttons
|
|
8
|
+
|
|
9
|
+
def initialize(collection, headers: true, builder:, title: '', background: nil, header_background: 'bg-secondary', turbo_frame: nil, max_height: nil)
|
|
10
|
+
super
|
|
11
|
+
@collection = collection
|
|
12
|
+
@builder = builder
|
|
13
|
+
@title = title
|
|
14
|
+
@background = background
|
|
15
|
+
@header_background = header_background
|
|
16
|
+
@turbo_frame = turbo_frame
|
|
17
|
+
@max_height = max_height
|
|
18
|
+
@headers = headers
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class TableComponent < ViewComponent::Base
|
|
22
|
+
with_collection_parameter :item
|
|
23
|
+
delegate :can?, :cannot?, to: :helpers
|
|
24
|
+
|
|
25
|
+
def initialize(item:, item_iteration:, builder:, headers:)
|
|
26
|
+
super
|
|
27
|
+
@item = item
|
|
28
|
+
@item_iteration = item_iteration
|
|
29
|
+
@builder = builder
|
|
30
|
+
@headers = headers
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Builder
|
|
35
|
+
attr_accessor :field_blocks, :header_tools, :footer_buttons
|
|
36
|
+
|
|
37
|
+
def initialize(collection, &block)
|
|
38
|
+
self.field_blocks = []
|
|
39
|
+
block.call(self) if block_given?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def field(key, alignment = 'text-left', &block)
|
|
43
|
+
unless block_given?
|
|
44
|
+
block = Proc.new{ |x| x.send(key).to_s.html_safe }
|
|
45
|
+
end
|
|
46
|
+
field_blocks << OpenStruct.new(key: key, alignment: alignment, block: block)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def with_header_tools(&block)
|
|
50
|
+
self.header_tools = block
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def with_footer_buttons(&block)
|
|
54
|
+
self.footer_buttons = block
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -44,19 +44,21 @@ module Olivander
|
|
|
44
44
|
end
|
|
45
45
|
else
|
|
46
46
|
only = self.columns.collect{ |x| x.name.to_sym } - SKIPPED_ATTRIBUTES if only.size.zero?
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
only.each do |inc|
|
|
48
|
+
self.columns.each do |att|
|
|
49
|
+
sym = att.name.to_sym
|
|
50
|
+
type = att.type
|
|
51
|
+
next unless inc == sym
|
|
52
|
+
|
|
53
|
+
reflections.map{ |x| x[1] }
|
|
54
|
+
.filter{ |x| x.foreign_key == att.name }
|
|
55
|
+
.each do |r|
|
|
56
|
+
sym = r.name
|
|
57
|
+
type = :association
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
resource_field sym, type
|
|
57
61
|
end
|
|
58
|
-
|
|
59
|
-
resource_field sym, type
|
|
60
62
|
end
|
|
61
63
|
end
|
|
62
64
|
end
|
|
@@ -146,5 +146,23 @@ module Olivander
|
|
|
146
146
|
"fas fa-question-circle"
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
|
+
|
|
150
|
+
def collection_component_builder_for(klass, collection, *args, &block)
|
|
151
|
+
builder = klass::Builder.new(self, &block)
|
|
152
|
+
options = args.extract_options!
|
|
153
|
+
options[:builder] = builder
|
|
154
|
+
render klass.new(collection, *(args + [options])) do |component|
|
|
155
|
+
if builder.header_tools.present?
|
|
156
|
+
component.with_header_tools do
|
|
157
|
+
builder.header_tools.call
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
if builder.footer_buttons.present?
|
|
161
|
+
component.with_footer_buttons do
|
|
162
|
+
builder.footer_buttons.call
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
149
167
|
end
|
|
150
168
|
end
|
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.31
|
|
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-08-
|
|
11
|
+
date: 2023-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chartkick
|
|
@@ -192,6 +192,9 @@ files:
|
|
|
192
192
|
- app/components/olivander/components/resource_show_component.rb
|
|
193
193
|
- app/components/olivander/components/small_box_component.html.haml
|
|
194
194
|
- app/components/olivander/components/small_box_component.rb
|
|
195
|
+
- app/components/olivander/components/table_portlet_component.html.haml
|
|
196
|
+
- app/components/olivander/components/table_portlet_component.rb
|
|
197
|
+
- app/components/olivander/components/table_portlet_component/table_component.html.haml
|
|
195
198
|
- app/controllers/concerns/olivander/resources/auto_form_attributes.rb
|
|
196
199
|
- app/controllers/concerns/olivander/resources/model_registrar.rb
|
|
197
200
|
- app/controllers/concerns/olivander/resources/model_registry.rb
|