katalyst-koi 4.7.3 → 4.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/builds/koi/admin.css +256 -152
  3. data/app/assets/builds/koi/admin.css.map +1 -1
  4. data/app/assets/javascripts/koi/controllers/index_actions_controller.js +0 -8
  5. data/app/assets/javascripts/koi/controllers/pagy_nav_controller.js +21 -0
  6. data/app/assets/stylesheets/koi/base/_index.scss +1 -0
  7. data/app/assets/stylesheets/koi/base/_tables.scss +15 -0
  8. data/app/assets/stylesheets/koi/components/_index.scss +0 -1
  9. data/app/components/concerns/koi/tables/cells.rb +85 -0
  10. data/app/components/koi/header/edit_component.rb +1 -1
  11. data/app/components/koi/header/show_component.rb +1 -1
  12. data/app/components/koi/summary_list/date_component.rb +2 -2
  13. data/app/components/koi/summary_list/datetime_component.rb +2 -2
  14. data/app/components/koi/summary_list/number_component.rb +2 -2
  15. data/app/components/koi/summary_table_component.rb +7 -0
  16. data/app/components/koi/table_component.rb +7 -0
  17. data/app/components/koi/tables/cells/enum_component.rb +27 -0
  18. data/app/components/koi/tables/table_component.rb +2 -54
  19. data/app/controllers/admin/admin_users_controller.rb +2 -2
  20. data/app/controllers/admin/sessions_controller.rb +8 -10
  21. data/app/controllers/admin/tokens_controller.rb +15 -13
  22. data/app/controllers/admin/url_rewrites_controller.rb +2 -2
  23. data/app/controllers/concerns/koi/controller/has_attachments.rb +1 -1
  24. data/app/controllers/concerns/koi/controller/has_webauthn.rb +1 -1
  25. data/app/controllers/concerns/koi/controller/is_admin_controller.rb +6 -4
  26. data/app/controllers/concerns/koi/controller/json_web_token.rb +1 -1
  27. data/app/helpers/koi/definition_list_helper.rb +2 -2
  28. data/app/helpers/koi/index_actions_helper.rb +3 -5
  29. data/app/helpers/koi/pagy.rb +15 -0
  30. data/app/models/url_rewrite.rb +1 -1
  31. data/app/views/admin/credentials/_credentials.html.erb +1 -1
  32. data/app/views/layouts/koi/application.html.erb +1 -1
  33. data/config/initializers/extensions.rb +1 -1
  34. data/config/initializers/flipper.rb +1 -1
  35. data/config/initializers/pagy.rb +2 -0
  36. data/config/locales/koi.en.yml +4 -0
  37. data/db/migrate/20130509235316_add_url_rewriter.rb +1 -1
  38. data/db/migrate/20230531063707_update_admin_users.rb +6 -3
  39. data/db/seeds.rb +1 -1
  40. data/lib/generators/koi/admin/admin_generator.rb +7 -1
  41. data/lib/generators/koi/admin_controller/admin_controller_generator.rb +6 -2
  42. data/lib/generators/koi/admin_controller/templates/controller.rb.tt +51 -53
  43. data/lib/generators/koi/admin_controller/templates/controller_spec.rb.tt +1 -1
  44. data/lib/generators/koi/admin_views/admin_views_generator.rb +8 -23
  45. data/lib/generators/koi/admin_views/templates/edit.html.erb.tt +1 -1
  46. data/lib/generators/koi/admin_views/templates/index.html.erb.tt +7 -7
  47. data/lib/generators/koi/admin_views/templates/new.html.erb.tt +1 -1
  48. data/lib/generators/koi/admin_views/templates/show.html.erb.tt +8 -4
  49. data/lib/govuk_design_system_formbuilder/elements/document.rb +5 -5
  50. data/lib/govuk_design_system_formbuilder/elements/image.rb +5 -5
  51. data/lib/koi/config.rb +2 -0
  52. data/lib/koi/form_builder.rb +12 -12
  53. data/lib/koi/menu/builder.rb +6 -6
  54. metadata +10 -5
  55. data/app/assets/stylesheets/koi/components/_index-table.scss +0 -147
  56. data/app/assets/stylesheets/koi/components/index-table/_ordinal.scss +0 -38
@@ -9,8 +9,8 @@ module GOVUKDesignSystemFormBuilder
9
9
  include FileElement
10
10
 
11
11
  def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:,
12
- **kwargs, &block)
13
- super(builder, object_name, attribute_name, &block)
12
+ **kwargs, &)
13
+ super(builder, object_name, attribute_name, &)
14
14
 
15
15
  @mime_types = mime_types
16
16
  @label = label
