Skip to content

Commit 72fd3e2

Browse files
committed
Making dynamic zones inheritance based
Few namespace changes Fixing template layout Alphabeticalised base query
1 parent 697d1c3 commit 72fd3e2

File tree

9 files changed

+42
-54
lines changed

9 files changed

+42
-54
lines changed

app/services/cms/collections/enrichment_page.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def self.is_collection = true
2222

2323
def self.collection_attribute_mappings
2424
[
25-
{model: Cms::Models::Data::WebPagePreview, key: nil}
25+
{model: Models::Data::WebPagePreview, key: nil}
2626
]
2727
end
2828

app/services/cms/models/dynamic_components/blocks/homepage_hero.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(title:, house_content:, buttons:)
1212
end
1313

1414
def render
15-
HomepageHeroComponent.new(title:, house_content:, buttons:)
15+
Cms::HomepageHeroComponent.new(title:, house_content:, buttons:)
1616
end
1717
end
1818
end

app/services/cms/models/dynamic_zones/enrichment_dynamic_zone.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
module Cms
22
module Models
33
module DynamicZones
4-
class EnrichmentDynamicZone
5-
attr_accessor :cms_models
6-
7-
def initialize(cms_models:)
8-
@cms_models = cms_models
9-
end
10-
11-
def render
12-
Cms::DynamicZoneComponent.new(cms_models:)
13-
end
4+
class EnrichmentDynamicZone < DynamicZone
145
end
156
end
167
end

app/services/cms/models/dynamic_zones/homepage_dynamic_zone.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
module Cms
22
module Models
33
module DynamicZones
4-
class HomepageDynamicZone
5-
attr_accessor :cms_models
6-
7-
def initialize(cms_models:)
8-
@cms_models = cms_models
9-
end
10-
11-
def render
12-
Cms::DynamicZoneComponent.new(cms_models:)
13-
end
4+
class HomepageDynamicZone < DynamicZone
145
end
156
end
167
end

app/services/cms/providers/strapi/mocks/dynamic_components/blocks/full_width_banner.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ class FullWidthBanner < StrapiMock
1010
attribute(:image) { Images::Image.generate_data }
1111
attribute(:imageLink) { Faker::Internet.url }
1212
attribute(:backgroundColor) { {name: "white"} }
13+
attribute(:boxColor) { {name: "white"} }
1314
attribute(:imageSide) { "right" }
1415
attribute(:buttons) { nil }
15-
attribute(:i_belong_flag) { false }
16-
attribute(:corner_flourish) { false }
16+
attribute(:iBelongFlag) { false }
17+
attribute(:cornerFlourish) { false }
18+
attribute(:imageFit) { false }
1719
end
1820
end
1921
end

app/services/cms/providers/strapi/mocks/dynamic_components/blocks/programme_picture_card_section.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class ProgrammePictureCardSection < StrapiMock
88
strapi_component "blocks.programme-picture-card-section"
99

1010
attribute(:sectionTitle) { Faker::Lorem.sentence }
11-
attribute(:introText) { Mocks::Text::RichBlocks.generate_data }
11+
attribute(:introText) { Text::RichBlocks.generate_data }
1212
attribute(:cardsPerRow) { 3 }
1313
attribute(:prog) { {data: {attributes: {slug: "i-belong"}}} }
14-
attribute(:programmeCards) { Array.new(3) { Mocks::DynamicComponents::ContentBlocks::ProgrammePictureCard.generate_data } }
14+
attribute(:programmeCards) { Array.new(3) { DynamicComponents::ContentBlocks::ProgrammePictureCard.generate_data } }
1515
end
1616
end
1717
end

app/services/cms/providers/strapi/queries/base_query.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ class BaseQuery
66
attr_accessor :resource_name, :resource_filter
77

