Class: Admin::ComponentsController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::ComponentsController
- Includes:
- ProcessedForms
- Defined in:
- app/controllers/admin/components_controller.rb
Overview
Handling components
Instance Method Summary collapse
-
#ckeditor ⇒ Object
post /admin/components/:slug/ckeditor.
-
#create_image ⇒ Object
post /admin/components/:slug/images.
-
#delete_parameter ⇒ Object
delete /admin/components/:slug/parameters/:parameter_slug.
-
#images ⇒ Object
get /admin/components/:slug/images.
-
#index ⇒ Object
get /admin/components.
-
#settings ⇒ Object
get /admin/components/:slug/settings.
-
#show ⇒ Object
get /admin/components/:slug.
-
#update_parameter ⇒ Object
patch /admin/components/:slug/parameters.
-
#update_settings ⇒ Object
patch /admin/components/:slug/settings.
Instance Method Details
#ckeditor ⇒ Object
post /admin/components/:slug/ckeditor
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/admin/components_controller.rb', line 72 def ckeditor parameters = { image: params[:upload], biovision_component: @handler.component }.merge(owner_for_entity(true)) @entity = @handler.upload_image(parameters) render json: { uploaded: 1, fileName: File.basename(@entity.image.path), url: @entity.image.medium_url } end |
#create_image ⇒ Object
post /admin/components/:slug/images
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/admin/components_controller.rb', line 58 def create_image if @handler.permit?('simple_images.create') @entity = @handler.upload_image(image_parameters) if @entity render 'image', formats: :json else form_processed_with_error(:new_image) end else handle_http_401('Uploading images is not allowed for current user') end end |
#delete_parameter ⇒ Object
delete /admin/components/:slug/parameters/:parameter_slug
44 45 46 47 48 49 |
# File 'app/controllers/admin/components_controller.rb', line 44 def delete_parameter @handler.component.parameters.delete(params[:parameter_slug]) @handler.component.save head :no_content end |
#images ⇒ Object
get /admin/components/:slug/images
52 53 54 55 |
# File 'app/controllers/admin/components_controller.rb', line 52 def images list = SimpleImage.in_component(@handler.component).list_for_administration @collection = list.page(current_page) end |
#index ⇒ Object
get /admin/components
11 12 13 |
# File 'app/controllers/admin/components_controller.rb', line 11 def index @collection = BiovisionComponent.active.list_for_administration end |
#settings ⇒ Object
get /admin/components/:slug/settings
22 23 |
# File 'app/controllers/admin/components_controller.rb', line 22 def settings end |
#show ⇒ Object
get /admin/components/:slug
16 17 18 19 |
# File 'app/controllers/admin/components_controller.rb', line 16 def show error = 'Viewing component is not allowed' handle_http_401(error) unless @handler.permit?('view') end |
#update_parameter ⇒ Object
patch /admin/components/:slug/parameters
34 35 36 37 38 39 40 41 |
# File 'app/controllers/admin/components_controller.rb', line 34 def update_parameter slug = param_from_request(:key, :slug).downcase value = param_from_request(:key, :value) @handler[slug] = value head :no_content end |
#update_settings ⇒ Object
patch /admin/components/:slug/settings
26 27 28 29 30 31 |
# File 'app/controllers/admin/components_controller.rb', line 26 def update_settings new_settings = params.dig(:component, :settings).permit! @handler.settings = new_settings.to_h flash[:success] = t('.success') redirect_to(admin_component_settings_path(slug: params[:slug])) end |