Skip to content

Commit 4d38710

Browse files
committed
Fixups to have new things and old things still working
1 parent b0a22ac commit 4d38710

16 files changed

Lines changed: 81 additions & 103 deletions

File tree

core/app/assets/stylesheets/refinery/mixins/_labels.scss

Lines changed: 0 additions & 17 deletions
This file was deleted.

core/app/assets/stylesheets/refinery/refinery.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
@import 'mixins/icon_base';
99
@import 'mixins/icon';
1010
@import 'mixins/rounded';
11-
@import 'mixins/labels';
1211
@import 'mixins/locales';
1312
@import 'mixins/images';
1413

core/app/assets/stylesheets/refinery/sections/_layout.scss

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,7 @@ textarea {
742742
width: auto;
743743
height: 25px;
744744
}
745-
746-
//label, .label_with_help {
747-
label {
745+
label, .label_with_help {
748746
margin-bottom: 5px;
749747
font-weight: bold;
750748
margin-top: 20px;
@@ -1631,21 +1629,20 @@ input.button.close_dialog:active, a.button.close_dialog:active, #content a.butto
16311629
}
16321630

16331631
.label_with_help {
1634-
@include label_with_help
1635-
}
1636-
1637-
//.label_with_help label, .label_with_help span.help, .label_with_help img.help {
1638-
// display: inline;
1639-
//}
1640-
//.label_with_help img.help {
1641-
// vertical-align: middle;
1642-
//}
1643-
//.label_with_help span.help {
1644-
// font-weight: normal;
1645-
// margin-left: 3px;
1646-
// border-bottom: 1px dotted #727272;
1647-
// cursor: help;
1648-
//}
1632+
vertical-align: middle;
1633+
}
1634+
.label_with_help label, .label_with_help span.help, .label_with_help img.help {
1635+
display: inline;
1636+
}
1637+
.label_with_help img.help {
1638+
vertical-align: middle;
1639+
}
1640+
.label_with_help span.help {
1641+
font-weight: normal;
1642+
margin-left: 3px;
1643+
border-bottom: 1px dotted #727272;
1644+
cursor: help;
1645+
}
16491646
#more_options_field {
16501647
position: relative;
16511648
}

core/app/helpers/refinery/action_helper.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ def edit_in_locale(locale, url:, title: nil, **options)
6161
end
6262
end
6363

64-
65-
def edit_in_locales(edit_url, locales = [])
66-
return if locales.empty? || locales.one?
64+
def edit_in_locales(edit_url, locales = [], i18n_scope: %i[refinery admin locale_picker])
65+
return if locales.empty?
6766

6867
edit_links = locales.map do |locale|
69-
edit_in_locale(locale, url: edit_url, title: t('.edit_in_locale', locale: locale))
68+
language = ::Refinery::I18n.config.locales.fetch(locale, locale)
69+
edit_in_locale(locale, url: edit_url, title: t('edit_in_language', language: language, scope: i18n_scope))
7070
end
71+
7172
tag.span edit_links.compact.join(' ').html_safe, class: :locales
7273
end
7374
end

core/app/helpers/refinery/site_bar_helper.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
# frozen_string_literal: true
2+
13
module Refinery
24
module SiteBarHelper
35

46
# Generates the link to determine where the site bar switch button returns to.
57
def site_bar_switch_link
68
link_to_if(admin?, t('.switch_to_your_website', **site_bar_translate_locale_args),
79
refinery.root_path(site_bar_translate_locale_args),
8-
'data-turbolinks' => false) do
10+
data: {turbolinks: false}) do
911
link_to t('.switch_to_your_website_editor', **site_bar_translate_locale_args),
1012
Refinery::Core.backend_path, 'data-turbolinks' => false
1113
end
1214
end
1315

