active_scaffold_kanban 0.1.1 → 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: c30f3ba06e1b5dec52e8e67082593ebcab28568de1b0fe3b2ef131f9ce168b43
4
- data.tar.gz: 9f2f3dc3ff0cc16e22d3884a05da241d329a7913ae8fc9083d983d2b3d1399c9
3
+ metadata.gz: 61f58e6990ca639f1f8f43cdfc1e614a32e73814a8238314ec9315673d6c1e63
4
+ data.tar.gz: fc874facb5a174965796350f54b70cf8a045e9730706b534baff2273f12d333d
5
5
  SHA512:
6
- metadata.gz: eb107961547eadf2c706cc8bf230357b131fb72f65239a73c6d66fc723b85cfb7a0169537d8279e62fbbf9941959663e17f83ca9a6a044d83b0c0b4a4e35d604
7
- data.tar.gz: 1e4e23545e5b9cd9cfc53dd20d80b1864216a3aded346813555b2d9c9b97102226d94d90cf3a54580236ebf989b5a607c4004103ffe7b409371d74e7ede41e78
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}
@@ -3,6 +3,7 @@
3
3
  <div class="card-title">
4
4
  <%= record.send(active_scaffold_config.kanban.title_method) %>
5
5
  <div class="actions">
6
+ <%= loading_indicator_tag(action: :record, id: record.id) %>
6
7
  <%= display_action_links(active_scaffold_config.action_links.member, record, for: record) %>
7
8
  </div>
8
9
  </div>
@@ -1,4 +1,18 @@
1
1
  <% if @kanban_view %>
2
+ <% if active_scaffold_config.list.messages_above_header %>
3
+ <table>
4
+ <tbody>
5
+ <tr>
6
+ <td class="messages-container">
7
+ <%= render 'list_messages_content' %>
8
+ </td>
9
+ </tr>
10
+ </tbody>
11
+ </table>
12
+ <% end %>
13
+ <table>
14
+ <%= render 'list_messages', column_count: 1 %>
15
+ </table>
2
16
  <%= render 'kanban' %>
3
17
  <% else %>
4
18
  <%= render :super %>
@@ -1,7 +1,6 @@
1
1
  <% if @kanban_view %>
2
2
  <% selector = ".kanban-column[data-value=\"#{@record.send(@kanban_column.name)}\"] .cards" %>
3
- // ActiveScaffold.create_record_row('<%= active_scaffold_id %>', html, <%= {insert_at: insert_at, body_selector: selector}.to_json.html_safe %>);
4
- jQuery(<%=raw selector.to_json %>).prepend('<%= escape_javascript render('kanban_card', record: @record) %>');
3
+ ActiveScaffold.create_record_row('<%= active_scaffold_id %>', '<%= escape_javascript render('kanban_card', record: @record) %>', <%= {insert_at: insert_at, body_selector: selector}.to_json.html_safe %>);
5
4
  jQuery(<%=raw selector.to_json %>).sortable('refresh');
6
5
  <% else %>
7
6
  <%= render :super %>
@@ -4,7 +4,7 @@ module ActiveScaffold
4
4
  module Actions
5
5
  module Kanban
6
6
  def self.included(base)
7
- base.before_action :setup_kanban, only: [:index, :update_column, :reorder, :create]
7
+ base.before_action :setup_kanban
8
8
  base.after_action :reorder_cards, only: :update_column
9
9
  base.after_action :set_error_status_code, only: [:update_column, :reorder]
10
10
  end
@@ -10,6 +10,7 @@ module ActiveScaffold
10
10
  @title_method = self.class.title_method
11
11
  @description_method = self.class.description_method
12
12
  @replace_list_view = self.class.replace_list_view
13
+ @links_position = self.class.links_position
13
14
  end
14
15
 
15
16
  # global level configuration
@@ -24,6 +25,10 @@ module ActiveScaffold
24
25
  # enable it to replace list view with kanban, instead of being optional with view=kanban param
25
26
  cattr_accessor :replace_list_view, instance_accessor: false
26
27
 
28
+ # the position to set on actions used in kanban cards
29
+ cattr_accessor :links_position, instance_accessor: false
30
+ @@links_position = :table
31
+
27
32
  # the model's method used for card's title
28
33
  attr_accessor :title_method
29
34
 
@@ -36,8 +41,10 @@ module ActiveScaffold
36
41
  # the model's column used for kanban columns
37
42
  attr_accessor :group_by_column
38
43
 
44
+ attr_accessor :links_position
45
+
39
46
  UserSettings.class_eval do
40
- user_attr :title_method, :description_method, :group_by_column, :replace_list_view
47
+ user_attr :title_method, :description_method, :group_by_column, :replace_list_view, :links_position
41
48
  end
42
49
  end
43
50
  end
@@ -1,6 +1,23 @@
1
1
  module ActiveScaffold
2
2
  module Helpers
3
3
  module KanbanHelpers
4
+ def list_record_view
5
+ @kanban_view ? 'kanban_card' : 'list_record'
6
+ end
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
+
4
21
  def kanban_columns
5
22
  record = active_scaffold_config.model.new
6
23
  if @kanban_column.association
@@ -39,8 +56,8 @@ module ActiveScaffold
39
56
 
40
57
  def action_link_html_options(link, record, options)
41
58
  options = super
42
- if @kanban_view && link.position == :after
43
- options[:data][:position] = :replace
59
+ if @kanban_view && link.type == :member && link.position.in?(%i[after replace before])
60
+ options[:data][:position] = active_scaffold_config.kanban.links_position
44
61
  end
45
62
  options
46
63
  end
@@ -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 = 1
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.1
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-13 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.7.10
19
+ version: 3.7.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.7.10
26
+ version: 3.7.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: active_scaffold_sortable
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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