Skip to content

Commit 227b3c1

Browse files
committed
Load inline editing based on seed flag
Replace URL-based editMode detection for inline editing loading with a loadInlineEditing flag in the seed config. The server sets the flag, the jbuilder template renders it and derives translation inclusion from it. This prepares for other features using the same pattern to control client-side loading. REDMINE-21261
1 parent c382b19 commit 227b3c1

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def scrolled_editor_iframe_seed_html_script_tag(entry)
2525
skip_collections: true,
2626
include_unused_additional_seed_data: true,
2727
include_theme_translations: true,
28-
translations: {include_inline_editing: true}
28+
load_inline_editing: true
2929
}
3030
})
3131

entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ json.config do
5353
json.cut_off entry.cutoff_mode_enabled_for?(request)
5454
json.embed options.fetch(:embed, false)
5555
json.origin_url options[:origin_url] if options[:origin_url]
56+
json.load_inline_editing true if options[:load_inline_editing]
5657
end
5758

5859
unless options[:skip_i18n]
5960
json.i18n do
6061
json.default_locale I18n.default_locale
6162
json.locale I18n.locale
62-
json.translations scrolled_i18n_translations(entry,
63-
**options.fetch(:translations, {}))
63+
json.translations scrolled_i18n_translations(
64+
entry,
65+
include_inline_editing: !!options[:load_inline_editing]
66+
)
6467
end
6568
end
6669

entry_types/scrolled/package/src/frontend/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ global.pageflowScrolledRender = async function(seed) {
157157
await browser.detectFeatures();
158158
await loadDashUnlessHlsSupported(seed);
159159

160-
if (editMode) {
160+
if (seed.config.loadInlineEditing) {
161161
await loadInlineEditingComponents();
162162
}
163163
else {

entry_types/scrolled/spec/helpers/pageflow_scrolled/entry_json_seed_helper_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,11 @@ def render(helper, entry, options = {})
11301130
})
11311131
end
11321132

1133-
it 'supports including scrolled inline editing translations' do
1133+
it 'includes inline editing translations when load_inline_editing is set' do
11341134
translation(I18n.locale, 'pageflow_scrolled.inline_editing.some', 'text')
11351135
entry = create(:published_entry, type_name: 'scrolled')
11361136

1137-
result = render(helper, entry, translations: {include_inline_editing: true})
1137+
result = render(helper, entry, load_inline_editing: true)
11381138

11391139
expect(result).to include_json(i18n: {
11401140
translations: {
@@ -1169,6 +1169,16 @@ def render(helper, entry, options = {})
11691169
end
11701170
end
11711171

1172+
context 'feature loading flags' do
1173+
it 'includes loadInlineEditing in config when load_inline_editing option is set' do
1174+
entry = create(:published_entry, type_name: 'scrolled')
1175+
1176+
result = render(helper, entry, load_inline_editing: true)
1177+
1178+
expect(result).to include_json(config: {loadInlineEditing: true})
1179+
end
1180+
end
1181+
11721182
it 'renders additional frontend seed data' do
11731183
pageflow_configure do |config|
11741184
config.for_entry_type(PageflowScrolled.entry_type) do |entry_type_config|

0 commit comments

Comments
 (0)