@@ -89,10 +89,10 @@ module GOVUKDesignSystemFormBuilder
89
89
  hint: {},
90
90
  form_group: {},
91
91
  mime_types: Koi.config.image_mime_types,
92
- **kwargs,
93
- &block)
92
+ **,
93
+ &)
94
94
  Elements::Image.new(
95
- self, object_name, attribute_name, label:, caption:, hint:, form_group:, mime_types:, **kwargs, &block
95
+ self, object_name, attribute_name, label:, caption:, hint:, form_group:, mime_types:, **, &
96
96
  ).html
97
97
  end
98
98
  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" }
@@ -7,31 +7,31 @@ module Koi
7
7
  include GOVUKDesignSystemFormBuilder::Builder
8
8
 
9
9
  # Generates a submit button for saving admin resources.
10
- def admin_save(text = "Save", name: :commit, value: :save, class: "button button--primary", **kwargs)
11
- button(text, name:, value:, class:, **kwargs)
10
+ def admin_save(text = "Save", name: :commit, value: :save, class: "button button--primary", **)
11
+ button(text, name:, value:, class:, **)
12
12
  end
13
13
 
14
14
  # Generates a delete link formatted as a button that will perform a turbo
15
15
  # delete with a confirmation.
16
- def admin_delete(text = "Delete", url: nil, confirm: "Are you sure?", data: {}, **kwargs)
16
+ def admin_delete(text = "Delete", url: nil, confirm: "Are you sure?", data: {}, **)
17
17
  return unless object.persisted?
18
18
 
19
19
  link_to(text, url || url_for(action: :destroy),
20
20
  class: "button button--secondary",
21
21
  data: data.reverse_merge(turbo_method: :delete, turbo_confirm: confirm),
22
- **kwargs)
22
+ **)
23
23
  end
24
24
 
25
25
  # Generates an archive link formatted as a button that will perform a turbo
26
26
  # delete with a confirmation.
27
- def admin_archive(text = "Archive", **kwargs)
28
- admin_delete(text, **kwargs)
27
+ def admin_archive(text = "Archive", **)
28
+ admin_delete(text, **)
29
29
  end
30
30
 
31
31
  # Generates a discard changes link formatted as a text button that navigates
32
32
  # the user back to the previous page.
33
- def admin_discard(text = "Discard", url: :back, **kwargs)
34
- link_to(text, url, class: "button button--text", **kwargs)
33
+ def admin_discard(text = "Discard", url: :back, **)
34
+ link_to(text, url, class: "button button--text", **)
35
35
  end
36
36
 
37
37
  # @api internal
@@ -42,7 +42,7 @@ module Koi
42
42
  hint[:text] ||= t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size))
43
43
  end
44
44
 
45
- super(attribute_name, hint:, **, &)
45
+ super
46
46
  end
47
47
 
48
48
  # @api internal
@@ -53,20 +53,20 @@ module Koi
53
53
  hint[:text] ||= t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size))
54
54
  end
55
55
 
56
- super(attribute_name, hint:, **, &)
56
+ super
57
57
  end
58
58
 
59
59
  # Use content editor trix setup by default.
60
60
  #
61
61
  # @api internal
62
62
  # @see GOVUKDesignSystemFormBuilder::Builder#govuk_rich_text_area
63
- def govuk_rich_text_area(attribute_name, data: {}, **kwargs, &block)
63
+ def govuk_rich_text_area(attribute_name, data: {}, **, &)
64
64
  data = data.reverse_merge(
65
65
  direct_upload_url: @template.katalyst_content.direct_uploads_url,
66
66
  controller: "content--editor--trix",
67
67
  action: "trix-initialize->content--editor--trix#trixInitialize",
68
68
  )
69
- super(attribute_name, data:, **kwargs, &block)
69
+ super
70
70
  end
71
71
  end
72
72
  end
@@ -27,10 +27,10 @@ module Koi
27
27
  end
28
28
  end
29
29
 
30
- def add_menu(title:, **options, &)
30
+ def add_menu(title:, **, &)
31
31
  @menu.items.build(type: Katalyst::Navigation::Heading.name,
32
32
  title:,
33
- **options,
33
+ **,
34
34
  index: @index,
35
35
  depth: @depth)
36
36
  @index += 1
@@ -39,21 +39,21 @@ module Koi
39
39
  @depth -= 1
40
40
  end
41
41
 
42
- def add_link(title:, url:, **options)
42
+ def add_link(title:, url:, **)
43
43
  @menu.items.build(type: Katalyst::Navigation::Link.name,
44
44
  title:,
45
45
  url:,
46
- **options,
46
+ **,
47
47
  index: @index,
48
48
  depth: @depth)
