generated from DFE-Digital/govuk-dotnet-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #565 from DFE-Digital/SFSW-2541-Create-Quote-box-c…
…omponent Sfsw 2541 create quote box component
- Loading branch information
Showing
15 changed files
with
266 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Contentful.Core.Models; | ||
|
||
namespace Childrens_Social_Care_CPD.Contentful.Models; | ||
|
||
public class QuoteBox : IContent | ||
{ | ||
public string Name { get; set; } | ||
public Document QuoteText { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@using Childrens_Social_Care_CPD.Contentful.Models; | ||
@using Childrens_Social_Care_CPD.Contentful; | ||
@using Childrens_Social_Care_CPD.Contentful.Renderers; | ||
|
||
@model QuoteBox | ||
|
||
|
||
<div class="blockquote-container"> | ||
<blockquote class="quote"> | ||
@{ | ||
await Html.RenderPartialAsync("_RichText", Model.QuoteText); | ||
} | ||
</blockquote> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
131 changes: 131 additions & 0 deletions
131
Contentful-Schema/migrations/0015-quote-box-component.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
module.exports = async function (migration, { makeRequest }) { | ||
|
||
const quoteBox = migration | ||
.createContentType("quoteBox") | ||
.name("Quote Box") | ||
.description("Allows display of quotes in a distinctive bordered box.") | ||
.displayField("name"); | ||
quoteBox | ||
.createField("name") | ||
.name("Name") | ||
.type("Symbol") | ||
.localized(false) | ||
.required(true) | ||
.validations([]) | ||
.disabled(false) | ||
.omitted(false); | ||
|
||
quoteBox | ||
.createField("quoteText") | ||
.name("Quote Text") | ||
.type("RichText") | ||
.localized(false) | ||
.required(false) | ||
.validations([ | ||
{ | ||
enabledMarks: [ | ||
"bold", | ||
"italic", | ||
"underline", | ||
"code", | ||
"superscript", | ||
"subscript" | ||
], | ||
|
||
message: | ||
"Only bold, italic, underline, code, superscript, subscript, and strikethrough marks are allowed", | ||
}, | ||
{ | ||
enabledNodeTypes: [ | ||
"heading-1", | ||
"heading-2", | ||
"heading-3", | ||
"heading-4", | ||
"heading-5", | ||
"heading-6", | ||
"ordered-list", | ||
"unordered-list", | ||
"hr", | ||
"blockquote", | ||
"embedded-entry-block", | ||
"embedded-asset-block", | ||
"table", | ||
"asset-hyperlink", | ||
"embedded-entry-inline", | ||
"entry-hyperlink", | ||
"hyperlink", | ||
], | ||
|
||
message: | ||
"Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, table, link to asset, inline entry, link to entry, and link to Url nodes are allowed", | ||
}, | ||
{ | ||
nodes: {}, | ||
}, | ||
]) | ||
.disabled(false) | ||
.omitted(false); | ||
|
||
quoteBox.changeFieldControl("name", "builtin", "singleLine", {}); | ||
quoteBox.changeFieldControl("quoteText", "builtin", "richTextEditor", {}); | ||
|
||
|
||
/* | ||
* Add quoteBox to list of content types allowed in content pages | ||
*/ | ||
var contentTypeId = "content", | ||
linkingFieldId = "items", | ||
quoteBoxTypeId = "quoteBox"; | ||
|
||
var response = await makeRequest({ | ||
method: "GET", | ||
url: `/content_types?sys.id[in]=${contentTypeId}`, | ||
}); | ||
|
||
var validations = response.items[0].fields | ||
.filter((field) => field.id == linkingFieldId)[0] | ||
.items.validations.map((rule) => { | ||
if ( | ||
rule.linkContentType && | ||
!rule.linkContentType.includes(quoteBoxTypeId) | ||
) { | ||
rule.linkContentType.push(quoteBoxTypeId); | ||
} | ||
return rule; | ||
}); | ||
|
||
migration.editContentType(contentTypeId).editField(linkingFieldId).items({ | ||
type: "Link", | ||
linkType: "Entry", | ||
validations: validations, | ||
}); | ||
|
||
/* | ||
* Add quoteBox to list of content types allowed in accordion sections | ||
*/ | ||
contentTypeId = "accordionSection"; | ||
linkingFieldId = "content"; | ||
|
||
response = await makeRequest({ | ||
method: "GET", | ||
url: `/content_types?sys.id[in]=${contentTypeId}`, | ||
}); | ||
|
||
validations = response.items[0].fields | ||
.filter((field) => field.id == linkingFieldId)[0] | ||
.items.validations.map((rule) => { | ||
if ( | ||
rule.linkContentType && | ||
!rule.linkContentType.includes(quoteBoxTypeId) | ||
) { | ||
rule.linkContentType.push(quoteBoxTypeId); | ||
} | ||
return rule; | ||
}); | ||
|
||
migration.editContentType(contentTypeId).editField(linkingFieldId).items({ | ||
type: "Link", | ||
linkType: "Entry", | ||
validations: validations, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.