activeadmin_dynamic_table 0.1.1 → 0.2.0

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: ba7175e5769ce38921f670c993df131448bc7b1b87087abd1d58befb05ea5df0
4
- data.tar.gz: bfe6d0ca3328fe82c084a5c283b59bf8719c7114350aee2bbc76eed8879f6a49
3
+ metadata.gz: 537aa432d0b52c8cf60622622c7893ccfb26094b9da6b48d3b529812266358e7
4
+ data.tar.gz: 5b7fdde7f367a01c537a3134e6db65c6e62478005bcc297db0dba9f13bea24a7
5
5
  SHA512:
6
- metadata.gz: f45638282a9d3eae1f882128623ee1a43afad08194ef05af73fd28435f85ffc4615415d6d4bb153ef8ffe5b2953dde6b51d301abbf9d125ca9e5fb43dc3a3faa
7
- data.tar.gz: 04ef3684e999f357f3e600b1a10c7d1e9a7bc5c2507d0b57573ac6ce7c790e71fbbeddf2d3236784cb89cad7955a03a77029f4b45806c6a64f99b8df84722c93
6
+ metadata.gz: f1153e6d83dcea9a7a21607cda3dc34d72e6775bf3a0c5237135bcdbe9c8e01abce4bd97628578d876f025849f6f9c03071db31455cc594d667ccd64b08242a7
7
+ data.tar.gz: e0fed908ba563f7513d675136094f4b7a6acb649ef55697c75c0e9e7deb4474f0e921bf8e339ca129600e4a4a42bc32f129477bef59a6d55b392259d6a312ed5
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activeadmin_dynamic_table (0.1.1)
5
- activeadmin (~> 2.9)
4
+ activeadmin_dynamic_table (0.2.0)
5
+ activeadmin (>= 2.9, < 4.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ActiveadminDynamicTable
2
2
 
3
- This is an [ActiveAdmin](https://github.com/activeadmin/activeadmin) extansion which allows to manage index table columns from the activeadmin UI.
3
+ This is an [ActiveAdmin](https://github.com/activeadmin/activeadmin) extension that allows managing index table columns from the activeadmin UI.
4
4
 
5
5
  ## Goals
6
6
  - Show/hide table columns from UI
@@ -66,7 +66,7 @@ All other options are the same as for `register_column`
66
66
  Method follows standard `column` dsl but also requires to provide at least `key` among options.
67
67
  All other options are the same as for `register_column`
68
68
 
69
- Expample:
69
+ Example:
70
70
 
71
71
  ```ruby
72
72
  index as: :dynamic_table do
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  # Uncomment to register a new dependency of your gem
32
- spec.add_dependency "activeadmin", "~> 2.9"
32
+ spec.add_dependency "activeadmin", ">= 2.9", "< 4.0"
33
33
 
34
34
  # For more information and examples about making a new gem, check out our
35
35
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -0,0 +1,34 @@
1
+ module ActiveAdmin
2
+ class DynamicCSVBuilder < CSVBuilder
3
+ def exec_columns(view_context = nil)
4
+ @view_context = view_context
5
+ settings = ActiveadminDynamicTable::SettingStringParser.new(@view_context.params[:columns])
6
+
7
+ @configurator = ActiveadminDynamicTable::Configurator.new(self, settings.parse)
8
+ @columns = [] # we want to re-render these every instance
9
+
10
+ instance_exec &@block
11
+ @configurator.columns
12
+
13
+ columns
14
+ end
15
+
16
+ def build_row(resource, columns, options)
17
+ columns.map do |column|
18
+ content = call_method_or_proc_on(resource, column.data)
19
+ encode view_context.strip_tags(content.to_s), options
20
+ end
21
+ end
22
+
23
+ def register_column(*args, &block)
24
+ @configurator.register_column(:column, *args, &block)
25
+ end
26
+
27
+ def register_id_column(*args, &block)
28
+ @configurator.register_column(:column, :id, key: :id)
29
+ end
30
+
31
+ def register_actions(*args, &block); end
32
+ def selectable_column; end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveAdmin
2
+ class ResourceDSL
3
+ def use_dynamic_csv(options = {})
4
+ options[:resource] = config
5
+
6
+ presenter = config.page_presenters[:index][:table]
7
+
8
+ config.csv_builder = DynamicCSVBuilder.new(options, &presenter.block)
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveadminDynamicTable
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -5,6 +5,8 @@ require_relative "activeadmin_dynamic_table/version"
5
5
  require_relative "activeadmin_dynamic_table/configurator"
6
6
  require_relative "activeadmin_dynamic_table/setting_string_parser"
7
7
  require_relative "activeadmin_dynamic_table/column_settings"
8
+ require_relative "activeadmin_dynamic_table/resource_dsl"
9
+ require_relative "activeadmin_dynamic_table/dynamic_csv_builder"
8
10
  require_relative "activeadmin_dynamic_table/views/index_as_dynamic_table"
9
11
 
10
12
  module ActiveadminDynamicTable
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_dynamic_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Biliaiev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
27
33
  description: Allow to controll activeadmin table columns from the UI. (Show/hide/resize/reorder
28
34
  table columns)
29
35
  email:
@@ -47,6 +53,8 @@ files:
47
53
  - lib/activeadmin_dynamic_table.rb
48
54
  - lib/activeadmin_dynamic_table/column_settings.rb
49
55
  - lib/activeadmin_dynamic_table/configurator.rb
56
+ - lib/activeadmin_dynamic_table/dynamic_csv_builder.rb
57
+ - lib/activeadmin_dynamic_table/resource_dsl.rb
50
58
  - lib/activeadmin_dynamic_table/setting_string_parser.rb
51
59
  - lib/activeadmin_dynamic_table/version.rb
52
60
  - lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb