Sha256: c1ec5cf60d5faf0fd6eb5cf6c8b8a77d440932d39dcb2eddbdb35aa27d02c4d4
Contents?: true
Size: 1.33 KB
Versions: 56
Compression:
Stored size: 1.33 KB
Contents
module Pageflow module Editor class WidgetsController < Pageflow::ApplicationController respond_to :json before_action :authenticate_user! def index subject = find_subject authorize!(:index_widgets_for, subject.to_model) @widgets = subject.resolve_widgets(include_placeholders: true) respond_with(@widgets) end def batch subject = find_subject authorize!(:edit, subject.to_model) subject.widgets.batch_update!(widget_batch_params) render(json: {}) end private def widget_batch_params widget_configurations = params.fetch(:widgets, []).map do |widget_params| widget_params[:configuration].try(:permit!) end params .permit(widgets: [:role, :type_name]) .fetch(:widgets, []) .zip(widget_configurations) .map do |(widget_params, widget_configuration)| if widget_configuration widget_params.merge(configuration: widget_configuration) else widget_params end end end def find_subject if params[:collection_name] == 'entries' DraftEntry.find(params[:subject_id]) else Theming.find(params[:subject_id]) end end end end end
Version data entries
56 entries across 56 versions & 1 rubygems