katalyst-koi 4.8.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/builds/koi/admin.css +172 -16
  3. data/app/assets/builds/koi/admin.css.map +1 -1
  4. data/app/assets/javascripts/koi/admin.js +1 -0
  5. data/app/assets/javascripts/koi/elements/index.js +1 -0
  6. data/app/assets/javascripts/koi/elements/toolbar.js +9 -0
  7. data/app/assets/stylesheets/koi/base/_tables.scss +2 -12
  8. data/app/assets/stylesheets/koi/components/_index.scss +2 -0
  9. data/app/assets/stylesheets/koi/components/_query.scss +57 -0
  10. data/app/assets/stylesheets/koi/components/_toolbar.scss +8 -0
  11. data/app/components/concerns/koi/tables/cells.rb +0 -28
  12. data/app/components/koi/table_query_component.rb +21 -0
  13. data/app/controllers/admin/admin_users_controller.rb +6 -16
  14. data/app/controllers/admin/url_rewrites_controller.rb +4 -16
  15. data/app/controllers/concerns/koi/controller/has_webauthn.rb +1 -1
  16. data/app/controllers/concerns/koi/controller/is_admin_controller.rb +1 -0
  17. data/app/helpers/koi/index_actions_helper.rb +1 -1
  18. data/app/models/admin/collection.rb +9 -0
  19. data/app/models/concerns/koi/model/archivable.rb +32 -0
  20. data/app/views/admin/admin_users/index.html.erb +4 -4
  21. data/app/views/admin/url_rewrites/index.html.erb +4 -4
  22. data/app/views/layouts/koi/application.html.erb +1 -1
  23. data/lib/generators/koi/admin_controller/admin_controller_generator.rb +4 -1
  24. data/lib/generators/koi/admin_controller/templates/controller.rb.tt +8 -7
  25. data/lib/generators/koi/admin_controller/templates/controller_spec.rb.tt +5 -5
  26. data/lib/generators/koi/admin_route/admin_route_generator.rb +26 -8
  27. data/lib/generators/koi/admin_views/admin_views_generator.rb +3 -44
  28. data/lib/generators/koi/admin_views/templates/index.html.erb.tt +4 -2
  29. data/lib/generators/koi/helpers/admin_generator_attributes.rb +66 -0
  30. data/lib/koi/collection/type/archivable.rb +23 -0
  31. data/lib/koi/collection.rb +11 -0
  32. data/lib/koi/config.rb +2 -0
  33. data/lib/koi.rb +1 -0
  34. metadata +12 -4
  35. data/app/components/koi/tables/cells/enum_component.rb +0 -27
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Koi
4
+ class TableQueryComponent < Katalyst::Tables::QueryComponent
5
+ def call
6
+ content_tag(:"koi-toolbar") do
7
+ render_parent
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ using Katalyst::HtmlAttributes::HasHtmlAttributes
14
+
15
+ def default_html_attributes
16
+ super.merge_html(data: { action: %w[
17
+ shortcut:search@document->tables--query#focus
18
+ ] })
19
+ end
20
+ end
21
+ end
@@ -60,25 +60,15 @@ module Admin
60
60
  params.require(:admin).permit(:name, :email, :password, :archived)
61
61
  end
62
62
 
63
- class Collection < Katalyst::Tables::Collection::Base
64
- attribute :search, :string, default: ""
65
- attribute :scope, :string, default: "active"
66
-
63
+ class Collection < Admin::Collection
67
64
  config.sorting = :name
68
65
  config.paginate = true
69
66
 
70
- def filter
71
- self.items = items.admin_search(search) if search.present?
72
-
73
- self.items = case scope&.to_sym
74
- when :archived
75
- items.archived
76
- when :all
77
- items.with_archived
78
- else
79
- items
80
- end
81
- end
67
+ attribute :name, :string
68
+ attribute :email, :string
69
+ attribute :status, :archivable, default: :active
70
+ attribute :last_sign_in_at, :date
71
+ attribute :sign_in_count, :integer
82
72
  end
