app/controllers/scrivito/objs_controller.rb in scrivito_sdk-0.60.0.rc1 vs app/controllers/scrivito/objs_controller.rb in scrivito_sdk-0.60.0.rc2
- old
+ new
@@ -96,31 +96,19 @@
render :obj
end
def page_class_selection
@page_class_markup = valid_page_classes.map do |page_class_name|
- begin
- markup = render_to_string("#{page_class_name.underscore}/thumbnail", formats: :html)
- {name: page_class_name, markup: markup}
- rescue ActionView::MissingTemplate
- end
+ build_selection_option(page_class_name)
end
- @page_class_markup.compact!
end
def widget_class_selection
load_obj
@widgets_classes = valid_widget_classes.map do |widget_class_name|
- template_path = "#{widget_class_name.underscore}/thumbnail"
- markup = begin
- render_to_string(template_path, layout: false, formats: :html)
- rescue ActionView::MissingTemplate
- render_to_string('scrivito/widget_thumbnail', layout: false, formats: :html,
- locals: {widget_class_name: widget_class_name, template_path: template_path})
- end
- {name: widget_class_name, markup: markup}
+ build_selection_option(widget_class_name)
end
end
def search
in_selected_workspace do
@@ -186,24 +174,36 @@
def fetch_formatter(name)
name ? Configuration.obj_formats[name] : proc { |obj, _| obj.id }
end
+ def build_selection_option(class_name)
+ template_path = "#{class_name.underscore}/thumbnail"
+ markup = begin
+ render_to_string(template_path, layout: false, formats: :html)
+ rescue ActionView::MissingTemplate
+ render_to_string('scrivito/fallback_thumbnail', layout: false, formats: :html,
+ locals: {class_name: class_name, template_path: template_path})
+ end
+ {name: class_name, markup: markup}
+ end
+
def valid_page_classes
- (page_classes_from_obj || page_descendants).map(&:to_s)
+ without_hidden_classes(page_classes_from_obj).map(&:to_s)
end
def page_classes_from_obj
- Obj.valid_page_classes_beneath(params[:parent_path])
+ Obj.valid_page_ruby_classes_beneath(params[:parent_path])
end
- def page_descendants
- Scrivito.models.pages
+ def valid_widget_classes
+ widget_classes = current_widget_or_obj.valid_widget_ruby_classes_for(params[:field_name])
+
+ without_hidden_classes(widget_classes).map(&:to_s)
end
- def valid_widget_classes
- current_widget_or_obj.valid_widget_class_names_for(params[:field_name]) -
- ['Scrivito::ContentWidget']
+ def without_hidden_classes(obj_types)
+ obj_types.reject(&:hide_from_editor?)
end
def current_widget_or_obj
widget_id = params[:widget_id]
(widget_id && current_obj.widgets[widget_id]) || current_obj