-
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.
Add update service page for both claims and placements
- Loading branch information
Showing
19 changed files
with
274 additions
and
40 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,5 @@ | ||
<section id="<%= service_update.id %>"> | ||
<%= title_element %> | ||
<p class="govuk-body govuk-!-margin-bottom-2"><%= date_pretty %></p> | ||
<div class="govuk-body"><%= content_html %></div> | ||
</section> |
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,31 @@ | ||
class ServiceUpdate::View < GovukComponent::Base | ||
attr_reader :service_update | ||
|
||
delegate :title, :content, :date, to: :service_update | ||
|
||
TITLE_CLASS = "govuk-heading-m govuk-!-margin-bottom-2" | ||
|
||
def initialize(service_update:, title_tag: "h2") | ||
@service_update = service_update | ||
@title_tag = title_tag | ||
end | ||
|
||
def title_element | ||
tag.h2(title, class: TITLE_CLASS) | ||
end | ||
|
||
def date_pretty | ||
date.to_date.strftime("%e %B %Y") | ||
end | ||
|
||
def content_html | ||
custom_render = | ||
Redcarpet::Render::HTML.new(link_attributes: { class: "govuk-link" }) | ||
markdown = Redcarpet::Markdown.new(custom_render) | ||
markdown.render(content).html_safe | ||
end | ||
|
||
private | ||
|
||
attr_reader :title_tag | ||
end |
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 @@ | ||
# frozen_string_literal: true | ||
|
||
class ServiceUpdatesController < ApplicationController | ||
include ApplicationHelper | ||
|
||
def index | ||
@service_updates = ServiceUpdate.where(service: current_service(request)) | ||
end | ||
end |
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,30 @@ | ||
class ServiceUpdate | ||
CLAIMS_SERVICE_UPDATES_YAML_FILE = | ||
Rails.root.join("db/claims_service_updates.yml").freeze | ||
PLACEMENTS_SERVICE_UPDATES_YAML_FILE = | ||
Rails.root.join("db/placements_service_updates.yml").freeze | ||
|
||
include ActiveModel::Model | ||
|
||
attr_accessor :date, :title, :content | ||
|
||
def id | ||
title.parameterize | ||
end | ||
|
||
def self.where(service:) | ||
path = file_path(service:) | ||
updates = YAML.load_file(path) || [] | ||
|
||
updates.map { |service_update| new(service_update) } | ||
end | ||
|
||
def self.file_path(service:) | ||
case service | ||
when :claims | ||
CLAIMS_SERVICE_UPDATES_YAML_FILE | ||
when :placements | ||
PLACEMENTS_SERVICE_UPDATES_YAML_FILE | ||
end | ||
end | ||
end |
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,17 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<h1 class="govuk-heading-xl"><%= t("service_updates.#{current_service(request)}.heading") %></h1> | ||
|
||
<h2 class="govuk-heading-m"><%= t("service_updates.contents") %></h2> | ||
<ul class="govuk-list app-list--dash govuk-!-margin-bottom-8 govuk-!-margin-left-3"> | ||
<% @service_updates.each do |service_update| %> | ||
<li><a class="govuk-link" href="#<%= service_update.id %>"><%= service_update.title %></a></li> | ||
<% end %> | ||
</ul> | ||
|
||
<% @service_updates.each do |service_update| %> | ||
<hr class="govuk-section-break govuk-section-break--l govuk-section-break--visible"> | ||
<%= render ServiceUpdate::View.new(service_update:) %> | ||
<% end %> | ||
</div> | ||
</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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
scope module: :placements, as: :placements, constraints: { host: ENV["PLACEMENTS_HOST"] } do | ||
scope module: :placements, | ||
as: :placements, | ||
constraints: { | ||
host: ENV["PLACEMENTS_HOST"] | ||
} do | ||
root to: "pages#index" | ||
end |
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,6 @@ | ||
# Example structure for adding service updates | ||
|
||
# - date: '2023-11-29' | ||
# title: claims | ||
# content: | | ||
# blah blah content |
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,6 @@ | ||
# Example structure for adding service updates | ||
|
||
# - date: '2023-11-29' | ||
# title: placements | ||
# content: | | ||
# blah blah content |
Oops, something went wrong.