katalyst-koi 4.10.3 → 4.11.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 +4 -4
- data/app/controllers/admin/admin_users_controller.rb +6 -1
- data/app/models/concerns/koi/model/archivable.rb +0 -20
- data/app/views/admin/admin_users/archived.html.erb +19 -0
- data/app/views/admin/admin_users/index.html.erb +2 -2
- data/config/locales/koi.en.yml +0 -5
- data/config/routes.rb +1 -0
- data/lib/koi/engine.rb +0 -4
- metadata +2 -2
- data/lib/koi/collection/type/archivable.rb +0 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e93ae67d5b7a194d086ac058e4ce50b719a6b09f8683cc75a77a3bbe65ba540
|
|
4
|
+
data.tar.gz: 57cf5e6fecd3feda7033316da41920a9018e423d87ed953618ce1ee32ce6101d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2951257ff44bb56a689d18dbae88a1644f6e4840b0a3d0fb5718821a023d4a04ea4bf9ffeaf0be714b8240170510da04356ec1f25f9e98c4426927087df3662e
|
|
7
|
+
data.tar.gz: 70946f90ec2799e9076041b99154b389d03e699f4fe746f72bccb17c9b49ade2c1bd6e311427708c3ee13d01003f5eb2c484944f145869e6e40258d361c517ef
|
|
@@ -12,6 +12,12 @@ module Admin
|
|
|
12
12
|
render locals: { collection: }
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def archived
|
|
16
|
+
collection = Collection.new.with_params(params).apply(Admin::User.archived.strict_loading)
|
|
17
|
+
|
|
18
|
+
render locals: { collection: }
|
|
19
|
+
end
|
|
20
|
+
|
|
15
21
|
def show
|
|
16
22
|
render :show, locals: { admin: }
|
|
17
23
|
end
|
|
@@ -78,7 +84,6 @@ module Admin
|
|
|
78
84
|
|
|
79
85
|
attribute :name, :string
|
|
80
86
|
attribute :email, :string
|
|
81
|
-
attribute :status, :archivable, default: :active
|
|
82
87
|
attribute :last_sign_in_at, :date
|
|
83
88
|
attribute :sign_in_count, :integer
|
|
84
89
|
end
|
|
@@ -14,15 +14,6 @@ module Koi
|
|
|
14
14
|
# Model.all # default scope, excludes archived
|
|
15
15
|
# Model.archived # only returns archived records
|
|
16
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.
|
|
26
17
|
module Archivable
|
|
27
18
|
extend ActiveSupport::Concern
|
|
28
19
|
|
|
@@ -31,17 +22,6 @@ module Koi
|
|
|
31
22
|
scope :archived, -> { unscope(where: :archived_at).where.not(archived_at: nil) }
|
|
32
23
|
scope :with_archived, -> { unscope(where: :archived_at) }
|
|
33
24
|
|
|
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
|
-
|
|
45
25
|
default_scope { not_archived }
|
|
46
26
|
|
|
47
27
|
alias_method :archived?, :archived
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<% content_for :header do %>
|
|
2
|
+
<%= render Koi::Header::IndexComponent.new(model: Admin::User, title: "Archived") do |component| %>
|
|
3
|
+
<% component.with_breadcrumb "Admins", admin_admin_users_path %>
|
|
4
|
+
<% end %>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<%= table_query_with(collection:) %>
|
|
8
|
+
|
|
9
|
+
<%= table_selection_with(collection:) do %>
|
|
10
|
+
<%= tag.button "Restore", formaction: restore_admin_admin_users_path, formmethod: :put %>
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
13
|
+
<%= table_with(collection:) do |row| %>
|
|
14
|
+
<% row.select %>
|
|
15
|
+
<% row.link :name, url: :admin_admin_user_path %>
|
|
16
|
+
<% row.text :email %>
|
|
17
|
+
<% end %>
|
|
18
|
+
|
|
19
|
+
<%== pagy_nav(collection.pagination) %>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<% content_for :header do %>
|
|
2
2
|
<%= render Koi::Header::IndexComponent.new(model: Admin::User) do |component| %>
|
|
3
3
|
<% component.with_action "New", new_admin_admin_user_path %>
|
|
4
|
+
<% component.with_action "Archived", archived_admin_admin_users_path %>
|
|
4
5
|
<% end %>
|
|
5
6
|
<% end %>
|
|
6
7
|
|
|
@@ -8,10 +9,9 @@
|
|
|
8
9
|
|
|
9
10
|
<%= table_selection_with(collection:) do %>
|
|
10
11
|
<%= tag.button "Archive", formaction: archive_admin_admin_users_path, formmethod: :put %>
|
|
11
|
-
<%= tag.button "Restore", formaction: restore_admin_admin_users_path, formmethod: :put %>
|
|
12
12
|
<% end %>
|
|
13
13
|
|
|
14
|
-
<%= table_with(collection:) do |row
|
|
14
|
+
<%= table_with(collection:) do |row| %>
|
|
15
15
|
<% row.select %>
|
|
16
16
|
<% row.link :name, url: :admin_admin_user_path %>
|
|
17
17
|
<% row.text :email %>
|
data/config/locales/koi.en.yml
CHANGED
data/config/routes.rb
CHANGED
|
@@ -10,6 +10,7 @@ Rails.application.routes.draw do
|
|
|
10
10
|
resources :admin_users do
|
|
11
11
|
resources :credentials, only: %i[new create destroy]
|
|
12
12
|
post :invite, on: :member, to: "tokens#create"
|
|
13
|
+
get :archived, on: :collection
|
|
13
14
|
put :archive, on: :collection
|
|
14
15
|
put :restore, on: :collection
|
|
15
16
|
end
|
data/lib/koi/engine.rb
CHANGED
|
@@ -63,10 +63,6 @@ module Koi
|
|
|
63
63
|
Pagy::I18n.load(locale: "en", filepath: root.join("config/locales/pagy.en.yml"))
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
initializer "koi.tables" do
|
|
67
|
-
Katalyst::Tables.config.collection_types[:archivable] = "Koi::Collection::Type::Archivable"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
66
|
initializer "koi.views" do
|
|
71
67
|
ActiveSupport.on_load(:action_view) do
|
|
72
68
|
# Workaround for de-duplicating nested module paths for admin controllers
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: katalyst-koi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katalyst Interactive
|
|
@@ -364,6 +364,7 @@ files:
|
|
|
364
364
|
- app/models/concerns/koi/model/archivable.rb
|
|
365
365
|
- app/models/url_rewrite.rb
|
|
366
366
|
- app/views/admin/admin_users/_fields.html.erb
|
|
367
|
+
- app/views/admin/admin_users/archived.html.erb
|
|
367
368
|
- app/views/admin/admin_users/edit.html.erb
|
|
368
369
|
- app/views/admin/admin_users/index.html.erb
|
|
369
370
|
- app/views/admin/admin_users/new.html.erb
|
|
@@ -445,7 +446,6 @@ files:
|
|
|
445
446
|
- lib/katalyst/koi.rb
|
|
446
447
|
- lib/koi.rb
|
|
447
448
|
- lib/koi/caching.rb
|
|
448
|
-
- lib/koi/collection/type/archivable.rb
|
|
449
449
|
- lib/koi/config.rb
|
|
450
450
|
- lib/koi/engine.rb
|
|
451
451
|
- lib/koi/extensions/object_rendering.rb
|
|
@@ -1,35 +0,0 @@
|
|
|
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(scope: :status)
|
|
10
|
-
super(multiple: false, scope:)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def type
|
|
14
|
-
:archivable
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def examples_for(scope, attribute)
|
|
18
|
-
_, model, = model_and_column_for(scope, attribute)
|
|
19
|
-
|
|
20
|
-
%i[active archived all].map do |key|
|
|
21
|
-
example(key, describe_key(model, attribute, key))
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def describe_key(model, attribute, key)
|
|
28
|
-
description = I18n.t("koi.view.#{attribute.name}.#{key}", model: model.model_name.human)
|
|
29
|
-
description += " (default)" if key.to_s.eql?(attribute.original_value.to_s)
|
|
30
|
-
description
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|