Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions app/models/configurable_document_types/navigation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"key": "navigation",
"title": "Navigation",
"description": "Spiking a navigation object. In the future this would likely live as a separate artefact in a tab on a given configurable document type. But this spike allows us to hard code a blob of JSON and send to Publishing API without having to worry about the lifecycle of the associated edition.",
"forms": {
"documents": {
"fields": {
"menu_items": {
"title": "Menu items",
"description": "JSON hash to be sent as part of the Navigation's `details` - for spike purposes only. The intention is to use this to describe the _structure_ of the navigation (e.g. nesting).",
"block": "default_textarea",
"attribute_path": ["block_content", "menu_items"],
"translatable": false
},
"navigation_items": {
"title": "Linked navigation documents",
"description": "JSON hash of content IDs of documents to be linked to this navigation document as `links.navigation_items` in the Publishing API payload. Should map to the same menu items referenced in the `menu_items` field. For spike purposes only.",
"block": "default_textarea",
"attribute_path": ["block_content", "navigation_items"],
"translatable": false
}
}
}
},
"schema": {
"attributes": {
"menu_items": {
"type": "string"
},
"navigation_items": {
"type": "string"
}
}
},
"presenters": {
"publishing_api": {
"details": {
"menu_items": "parsed_as_hash"
},
"links": [
"navigation_items"
]
}
},
"settings": {
"publishing_api_schema_name": "shared_navigation",
"publishing_api_document_type": "shared_navigation",
"send_change_history": false,
"file_attachments_enabled": false,
"images": {
"enabled": false
},
"organisations": null,
"backdating_enabled": false,
"history_mode_enabled": false,
"taxon_required": false,
"translations_enabled": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def raw(attribute)
item.block_content&.public_send(attribute)
end

def parsed_as_hash(attribute)
content = item.block_content&.public_send(attribute)
return nil if content.nil?

JSON.parse(content)
end

def govspeak(attribute)
content = item.block_content&.public_send(attribute)
return nil if content.nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,19 @@ def self.worldwide_organisations(item)
def self.government(item)
{ government: [item.government&.content_id].compact }
end

def self.navigation_items(item)
content = item.block_content["navigation_items"]
return nil if content.nil?

# TODO: simplify. This originally was going to be an array of objects but is now just a list of content IDs
# e.g.
# [
# "05c902c3-8272-4940-be0c-2c71e36e538d"
# ]
# All we're doing is parsing the JSON above, but we could probably make this
# a comma separated list, or even better, use the array / add-another component
{ navigation_items: JSON.parse(content) }
end
end
end
10 changes: 6 additions & 4 deletions public/configurable-document-type.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
"govspeak",
"rfc3339_date",
"image",
"parsed_as_hash",
"raw",
"social_media_links"
]
Expand All @@ -302,6 +303,7 @@
"type": "string",
"description": "The builder methods to use for populating the links object when presenting to the Publishing API.",
"enum": [
"navigation_items",
"ministerial_role_appointments",
"topical_events",
"world_locations",
Expand Down Expand Up @@ -345,7 +347,8 @@
"history",
"topical_event",
"news_article",
"case_study"
"case_study",
"shared_navigation"
]
},
"publishing_api_document_type": {
Expand All @@ -358,7 +361,8 @@
"world_news_story",
"history",
"topical_event",
"case_study"
"case_study",
"shared_navigation"
]
},
"rendering_app": {
Expand Down Expand Up @@ -467,10 +471,8 @@
}
},
"required": [
"base_path_prefix",
"publishing_api_schema_name",
"publishing_api_document_type",
"rendering_app",
"images",
"send_change_history",
"organisations",
Expand Down