88
QUERY_MAPS = {
9-
Models::DynamicComponents::ContentBlocks::QuestionBankForm => Components::ContentBlocks::QuestionBankForm,
109
Models::Collections::Aside => Aside,
1110
Models::Collections::BlogPreview => BlogPreview,
12-
Models::Meta::SimpleTitle => SimpleField,
11+
Models::Collections::EmailTemplate => EmailTemplate,
12+
Models::Collections::EnrichmentList => EnrichmentList,
13+
Models::Data::Slug => Slug,
14+
Models::Data::TextField => SimpleField,
15+
Models::Data::WebPagePreview => WebPagePreview,
16+
Models::DynamicComponents::ContentBlocks::QuestionBankForm => Components::ContentBlocks::QuestionBankForm,
1317
Models::DynamicZones::DynamicZone => DynamicZone,
1418
Models::DynamicZones::EnrichmentDynamicZone => EnrichmentDynamicZone,
1519
Models::DynamicZones::HomepageDynamicZone => HomepageDynamicZone,
16-
Models::Collections::EmailTemplate => EmailTemplate,
17-
Models::Collections::EnrichmentList => EnrichmentList,
18-
Models::Meta::HeaderMenu => HeaderMenu,
1920
Models::Images::FeaturedImage => FeaturedImage,
21+
Models::Meta::HeaderMenu => HeaderMenu,
2022
Models::Meta::PageTitle => PageTitle,
2123
Models::Meta::Seo => Seo,
22-
Models::Data::Slug => Slug,
23-
Models::Data::WebPagePreview => WebPagePreview,
24+
Models::Meta::SimpleTitle => SimpleField,
2425
Models::Text::TextBlock => SimpleField,
25-
Models::Text::TextBlockWithoutWrapper => SimpleField,
26-
Models::Data::TextField => SimpleField
26+
Models::Text::TextBlockWithoutWrapper => SimpleField
2727
}.freeze
2828

2929
def initialize(collection_class, resource_filter = "slug")
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
module Cms
2-
module Models module DynamicComponents
3-
module <%= @component_type_class %>
4-
class <%= @component_name_class %>
5-
attr_accessor <%= @rails_param_names.map{":#{_1}"}.join(", ") %>
2+
module Models
3+
module DynamicComponents
4+
module <%= @component_type_class %>
5+
class <%= @component_name_class %>
6+
attr_accessor <%= @rails_param_names.map{":#{_1}"}.join(", ") %>
67

7-
def initialize(<%= @rails_param_names.map{"#{_1}:"}.join(", ") %>)
8-
<%- @rails_param_names.each do |param| -%>
9-
<%= "@#{param} = #{param}" %>
10-
<%- end -%>
11-
end
8+
def initialize(<%= @rails_param_names.map{"#{_1}:"}.join(", ") %>)
9+
<%- @rails_param_names.each do |param| -%>
10+
<%= "@#{param} = #{param}" %>
11+
<%- end -%>
12+
end
1213

13-
def render
14-
Cms::<%= @component_name_class %>Component.new(<%= @rails_param_names.map{"#{_1}:"}.join(", ") %>)
14+
def render
15+
Cms::<%= @component_name_class %>Component.new(<%= @rails_param_names.map{"#{_1}:"}.join(", ") %>)
16+
end
1517
end
1618
end
1719
end
1820
end
19-
end
21+
end

lib/generators/strapi/component_templates/mock_template.rb.tt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ module Cms
22
module Providers
33
module Strapi
44
module Mocks
5-
module Models module DynamicComponents
6-
module <%= @component_type_class %>
7-
class <%= @component_name_class %> < StrapiMock
8-
strapi_component "blocks.<%= @component_strapi_name %>"
5+
module Models
6+
module DynamicComponents
7+
module <%= @component_type_class %>
8+
class <%= @component_name_class %> < StrapiMock
9+
strapi_component "blocks.<%= @component_strapi_name %>"
910

10-
<%- @strapi_params.each do |param| -%>
11-
attribute(:<%= param %>) { }
12-
<%- end -%>
11+
<%- @strapi_params.each do |param| -%>
12+
attribute(:<%= param %>) { }
13+
<%- end -%>
14+
end
1315
end
1416
end
1517
end

0 commit comments

Comments
 (0)