Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to edit in locales #349

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ApplicationController < ::Spina::Admin::AdminController

def set_locale
@locale = params[:locale] || I18n.default_locale
Mobility.locale = @locale
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def new
# Renders a form for an existing presentation.
# @return [void]
def edit
add_breadcrumb @presentation.title
add_breadcrumb @presentation.title.truncate(33, separator: /\s/, omission: '…')
end

# Creates a presentation.
Expand Down Expand Up @@ -58,7 +58,7 @@ def update # rubocop:disable Metrics/MethodLength
else
respond_to do |format|
format.html do
add_breadcrumb @presentation.title
add_breadcrumb @presentation.title.try(:truncate, 33, separator: /\s/, omission: '…')
render :edit
end
format.turbo_stream { render partial: 'errors', locals: { errors: @presentation.errors } }
Expand All @@ -74,7 +74,7 @@ def destroy # rubocop:disable Metrics/MethodLength
else
respond_to do |format|
format.html do
add_breadcrumb @presentation.title
add_breadcrumb @presentation.title.try(:truncate, 33, separator: /\s/, omission: '…')
render :edit
end
format.turbo_stream { render partial: 'errors', locals: { errors: @presentation.errors } }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.breadcrumbs
= render_breadcrumbs separator: tag.div(class: 'divider')
%span{ style: 'margin-left: 10px' }
- if Spina.config.locales.many?
%div{ style: 'display: inline-block', data: { dropdown: true } }
= link_to '#', class: %w[button button-default button-small], style: 'margin-left: 0; margin-right: 0',
data: { trigger: 'dropdown', target: '#locales' } do
.button-content
= icon('comment')
= t "spina.languages.#{@locale}"
%i.icon.icon-chevron-down{ style: 'font-size: 9px; margin-right: 0; margin-left: 5px' }
%ul#locales
- Spina.config.locales.each do |locale|
%li
= link_to_if @locale.to_s == locale.to_s, t("spina.languages.#{locale}"), "?locale=#{locale}", style: 'font-weight: 600' do
= link_to t("spina.languages.#{locale}"), "?locale=#{locale}"
17 changes: 10 additions & 7 deletions app/views/spina/admin/conferences/conferences/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @conference], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @conference.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,9 +19,12 @@
%li{ class: ('active' if i == 0) }
= link_to t(".#{tab}"), "##{tab}"

#conference_details.tab-content.active= render 'form_conference_details', f: f
#parts.tab-content= render 'form_parts', f: f
#rooms.tab-content= render partial: 'rooms', object: @conference.rooms
#presentation_types.tab-content= render partial: 'presentation_types', object: @conference.presentation_types
#delegates.tab-content= render partial: 'delegates', object: @conference.delegates
#presentations.tab-content= render partial: 'presentations', object: @conference.presentations
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#conference_details.tab-content.active= render 'form_conference_details', f: f
#parts.tab-content= render 'form_parts', f: f
#rooms.tab-content= render partial: 'rooms', object: @conference.rooms
#presentation_types.tab-content= render partial: 'presentation_types', object: @conference.presentation_types
#delegates.tab-content= render partial: 'delegates', object: @conference.delegates
#presentations.tab-content= render partial: 'presentations', object: @conference.presentations
11 changes: 7 additions & 4 deletions app/views/spina/admin/conferences/delegates/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @delegate], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @delegate.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,6 +19,9 @@
%li{ class: ('active' if i == 0) }
= link_to t(".#{tab}"), "##{tab}"

#delegate_details.tab-content.active= render 'form_delegate_details', f: f
#conferences.tab-content= render partial: 'conferences', object: @delegate.conferences
#presentations.tab-content= render partial: 'presentations', object: @delegate.presentations
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#delegate_details.tab-content.active= render 'form_delegate_details', f: f
#conferences.tab-content= render partial: 'conferences', object: @delegate.conferences
#presentations.tab-content= render partial: 'presentations', object: @delegate.presentations
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @dietary_requirement], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @dietary_requirement.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,5 +19,8 @@
%li{ class: ('active' if i == 0) }
= link_to t(".#{tab}"), "##{tab}"

#dietary_requirement_details.tab-content.active= render 'form_dietary_requirement_details', f: f
#delegates.tab-content= render partial: 'delegates', object: @dietary_requirement.delegates
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#dietary_requirement_details.tab-content.active= render 'form_dietary_requirement_details', f: f
#delegates.tab-content= render partial: 'delegates', object: @dietary_requirement.delegates
11 changes: 7 additions & 4 deletions app/views/spina/admin/conferences/institutions/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @institution], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @institution.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,6 +19,9 @@
%li{ class: ('active' if i == 0) }
= link_to t(".#{tab}"), "##{tab}"

