katalyst-content 3.0.0.alpha.5 → 3.0.0.alpha.7
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/assets/builds/katalyst/content.esm.js +1 -1
- data/app/assets/builds/katalyst/content.js +1 -1
- data/app/assets/builds/katalyst/content.min.js +1 -1
- data/app/assets/builds/katalyst/content.min.js.map +1 -1
- data/app/assets/stylesheets/katalyst/content/_editor.scss +1 -0
- data/app/assets/stylesheets/katalyst/content/editor/statuses.css +14 -0
- data/app/assets/stylesheets/katalyst/content/editor/table.css +66 -32
- data/app/assets/stylesheets/katalyst/content/editor.css +1 -0
- data/app/assets/stylesheets/katalyst/content/frontend/frontend.css +87 -9
- data/app/controllers/katalyst/content/items_controller.rb +4 -19
- data/app/helpers/katalyst/content/editor_helper.rb +44 -0
- data/app/javascript/content/editor/table_controller.js +1 -1
- data/app/models/concerns/katalyst/content/has_tree.rb +6 -0
- data/app/models/katalyst/content/item.rb +1 -4
- data/app/views/katalyst/content/asides/_aside.html+form.erb +4 -26
- data/app/views/katalyst/content/asides/_aside.html.erb +8 -6
- data/app/views/katalyst/content/columns/_column.html+form.erb +3 -21
- data/app/views/katalyst/content/columns/_column.html.erb +5 -5
- data/app/views/katalyst/content/contents/_content.html+form.erb +4 -26
- data/app/views/katalyst/content/figures/_figure.html+form.erb +6 -30
- data/app/views/katalyst/content/groups/_group.html+form.erb +3 -21
- data/app/views/katalyst/content/groups/_group.html.erb +2 -2
- data/app/views/katalyst/content/items/_form.html.erb +1 -1
- data/app/views/katalyst/content/items/_form_errors.html.erb +3 -5
- data/app/views/katalyst/content/items/_hidden_fields.html.erb +2 -0
- data/app/views/katalyst/content/items/_item.html+form.erb +3 -21
- data/app/views/katalyst/content/sections/_section.html+form.erb +3 -21
- data/app/views/katalyst/content/sections/_section.html.erb +1 -1
- data/app/views/katalyst/content/tables/_table.html+form.erb +32 -39
- data/db/migrate/20230515151440_change_katalyst_content_items_show_heading_column.rb +3 -1
- data/db/migrate/20250619122652_remove_not_null_on_katalyst_content_items_theme.rb +7 -0
- data/lib/katalyst/content/config.rb +1 -0
- data/lib/katalyst/content/engine.rb +1 -0
- metadata +17 -1
@@ -1,19 +1,46 @@
|
|
1
1
|
/* Spacing */
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
:root {
|
4
|
+
/*
|
5
|
+
The container width at which the component switches between a horizontal and vertical layout.
|
6
|
+
*/
|
7
|
+
--content-gap: var(--space-l);
|
8
|
+
--content-gutter: var(--space-m);
|
9
|
+
--content-block-gutter: var(--content-gutter);
|
10
|
+
--content-block-gap: var(--content-gap);
|
11
|
+
--content-inline-gutter: var(--content-gutter);
|
12
|
+
--content-inline-gap: var(--content-gap);
|
6
13
|
}
|
7
14
|
|
8
|
-
|
15
|
+
.content-items {
|
16
|
+
/* gutters where the theme changes */
|
9
17
|
|
10
|
-
[data-content-theme] {
|
11
|
-
|
18
|
+
&[data-content-theme] {
|
19
|
+
padding-block: var(--content-block-gutter);
|
20
|
+
}
|
21
|
+
|
22
|
+
/* gaps between items with the same theme */
|
23
|
+
|
24
|
+
> * + * {
|
25
|
+
margin-block-start: var(--content-block-gap);
|
26
|
+
}
|
27
|
+
|
28
|
+
/* add gutters to non themed siblings */
|
29
|
+
|
30
|
+
&[data-content-theme] + .content-items:not([data-content-theme]),
|
31
|
+
.content-items:not([data-content-theme]) + &[data-content-theme] {
|
32
|
+
margin-block-start: var(--content-block-gutter);
|
33
|
+
}
|
12
34
|
}
|
13
35
|
|
14
|
-
|
15
|
-
|
16
|
-
|
36
|
+
/*
|
37
|
+
If a content item has children with a theme applied, we want to steal some space
|
38
|
+
from the item to give to the children for a gutter. This makes content line up
|
39
|
+
between items with and without a theme.
|
40
|
+
*/
|
41
|
+
.content-item [data-content-theme] {
|
42
|
+
margin-inline: calc(-1 * var(--content-inline-gutter));
|
43
|
+
padding-inline: var(--content-inline-gutter);
|
17
44
|
}
|
18
45
|
|
19
46
|
[data-content-theme="light"] {
|
@@ -44,3 +71,54 @@
|
|
44
71
|
margin-inline: auto;
|
45
72
|
}
|
46
73
|
}
|
74
|
+
|
75
|
+
/*
|
76
|
+
Columns
|
77
|
+
|
78
|
+
A two-column horizontal layout that switches to vertical layout on narrow screens.
|
79
|
+
Based on https://every-layout.dev/layouts/switcher/
|
80
|
+
*/
|
81
|
+
|
82
|
+
:root {
|
83
|
+
/*
|
84
|
+
The container width at which the component switches between a horizontal and vertical layout.
|
85
|
+
*/
|
86
|
+
--content-column-threshold-width: var(--mobile-breakpoint, 37.5rem);
|
87
|
+
}
|
88
|
+
|
89
|
+
.content-columns {
|
90
|
+
display: flex;
|
91
|
+
flex-wrap: wrap;
|
92
|
+
gap: var(--content-inline-gap) calc(2 * var(--content-inline-gap));
|
93
|
+
|
94
|
+
> * {
|
95
|
+
flex-grow: 1;
|
96
|
+
flex-basis: calc((var(--content-column-threshold-width) - 100%) * 999);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
.content-column {
|
101
|
+
display: grid; /* equal height columns */
|
102
|
+
}
|
103
|
+
|
104
|
+
.content-aside {
|
105
|
+
display: flex;
|
106
|
+
flex-wrap: wrap;
|
107
|
+
gap: var(--content-inline-gap) calc(2 * var(--content-inline-gap));
|
108
|
+
align-items: start;
|
109
|
+
|
110
|
+
> :last-child {
|
111
|
+
flex-basis: max(var(--content-aside-min-width, 16rem), 33%);
|
112
|
+
flex-grow: 1;
|
113
|
+
}
|
114
|
+
|
115
|
+
> :first-child {
|
116
|
+
flex-basis: 0;
|
117
|
+
flex-grow: 999;
|
118
|
+
min-inline-size: 55%;
|
119
|
+
}
|
120
|
+
|
121
|
+
&[data-wrap-reverse] {
|
122
|
+
flex-wrap: wrap-reverse;
|
123
|
+
}
|
124
|
+
}
|
@@ -9,6 +9,8 @@ module Katalyst
|
|
9
9
|
|
10
10
|
attr_reader :container, :item, :editor
|
11
11
|
|
12
|
+
default_form_builder "Katalyst::Content::EditorHelper::FormBuilder"
|
13
|
+
|
12
14
|
helper EditorHelper
|
13
15
|
|
14
16
|
def new
|
@@ -87,17 +89,6 @@ module Katalyst
|
|
87
89
|
# This mimics the behaviour of direct uploads without requiring the JS
|
88
90
|
# integration.
|
89
91
|
#
|
90
|
-
# Note: this idea comes from various blogs who have documented this approach, such as
|
91
|
-
# https://medium.com/@TETRA2000/active-storage-how-to-retain-uploaded-files-on-form-resubmission-91b57be78d53
|
92
|
-
#
|
93
|
-
# In Rails 7.2 the simple version of this approach was broken to work around a bug that Rails plans to address
|
94
|
-
# in a future release.
|
95
|
-
# https://github.com/rails/rails/commit/82d4ad5da336a18a55a05a50b851e220032369a0
|
96
|
-
#
|
97
|
-
# The work around is to decouple the blobs from their attachments before saving by duping
|
98
|
-
# them. This approach feels a bit hairy and might need to be replaced by a 'standard' direct upload approach
|
99
|
-
# in the future.
|
100
|
-
#
|
101
92
|
# The reason we use this approach currently is to avoid needing a separate direct upload controller for
|
102
93
|
# content which would potentially introduce a back door where un-trusted users are allowed to upload
|
103
94
|
# attachments.
|
@@ -106,12 +97,10 @@ module Katalyst
|
|
106
97
|
case change
|
107
98
|
when ActiveStorage::Attached::Changes::CreateOne
|
108
99
|
change.upload
|
109
|
-
change.
|
100
|
+
change.blob.save!
|
110
101
|
when ActiveStorage::Attached::Changes::CreateMany
|
111
102
|
change.upload
|
112
|
-
change.
|
113
|
-
attachment.blob = blob.dup.tap(&:save!)
|
114
|
-
end
|
103
|
+
change.blobs.each(&:save!)
|
115
104
|
end
|
116
105
|
end
|
117
106
|
end
|
@@ -120,10 +109,6 @@ module Katalyst
|
|
120
109
|
def prefix_partial_path_with_controller_namespace
|
121
110
|
false
|
122
111
|
end
|
123
|
-
|
124
|
-
def kpop_fallback_location
|
125
|
-
main_app.root_path
|
126
|
-
end
|
127
112
|
end
|
128
113
|
end
|
129
114
|
end
|
@@ -16,6 +16,50 @@ module Katalyst
|
|
16
16
|
},
|
17
17
|
}.merge_html(attributes)
|
18
18
|
end
|
19
|
+
|
20
|
+
module Builder
|
21
|
+
def content_heading_fieldset(legend: { text: "Heading" })
|
22
|
+
govuk_fieldset(legend:) do
|
23
|
+
concat(content_heading_field(label: { text: "Heading", class: "govuk-visually-hidden" }))
|
24
|
+
concat(content_heading_style_field)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def content_heading_field(label: { text: "Heading" }, **)
|
29
|
+
govuk_text_field(:heading, label:, **)
|
30
|
+
end
|
31
|
+
|
32
|
+
def content_heading_style_field(legend: { text: "Style" }, **)
|
33
|
+
govuk_enum_radio_buttons(:heading_style, legend:, **)
|
34
|
+
end
|
35
|
+
|
36
|
+
def content_url_field(label: { text: "URL" }, **)
|
37
|
+
govuk_text_field(:url, label:, **)
|
38
|
+
end
|
39
|
+
|
40
|
+
def content_http_method_field(label: { text: "HTTP method" }, **)
|
41
|
+
govuk_enum_select(:http_method, label:, **)
|
42
|
+
end
|
43
|
+
|
44
|
+
def content_target_field(label: { text: "HTTP target" }, **)
|
45
|
+
govuk_enum_select(:target, label:, **)
|
46
|
+
end
|
47
|
+
|
48
|
+
def content_theme_field(options: { include_blank: true }, **)
|
49
|
+
govuk_enum_select(:theme, options:, **)
|
50
|
+
end
|
51
|
+
|
52
|
+
def content_visible_field(label: { text: "Visible?" }, **)
|
53
|
+
govuk_check_box_field(:visible, label:, **)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class FormBuilder < ActionView::Helpers::FormBuilder
|
58
|
+
include GOVUKDesignSystemFormBuilder::Builder
|
59
|
+
include Builder
|
60
|
+
|
61
|
+
delegate_missing_to :@template
|
62
|
+
end
|
19
63
|
end
|
20
64
|
end
|
21
65
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus";
|
2
2
|
|
3
3
|
const EDITOR = `
|
4
|
-
<div class="content--editor--table-
|
4
|
+
<div class="content--editor--table-content"
|
5
5
|
contenteditable="true"
|
6
6
|
data-content--editor--table-target="content"
|
7
7
|
data-action="paste->content--editor--table#paste"
|
@@ -42,6 +42,12 @@ module Katalyst
|
|
42
42
|
node.previous_sibling = previous
|
43
43
|
end
|
44
44
|
|
45
|
+
# If the node does not have an explicit theme set already then set a
|
46
|
+
# rendering theme from context.
|
47
|
+
if node.theme.blank?
|
48
|
+
node.theme = current ? current.theme : Content.config.default_theme
|
49
|
+
end
|
50
|
+
|
45
51
|
self
|
46
52
|
end
|
47
53
|
|
@@ -11,6 +11,7 @@ module Katalyst
|
|
11
11
|
end
|
12
12
|
|
13
13
|
enum :heading_style, config.heading_styles, prefix: :heading
|
14
|
+
enum :theme, config.themes.index_with(&:itself), prefix: :theme
|
14
15
|
|
15
16
|
belongs_to :container, polymorphic: true
|
16
17
|
|
@@ -59,10 +60,6 @@ module Katalyst
|
|
59
60
|
model_name.param_key
|
60
61
|
end
|
61
62
|
|
62
|
-
def theme
|
63
|
-
super.presence || parent&.theme
|
64
|
-
end
|
65
|
-
|
66
63
|
private
|
67
64
|
|
68
65
|
def initialize_tree
|
@@ -1,28 +1,6 @@
|
|
1
1
|
<%# locals: (form:, aside:) %>
|
2
2
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<%= form.text_field :heading %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="field">
|
11
|
-
<%= form.label :heading_style %>
|
12
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :theme %>
|
17
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :visible %>
|
22
|
-
<%= form.check_box :visible %>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<div class="field">
|
26
|
-
<%= form.label :reverse %>
|
27
|
-
<%= form.check_box :reverse %>
|
28
|
-
</div>
|
3
|
+
<%= form.content_heading_fieldset %>
|
4
|
+
<%= form.govuk_check_box_field(:reverse, label: { text: "Show aside before content on mobile" }) %>
|
5
|
+
<%= form.content_theme_field %>
|
6
|
+
<%= form.content_visible_field %>
|
@@ -1,14 +1,16 @@
|
|
1
|
-
<%= content_item_tag(aside,
|
1
|
+
<%= content_item_tag(aside, class: "flow") do %>
|
2
2
|
<%= tag.h3 aside.heading, class: aside.heading_style_class if aside.show_heading? %>
|
3
3
|
|
4
4
|
<% if aside.children.any? %>
|
5
5
|
<% items = aside.children.select(&:visible?) %>
|
6
6
|
<% last = items.pop %>
|
7
|
-
|
8
|
-
<div
|
9
|
-
<%= render_content_items(*items, theme: aside.theme
|
7
|
+
<%= tag.div(class: "content-aside", data: { wrap_reverse: ("" if aside.reverse) }) do %>
|
8
|
+
<div>
|
9
|
+
<%= render_content_items(*items, theme: aside.theme) %>
|
10
10
|
</div>
|
11
|
-
|
12
|
-
|
11
|
+
<div>
|
12
|
+
<%= render_content_items(last, tag: :aside, theme: aside.theme) %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
13
15
|
<% end %>
|
14
16
|
<% end %>
|
@@ -1,23 +1,5 @@
|
|
1
1
|
<%# locals: (form:, column:) %>
|
2
2
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
6
|
-
<%= form.label :heading %>
|
7
|
-
<%= form.text_field :heading %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="field">
|
11
|
-
<%= form.label :heading_style %>
|
12
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :theme %>
|
17
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :visible %>
|
22
|
-
<%= form.check_box :visible %>
|
23
|
-
</div>
|
3
|
+
<%= form.content_heading_fieldset %>
|
4
|
+
<%= form.content_theme_field %>
|
5
|
+
<%= form.content_visible_field %>
|
@@ -1,17 +1,17 @@
|
|
1
|
-
<%= content_item_tag
|
1
|
+
<%= content_item_tag(column, class: "flow") do %>
|
2
2
|
<%= tag.h3 column.heading, class: column.heading_style_class if column.show_heading? %>
|
3
3
|
|
4
4
|
<% items = column.children.select(&:visible?) %>
|
5
5
|
<% last = items.pop %>
|
6
|
-
<div class="columns
|
7
|
-
<div class="column">
|
6
|
+
<div class="content-columns">
|
7
|
+
<div class="content-column">
|
8
8
|
<% if items.any? %>
|
9
|
-
<%= render_content_items(*items, theme: column.theme
|
9
|
+
<%= render_content_items(*items, theme: column.theme) %>
|
10
10
|
<% elsif last %>
|
11
11
|
<%= render_content_items(last, theme: column.theme) %>
|
12
12
|
<% end %>
|
13
13
|
</div>
|
14
|
-
<div class="column">
|
14
|
+
<div class="content-column">
|
15
15
|
<%= render_content_items(last, theme: column.theme) if last && items.any? %>
|
16
16
|
</div>
|
17
17
|
</div>
|
@@ -1,28 +1,6 @@
|
|
1
1
|
<%# locals: (form:, content:) %>
|
2
2
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<%= form.text_field :heading %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="field">
|
11
|
-
<%= form.label :heading_style %>
|
12
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :theme %>
|
17
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :visible %>
|
22
|
-
<%= form.check_box :visible %>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<div class="field">
|
26
|
-
<%= form.label :content %>
|
27
|
-
<%= form.rich_text_area :content, content_editor_rich_text_attributes %>
|
28
|
-
</div>
|
3
|
+
<%= form.content_heading_fieldset %>
|
4
|
+
<%= form.govuk_rich_text_area(:content) %>
|
5
|
+
<%= form.content_theme_field %>
|
6
|
+
<%= form.content_visible_field %>
|
@@ -1,33 +1,9 @@
|
|
1
1
|
<%# locals: (form:, figure:) %>
|
2
2
|
|
3
|
-
<%=
|
3
|
+
<%= form.govuk_image_field(:image) do %>
|
4
|
+
<%= form.govuk_text_field(:heading, label: { text: "Alternate text" }) %>
|
5
|
+
<%= form.govuk_text_field(:caption, label: { text: "Caption (optional)" }, optional: true) %>
|
6
|
+
<% end %>
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
<% if (image = form.object.image).attached? %>
|
8
|
-
<%= image.filename %>
|
9
|
-
<br>
|
10
|
-
<%= form.hidden_field :image, value: form.object.image.signed_id %>
|
11
|
-
<% end %>
|
12
|
-
<%= form.file_field :image %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :heading %>
|
17
|
-
<%= form.text_field :heading %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :theme %>
|
22
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<div class="field">
|
26
|
-
<%= form.label :visible %>
|
27
|
-
<%= form.check_box :visible %>
|
28
|
-
</div>
|
29
|
-
|
30
|
-
<div class="field">
|
31
|
-
<%= form.label :caption %>
|
32
|
-
<%= form.text_field :caption %>
|
33
|
-
</div>
|
8
|
+
<%= form.content_theme_field %>
|
9
|
+
<%= form.content_visible_field %>
|
@@ -1,23 +1,5 @@
|
|
1
1
|
<%# locals: (form:, group:) %>
|
2
2
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
6
|
-
<%= form.label :heading %>
|
7
|
-
<%= form.text_field :heading %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="field">
|
11
|
-
<%= form.label :heading_style %>
|
12
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :theme %>
|
17
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :visible %>
|
22
|
-
<%= form.check_box :visible %>
|
23
|
-
</div>
|
3
|
+
<%= form.content_heading_fieldset %>
|
4
|
+
<%= form.content_theme_field %>
|
5
|
+
<%= form.content_visible_field %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%= content_item_tag
|
1
|
+
<%= content_item_tag(group, class: "flow") do %>
|
2
2
|
<%= tag.h3 group.heading, class: group.heading_style_class if group.show_heading? %>
|
3
3
|
|
4
|
-
<%= render_content_items(*group.children, theme: group.theme
|
4
|
+
<%= render_content_items(*group.children, theme: group.theme) %>
|
5
5
|
<% end %>
|
@@ -1,23 +1,5 @@
|
|
1
1
|
<%# locals: (form:, item:) %>
|
2
2
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
6
|
-
<%= form.label :heading %>
|
7
|
-
<%= form.text_field :heading %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="field">
|
11
|
-
<%= form.label :heading_style %>
|
12
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :theme %>
|
17
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :visible %>
|
22
|
-
<%= form.check_box :visible %>
|
23
|
-
</div>
|
3
|
+
<%= form.content_heading_fieldset %>
|
4
|
+
<%= form.content_theme_field %>
|
5
|
+
<%= form.content_visible_field %>
|
@@ -1,23 +1,5 @@
|
|
1
1
|
<%# locals: (form:, section:) %>
|
2
2
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
6
|
-
<%= form.label :heading %>
|
7
|
-
<%= form.text_field :heading %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="field">
|
11
|
-
<%= form.label :heading_style %>
|
12
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="field">
|
16
|
-
<%= form.label :theme %>
|
17
|
-
<%= form.select :theme, Katalyst::Content.config.themes, include_blank: true %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="field">
|
21
|
-
<%= form.label :visible %>
|
22
|
-
<%= form.check_box :visible %>
|
23
|
-
</div>
|
3
|
+
<%= form.content_heading_fieldset %>
|
4
|
+
<%= form.content_theme_field %>
|
5
|
+
<%= form.content_visible_field %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= content_item_tag(section, tag: :section, class: "flow") do %>
|
2
2
|
<%= tag.h2(section.heading, class: section.heading_style_class) if section.show_heading? %>
|
3
3
|
|
4
|
-
<%= render_content_items(*section.children, theme: section.theme
|
4
|
+
<%= render_content_items(*section.children, theme: section.theme) %>
|
5
5
|
<% end %>
|
@@ -1,46 +1,39 @@
|
|
1
1
|
<%# locals: (form:, table:) %>
|
2
2
|
|
3
|
-
<div class="flow" data-controller="content--editor--table">
|
4
|
-
<%=
|
3
|
+
<div class="content--editor--table-editor | flow" data-controller="content--editor--table">
|
4
|
+
<%= form.content_heading_fieldset %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
<% content = sanitize_content_table(normalize_content_table(form.object, heading: false)) %>
|
7
|
+
<%= form.govuk_text_area(:content,
|
8
|
+
value: content,
|
9
|
+
class: "table-input",
|
10
|
+
data: { content__editor__table_target: "input" }) %>
|
10
11
|
|
11
|
-
<
|
12
|
-
|
13
|
-
<%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
|
14
|
-
</div>
|
12
|
+
<%# hidden button to receive <Enter> events (HTML-default is to click first button in form) %>
|
13
|
+
<%= form.button("Save", hidden: "") %>
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
</div>
|
20
|
-
|
21
|
-
<div class="field">
|
22
|
-
<%= form.label :visible %>
|
23
|
-
<%= form.check_box :visible %>
|
24
|
-
</div>
|
25
|
-
|
26
|
-
<div class="field">
|
27
|
-
<%= form.label :content %>
|
28
|
-
<% content = sanitize_content_table(normalize_content_table(form.object, heading: false)) %>
|
29
|
-
<%= form.hidden_field :content, value: content, data: { content__editor__table_target: "input" } %>
|
30
|
-
</div>
|
31
|
-
|
32
|
-
<div class="field">
|
33
|
-
<%= form.label :heading_rows %>
|
34
|
-
<%= form.text_field :heading_rows, type: :number, data: { action: "input->content--editor--table#update" } %>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<div class="field">
|
38
|
-
<%= form.label :heading_columns %>
|
39
|
-
<%= form.text_field :heading_columns, type: :number, data: { action: "input->content--editor--table#update" } %>
|
40
|
-
</div>
|
41
|
-
|
42
|
-
<%= form.button "Update",
|
43
|
-
class: "button",
|
15
|
+
<%# hidden button to submit the table for re-rendering %>
|
16
|
+
<%= form.button("Update",
|
17
|
+
hidden: "",
|
44
18
|
formaction: table.persisted? ? katalyst_content.table_path : katalyst_content.tables_path,
|
45
|
-
data: {
|
19
|
+
data: { content__editor__table_target: "update" }) %>
|
20
|
+
|
21
|
+
<%= form.govuk_number_field(:heading_rows,
|
22
|
+
label: { text: "Heading rows" },
|
23
|
+
width: 2,
|
24
|
+
placeholder: 0,
|
25
|
+
min: 0,
|
26
|
+
data: { content__editor__table_target: "headerRows",
|
27
|
+
action: "input->content--editor--table#update" }) %>
|
28
|
+
|
29
|
+
<%= form.govuk_number_field(:heading_columns,
|
30
|
+
label: { text: "Heading columns" },
|
31
|
+
width: 2,
|
32
|
+
placeholder: 0,
|
33
|
+
min: 0,
|
34
|
+
data: { content__editor__table_target: "headerColumns",
|
35
|
+
action: "input->content--editor--table#update" }) %>
|
46
36
|
</div>
|
37
|
+
|
38
|
+
<%= form.content_theme_field %>
|
39
|
+
<%= form.content_visible_field %>
|
@@ -4,7 +4,9 @@ class ChangeKatalystContentItemsShowHeadingColumn < ActiveRecord::Migration[7.0]
|
|
4
4
|
# rubocop:disable Rails/SkipsModelValidations
|
5
5
|
def up
|
6
6
|
add_column :katalyst_content_items, :heading_style, :integer, null: false, default: 0
|
7
|
-
|
7
|
+
ActiveRecord::Base.connection.execute(<<~SQL)
|
8
|
+
UPDATE katalyst_content_items SET heading_style = 1 WHERE show_heading = true;
|
9
|
+
SQL
|
8
10
|
remove_column :katalyst_content_items, :show_heading, :boolean
|
9
11
|
end
|
10
12
|
# rubocop:enable Rails/SkipsModelValidations
|