-
Notifications
You must be signed in to change notification settings - Fork 43
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 #2035 from alphagov/transition_add_downtime_page
Transition add downtime page
- Loading branch information
Showing
6 changed files
with
190 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<% | ||
|
||
id ||= "input-#{SecureRandom.hex(4)}" | ||
name ||= nil | ||
items ||= [ | ||
{ :name => "hour", :width => 2 }, | ||
{ :name => "minute", :width => 2 } | ||
] | ||
|
||
legend_text ||= nil | ||
hint ||= nil | ||
error_message ||= nil | ||
error_items ||= [] | ||
describedby ||= nil | ||
has_error ||= error_message || error_items.any? | ||
|
||
css_classes = %w(gem-c-date-input govuk-date-input) | ||
form_group_css_classes = %w(govuk-form-group) | ||
form_group_css_classes << "govuk-form-group--error" if has_error | ||
|
||
hint_id = "hint-#{SecureRandom.hex(4)}" | ||
error_id = "error-#{SecureRandom.hex(4)}" | ||
|
||
aria_described_by ||= nil | ||
if hint || has_error || describedby | ||
aria_described_by = [] | ||
aria_described_by << hint_id if hint | ||
aria_described_by << error_id if has_error | ||
aria_described_by << describedby if describedby | ||
aria_described_by = aria_described_by.join(" ") | ||
end | ||
%> | ||
<%= content_tag :div, class: form_group_css_classes do %> | ||
<% fieldset_content = capture do %> | ||
<% if hint %> | ||
<%= render "govuk_publishing_components/components/hint", { | ||
id: hint_id, | ||
text: hint, | ||
margin_bottom: 2 | ||
} %> | ||
<% end %> | ||
<% if has_error %> | ||
<%= render "govuk_publishing_components/components/error_message", { | ||
id: error_id, | ||
text: error_message, | ||
items: error_items, | ||
} %> | ||
<% end %> | ||
<%= tag.div class: css_classes, id: id do %> | ||
<% items.each do |item, index| %> | ||
<%= tag.div class: "govuk-date-input__item" do %> | ||
<%= render "govuk_publishing_components/components/input", { | ||
label: { | ||
text: item[:label] || item[:name].capitalize | ||
}, | ||
grouped: true, | ||
has_error: has_error, | ||
name: name ? (name + "[" + item[:name] + "]") : item[:name], | ||
value: item[:value], | ||
width: item[:width], | ||
id: item[:id], | ||
type: "number", | ||
data: item[:data] | ||
} %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% if legend_text %> | ||
<%= render "govuk_publishing_components/components/fieldset", { | ||
describedby: aria_described_by, | ||
legend_text: legend_text, | ||
text: fieldset_content, | ||
role: "group" | ||
} %> | ||
<% else %> | ||
<%= fieldset_content %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
<% content_for :page_title, 'Schedule downtime' %> | ||
<% content_for :title, 'Add downtime message' %> | ||
<% content_for :title_context, @downtime.artefact.name %> | ||
|
||
<ul class="breadcrumb"> | ||
<li class="crumb"><%= link_to 'Downtime', downtimes_path %></li> | ||
<li class="active"><%= @downtime.artefact.name %></li> | ||
</ul> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= render "govuk_publishing_components/components/lead_paragraph", { | ||
text: "Downtime message appear on the service's start page one day before the downtime is due to occur.", | ||
margin_bottom: 6 | ||
} %> | ||
<div class="page-title"> | ||
<h1> | ||
<span class="small"><%= @downtime.artefact.name %></span> | ||
Schedule a downtime message | ||
</h1> | ||
</div> | ||
<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module' => 'downtime-message' } do |f| %> | ||
<%= render 'form', f: f %> | ||
|
||
<div class="govuk-button-group"> | ||
<%= render "govuk_publishing_components/components/button", { | ||
text: "Save", | ||
value: "save", | ||
name: "save" | ||
} %> | ||
<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module' => 'downtime-message' } do |f| %> | ||
<%= render 'form', f: f %> | ||
<%= f.submit 'Schedule downtime message', class: 'js-submit btn btn-success' %> | ||
<% end %> | ||
<%= link_to "Cancel", downtimes_path, class: "govuk-link govuk-link--no-visited-state" %> | ||
</div> | ||
<% end %> | ||
</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