active_scaffold_kanban 0.1.2 → 0.1.3

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: d75bed289605098b25dc9b8d70ff38988681a70b8b61e00c3ef504993f322053
4
- data.tar.gz: 2a9b39b0463fef41905e8f737befbe6dbde0fe1d8cd3840bb732a1137b1bf1f9
3
+ metadata.gz: 61f58e6990ca639f1f8f43cdfc1e614a32e73814a8238314ec9315673d6c1e63
4
+ data.tar.gz: fc874facb5a174965796350f54b70cf8a045e9730706b534baff2273f12d333d
5
5
  SHA512:
6
- metadata.gz: 4c3fdcf46fffadab3cb74764ce0e0c04bbb7ba7cde02b21adaab802bc21337eb563e55af7c7fabe380e097d6dad823897d9407290635c3c912c2e4e503842976
7
- data.tar.gz: 38000a05e2567eb216763d02d6937d97f09a4090cfd322426800485d6f88f66864200bc80fd162668bf4a4c00af1f4a7ca57df3574b5bf20c3626d639ac02b93
6
+ metadata.gz: d0e202bd9f684561fcd84cf71e3e6fd09def878a3867b76bf9de2d397fe5cb9a5f24b0471b2d7576e31a671711d4f71c56a08f237199ffcd136192eef4311564
7
+ data.tar.gz: 2521cca6b1fa2ae2a1e81e9631d3c0097bde43fbe3f3c1623d1c9aa9474bd92e89b562b29ca8e0fe547abbef4ec2aab073cff111e3190633ea6043133cb2f5de
@@ -1,6 +1,6 @@
1
1
  <% column_receive_only_method = override_helper_per_model(:kanban_column_receive_only?, active_scaffold_config.model) %>
2
2
  <%= content_tag :div, class: 'kanban', data: kanban_data_attrs do %>
3
- <% send(override_helper_per_model(:kanban_columns, active_scaffold_config.model)).each do |label, value| %>
3
+ <% user_kanban_columns.each do |label, value| %>
4
4
  <%
5
5
  id = value.id if @kanban_column.association
6
6
  column_data = {value: id || value}
@@ -5,6 +5,19 @@ module ActiveScaffold
5
5
  @kanban_view ? 'kanban_card' : 'list_record'
6
6
  end
7
7
 
8
+ def user_kanban_columns
9
+ if active_scaffold_config.actions.include?(:config_list) && config_list_params
10
+ columns = available_kanban_columns.index_by { |_, value| (@kanban_column.association ? value.id : value).to_s.to_sym }
11
+ config_list_params.map { |value| columns[value] }
12
+ else
13
+ available_kanban_columns
14
+ end
15
+ end
16
+
17
+ def available_kanban_columns
18
+ @available_kanban_columns ||= send(override_helper_per_model(:kanban_columns, active_scaffold_config.model))
19
+ end
20
+
8
21
  def kanban_columns
9
22
  record = active_scaffold_config.model.new
10
23
  if @kanban_column.association
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveScaffoldKanban
4
+ module ConfigListAction
5
+ def config_list_session_storage_key
6
+ @kanban_view ? "#{super}:kanban" : super
7
+ end
8
+
9
+ def config_list_controller_name
10
+ @kanban_view ? "#{super}:kanban" : super
11
+ end
12
+
13
+ def config_list_session_storage(storage = false)
14
+ if @kanban_view
15
+ hsh = super()
16
+ return hsh if storage
17
+ hsh['kanban'] || {}
18
+ else
19
+ super()
20
+ end
21
+ end
22
+
23
+ def delete_config_list_params
24
+ super
25
+ config_list_session_storage(true).delete 'kanban' if @kanban_view
26
+ end
27
+
28
+ def save_config_list_params(...)
29
+ unless active_scaffold_config.config_list.save_to_user && active_scaffold_current_user
30
+ config_list_session_storage(true)['kanban'] ||= {} if @kanban_view
31
+ end
32
+ super
33
+ end
34
+ end
35
+
36
+ module ConfigListHelpers
37
+ def config_list_sorting?
38
+ super unless @kanban_view
39
+ end
40
+
41
+ def config_list_columns
42
+ if @kanban_view
43
+ columns = user_kanban_columns # get selected columns first, to keep sorting
44
+ columns += available_kanban_columns - columns # add not selected columns if user has selected some
45
+ columns.map do |label, value|
46
+ [label, (@kanban_column.association ? value.id : value).to_s.to_sym]
47
+ end
48
+ else
49
+ super
50
+ end
51
+ end
52
+ end
53
+ end
@@ -5,5 +5,13 @@ module ActiveScaffoldKanban
5
5
  ActionView::Base.send :include, ActiveScaffold::Helpers::KanbanHelpers
6
6
  end
7
7
  end
8
+
9
+ initializer 'active_scaffold_kanban.config_list' do
10
+ ActiveSupport.on_load :active_scaffold_config_list do
11
+ require 'active_scaffold_kanban/config_list'
12
+ ActiveScaffold::Actions::ConfigList.prepend(ActiveScaffoldKanban::ConfigListAction)
13
+ ActiveScaffold::Helpers::ConfigListHelpers.prepend(ActiveScaffoldKanban::ConfigListHelpers)
14
+ end
15
+ end
8
16
  end
9
17
  end
@@ -2,7 +2,7 @@ module ActiveScaffoldKanban
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 2
5
+ PATCH = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_kanban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-17 00:00:00.000000000 Z
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_scaffold
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.2.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: active_scaffold_config_list
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.6.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.6.0
41
55
  description: User may reorder records and change to a different column
42
56
  email: activescaffold@googlegroups.com
43
57
  executables: []
@@ -58,6 +72,7 @@ files:
58
72
  - lib/active_scaffold/config/kanban.rb
59
73
  - lib/active_scaffold/helpers/kanban_helpers.rb
60
74
  - lib/active_scaffold_kanban.rb
75
+ - lib/active_scaffold_kanban/config_list.rb
61
76
  - lib/active_scaffold_kanban/engine.rb
62
77
  - lib/active_scaffold_kanban/version.rb
63
78
  homepage: https://activescaffold.eu