83
73
  end
84
74
  end
@@ -59,25 +59,13 @@ module Admin
59
59
  @url_rewrite = UrlRewrite.find(params[:id])
60
60
  end
61
61
 
62
- class Collection < Katalyst::Tables::Collection::Base
63
- attribute :search, :string, default: ""
64
- attribute :scope, :string, default: "active"
65
-
62
+ class Collection < Admin::Collection
66
63
  config.sorting = "from"
67
64
  config.paginate = true
68
65
 
69
- def filter
70
- self.items = items.admin_search(search) if search.present?
71
-
72
- self.items = case scope&.to_sym
73
- when :active
74
- items.where(active: true)
75
- when :inactive
76
- items.where(active: false)
77
- else
78
- items
79
- end
80
- end
66
+ attribute :from, :string
67
+ attribute :to, :string
68
+ attribute :active, :boolean
81
69
  end
82
70
  end
83
71
  end
@@ -12,7 +12,7 @@ module Koi
12
12
  def webauthn_relying_party
13
13
  @webauthn_relying_party ||=
14
14
  WebAuthn::RelyingParty.new(
15
- name: "Koi Admin",
15
+ name: Koi.config.admin_name,
16
16
  origin: request.base_url,
17
17
  )
18
18
  end
@@ -19,6 +19,7 @@ module Koi
19
19
 
20
20
  default_form_builder "Koi::FormBuilder"
21
21
  default_table_component Koi::TableComponent
22
+ default_table_query_component Koi::TableQueryComponent
22
23
  default_summary_table_component Koi::SummaryTableComponent
23
24
 
24
25
  helper Katalyst::GOVUK::Formbuilder::Frontend
@@ -71,7 +71,7 @@ module Koi
71
71
  form.search_field(:search,
72
72
  placeholder: t("koi.labels.search", default: "Search"),
73
73
  value: params[:search],
74
- data: { index_actions_target: "search" })
74
+ data: { index_actions_target: "search", turbo_permanent: "" })
75
75
  end
76
76
 
77
77
  def links(form, &)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Admin
4
+ class Collection < Katalyst::Tables::Collection::Base
5
+ include Katalyst::Tables::Collection::Query
6
+
7
+ attribute :search, :search, scope: :admin_search
8
+ end
9
+ end
@@ -2,6 +2,27 @@
2
2
 
3
3
  module Koi
4
4
  module Model
5
+ # Add support for archiving using an `:archived_at` column. Adds scopes for
6
+ # including/excluding collection elements based on whether they have an
7
+ # archived_at date set or not.
8
+ #
9
+ # Usage:
10
+ # Include this module in your model and add the `archived_at` column via a
11
+ # migration.
12
+ #
13
+ # Examples:
14
+ # Model.all # default scope, excludes archived
15
+ # Model.archived # only returns archived records
16
+ # Model.with_archived # returns all records
17
+ #
18
+ # Filtering:
19
+ # Use the custom `:archivable` enum attribute in Admin::Collections to
20
+ # filter on this property, e.g.
21
+ #
22
+ # attribute :status, :archivable, default: :active
23
+ #
24
+ # Note: although it's theoretically possible to archive something in the
25
+ # future, this module does not support queries using dates.
5
26
  module Archivable
6
27
  extend ActiveSupport::Concern
7
28
 
@@ -10,6 +31,17 @@ module Koi
10
31
  scope :archived, -> { unscope(where: :archived_at).where.not(archived_at: nil) }
11
32
  scope :with_archived, -> { unscope(where: :archived_at) }
12
33
 
34
+ scope :status, ->(status) do
35
+ case status.to_s
36
+ when "active"
37
+ not_archived
38
+ when "archived"
39
+ archived
40
+ else
41
+ with_archived
42
+ end
43
+ end
44
+
13
45
  default_scope { not_archived }
14
46
 
15
47
  alias_method :archived?, :archived
@@ -1,10 +1,10 @@
1
1
  <% content_for :header do %>
