-
Notifications
You must be signed in to change notification settings - Fork 193
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 #8964 from alphagov/worlwide-organisation-page-tra…
…nslations Worldwide organisation page translations
- Loading branch information
Showing
22 changed files
with
503 additions
and
29 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
app/components/admin/worldwide_organisation_pages/index/summary_card_component.html.erb
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
46 changes: 46 additions & 0 deletions
46
app/controllers/admin/worldwide_organisation_page_translations_controller.rb
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,46 @@ | ||
class Admin::WorldwideOrganisationPageTranslationsController < Admin::BaseController | ||
include TranslationControllerConcern | ||
|
||
def index; end | ||
|
||
def edit; end | ||
|
||
private | ||
|
||
def create_redirect_path | ||
edit_admin_editionable_worldwide_organisation_page_translation_path(@worldwide_organisation, @worldwide_page, id: translation_locale) | ||
end | ||
|
||
def destroy_redirect_path | ||
admin_editionable_worldwide_organisation_pages_path(@worldwide_organisation) | ||
end | ||
|
||
def update_redirect_path | ||
admin_editionable_worldwide_organisation_pages_path(@worldwide_organisation) | ||
end | ||
|
||
def load_translatable_item | ||
@worldwide_organisation = Edition.find(params[:editionable_worldwide_organisation_id]) | ||
@worldwide_page = @worldwide_organisation.pages.find(params[:page_id]) | ||
end | ||
|
||
def load_translated_models | ||
@translated_page = LocalisedModel.new(@worldwide_page, translation_locale.code) | ||
@english_page = LocalisedModel.new(@worldwide_page, :en) | ||
end | ||
|
||
def translatable_item | ||
@translated_page | ||
end | ||
|
||
def translated_item_name | ||
@translated_page.title | ||
end | ||
|
||
def translation_params | ||
params.require(:page) | ||
.permit(:title, | ||
:summary, | ||
:body) | ||
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
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
29 changes: 29 additions & 0 deletions
29
app/views/admin/worldwide_organisation_page_translations/confirm_destroy.html.erb
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,29 @@ | ||
<% content_for :context, @worldwide_page.title %> | ||
<% content_for :page_title, "Delete #{@translation_locale.native_and_english_language_name} translation" %> | ||
<% content_for :title, "Delete translation" %> | ||
<% content_for :title_margin_bottom, 6 %> | ||
|
||
<div class="govuk-grid-row"> | ||
<section class="govuk-grid-column-two-thirds"> | ||
<%= form_with url: admin_editionable_worldwide_organisation_page_translation_path(@worldwide_organisation, @worldwide_page, @translation_locale), method: :delete do %> | ||
<p class="govuk-body govuk-!-margin-bottom-7"> | ||
Are you sure you want to delete the "<%= @translation_locale.native_and_english_language_name %>" translation for "<%= @worldwide_page.title %>"? | ||
</p> | ||
|
||
<div class="govuk-button-group"> | ||
<%= render "govuk_publishing_components/components/button", { | ||
text: "Delete", | ||
destructive: true, | ||
data_attributes: { | ||
module: "gem-track-click", | ||
"track-category": "form-button", | ||
"track-action": "worldwide-page-translations-button", | ||
"track-label": "Delete", | ||
}, | ||
} %> | ||
<%= link_to("Cancel", admin_editionable_worldwide_organisation_pages_path(@worldwide_organisation), class: "govuk-link govuk-link--no-visited-state") %> | ||
</div> | ||
<% end %> | ||
</section> | ||
</div> |
66 changes: 66 additions & 0 deletions
66
app/views/admin/worldwide_organisation_page_translations/edit.html.erb
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,66 @@ | ||
<% content_for :page_title, "#{@translated_page.translation.persisted? ? "Edit" : "New"} translation for #{@worldwide_page.title}" %> | ||
<% content_for :title, "#{@translated_page.translation.persisted? ? "Edit" : "New"} translation" %> | ||
<% content_for :context, @worldwide_page.title %> | ||
<% content_for :error_summary, render(Admin::ErrorSummaryComponent.new(object: @translated_page)) %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with model: @worldwide_page, as: :contact, url: admin_editionable_worldwide_organisation_page_translation_path(@worldwide_organisation, @worldwide_page, translation_locale), method: :put do |form| %> | ||
<%= render "components/translated_textarea", { | ||
textarea: { | ||
label: { | ||
heading_size: "l", | ||
text: "Translated summary", | ||
}, | ||
name: "page[summary]", | ||
id: "page_summary", | ||
value: @translated_page.summary, | ||
rows: 2, | ||
error_items: errors_for(form.object.errors, :summary), | ||
right_to_left: @translated_page.translation_locale.rtl?, | ||
right_to_left_help: false, | ||
}, | ||
details: { | ||
text: @worldwide_page.summary, | ||
}, | ||
} %> | ||
<%= render "components/translated_textarea", { | ||
textarea: { | ||
label: { | ||
heading_size: "l", | ||
text: "Translated body (required)", | ||
}, | ||
name: "page[body]", | ||
id: "page_body", | ||
value: @translated_page.body, | ||
rows: 20, | ||
error_items: errors_for(form.object.errors, :body), | ||
right_to_left: @translated_page.translation_locale.rtl?, | ||
right_to_left_help: false, | ||
}, | ||
details: { | ||
text: @worldwide_page.body, | ||
}, | ||
} %> | ||
|
||
<div class="govuk-button-group govuk-!-margin-top-8"> | ||
<%= render "govuk_publishing_components/components/button", { | ||
text: "Save", | ||
data_attributes: { | ||
module: "gem-track-click", | ||
"track-category": "form-button", | ||
"track-action": "worldwide-office-translation-button", | ||
"track-label": "Save", | ||
}, | ||
} %> | ||
<% if @translated_page.translation.persisted? %> | ||
<%= link_to("Cancel", admin_editionable_worldwide_organisation_pages_path(@worldwide_organisation), class: "govuk-link govuk-link--no-visited-state") %> | ||
<% else %> | ||
<%= link_to("Cancel", admin_editionable_worldwide_organisation_page_translations_path(@worldwide_organisation, @worldwide_page), class: "govuk-link govuk-link--no-visited-state") %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
38 changes: 38 additions & 0 deletions
38
app/views/admin/worldwide_organisation_page_translations/index.html.erb
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,38 @@ | ||
<% content_for :page_title, "New translation for #{@worldwide_page.title}" %> | ||
<% content_for :title, "New translation" %> | ||
<% content_for :context, @worldwide_page.title %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with url: admin_editionable_worldwide_organisation_page_translations_path(@worldwide_organisation, @worldwide_page) do %> | ||
<%= render "govuk_publishing_components/components/select", { | ||
id: "translation_locale", | ||
name: "translation_locale", | ||
label: "Select language", | ||
hint: "This is the first step before creating a translated version of this content", | ||
heading_size: "l", | ||
full_width: true, | ||
options: @worldwide_page.missing_translations.map do |locale| | ||
{ | ||
value: locale.code, | ||
text: Locale.coerce(locale).native_and_english_language_name, | ||
} | ||
end, | ||
} %> | ||
|
||
<div class="govuk-button-group govuk-!-margin-top-8"> | ||
<%= render "govuk_publishing_components/components/button", { | ||
text: "Next", | ||
data_attributes: { | ||
module: "gem-track-click", | ||
"track-category": "form-button", | ||
"track-action": "worldwide-office-translation-button", | ||
"track-label": "Next", | ||
}, | ||
} %> | ||
<%= link_to("Cancel", admin_editionable_worldwide_organisation_pages_path(@worldwide_organisation), class: "govuk-link govuk-link--no-visited-state") %> | ||
</div> | ||
<% 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
9 changes: 9 additions & 0 deletions
9
db/migrate/20240412103303_add_worldwide_organisation_page_translations_table.rb
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 @@ | ||
class AddWorldwideOrganisationPageTranslationsTable < ActiveRecord::Migration[7.1] | ||
def up | ||
WorldwideOrganisationPage.create_translation_table! title: :string, summary: :text, body: :text | ||
end | ||
|
||
def down | ||
WorldwideOrganisationPage.drop_translation_table! | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240422091946_remove_worldwide_organisation_page_fields.rb
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 @@ | ||
class RemoveWorldwideOrganisationPageFields < ActiveRecord::Migration[7.1] | ||
def change | ||
remove_columns(:worldwide_organisation_pages, :body, :summary, type: "text") | ||
end | ||
end |
Oops, something went wrong.