Class: Scrivito::ObjsController
- Inherits:
-
WebserviceController
- Object
- ActionController::Base
- WebserviceController
- Scrivito::ObjsController
- Defined in:
- app/controllers/scrivito/objs_controller.rb
Instance Method Summary collapse
- #binary_no_cache ⇒ Object
- #conflicting_workspaces ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #details ⇒ Object
- #page_class_selection ⇒ Object
- #restore ⇒ Object
- #restore_widget ⇒ Object
- #revert ⇒ Object
- #revert_widget ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #transfer_modifications ⇒ Object
- #update ⇒ Object
- #widget ⇒ Object
- #widget_class_selection ⇒ Object
Instance Method Details
#binary_no_cache ⇒ Object
83 84 85 86 87 88 |
# File 'app/controllers/scrivito/objs_controller.rb', line 83 def binary_no_cache in_selected_workspace do binary = current_obj[params[:attribute_name]] @no_cache_url = binary.no_cache_url end end |
#conflicting_workspaces ⇒ Object
78 79 80 81 |
# File 'app/controllers/scrivito/objs_controller.rb', line 78 def conflicting_workspaces @workspaces = selected_workspace.conflict_warning_for(params[:id]) render :workspaces end |
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/scrivito/objs_controller.rb', line 28 def create params_parser = ObjCreateParamsParser.new(request.host, request.port) @obj = Obj.create(params_parser.parse(params[:obj]), scrivito_user: scrivito_user) render :obj rescue ObjClassNotFound => e raise ClientError.new( "You've tried to create a CMS object based on the \"#{e.message}\" class, which is "\ "either missing or not suitable for the object." ) end |
#destroy ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/controllers/scrivito/objs_controller.rb', line 50 def destroy in_selected_workspace do parent = current_obj.parent @redirect_to = parent ? scrivito_path(parent) : "/" current_obj.destroy end end |
#details ⇒ Object
39 40 41 42 |
# File 'app/controllers/scrivito/objs_controller.rb', line 39 def details assert_dialog_layout render current_obj.details_view_path, layout: 'scrivito_dialog', formats: :html end |
#page_class_selection ⇒ Object
106 107 108 109 110 |
# File 'app/controllers/scrivito/objs_controller.rb', line 106 def page_class_selection @page_class_markup = valid_page_classes.map do |page_class_name| build_selection_option(page_class_name) end end |
#restore ⇒ Object
68 69 70 71 |
# File 'app/controllers/scrivito/objs_controller.rb', line 68 def restore in_selected_workspace { Obj.restore(params[:id]) } render_empty_json end |
#restore_widget ⇒ Object
73 74 75 76 |
# File 'app/controllers/scrivito/objs_controller.rb', line 73 def in_selected_workspace { current_obj.(params[:widget_id]) } render_empty_json end |
#revert ⇒ Object
58 59 60 61 |
# File 'app/controllers/scrivito/objs_controller.rb', line 58 def revert in_selected_workspace { current_obj.revert } render_empty_json end |
#revert_widget ⇒ Object
63 64 65 66 |
# File 'app/controllers/scrivito/objs_controller.rb', line 63 def in_selected_workspace { .revert } render_empty_json end |
#search ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'app/controllers/scrivito/objs_controller.rb', line 120 def search in_selected_workspace do @query = MultiJson.decode(params[:query]).with_indifferent_access @enumerator = ObjSearchBuilder.new(@query).build if params[:query_action] == 'size' return render action: 'search/size' end unless @formatter = fetch_formatter(@query[:format]) return render action: 'search/missing_formatter', status: :not_found end if facet_params = params[:facet] attribute, = MultiJson.decode(facet_params).values_at('attribute', 'options') @facets = @enumerator.facet(attribute, || {}) return render action: 'search/facet' end @batch = @enumerator.fetch_batch(params[:continuation]) render :search end end |
#show ⇒ Object
20 21 22 |
# File 'app/controllers/scrivito/objs_controller.rb', line 20 def show in_selected_workspace { render } end |
#transfer_modifications ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/controllers/scrivito/objs_controller.rb', line 90 def transfer_modifications in_selected_workspace do begin obj = Obj.find_including_deleted(params[:id]) workspace = Workspace.find(params[:workspace_id]) (:write, workspace) do obj.transfer_modifications_to(workspace) end rescue TransferModificationsModifiedError @error_reason = :modified rescue TransferModificationsConflictError @error_reason = :conflict end end end |
#update ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/scrivito/objs_controller.rb', line 44 def update params_parser = ObjUpdateParamsParser.new(request.host, request.port, current_obj: current_obj, scrivito_user: scrivito_user) current_obj.update(params_parser.parse(params[:obj])) end |
#widget ⇒ Object
24 25 26 |
# File 'app/controllers/scrivito/objs_controller.rb', line 24 def in_selected_workspace { render } end |
#widget_class_selection ⇒ Object
112 113 114 115 116 117 118 |
# File 'app/controllers/scrivito/objs_controller.rb', line 112 def load_obj = .map do || build_selection_option() end end |