2
- <%= render Koi::Header::IndexComponent.new(model: Admin::User) %>
2
+ <%= render Koi::Header::IndexComponent.new(model: Admin::User) do |component| %>
3
+ <% component.with_action "New", new_admin_admin_user_path %>
4
+ <% end %>
3
5
  <% end %>
4
6
 
5
- <%= koi_index_actions create: true, search: true do %>
6
- <%= select_tag(:scope, options_for_select([["Active", :active], ["All", :all], ["Archived", :archived]], params[:scope])) %>
7
- <% end %>
7
+ <%= table_query_with(collection:) %>
8
8
 
9
9
  <%= table_with(collection:) do |row, admin| %>
10
10
  <%= row.link :name, url: :admin_admin_user_path %>
@@ -1,11 +1,11 @@
1
1
  <%# locals: { table:, collection } %>
2
2
  <% content_for :header do %>
3
- <%= render Koi::Header::IndexComponent.new(model: UrlRewrite) %>
3
+ <%= render Koi::Header::IndexComponent.new(model: UrlRewrite) do |component| %>
4
+ <% component.with_action "New", new_admin_url_rewrite_path %>
5
+ <% end %>
4
6
  <% end %>
5
7
 
6
- <%= koi_index_actions create: true, search: true do |form| %>
7
- <%= select_tag(:scope, options_for_select([["Active", :active], ["All", :all], ["Inactive", :inactive]], params[:scope])) %>
8
- <% end %>
8
+ <%= table_query_with(collection:) %>
9
9
 
10
10
  <%= table_with(collection:) do |row, url_rewrite| %>
11
11
  <%= row.link :from, url: [:admin, url_rewrite] %>
@@ -5,7 +5,7 @@
5
5
  <meta charset="UTF-8">
6
6
 
7
7
  <!-- title -->
8
- <title>Koi <%= "- #{yield :title}" if content_for? :title %></title>
8
+ <title><%= Koi.config.admin_name %><%= " - #{yield :title}" if content_for? :title %></title>
9
9
 
10
10
  <!-- META -->
11
11
  <%= csrf_meta_tags %>
@@ -3,9 +3,12 @@
3
3
  require "rails/generators/named_base"
4
4
  require "rails/generators/resource_helpers"
5
5
 
6
+ require_relative "../helpers/admin_generator_attributes"
7
+
6
8
  module Koi
7
9
  class AdminControllerGenerator < Rails::Generators::NamedBase
8
10
  include Rails::Generators::ResourceHelpers
11
+ include Helpers::AdminGeneratorAttributes
9
12
 
10
13
  source_root File.expand_path("templates", __dir__)
11
14
 
@@ -48,7 +51,7 @@ module Koi
48
51
  attribute&.attachments?
49
52
  end
50
53
 
51
- def search_attribute
54
+ def sort_attribute
52
55
  attributes.find { |attr| attr.type == :string }&.name
53
56
  end
54
57
  end
@@ -61,14 +61,15 @@ class <%= controller_class_name %>Controller < ApplicationController
61
61
  @<%= singular_name %> = ::<%= class_name %>.find(params[:id])
62
62
  end
63
63
 
64
- class Collection < Katalyst::Tables::Collection::Base
65
- attribute :search, :string
66
-
67
- config.sorting = :<%= search_attribute %>
64
+ class Collection < Admin::Collection
65
+ config.sorting = :<%= sort_attribute %>
68
66
  config.paginate = true
69
67
 
70
- def filter
71
- self.items = items.admin_search(search) if search.present?
72
- end
68
+ <%- attributes.each do |attribute| -%>
69
+ <% definition = collection_attribute_for(attribute) -%>
70
+ <%- if definition.present? -%>
71
+ <%= definition %>
72
+ <%- end -%>
73
+ <%- end -%>
73
74
  end
74
75
  end
@@ -28,11 +28,11 @@ RSpec.describe <%= controller_class_name %>Controller do
28
28
  end
29
29
 
30
30
  context "with sort parameter" do
