Skip to content

Commit ce7f039

Browse files
committed
Attempt a few patches
1 parent dc8b37f commit ce7f039

File tree

12 files changed

+38
-14
lines changed

12 files changed

+38
-14
lines changed

core/app/helpers/refinery/action_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def edit_in_current_locale(url:, title:, **options)
3939

4040
def edit_in_locale(locale, url:, title:, **options)
4141
if options.delete(:label)
42-
title = language(locale)
42+
title = locale_language(locale)
4343
action_label(:locale, "#{url}?switch_locale=#{locale}", title, **options,
4444
id: locale, class: :edit, **options
4545
)

core/app/helpers/refinery/translation_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def translated_field(record, field)
1717

1818
def locales_with_translated_field(record, field_name, include_current: true)
1919
field_name = field_name.to_sym
20-
translations = record.translations.where.not(field_name, nil )
20+
translations = record.translations.where.not(field_name => [nil, ""])
2121
translations = translations.where.not(locale: current_locale) unless include_current
22-
translations.map(&:locale).sort_by { |t| Refinery::I18n.frontend_locales.index(t.to_sym) }
22+
translations.map { |t| t.locale.to_sym }.sort_by { |locale| Refinery::I18n.frontend_locales.index(locale) }
2323
end
2424

2525
def current_locale?(locale) = locale.to_sym == Refinery::I18n.current_locale

core/lib/refinery/crud.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def crudify(model_name, options = {})
6060
def self.crudify_options
6161
#{options.inspect}
6262
end
63-
63+
6464
prepend_before_action :find_#{singular_name}, only: #{actions}
6565
prepend_before_action :merge_position_into_params!, :only => :create
6666

core/lib/refinery/generators/generated_attribute.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,22 @@
33
module Refinery
44
module Generators
55
class GeneratedAttribute < Rails::Generators::GeneratedAttribute
6+
REFINERY_TYPES = %w(image resource radio select checkbox)
7+
68
attr_accessor :refinery_type
79

810
class << self
11+
def parse(column_definition)
12+
name, type, index_type = column_definition.split(":")
13+
14+
# Handle Refinery's custom types before Rails validates them
15+
if type && REFINERY_TYPES.include?(type)
16+
new(name, type.to_sym, index_type)
17+
else
18+
super
19+
end
20+
end
21+
922
def reference?(type)
1023
[:references, :belongs_to, :image, :resource].include? type
1124
end

core/spec/lib/refinery/crud_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class CrudDummy < ActiveRecord::Base
1515
end
1616

1717
class CrudDummyController < ::ApplicationController
18-
crudify :'refinery/crud_dummy'
18+
skip_before_action :find_or_set_locale, raise: false
19+
crudify :'refinery/crud_dummy', find_actions: [:update, :destroy, :edit]
1920
end
2021
end
2122

core/spec/system/refinery/admin/xhr_paging_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module Refinery
2121
it 'performs ajax paging of index' do
2222
visit refinery.admin_images_path
2323

24-
expect(page).to have_selector('ul#image_grid li > img', count: 1)
25-
expect(page).to have_css(%Q{img[alt="#{first_image.title}"]})
24+
expect(page).to have_selector('ul#image_index li.image', count: 1)
25+
expect(page).to have_css(%Q{img[alt="#{first_image.alt}"]})
2626

2727
# placeholder which would disappear in a full page refresh.
2828
page.execute_script("node = document.createElement('i');")
@@ -33,7 +33,7 @@ module Refinery
3333
click_link '2'
3434
end
3535

36-
expect(page).to have_css(%Q{img[alt="#{last_image.title}"]})
36+
expect(page).to have_css(%Q{img[alt="#{last_image.alt}"]})
3737
expect(page.evaluate_script(
3838
%{$('i#has_not_refreshed_entire_page').length}
3939
)).to eq(1)

images/app/controllers/refinery/admin/images_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class ImagesController < ::Refinery::AdminController
77
include: [:translations, :crops],
88
order: "updated_at DESC",
99
sortable: false,
10-
conditions: 'parent_id IS NULL'
10+
conditions: 'parent_id IS NULL',
11+
find_actions: [:update, :destroy, :edit]
1112

1213
before_action :change_view_if_specified, :init_dialog
1314

images/app/presenters/refinery/admin/image_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ImagePresenter < Refinery::BasePresenter
6767
attr_reader :image, :context, :index_keys, :i18n_scope
6868
attr_writer :title, :alt, :filename, :translations, :edit_attributes, :delete_attributes, :preview_attributes
6969
delegate_missing_to :image
70+
delegate :t, to: :context
7071

7172
IndexEntry = Struct.new('ImageEntry', :id, :edit_link, :text_elements, :locales, :actions)
7273

images/lib/refinery/images/configuration.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Images
66

77
config_accessor :max_image_size, :pages_per_dialog, :pages_per_admin_index,
88
:pages_per_dialog_that_have_size_options, :user_image_sizes, :user_image_ratios,
9-
:image_views, :preferred_image_view, :admin_image_sizes,
9+
:index_views, :preferred_index_view, :admin_image_sizes,
1010
:allowed_mime_types, :allowed_mime_types_msg
1111

1212
self.max_image_size = 5_242_880
@@ -29,8 +29,8 @@ module Images
2929
}
3030
self.allowed_mime_types = %w[image/jpeg image/png image/gif image/tiff]
3131
self.allowed_mime_types_msg = self.allowed_mime_types.to_sentence(last_word_connector: ' or ')
32-
self.image_views = [:grid, :list]
33-
self.preferred_image_view = :grid
32+
self.index_views = [:grid, :list]
33+
self.preferred_index_view = :grid
3434

3535
# Images should always use these changes to the dragonfly defaults
3636
self.dragonfly_name = :refinery_images

pages/app/controllers/refinery/pages/admin/preview_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class PreviewController < Refinery::PagesController
99
include Pages::RenderOptions
1010

1111
skip_before_action :error_404, :set_canonical
12+
skip_after_action :store_location?, raise: false
1213

1314
layout :layout
1415

0 commit comments

Comments
 (0)