1416
def site_bar_edit_link
1517
return nil if admin? || @page.nil?
16-
link_to t('refinery.admin.pages.edit', **site_bar_translate_locale_args),
18+
19+
link_to t('refinery.admin.pages.page.edit', **site_bar_translate_locale_args),
1720
refinery.admin_edit_page_path(@page.nested_url,
18-
:switch_locale => (@page.translations.first.locale unless @page.translated_to_default_locale?)),
19-
'data-turbolinks' => false
21+
switch_locale: (@page.translations.first.locale unless @page.translated_to_default_locale?)),
22+
data: {turbolinks: false}
2023
end
2124

2225
def site_bar_translate_locale_args

core/app/helpers/refinery/tag_helper.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module Refinery
22
module TagHelper
3+
include ActionHelper
34

45
# Returns <img class='help' tooltip='Your Input' src='refinery/icons/information.png' />
56

67
# Remember to wrap your block with <span class='label_with_help'></span> if you're using a label next to the help tag.
78
def refinery_help_tag(title='Tip')
89
title = title.html_safe? ? title : h(title)
9-
tag.span title, class: :help
10+
action_icon(:info, '#', title, {tooltip: title})
1011
end
1112

1213
# This is just a quick wrapper to render an image tag that lives inside refinery/icons.
@@ -16,7 +17,7 @@ def refinery_icon_tag(filename, options = {})
1617

1718
filename = "#{filename}.png" unless filename.split('.').many?
1819
path = image_path "refinery/icons/#{filename}", skip_pipeline: true
19-
image_tag path, {:width => 16, :height => 16}.merge(options)
20+
image_tag path, {width: 16, height: 16}.merge(options)
2021
end
2122

2223
end

core/app/helpers/refinery/translation_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ def translated_field(record, field)
1818
def locales_with_translated_field(record, field_name, include_current: true)
1919
field_name = field_name.to_sym
2020
translations = record.translations.where.not(field_name => [nil, ""])
21-
translations = translations.where.not(locale: current_locale) unless include_current
22-
translations.map { |t| t.locale.to_sym }.sort_by { |locale| Refinery::I18n.frontend_locales.index(locale) }
23-
end
21+
translations = translations.where.not(locale: Refinery::I18n.default_frontend_locale.to_s) unless include_current
2422

25-
private def current_locale
26-
Refinery::I18n.current_locale.to_s
23+
translations.pluck(:locale).map(&:to_sym).sort_by do |locale|
24+
index = Refinery::I18n.frontend_locales.index(locale)
25+
index ? [0, index] : [1, locale]
26+
end
2727
end
2828
end
2929
end

core/app/views/refinery/admin/_locale_picker.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<input type="hidden" name="switch_locale" id="switch_locale" value="<%= local_assigns[:current_locale] %>" />
1+
<input type="hidden" name="switch_locale" id="switch_locale" value="<%= local_assigns[:current_locale] %>">
22
<% if Refinery::I18n.frontend_locales.many? %>
33
<label><%= t('.language') %></label>
4-
<div id="switch_locale_picker" class='locales'>
4+
<div id="switch_locale_picker" class="locales">
55
<% Refinery::I18n.frontend_locales.each do |locale, language| %>
66
<% classes = locale.to_s == local_assigns[:current_locale].to_s ? 'selected' : '' %>
77
<%= edit_in_locale(locale,

core/config/locales/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ en:
4444
show: Show
4545
locale_picker:
4646
language: Language,
47-
edit_in_locale: Edit in %{locale}
47+
edit_in_locale: Edit in '%{locale_code}'
4848
edit_in_language: Edit in %{language}
4949
resource_picker:
5050
download_current: Download current file

core/spec/system/refinery/site_bar_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# frozen_string_literal: true
2+
13
require "spec_helper"
24

35
module Refinery
4-
describe "site bar", :type => :system do
6+
describe "site bar", type: :system do
57
refinery_login
68

79
describe "logout link" do
@@ -62,7 +64,7 @@ module Refinery
6264
end
6365

6466
it "has an 'edit this page' button" do
65-
expect(page).to have_link("Edit this page", :href => refinery.edit_admin_page_path(root_page))
67+
expect(page).to have_link("Edit this page", href: refinery.edit_admin_page_path(root_page))
6668
end
6769

6870
end

0 commit comments

Comments
 (0)