31
- let(:action) { get polymorphic_path([:admin, <%= class_name %>], sort: "<%= search_attribute %> desc") }
31
+ let(:action) { get polymorphic_path([:admin, <%= class_name %>], sort: "<%= sort_attribute %> desc") }
32
32
 
33
33
  before do
34
- create(:<%= singular_name %>, <%= search_attribute %>: "first")
35
- create(:<%= singular_name %>, <%= search_attribute %>: "second")
34
+ create(:<%= singular_name %>, <%= sort_attribute %>: "first")
35
+ create(:<%= singular_name %>, <%= sort_attribute %>: "second")
36
36
  end
37
37
 
38
38
  it "finds first in second place" do
@@ -45,8 +45,8 @@ RSpec.describe <%= controller_class_name %>Controller do
45
45
  let(:action) { get polymorphic_path([:admin, <%= class_name %>], search: "first") }
46
46
 
47
47
  before do
48
- create(:<%= singular_name %>, <%= search_attribute %>: "first")
49
- create(:<%= singular_name %>, <%= search_attribute %>: "second")
48
+ create(:<%= singular_name %>, <%= sort_attribute %>: "first")
49
+ create(:<%= singular_name %>, <%= sort_attribute %>: "second")
50
50
  end
51
51
 
52
52
  it "finds the needle" do
@@ -26,10 +26,28 @@ module Koi
26
26
  end
27
27
 
28
28
  def add_navigation
29
- insert_into_file("config/initializers/koi.rb",
30
- " \"#{[*regular_class_path.map(&:humanize),
31
- human_name.pluralize].join(' ')}\" => \"/admin#{route_url}\",\n",
32
- after: "Koi::Menu.modules = {\n")
29
+ gsub_file("config/initializers/koi.rb", /Koi::Menu.modules = ({}|{\n(?:\s+.*\n)*})\n/) do |match|
30
+ config = eval(match) # rubocop:disable Security/Eval # we know that this only during generation
31
+ label = [*regular_class_path.map(&:humanize), human_name.pluralize].join(" ")
32
+ path = "/admin#{route_url}"
33
+ config[label] = path
34
+ config = config.sort.to_h
35
+ StringIO.new.tap do |io|
36
+ io.puts "Koi::Menu.modules = {"
37
+ config.each do |k, v|
38
+ if v.is_a?(Hash)
39
+ io.puts " #{k.inspect} => {"
40
+ v.each do |kk, vv|
41
+ io.puts " #{kk.inspect} => #{vv.inspect},"
42
+ end
43
+ io.puts " },"
44
+ else
45
+ io.puts " #{k.inspect} => #{v.inspect},"
46
+ end
47
+ end
48
+ io.puts "}"
49
+ end.string
50
+ end
33
51
  end
34
52
 
35
53
  private
@@ -37,9 +55,9 @@ module Koi
37
55
  # See Rails::Generators::Actions
38
56
  # Replaces hard-coded route with admin route file
39
57
  def route(routing_code, namespace: nil)
40
- namespace = Array(namespace)
58
+ namespace = Array(namespace)
41
59
  namespace_pattern = route_namespace_pattern(namespace)
42
- routing_code = namespace.reverse.reduce(routing_code) do |code, name|
60
+ routing_code = namespace.reverse.reduce(routing_code) do |code, name|
43
61
  "namespace :#{name} do\n#{rebase_indentation(code, 2)}end"
44
62
  end
45
63
 
@@ -48,7 +66,7 @@ module Koi
48
66
  in_root do
49
67
  if (namespace_match = match_file(route_file, namespace_pattern))
50
68
  base_indent, *, existing_block_indent = namespace_match.captures.compact.map(&:length)