#institution_details.tab-content.active= render 'form_institution_details', f: f
#rooms.tab-content= render partial: 'rooms', object: @institution.rooms
#delegates.tab-content= render partial: 'delegates', object: @institution.delegates
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#institution_details.tab-content.active= render 'form_institution_details', f: f
#rooms.tab-content= render partial: 'rooms', object: @institution.rooms
#delegates.tab-content= render partial: 'delegates', object: @institution.delegates
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @presentation_attachment_type], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @presentation_attachment_type.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -13,11 +13,14 @@

= link_to t('spina.cancel'), admin_conferences_presentation_attachment_types_path, class: 'button', style: 'margin-right: 0'

%div{ style: 'margin-top: 40px' }
.horizontal-form
.horizontal-form-group
.horizontal-form-label= Spina::Admin::Conferences::DietaryRequirement.human_attribute_name :name
.horizontal-form-content= f.text_field :name, placeholder: Spina::Admin::Conferences::DietaryRequirement.human_attribute_name(:name), required: true
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
%div{ style: 'margin-top: 40px' }
.horizontal-form
.horizontal-form-group
.horizontal-form-label= Spina::Admin::Conferences::DietaryRequirement.human_attribute_name :name
.horizontal-form-content= f.text_field :name, placeholder: Spina::Admin::Conferences::DietaryRequirement.human_attribute_name(:name), required: true

- unless @presentation_attachment_type.new_record?
.pull-right= link_to t('spina.permanently_delete'), admin_conferences_presentation_attachment_type_path(@presentation_attachment_type), method: :delete, data: { confirm: t('.delete_confirmation', presentation_attachment_type: @presentation_attachment_type.name) }, class: %w[button button-link button-danger]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @presentation_type], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @presentation_type.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,6 +19,9 @@
%li{ class: ('active' if i == 0) }
= link_to t(".#{tab}"), "##{tab}"

#presentation_type_details.tab-content.active= render 'form_presentation_type_details', f: f
#sessions.tab-content= render partial: 'sessions', object: @presentation_type.sessions
#presentations.tab-content= render partial: 'presentations', object: @presentation_type.presentations
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#presentation_type_details.tab-content.active= render 'form_presentation_type_details', f: f
#sessions.tab-content= render partial: 'sessions', object: @presentation_type.sessions
#presentations.tab-content= render partial: 'presentations', object: @presentation_type.presentations
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @presentation], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @presentation.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,5 +19,8 @@
%li{ class: ('active' if i == 0) }
= link_to t(".#{tab}"), "##{tab}"

#presentation_details.tab-content.active= render 'form_presentation_details', f: f
#presenters.tab-content= render partial: 'delegates', object: @presentation.presenters
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#presentation_details.tab-content.active= render 'form_presentation_details', f: f
#presenters.tab-content= render partial: 'delegates', object: @presentation.presenters
9 changes: 6 additions & 3 deletions app/views/spina/admin/conferences/rooms/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @room], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @room.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,5 +19,8 @@
%li{ class: ('active'if i == 0)}
= link_to t(".#{tab}"), "##{tab}"

#room_details.tab-content.active= render 'form_room_details', f: f
#presentations.tab-content= render partial: 'presentations', object: @room.presentations
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#room_details.tab-content.active= render 'form_room_details', f: f
#presentations.tab-content= render partial: 'presentations', object: @room.presentations
9 changes: 6 additions & 3 deletions app/views/spina/admin/conferences/sessions/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

= form_for [:admin_conferences, @session], html: { autocomplete: 'off' } do |f|
%header#header
= render partial: 'spina/admin/shared/breadcrumbs'
= render partial: @session.new_record? ? 'spina/admin/shared/breadcrumbs' : 'breadcrumbs'

#header_actions
%button.button.button-primary{ type: 'submit' }
Expand All @@ -19,5 +19,8 @@
%li{ class: ('active'if i == 0)}
= link_to t(".#{tab}"), "##{tab}"

#session_details.tab-content.active= render 'form_session_details', f: f
#presentations.tab-content= render partial: 'presentations', object: @session.presentations
= hidden_field_tag :locale, @locale

- Mobility.with_locale(@locale) do
#session_details.tab-content.active= render 'form_session_details', f: f
#presentations.tab-content= render partial: 'presentations', object: @session.presentations
10 changes: 10 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
include ::Spina::Engine.routes.url_helpers

driven_by :selenium, using: :headless_chrome, screen_size: [1400, 800]

setup do
@user = spina_users :joe
visit admin_login_path
within '.login-fields' do
fill_in 'email', with: @user.email
fill_in 'password', with: 'password'
end
click_on 'Login'
end
end

Capybara.default_max_wait_time = 5
Loading