katalyst-content 3.2.0 → 3.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9558cc7faf09be934b8dbf023ff6ca6edf5a2b3668fe5257bbef59357a094e05
4
- data.tar.gz: 5772c57c1058220532f2fce359115e9851aa0d8836314118e56d8eb99a173281
3
+ metadata.gz: ce423d4d4bb7d893c648269c366f476cbd96608d9d28fbf29a2bcbf169f5de9f
4
+ data.tar.gz: bf06500cb74acb31718e604fc307b588239a202df76a5ba0f99b2f7e0920b4a7
5
5
  SHA512:
6
- metadata.gz: 5f70e7a6d56b74c25ce4c1882cf3c3925ba967160731272986a1298f42e713262af98bad60e1227207824e6745e6bd789d18c8c1c291fba400689c99015a18ba
7
- data.tar.gz: a099fbe7acd0585d356774492b2ea836fa02d855e0f344695022ac7de9a750fb4701945153814a5fa3ada8671c57f6aeb25915c008c235613a7459c4e6215930
6
+ metadata.gz: 529034763b15a240a55240beaf396cd635228762cda698724bc8d2ae4b157f1fafb31e53f3a454677f5304d8d0a996cce9892dcef10bf11939ac781e84cc586f
7
+ data.tar.gz: d950bc7a15c6f62a996dd172e32ae4a1b3209d6d49a372a88654cc8aae012f29d438b30fa67bea45c3611e7c57272e7617b88223f4d59c4a50db9f7f042cafa2
@@ -9,8 +9,6 @@ module Katalyst
9
9
 
10
10
  attr_reader :container, :item, :editor
11
11
 
12
- default_form_builder "Katalyst::Content::EditorHelper::FormBuilder"
13
-
14
12
  helper EditorHelper
15
13
 
16
14
  def new
@@ -5,59 +5,32 @@ module Katalyst
5
5
  module EditorHelper
6
6
  include TableHelper
7
7
 
8
- using Katalyst::HtmlAttributes::HasHtmlAttributes
8
+ class FormBuilder < ActionView::Helpers::FormBuilder
9
+ include GOVUKDesignSystemFormBuilder::Builder
10
+ include Katalyst::Content::Form::Builder
9
11
 
10
- def content_editor_rich_text_attributes(attributes = {})
11
- {
12
- data: {
13
- controller: "content--editor--trix",
14
- action: "trix-initialize->content--editor--trix#trixInitialize",
15
- },
16
- }.merge_html(attributes)
12
+ delegate :content_tag, :tag, :safe_join, :link_to, :capture, to: :@template
17
13
  end
18
14
 
19
- module Builder
20
- def content_heading_fieldset(legend: { text: t("activerecord.attributes.katalyst/content/item.heading") })
21
- govuk_fieldset(legend:) do
22
- concat(content_heading_field(label: { class: "govuk-visually-hidden" }))
23
- concat(content_heading_style_field)
24
- end
25
- end
26
-
27
- def content_heading_field(**)
28
- govuk_text_field(:heading, **)
29
- end
30
-
31
- def content_heading_style_field(**)
32
- govuk_enum_select(:heading_style, **)
33
- end
34
-
35
- def content_url_field(**)
36
- govuk_text_field(:url, **)
37
- end
38
-
39
- def content_http_method_field(**)
40
- govuk_enum_select(:http_method, **)
41
- end
42
-
43
- def content_target_field(**)
44
- govuk_enum_select(:target, **)
45
- end
15
+ # @deprecated no longer required
16
+ def content_editor_rich_text_attributes(attributes = {})
17
+ attributes
18
+ end
46
19
 
47
- def content_theme_field(options: { include_blank: true }, **)
48
- govuk_enum_select(:theme, options:, **)
49
- end
20
+ private
50
21
 