49
49
  @index += 1
50
50
  end
51
51
 
52
- def add_button(title:, url:, **options)
52
+ def add_button(title:, url:, **)
53
53
  @menu.items.build(type: Katalyst::Navigation::Button.name,
54
54
  title:,
55
55
  url:,
56
- **options,
56
+ **,
57
57
  index: @index,
58
58
  depth: @depth)
59
59
  @index += 1
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.7.3
4
+ version: 4.8.1
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-05-30 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -260,6 +260,7 @@ files:
260
260
  - app/assets/javascripts/koi/controllers/keyboard_controller.js
261
261
  - app/assets/javascripts/koi/controllers/navigation_controller.js
262
262
  - app/assets/javascripts/koi/controllers/navigation_toggle_controller.js
263
+ - app/assets/javascripts/koi/controllers/pagy_nav_controller.js
263
264
  - app/assets/javascripts/koi/controllers/show_hide_controller.js
264
265
  - app/assets/javascripts/koi/controllers/sluggable_controller.js
265
266
  - app/assets/javascripts/koi/controllers/webauthn_authentication_controller.js
@@ -272,17 +273,16 @@ files:
272
273
  - app/assets/stylesheets/koi/base/_input.scss
273
274
  - app/assets/stylesheets/koi/base/_link.scss
274
275
  - app/assets/stylesheets/koi/base/_list.scss
276
+ - app/assets/stylesheets/koi/base/_tables.scss
275
277
  - app/assets/stylesheets/koi/base/_typography.scss
276
278
  - app/assets/stylesheets/koi/components/_actions-group.scss
277
279
  - app/assets/stylesheets/koi/components/_clipboard.scss
278
280
  - app/assets/stylesheets/koi/components/_document-field.scss
279
281
  - app/assets/stylesheets/koi/components/_image-field.scss
280
282
  - app/assets/stylesheets/koi/components/_index-actions.scss
281
- - app/assets/stylesheets/koi/components/_index-table.scss
282
283
  - app/assets/stylesheets/koi/components/_index.scss
283
284
  - app/assets/stylesheets/koi/components/_pagy.scss
284
285
  - app/assets/stylesheets/koi/components/_summary-list.scss
285
- - app/assets/stylesheets/koi/components/index-table/_ordinal.scss
286
286
  - app/assets/stylesheets/koi/layouts/_banner.scss
287
287
  - app/assets/stylesheets/koi/layouts/_content.scss
288
288
  - app/assets/stylesheets/koi/layouts/_flash.scss
@@ -303,6 +303,7 @@ files:
303
303
  - app/assets/stylesheets/koi/utils/_hide.scss
304
304
  - app/assets/stylesheets/koi/utils/_index.scss
305
305
  - app/assets/stylesheets/koi/utils/_typography.scss
306
+ - app/components/concerns/koi/tables/cells.rb
306
307
  - app/components/koi/content/editor/errors_component.html.erb
307
308
  - app/components/koi/content/editor/errors_component.rb
308
309
  - app/components/koi/content/editor/item_form_component.html.erb
@@ -326,7 +327,10 @@ files:
326
327
  - app/components/koi/summary_list/text_component.rb
327
328
  - app/components/koi/summary_list_component.html.erb
328
329
  - app/components/koi/summary_list_component.rb
330
+ - app/components/koi/summary_table_component.rb
331
+ - app/components/koi/table_component.rb
329
332
  - app/components/koi/tables/cells/attachment_component.rb
333
+ - app/components/koi/tables/cells/enum_component.rb
330
334
  - app/components/koi/tables/cells/link_component.rb
331
335
  - app/components/koi/tables/table_component.rb
332
336
  - app/controllers/admin/admin_users_controller.rb
@@ -346,6 +350,7 @@ files:
346
350
  - app/helpers/koi/date_helper.rb
347
351
  - app/helpers/koi/definition_list_helper.rb
348
352
  - app/helpers/koi/index_actions_helper.rb
353
+ - app/helpers/koi/pagy.rb
349
354
  - app/jobs/koi/application_job.rb
350
355
  - app/mailers/koi/application_mailer.rb
351
356
  - app/models/admin/credential.rb
@@ -470,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
470
475
  - !ruby/object:Gem::Version
471
476
  version: '0'
472
477
  requirements: []
473
- rubygems_version: 3.5.9
478
+ rubygems_version: 3.5.11
474
479
  signing_key:
475
480
  specification_version: 4
476
481
  summary: Koi CMS admin framework
