katalyst-koi 4.18.1 → 5.0.0.alpha.2

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.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/koi/icons/add.svg +3 -0
  3. data/app/assets/images/koi/icons/close.svg +1 -0
  4. data/app/assets/images/koi/koi.png +0 -0
  5. data/app/assets/javascripts/koi/controllers/file_field_controller.js +2 -2
  6. data/app/assets/javascripts/koi/controllers/index.js +0 -3
  7. data/app/assets/javascripts/koi/controllers/koi/modal_controller.js +40 -0
  8. data/app/assets/javascripts/koi/controllers/navigation_controller.js +14 -21
  9. data/app/assets/javascripts/koi/controllers/webauthn_registration_controller.js +4 -1
  10. data/app/assets/stylesheets/koi/blocks/actions.css +8 -0
  11. data/app/assets/stylesheets/koi/blocks/application-header.css +15 -0
  12. data/app/assets/stylesheets/koi/blocks/application-navigation.css +54 -0
  13. data/app/assets/stylesheets/koi/blocks/button.css +90 -0
  14. data/app/assets/stylesheets/koi/blocks/flash.css +19 -0
  15. data/app/assets/stylesheets/koi/blocks/icon.css +15 -0
  16. data/app/assets/stylesheets/koi/blocks/index.css +13 -0
  17. data/app/assets/stylesheets/koi/blocks/modal.css +26 -0
  18. data/app/assets/stylesheets/koi/blocks/navigation.css +23 -0
  19. data/app/assets/stylesheets/koi/blocks/page-header.css +31 -0
  20. data/app/assets/stylesheets/koi/blocks/pagy.css +82 -0
  21. data/app/assets/stylesheets/koi/blocks/prose.css +37 -0
  22. data/app/assets/stylesheets/koi/blocks/tables/index.css +4 -0
  23. data/app/assets/stylesheets/koi/{components/_query.scss → blocks/tables/query.css} +13 -13
  24. data/app/assets/stylesheets/koi/{base/_tables.scss → blocks/tables/table.css} +12 -60
  25. data/app/assets/stylesheets/koi/compositions/cover.css +17 -0
  26. data/app/assets/stylesheets/koi/{base/_flow.scss → compositions/flow.css} +1 -1
  27. data/app/assets/stylesheets/koi/compositions/index.css +4 -0
  28. data/app/assets/stylesheets/koi/compositions/wrapper.css +11 -0
  29. data/app/assets/stylesheets/koi/forms/caption.css +22 -0
  30. data/app/assets/stylesheets/koi/forms/checkboxes.css +153 -0
  31. data/app/assets/stylesheets/koi/forms/date-input.css +12 -0
  32. data/app/assets/stylesheets/koi/{components/_document-field.scss → forms/document-field.css} +20 -15
  33. data/app/assets/stylesheets/koi/forms/errors.css +38 -0
  34. data/app/assets/stylesheets/koi/forms/fieldset.css +73 -0
  35. data/app/assets/stylesheets/koi/forms/file-upload.css +20 -0
  36. data/app/assets/stylesheets/koi/forms/form-group.css +19 -0
  37. data/app/assets/stylesheets/koi/forms/hint.css +11 -0
  38. data/app/assets/stylesheets/koi/forms/image-field.css +96 -0
  39. data/app/assets/stylesheets/koi/forms/index.css +44 -0
  40. data/app/assets/stylesheets/koi/forms/input.css +194 -0
  41. data/app/assets/stylesheets/koi/forms/label.css +43 -0
  42. data/app/assets/stylesheets/koi/forms/password.css +18 -0
  43. data/app/assets/stylesheets/koi/forms/radios.css +162 -0
  44. data/app/assets/stylesheets/koi/forms/select.css +18 -0
  45. data/app/assets/stylesheets/koi/forms/textarea.css +3 -0
  46. data/app/assets/stylesheets/koi/forms/trix.css +33 -0
  47. data/app/assets/stylesheets/koi/global/fonts.css +22 -0
  48. data/app/assets/stylesheets/koi/global/global-styles.css +297 -0
  49. data/app/assets/stylesheets/koi/global/reset.css +98 -0
  50. data/app/assets/stylesheets/koi/global/variables.css +97 -0
  51. data/app/assets/stylesheets/koi/icons.css +14 -0
  52. data/app/assets/stylesheets/koi/index.css +17 -0
  53. data/app/assets/stylesheets/koi/login.css +26 -0
  54. data/app/assets/stylesheets/koi/utilities/index.css +1 -0
  55. data/app/assets/stylesheets/koi/utilities/visually-hidden.css +18 -0
  56. data/app/components/concerns/koi/tables/cells.rb +3 -3
  57. data/app/components/koi/header_component.html.erb +12 -11
  58. data/app/components/koi/header_component.rb +2 -0
  59. data/app/components/koi/table_component.rb +8 -0
  60. data/app/controllers/admin/admin_users_controller.rb +24 -18
  61. data/app/controllers/admin/application_controller.rb +1 -3
  62. data/app/controllers/admin/credentials_controller.rb +18 -14
  63. data/app/controllers/admin/otps_controller.rb +15 -13
  64. data/app/controllers/admin/sessions_controller.rb +12 -1
  65. data/app/controllers/admin/url_rewrites_controller.rb +19 -17
  66. data/app/controllers/admin/well_knowns_controller.rb +20 -18
  67. data/app/controllers/concerns/koi/controller.rb +37 -0
  68. data/app/helpers/koi/form_helper.rb +18 -0
  69. data/app/helpers/koi/header_helper.rb +122 -0
  70. data/app/helpers/koi/index_actions_helper.rb +3 -2
  71. data/app/helpers/koi/modal_helper.rb +71 -0
  72. data/app/models/admin/user.rb +7 -1
  73. data/app/models/url_rewrite.rb +1 -9
  74. data/app/views/admin/admin_users/_form.html+self.erb +8 -0
  75. data/app/views/admin/admin_users/_form.html.erb +8 -0
  76. data/app/views/admin/admin_users/archived.html.erb +7 -4
  77. data/app/views/admin/admin_users/edit.html+self.erb +12 -0
  78. data/app/views/admin/admin_users/edit.html.erb +13 -8
  79. data/app/views/admin/admin_users/index.html.erb +10 -5
  80. data/app/views/admin/admin_users/new.html.erb +8 -8
  81. data/app/views/admin/admin_users/show.html+self.erb +26 -14
  82. data/app/views/admin/admin_users/show.html.erb +22 -20
  83. data/app/views/admin/credentials/_credentials.html+self.erb +8 -6
  84. data/app/views/admin/credentials/_credentials.html.erb +3 -1
  85. data/app/views/admin/credentials/create.turbo_stream.erb +4 -3
  86. data/app/views/admin/credentials/destroy.turbo_stream.erb +4 -2
  87. data/app/views/admin/credentials/new.html.erb +42 -36
  88. data/app/views/admin/dashboards/show.html.erb +13 -1
  89. data/app/views/admin/otps/_form.html.erb +7 -7
  90. data/app/views/admin/otps/create.turbo_stream.erb +3 -3
  91. data/app/views/admin/otps/new.html.erb +5 -3
  92. data/app/views/admin/sessions/new.html.erb +2 -3
  93. data/app/views/admin/sessions/otp.html.erb +1 -3
  94. data/app/views/admin/sessions/password.html.erb +1 -3
  95. data/app/views/admin/tokens/show.html.erb +4 -6
  96. data/app/views/admin/url_rewrites/_form.html.erb +9 -0
  97. data/app/views/admin/url_rewrites/edit.html.erb +13 -9
  98. data/app/views/admin/url_rewrites/index.html.erb +10 -7
  99. data/app/views/admin/url_rewrites/new.html.erb +8 -8
  100. data/app/views/admin/url_rewrites/show.html.erb +17 -12
  101. data/app/views/admin/well_knowns/_form.html.erb +9 -0
  102. data/app/views/admin/well_knowns/edit.html.erb +13 -9
  103. data/app/views/admin/well_knowns/index.html.erb +8 -5
  104. data/app/views/admin/well_knowns/new.html.erb +8 -8
  105. data/app/views/admin/well_knowns/show.html.erb +14 -13
  106. data/app/views/katalyst/content/asides/_aside.html+form.erb +6 -4
  107. data/app/views/katalyst/content/columns/_column.html+form.erb +5 -3
  108. data/app/views/katalyst/content/contents/_content.html+form.erb +8 -6
  109. data/app/views/katalyst/content/figures/_figure.html+form.erb +8 -5
  110. data/app/views/katalyst/content/groups/_group.html+form.erb +5 -3
  111. data/app/views/katalyst/content/items/_item.html+form.erb +5 -3
  112. data/app/views/katalyst/content/sections/_section.html+form.erb +5 -3
  113. data/app/views/katalyst/content/tables/_table.html+form.erb +16 -11
  114. data/app/views/katalyst/navigation/items/_button.html.erb +6 -12
  115. data/app/views/katalyst/navigation/items/_heading.html.erb +3 -10
  116. data/app/views/katalyst/navigation/items/_link.html.erb +6 -11
  117. data/app/views/katalyst/navigation/menus/edit.html.erb +10 -6
  118. data/app/views/katalyst/navigation/menus/index.html.erb +4 -2
  119. data/app/views/katalyst/navigation/menus/new.html.erb +5 -3
  120. data/app/views/katalyst/navigation/menus/show.html.erb +8 -7
  121. data/app/views/layouts/koi/_application_header.html.erb +20 -0
  122. data/app/views/layouts/koi/_application_navigation.html.erb +34 -0
  123. data/app/views/layouts/koi/_flash.html.erb +6 -3
  124. data/app/views/layouts/koi/_navigation_header.html.erb +0 -2
  125. data/app/views/layouts/koi/application.html.erb +22 -27
  126. data/app/views/layouts/koi/frame.html.erb +1 -3
  127. data/app/views/layouts/koi/login.html.erb +12 -5
  128. data/config/locales/koi.en.yml +9 -1
  129. data/config/routes.rb +1 -1
  130. data/lib/generators/koi/admin/admin_generator.rb +3 -13
  131. data/lib/generators/koi/admin_controller/admin_controller_generator.rb +6 -16
  132. data/lib/generators/koi/admin_controller/templates/controller.rb.tt +82 -18
  133. data/lib/generators/koi/admin_controller/templates/controller_spec.rb.tt +113 -47
  134. data/lib/generators/koi/admin_route/admin_route_generator.rb +60 -6
  135. data/lib/generators/koi/admin_views/USAGE +18 -7
  136. data/lib/generators/koi/admin_views/admin_views_generator.rb +19 -11
  137. data/lib/generators/koi/admin_views/templates/_form.html.erb.tt +8 -0
  138. data/lib/generators/koi/admin_views/templates/archived.html.erb.tt +33 -0
  139. data/lib/generators/koi/admin_views/templates/edit.html.erb.tt +17 -9
  140. data/lib/generators/koi/admin_views/templates/index.html.erb.tt +31 -3
  141. data/lib/generators/koi/admin_views/templates/new.html.erb.tt +8 -8
  142. data/lib/generators/koi/admin_views/templates/show.html.erb.tt +15 -18
  143. data/lib/generators/koi/helpers/attribute_helpers.rb +147 -0
  144. data/lib/generators/koi/helpers/attribute_types.rb +218 -0
  145. data/lib/generators/koi/helpers/resource_helpers.rb +121 -0
  146. data/lib/generators/koi/{active_record/active_record_generator.rb → model/model_generator.rb} +1 -1
  147. data/lib/koi/config.rb +3 -1
  148. data/lib/koi/engine.rb +0 -9
  149. data/lib/koi/form/builder.rb +4 -4
  150. data/lib/koi/form/content.rb +55 -0
  151. data/lib/koi/form/elements/document.rb +1 -1
  152. data/lib/koi/form/elements/image.rb +1 -1
  153. data/lib/koi/form_builder.rb +1 -0
  154. data/lib/koi/menu.rb +14 -1
  155. data/spec/factories/admins.rb +1 -1
  156. metadata +90 -103
  157. data/app/assets/builds/koi/admin.css +0 -1
  158. data/app/assets/stylesheets/koi/admin.scss +0 -27
  159. data/app/assets/stylesheets/koi/base/_button.scss +0 -122
  160. data/app/assets/stylesheets/koi/base/_icon.scss +0 -29
  161. data/app/assets/stylesheets/koi/base/_index.scss +0 -21
  162. data/app/assets/stylesheets/koi/base/_input.scss +0 -19
  163. data/app/assets/stylesheets/koi/base/_link.scss +0 -26
  164. data/app/assets/stylesheets/koi/base/_list.scss +0 -11
  165. data/app/assets/stylesheets/koi/base/_typography.scss +0 -160
  166. data/app/assets/stylesheets/koi/components/_actions-group.scss +0 -7
  167. data/app/assets/stylesheets/koi/components/_image-field.scss +0 -95
  168. data/app/assets/stylesheets/koi/components/_index.scss +0 -9
  169. data/app/assets/stylesheets/koi/components/_pagy.scss +0 -29
  170. data/app/assets/stylesheets/koi/components/_summary-list.scss +0 -40
  171. data/app/assets/stylesheets/koi/layouts/_banner.scss +0 -7
  172. data/app/assets/stylesheets/koi/layouts/_content.scss +0 -40
  173. data/app/assets/stylesheets/koi/layouts/_flash.scss +0 -41
  174. data/app/assets/stylesheets/koi/layouts/_header.scss +0 -61
  175. data/app/assets/stylesheets/koi/layouts/_index.scss +0 -48
  176. data/app/assets/stylesheets/koi/layouts/_main.scss +0 -23
  177. data/app/assets/stylesheets/koi/layouts/_navigation.scss +0 -180
  178. data/app/assets/stylesheets/koi/layouts/_stack.scss +0 -13
  179. data/app/assets/stylesheets/koi/pages/_index.scss +0 -1
  180. data/app/assets/stylesheets/koi/pages/_login.scss +0 -46
  181. data/app/assets/stylesheets/koi/themes/_content.scss +0 -62
  182. data/app/assets/stylesheets/koi/themes/_govuk.scss +0 -56
  183. data/app/assets/stylesheets/koi/themes/_index.scss +0 -5
  184. data/app/assets/stylesheets/koi/themes/_kpop.scss +0 -5
  185. data/app/assets/stylesheets/koi/themes/_navigation.scss +0 -5
  186. data/app/assets/stylesheets/koi/themes/_trix.scss +0 -32
  187. data/app/assets/stylesheets/koi/utils/_breakpoints.scss +0 -13
  188. data/app/assets/stylesheets/koi/utils/_hide.scss +0 -11
  189. data/app/assets/stylesheets/koi/utils/_index.scss +0 -2
  190. data/app/assets/stylesheets/koi/utils/_typography.scss +0 -42
  191. data/app/components/koi/content/editor/item_form_component.html.erb +0 -11
  192. data/app/components/koi/content/editor/item_form_component.rb +0 -94
  193. data/app/components/koi/summary_list/attachment_component.rb +0 -47
  194. data/app/components/koi/summary_list/base.rb +0 -59
  195. data/app/components/koi/summary_list/boolean_component.rb +0 -15
  196. data/app/components/koi/summary_list/date_component.rb +0 -17
  197. data/app/components/koi/summary_list/datetime_component.rb +0 -17
  198. data/app/components/koi/summary_list/item_component.rb +0 -26
  199. data/app/components/koi/summary_list/number_component.rb +0 -21
  200. data/app/components/koi/summary_list/rich_text_component.rb +0 -8
  201. data/app/components/koi/summary_list/text_component.rb +0 -8
  202. data/app/components/koi/summary_list_component.html.erb +0 -5
  203. data/app/components/koi/summary_list_component.rb +0 -75
  204. data/app/controllers/concerns/koi/controller/is_admin_controller.rb +0 -66
  205. data/app/helpers/koi/application_helper.rb +0 -7
  206. data/app/helpers/koi/date_helper.rb +0 -26
  207. data/app/helpers/koi/definition_list_helper.rb +0 -10
  208. data/app/views/admin/admin_users/_fields.html+self.erb +0 -3
  209. data/app/views/admin/admin_users/_fields.html.erb +0 -3
  210. data/app/views/admin/url_rewrites/_fields.html.erb +0 -4
  211. data/app/views/admin/well_knowns/_fields.html.erb +0 -6
  212. data/app/views/layouts/koi/_environment.html.erb +0 -4
  213. data/app/views/layouts/koi/_header.html.erb +0 -11
  214. data/app/views/layouts/koi/_navigation.html.erb +0 -23
  215. data/app/views/layouts/koi/_navigation_collapse.html.erb +0 -3
  216. data/lib/generators/koi/admin_views/templates/_fields.html.erb.tt +0 -3
  217. data/lib/generators/koi/helpers/admin_generator_attributes.rb +0 -66
  218. data/lib/koi/extensions/dartsass.rb +0 -23
  219. /data/app/assets/stylesheets/koi/{components/_clipboard.scss → blocks/clipboard.css} +0 -0
  220. /data/app/assets/stylesheets/koi/{components/_index-actions.scss → blocks/index-actions.css} +0 -0
  221. /data/app/assets/stylesheets/koi/{components/_toolbar.scss → blocks/toolbar.css} +0 -0
  222. /data/app/assets/stylesheets/koi/{base/_repel.scss → compositions/repel.css} +0 -0
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class BooleanComponent < Base
6
- def render?
7
- true
8
- end
9
-
10
- def attribute_value
11
- raw_value ? "Yes" : "No"
12
- end
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class DateComponent < Base
6
- def initialize(model, attribute, format: :admin, **)
7
- super(model, attribute, **)
8
-
9
- @format = format
10
- end
11
-
12
- def attribute_value
13
- l(raw_value.to_date, format: @format) if raw_value.present?
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class DatetimeComponent < Base
6
- def initialize(model, attribute, format: :admin, **)
7
- super(model, attribute, **)
8
-
9
- @format = format
10
- end
11
-
12
- def attribute_value
13
- l(raw_value.to_datetime, format: @format) if raw_value.present?
14
- end
15
- end
16
- end
17
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class ItemComponent < Base
6
- def render?
7
- !(@skip_blank && raw_value.blank? && raw_value != false)
8
- end
9
-
10
- def attribute_value
11
- case raw_value
12
- when Array
13
- raw_value.join(", ")
14
- when ActiveStorage::Attached::One
15
- raw_value.attached? ? link_to(raw_value.filename, url_for(raw_value)) : ""
16
- when Date, Time, DateTime, ActiveSupport::TimeWithZone
17
- l(raw_value, format: :admin)
18
- when TrueClass, FalseClass
19
- raw_value ? "Yes" : "No"
20
- else
21
- raw_value.to_s
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class NumberComponent < Base
6
- def initialize(model, attribute, format: :admin, **)
7
- super(model, attribute, **)
8
-
9
- @format = format
10
- end
11
-
12
- def attribute_value
13
- number_to_human(raw_value) if raw_value.present?
14
- end
15
-
16
- def default_description_attributes
17
- { class: "number" }
18
- end
19
- end
20
- end
21
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class RichTextComponent < Base
6
- end
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module SummaryList
5
- class TextComponent < Base
6
- end
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- <%= tag.dl **html_attributes do %>
2
- <% definitions.each do |definition| %>
3
- <%= definition %>
4
- <% end %>
5
- <% end %>
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- class SummaryListComponent < ViewComponent::Base
5
- include Katalyst::HtmlAttributes
6
-
7
- renders_many :definitions, types: {
8
- boolean: SummaryList::BooleanComponent,
9
- date: SummaryList::DateComponent,
10
- datetime: SummaryList::DatetimeComponent,
11
- number: SummaryList::NumberComponent,
12
- rich_text: SummaryList::RichTextComponent,
13
- text: SummaryList::TextComponent,
14
- attachment: SummaryList::AttachmentComponent,
15
-
16
- # @deprecated legacy interface
17
- item: SummaryList::ItemComponent,
18
- }
19
-
20
- def initialize(model: nil, skip_blank: true, **)
21
- super(**)
22
-
23
- @model = model
24
- @skip_blank = skip_blank
25
- end
26
-
27
- def boolean(attribute, label: nil, &)
28
- with_definition_boolean(@model, attribute, label:, &)
29
- end
30
-
31
- def date(attribute, label: nil, format: :admin, skip_blank: @skip_blank, &)
32
- with_definition_date(@model, attribute, label:, format:, skip_blank:, &)
33
- end
34
-
35
- def datetime(attribute, label: nil, format: :admin, skip_blank: @skip_blank, &)
36
- with_definition_datetime(@model, attribute, label:, format:, skip_blank:, &)
37
- end
38
-
39
- def rich_text(attribute, label: nil, skip_blank: @skip_blank, &)
40
- with_definition_rich_text(@model, attribute, label:, skip_blank:, &)
41
- end
42
-
43
- def number(attribute, label: nil, skip_blank: @skip_blank, &)
44
- with_definition_number(@model, attribute, label:, skip_blank:, &)
45
- end
46
-
47
- def text(attribute, label: nil, skip_blank: @skip_blank, &)
48
- with_definition_text(@model, attribute, label:, skip_blank:, &)
49
- end
50
-
51
- def attachment(attribute, label: nil, skip_blank: @skip_blank, variant: :thumb, &)
52
- with_definition_attachment(@model, attribute, label:, skip_blank:, variant:, &)
53
- end
54
-
55
- # @deprecated legacy interface
56
- def item(model, attribute, label: nil, skip_blank: @skip_blank, &)
57
- with_definition_item(model, attribute, label:, skip_blank:, &)
58
- end
59
-
60
- # @deprecated legacy interface
61
- def items_with(model:, attributes:, **options)
62
- attributes.each do |attribute|
63
- item(model, attribute, **options)
64
- end
65
- end
66
-
67
- def inspect
68
- "#<#{self.class.name}>"
69
- end
70
-
71
- def default_html_attributes
72
- { class: "summary-list" }
73
- end
74
- end
75
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module Controller
5
- module IsAdminController
6
- extend ActiveSupport::Concern
7
-
8
- class_methods do
9
- def authenticate_local_admins(value)
10
- Koi::Controller::IsAdminController.authenticate_local_admins = value
11
- end
12
- end
13
-
14
- included do
15
- include HasAdminUsers
16
- include HasAttachments
17
- include Katalyst::Tables::Backend
18
- include ::Pagy::Backend
19
-
20
- default_form_builder "Koi::FormBuilder"
21
- default_table_component Koi::TableComponent
22
- default_table_query_component Koi::TableQueryComponent
23
- default_summary_table_component Koi::SummaryTableComponent
24
-
25
- helper Katalyst::GOVUK::Formbuilder::Frontend
26
- helper Katalyst::Navigation::FrontendHelper
27
- helper Katalyst::Tables::Frontend
28
- helper ::Pagy::Frontend
29
- helper Koi::Pagy::Frontend
30
- helper IndexActionsHelper
31
- helper :all
32
-
33
- layout -> { turbo_frame_layout || "koi/application" }
34
- end
35
-
36
- class << self
37
- attr_accessor :authenticate_local_admins
38
- end
39
-
40
- protected
41
-
42
- def authenticate_local_admin
43
- return if admin_signed_in? || !Rails.env.development?
44
-
45
- session[:admin_user_id] =
46
- Admin::User.where(email: %W[#{ENV.fetch('USER', nil)}@katalyst.com.au admin@katalyst.com.au]).first&.id
47
-
48
- flash.delete(:redirect) if (redirect = flash[:redirect])
49
-
50
- redirect_to(redirect || admin_dashboard_path, status: :see_other)
51
- end
52
-
53
- def authenticate_local_admins?
54
- IsAdminController.authenticate_local_admins
55
- end
56
-
57
- def turbo_frame_layout
58
- if kpop_frame_request?
59
- "koi/frame"
60
- elsif turbo_frame_request?
61
- "turbo_rails/frame"
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module ApplicationHelper
5
- include Katalyst::Tables::Frontend
6
- end
7
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module DateHelper
5
- # Returns a string representing the number of days ago or from now.
6
- # If the date is not 'recent' returns nil.
7
- def days_ago_in_words(value)
8
- from_time = value.to_time
9
- to_time = Date.current.to_time
10
- distance_in_days = ((to_time - from_time) / (24.0 * 60.0 * 60.0)).round
11
-
12
- case distance_in_days
13
- when 0
14
- "today"
15
- when 1
16
- "yesterday"
17
- when -1
18
- "tomorrow"
19
- when 2..5
20
- "#{distance_in_days} days ago"
21
- when -5..-2
22
- "#{distance_in_days.abs} days from now"
23
- end
24
- end
25
- end
26
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module DefinitionListHelper
5
- # @deprecated This method is deprecated and will be removed in Koi 5.
6
- def definition_list(**, &)
7
- render(Koi::SummaryListComponent.new(**), &)
8
- end
9
- end
10
- end
@@ -1,3 +0,0 @@
1
- <%= form.govuk_text_field :email %>
2
- <%= form.govuk_text_field :name %>
3
- <%= form.govuk_password_field :password, label: { text: "Password (optional)" } %>
@@ -1,3 +0,0 @@
1
- <%= form.govuk_text_field :email %>
2
- <%= form.govuk_text_field :name %>
3
- <%= form.govuk_check_box_field :archived if form.object.persisted? %>
@@ -1,4 +0,0 @@
1
- <%= form.govuk_text_field :from, hint: { text: "Should begin with /" } %>
2
- <%= form.govuk_text_field :to %>
3
- <%= form.govuk_collection_radio_buttons :status_code, UrlRewrite::STATUS_CODES, :code, :label %>
4
- <%= form.govuk_check_box_field :active %>
@@ -1,6 +0,0 @@
1
- <%= form.govuk_text_field :name %>
2
- <%= form.govuk_text_field :purpose %>
3
- <%= form.govuk_collection_radio_buttons(
4
- :content_type, WellKnown::CONTENT_TYPES, :first, :second, small: true
5
- ) %>
6
- <%= form.govuk_text_area :content %>
@@ -1,4 +0,0 @@
1
- <header role="banner" aria-label="Environment" data-environment="<%= Rails.env %>">
2
- <span class="environment"><%= Rails.env.capitalize %></span>
3
- <span class="release">(<%= Koi::Release.version %>)</span>
4
- </header>
@@ -1,11 +0,0 @@
1
- <header>
2
- <h1 class="heading"><%= yield(:title) %></h1>
3
-
4
- <div class="breadcrumbs" role="navigation" aria-label="Breadcrumbs">
5
- <%= yield(:breadcrumbs) %>
6
- </div>
7
-
8
- <div class="actions" role="navigation" aria-label="Related pages">
9
- <%= yield(:actions) %>
10
- </div>
11
- </header>
@@ -1,23 +0,0 @@
1
- <nav role="navigation" aria-label="Main menu" aria-expanded="true" data-controller="navigation"
2
- data-action="shortcut:go@document->navigation#focus
3
- navigation:toggle@document->navigation#toggle
4
- shortcut:nav-toggle@document->navigation#toggle">
5
- <%= render "layouts/koi/navigation_header", admin: current_admin %>
6
- <div class="filter">
7
- <input type="search" placeholder="Filter menu" autocomplete="off"
8
- data-navigation-target="filter"
9
- data-action="input->navigation#filter change->navigation#filter
10
- keydown.enter->navigation#go keydown.esc->navigation#clear">
11
- </div>
12
- <ul role="list">
13
- <li>
14
- <span><%= current_admin_user.name %></span>
15
- <ul role="list">
16
- <li><%= link_to("Profile", main_app.admin_admin_user_path(current_admin_user)) %></li>
17
- <li><%= link_to("Log out", main_app.admin_session_path, data: { turbo_method: :delete }) %></li>
18
- </ul>
19
- </li>
20
- </ul>
21
- <%= navigation_menu_with(menu: Koi::Menu.admin_menu(self)) %>
22
- </nav>
23
- <%= render "layouts/koi/navigation_collapse" %>
@@ -1,3 +0,0 @@
1
- <div class="navigation-collapse" data-controller="navigation-toggle" data-action="click->navigation-toggle#trigger">
2
- <%= image_tag "koi/application/chevron-right.svg" %>
3
- </div>
@@ -1,3 +0,0 @@
1
- <%- attributes.each do |attribute| -%>
2
- <%= govuk_input_for attribute %>
3
- <%- end -%>
@@ -1,66 +0,0 @@
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
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koi
4
- module Extensions
5
- module Dartsass
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- module_function
10
-
11
- # Removes gem `build` directories from dartsass load path. This ensures
12
- # that css assets will not take precedence over scss assets of the same
13
- # name.
14
- def dartsass_load_paths
15
- [::Dartsass::Runner::CSS_LOAD_PATH]
16
- .concat(Rails.application.config.assets.paths)
17
- .reject { |path| %r{app/assets/builds$}.match?(path.to_s) }
18
- .flat_map { |path| ["--load-path", path.to_s] }
19
- end
20
- end
21
- end
22
- end
23
- end