51
- existing_line_pattern = /^ {,#{existing_block_indent}}\S.+\n?/
69
+ existing_line_pattern = /^ {,#{existing_block_indent}}\S.+\n?/
52
70
  routing_code = rebase_indentation(routing_code, base_indent + 2).gsub(existing_line_pattern, "")
53
71
  namespace_pattern = /#{Regexp.escape namespace_match.to_s}/
54
72
  end
@@ -61,7 +79,7 @@ module Koi
61
79
  # Replaces Routes.draw with namespace :admin as the search term
62
80
  def route_namespace_pattern(namespace)
63
81
  namespace.each_with_index.reverse_each.reduce(nil) do |pattern, (name, i)|
64
- cummulative_margin = "\\#{i + 1}[ ]{2}"
82
+ cummulative_margin = "\\#{i + 1}[ ]{2}"
65
83
  blank_or_indented_line = "^[ ]*\n|^#{cummulative_margin}.*\n"
66
84
  "(?:(?:#{blank_or_indented_line})*?^(#{cummulative_margin})namespace :#{name} do\n#{pattern})?"
67
85
  end.then do |pattern|
@@ -3,9 +3,12 @@
3
3
  require "rails/generators/named_base"
4
4
  require "rails/generators/resource_helpers"
5
5
 
6
+ require_relative "../helpers/admin_generator_attributes"
7
+
6
8
  module Koi
7
9
  class AdminViewsGenerator < Rails::Generators::NamedBase
8
10
  include Rails::Generators::ResourceHelpers
11
+ include Helpers::AdminGeneratorAttributes
9
12
 
10
13
  source_root File.expand_path("templates", __dir__)
11
14
 
@@ -31,49 +34,5 @@ module Koi
31
34
  def controller_class_path
32
35
  ["admin"] + super
33
36
  end
34
-
35
- def govuk_input_for(attribute)
36
- case attribute.type
37
- when :string
38
- %(<%= form.govuk_text_field :#{attribute.name} %>)
39
- when :integer
40
- %(<%= form.govuk_number_field :#{attribute.name} %>)
41
- when :boolean
42
- %(<%= form.govuk_check_box_field :#{attribute.name} %>)
43
- when :date
44
- %(<%= form.govuk_date_field :#{attribute.name}, legend: { size: "s" } %>)
45
- when :rich_text, :text
46
- %(<%= form.govuk_rich_text_area :#{attribute.name} %>)
47
- when :attachment
48
- %(<%= form.govuk_image_field :#{attribute.name} %>)
49
- else
50
- ""
51
- end
52
- end
53
-
54
- def index_attribute_for(attribute)
55
- case attribute.type
56
- when :integer
57
- %(<% row.number :#{attribute.name} %>)
58
- when :boolean
59
- %(<% row.boolean :#{attribute.name} %>)
60
- when :date
61
- %(<% row.date :#{attribute.name} %>)
62
- when :datetime
63
- %(<% row.datetime :#{attribute.name} %>)
64
- when :rich_text
65
- %(<% row.rich_text :#{attribute.name} %>)
66
- when :attachment
67
- %(<% row.attachment :#{attribute.name} %>)
68
- else
69
- %(<% row.text :#{attribute.name} %>)
70
- end
71
- end
72
-
73
- alias_method :summary_attribute_for, :index_attribute_for
74
-
75
- def index_attributes
76
- attributes
77
- end
78
37
  end
79
38
  end
@@ -1,8 +1,10 @@
1
1
  <%% content_for :header do %>
2
- <%%= render(Koi::Header::IndexComponent.new(model: <%= class_name %>)) %>
2
+ <%%= render(Koi::Header::IndexComponent.new(model: <%= class_name %>)) do |component| %>
3
+ <%% component.with_action "New", <%= new_helper(type: :path) %> %>
4
+ <%% end %>
3
5
  <%% end %>
4
6
 
5
- <%%= koi_index_actions create: true, search: true %>
7
+ <%%= table_query_with(collection:) %>
6
8
 
7
9
  <%%= table_with(collection:) do |row, <%= singular_name %>| %>
8
10
  <%- index_attributes.each_with_index do |attribute, index| -%>
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Koi
4
+ module Helpers
5
+ module AdminGeneratorAttributes
6
+ extend ActiveSupport::Concern
7
+
8
+ def govuk_input_for(attribute)
9
+ case attribute.type
10
+ when :string
11
+ %(<%= form.govuk_text_field :#{attribute.name} %>)
12
+ when :integer
13
+ %(<%= form.govuk_number_field :#{attribute.name} %>)
14
+ when :boolean
15
+ %(<%= form.govuk_check_box_field :#{attribute.name} %>)
16
+ when :date
17
+ %(<%= form.govuk_date_field :#{attribute.name}, legend: { size: "s" } %>)
18
+ when :rich_text, :text
19
+ %(<%= form.govuk_rich_text_area :#{attribute.name} %>)
20
+ when :attachment
21
+ %(<%= form.govuk_image_field :#{attribute.name} %>)
22
+ else
23
+ ""
24
+ end
25
+ end
26
+
27
+ def index_attribute_for(attribute)
28
+ case attribute.type
29
+ when :integer
30
+ %(<% row.number :#{attribute.name} %>)
31
+ when :boolean
32
+ %(<% row.boolean :#{attribute.name} %>)
33
+ when :date
34
+ %(<% row.date :#{attribute.name} %>)
35
+ when :datetime
36
+ %(<% row.datetime :#{attribute.name} %>)
37
+ when :rich_text
38
+ %(<% row.rich_text :#{attribute.name} %>)
39
+ when :attachment
40
+ %(<% row.attachment :#{attribute.name} %>)
41
+ else
42
+ %(<% row.text :#{attribute.name} %>)
43
+ end
44
+ end
45
+
46
+ alias_method :summary_attribute_for, :index_attribute_for
47
+
48
+ def collection_attribute_for(attribute)
49
+ case attribute.type
50
+ when :string
51
+ %(attribute :#{attribute.name}, :string)
52
+ when :integer
53
+ %(attribute :#{attribute.name}, :integer)
54
+ when :boolean
55
+ %(attribute :#{attribute.name}, :boolean)
56
+ when :date, :datetime
57
+ %(attribute :#{attribute.name}, :date)
58
+ end
59
+ end
60
+
61
+ def index_attributes
62
+ attributes
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Koi
4
+ module Collection
5
+ module Type
6
+ # Add support for `attribute :status, :archivable, default: :active` to
7
+ # Koi collections to support filtering on Koi::Model::Archivable models.
8
+ class Archivable < Katalyst::Tables::Collection::Type::Enum
9
+ def initialize
10
+ super(multiple: false, scope: :status)
11
+ end
12
+
13
+ def type
14
+ :archivable
15
+ end
16
+
17
+ def examples_for(...)
18
+ %i[active archived all]
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "koi/collection/type/archivable"
4
+
5
+ module Koi
6
+ module Collection
7
+ class << self
8
+ Katalyst::Tables::Collection::Type.register(:archivable, Koi::Collection::Type::Archivable)
9
+ end
10
+ end
11
+ end
data/lib/koi/config.rb CHANGED
@@ -7,6 +7,8 @@ module Koi
7
7
  class Config
8
8
  include ActiveSupport::Configurable
9
9
 
10
+ config_accessor(:admin_name) { "Koi" }
11
+
10
12
  config_accessor(:resource_name_candidates) { %i[title name] }
11
13
 
12
14
  config_accessor(:admin_stylesheet) { "koi/admin" }
data/lib/koi.rb CHANGED
@@ -14,6 +14,7 @@ require "webauthn"
14
14
  require "koi/form_builder"
15
15
  require "koi/menu"
16
16
  require "koi/caching"
17
+ require "koi/collection"
17
18
  require "koi/config"
18
19
  require "koi/engine"
19
20
  require "koi/extensions"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-koi
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-14 00:00:00.000000000 Z
11
+ date: 2024-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -265,6 +265,8 @@ files:
265
265
  - app/assets/javascripts/koi/controllers/sluggable_controller.js
266
266
  - app/assets/javascripts/koi/controllers/webauthn_authentication_controller.js
267
267
  - app/assets/javascripts/koi/controllers/webauthn_registration_controller.js
268
+ - app/assets/javascripts/koi/elements/index.js
269
+ - app/assets/javascripts/koi/elements/toolbar.js
268
270
  - app/assets/javascripts/koi/utils/transition.js
269
271
  - app/assets/stylesheets/koi/admin.scss
270
272
  - app/assets/stylesheets/koi/base/_button.scss
@@ -282,7 +284,9 @@ files:
282
284
  - app/assets/stylesheets/koi/components/_index-actions.scss
283
285
  - app/assets/stylesheets/koi/components/_index.scss
284
286
  - app/assets/stylesheets/koi/components/_pagy.scss
287
+ - app/assets/stylesheets/koi/components/_query.scss
285
288
  - app/assets/stylesheets/koi/components/_summary-list.scss
289
+ - app/assets/stylesheets/koi/components/_toolbar.scss
286
290
  - app/assets/stylesheets/koi/layouts/_banner.scss
287
291
  - app/assets/stylesheets/koi/layouts/_content.scss
288
292
  - app/assets/stylesheets/koi/layouts/_flash.scss
@@ -329,8 +333,8 @@ files:
329
333
  - app/components/koi/summary_list_component.rb
330
334
  - app/components/koi/summary_table_component.rb
331
335
  - app/components/koi/table_component.rb
336
+ - app/components/koi/table_query_component.rb
332
337
  - app/components/koi/tables/cells/attachment_component.rb
333
- - app/components/koi/tables/cells/enum_component.rb
334
338
  - app/components/koi/tables/cells/link_component.rb
335
339
  - app/components/koi/tables/table_component.rb
336
340
  - app/controllers/admin/admin_users_controller.rb
@@ -353,6 +357,7 @@ files:
353
357
  - app/helpers/koi/pagy.rb
354
358
  - app/jobs/koi/application_job.rb
355
359
  - app/mailers/koi/application_mailer.rb
360
+ - app/models/admin/collection.rb
356
361
  - app/models/admin/credential.rb
357
362
  - app/models/admin/user.rb
358
363
  - app/models/application_record.rb
@@ -438,12 +443,15 @@ files:
438
443
  - lib/generators/koi/admin_views/templates/index.html.erb.tt
439
444
  - lib/generators/koi/admin_views/templates/new.html.erb.tt
440
445
  - lib/generators/koi/admin_views/templates/show.html.erb.tt
446
+ - lib/generators/koi/helpers/admin_generator_attributes.rb
441
447
  - lib/govuk_design_system_formbuilder/concerns/file_element.rb
442
448
  - lib/govuk_design_system_formbuilder/elements/document.rb
443
449
  - lib/govuk_design_system_formbuilder/elements/image.rb
444
450
  - lib/katalyst/koi.rb
445
451
  - lib/koi.rb
446
452
  - lib/koi/caching.rb
453
+ - lib/koi/collection.rb
454
+ - lib/koi/collection/type/archivable.rb
447
455
  - lib/koi/config.rb
448
456
  - lib/koi/engine.rb
449
457
  - lib/koi/extensions.rb
@@ -475,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
475
483
  - !ruby/object:Gem::Version
476
484
  version: '0'
477
485
  requirements: []
478
- rubygems_version: 3.5.9
486
+ rubygems_version: 3.5.11
479
487
  signing_key:
480
488
  specification_version: 4
481
489
  summary: Koi CMS admin framework
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module Tables
5
- module Cells
6
- # Displays an enum value using data inferred from the model.
7
- class EnumComponent < Katalyst::Tables::CellComponent
8
- def rendered_value
9
- if (value = self.value).present?
10
- label = t(i18n_enum_label_key(value), default: value)
11
- tag.span(label, data: { enum: column, value: })
12
- end
13
- end
14
-
15
- private
16
-
17
- def default_html_attributes
18
- { class: "type-enum" }
19
- end
20
-
21
- def i18n_enum_label_key(value)
22
- "active_record.attributes.#{collection.model_name.i18n_key}/#{column}.#{value}"
23
- end
24
- end
25
- end
26
- end
27
- end