@@ -1,147 +0,0 @@
1
- @use "index-table/ordinal" as *;
2
-
3
- @mixin sort-icon {
4
- display: inline-block;
5
- content: " ";
6
- position: relative;
7
- right: -1rem;
8
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 13'%3E%3Cpath d='M.541 0l11.125 12.573a.5.5 0 00.749 0L23.541 0h-23z' fill='%23000' fill-rule='evenodd'/%3E%3C/svg%3E");
9
- background-size: 14px 14px;
10
- height: 14px;
11
- width: 14px;
12
- }
13
-
14
- $grey: #f0ecf3 !default;
15
-
16
- $table-header-color: transparent !default;
17
- $row-border-color: $grey !default;
18
- $row-height: 48px !default;
19
- $cell-spacing: 0.5rem !default;
20
-
21
- $width-small: 6rem !default;
22
- $width-medium: 12rem !default;
23
- $width-large: 16rem !default;
24
-
25
- .index-table {
26
- --row-height: #{$row-height};
27
- --cell-spacing: #{$cell-spacing};
28
- --table-header-color: #{$table-header-color};
29
- --row-border-color: #{$row-border-color};
30
-
31
- --width-small: #{$width-small};
32
- --width-medium: #{$width-medium};
33
- --width-large: #{$width-large};
34
- }
35
-
36
- .index-table {
37
- border: none;
38
- table-layout: fixed;
39
- border-collapse: collapse;
40
- text-align: left;
41
- width: 100%;
42
-
43
- thead {
44
- background: var(--table-header-color);
45
- }
46
-
47
- tr {
48
- height: var(--row-height);
49
- line-height: var(--row-height);
50
- }
51
-
52
- th,
53
- td {
54
- border: none;
55
- box-shadow: inset 0px -1px 0px var(--row-border-color);
56
- overflow: hidden;
57
- text-overflow: ellipsis;
58
- vertical-align: top;
59
- white-space: nowrap;
60
- background-color: white;
61
- padding-right: var(--cell-spacing);
62
-
63
- &:last-child {
64
- padding-right: 0;
65
- }
66
-
67
- > a {
68
- display: block;
69
- overflow: hidden;
70
- white-space: nowrap;
71
- text-overflow: ellipsis;
72
- text-decoration: none;
73
- }
74
-
75
- > img,
76
- > a > img {
77
- max-height: 3rem;
78
- padding: 0;
79
- }
80
-
81
- > .trix-content {
82
- overflow: hidden;
83
- text-overflow: ellipsis;
84
- }
85
- }
86
-
87
- th {
88
- font-weight: bold;
89
- }
90
-
91
- thead th {
92
- // types defined first so they can be overridden with width classes
93
- &.type-boolean,
94
- &.type-number {
95
- width: var(--width-small);
96
- }
97
-
98
- &.type-date,
99
- &.type-currency {
100
- width: var(--width-medium);
101
- }
102
-
103
- &.type-datetime {
104
- width: var(--width-large);
105
- }
106
-
107
- &.width-s {
108
- width: var(--width-small);
109
- }
110
-
111
- &.width-m {
112
- width: var(--width-medium);
113
- }
114
-
115
- &.width-l {
116
- width: var(--width-large);
117
- }
118
- }
119
-
120
- td {
121
- &.type-currency,
122
- &.type-number {
123
- text-align: right;
124
- }
125
- }
126
-
127
- thead a.ascending:after,
128
- [data-sort="asc"] a::after {
129
- @include sort-icon;
130
- top: 0;
131
- transform: rotate(180deg);
132
- }
133
-
134
- thead a.descending:after,
135
- [data-sort="desc"] a::after {
136
- @include sort-icon;
137
- top: 4px;
138
- }
139
-
140
- .button_to {
141
- line-height: 1.5;
142
- }
143
-
144
- caption {
145
- margin: 2rem 0;
146
- }
147
- }
@@ -1,38 +0,0 @@
1
- $width: 2rem !default;
2
- $time: 125ms !default;
3
-
4
- .index-table {
5
- tr {
6
- transition:
7
- top $time ease-in-out,
8
- transform $time ease-in-out;
9
- }
10
-
11
- tr[dragging] {
12
- transition: transform $time ease-in-out;
13
- filter: drop-shadow(0 0 0.5rem var(--row-border-color));
14
- transform: scale(1.01);
15
- td {
16
- box-shadow: none;
17
- }
18
- }
19
-
20
- th.ordinal {
21
- width: $width;
22
- padding-left: 0;
23
- a {
24
- width: $width;
25
- height: 3rem;
26
- }
27
- a::after {
28
- right: 0;
29
- }
30
- }
31
-
32
- td.ordinal {
33
- width: $width;
34
- padding-left: 0;
35
- cursor: grab;
36
- text-align: center;
37
- }
38
- }