51
- def content_visible_field(**)
52
- govuk_check_box_field(:visible, **)
22
+ def instantiate_builder(record_name, record_object, options)
23
+ super.tap do |builder|
24
+ builder.extend(Katalyst::Content::Form::Builder) unless builder.is_a?(Katalyst::Content::Form::Builder)
53
25
  end
54
26
  end
55
27
 
56
- class FormBuilder < ActionView::Helpers::FormBuilder
57
- include GOVUKDesignSystemFormBuilder::Builder
58
- include Builder
59
-
60
- delegate_missing_to :@template
28
+ # Provides a compatible formbuilder if the default does not include GovUK
29
+ # @api internal
30
+ # @see ActionView::Helpers::FormHelper#default_form_builder_class
31
+ def default_form_builder_class
32
+ builder = super
33
+ builder.include?(GOVUKDesignSystemFormBuilder::Builder) ? builder : FormBuilder
61
34
  end
62
35
  end
63
36
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Katalyst
4
+ module Content
5
+ module Form
6
+ module Builder
7
+ def content_heading_fieldset(legend: {
8
+ text: I18n.t("activerecord.attributes.katalyst/content/item.heading"),
9
+ })
10
+ govuk_fieldset(legend:) do
11
+ heading = content_heading_field(label: { class: "govuk-visually-hidden" })
12
+ style = content_heading_style_field
13
+ safe_join([heading, style])
14
+ end
15
+ end
16
+
17
+ def content_heading_field(**)
18
+ govuk_text_field(:heading, **)
19
+ end
20
+
21
+ def content_heading_style_field(**)
22
+ govuk_enum_select(:heading_style, **)
23
+ end
24
+
25
+ def content_url_field(**)
26
+ govuk_text_field(:url, **)
27
+ end
28
+
29
+ def content_http_method_field(**)
30
+ govuk_enum_select(:http_method, **)
31
+ end
32
+
33
+ def content_target_field(**)
34
+ govuk_enum_select(:target, **)
35
+ end
36
+
37
+ def content_theme_field(options: { include_blank: true }, **)
38
+ govuk_enum_select(:theme, options:, **)
39
+ end
40
+
41
+ def content_visible_field(**)
42
+ govuk_check_box_field(:visible, **)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,6 +1,6 @@
1
1
  <%# locals: (form:, content:) %>
2
2
 
3
3
  <%= form.content_heading_fieldset %>
4
- <%= form.govuk_rich_text_area(:content, **content_editor_rich_text_attributes) %>
4
+ <%= form.govuk_rich_text_area(:content) %>
5
5
  <%= form.content_theme_field %>
6
6
  <%= form.content_visible_field %>
data/config/ci.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run using bin/ci
4
+
5
+ CI.run do
6
+ step "Style: RuboCop", "bundle exec rake lint"
7
+ step "Style: ERB", "bundle exec rake erb_lint"
8
+ step "Style: Prettier", "bundle exec rake prettier"
9
+ step "Assets: Build", "bundle exec rake build"
10
+ step "Tests: RSpec", "bundle exec rake spec"
11
+ step "Security: Brakeman", "bundle exec rake security"
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
@@ -138,6 +138,7 @@ files:
138
138
  - app/controllers/katalyst/content/items_controller.rb
139
139
  - app/controllers/katalyst/content/tables_controller.rb
140
140
  - app/helpers/katalyst/content/editor_helper.rb
141
+ - app/helpers/katalyst/content/form/builder.rb
141
142
  - app/helpers/katalyst/content/frontend_helper.rb
142
143
  - app/helpers/katalyst/content/table_helper.rb
143
144
  - app/javascript/content/application.js
@@ -194,6 +195,7 @@ files:
194
195
  - app/views/katalyst/content/tables/_table.html.erb
195
196
  - app/views/katalyst/content/tables/update.turbo_stream.erb
196
197
  - app/views/layouts/action_text/contents/_content.html.erb
198
+ - config/ci.rb
197
199
  - config/importmap.rb
198
200
  - config/locales/en.yml
199
201
  - config/routes.rb