Class: Admin::ComponentsController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::ComponentsController
- 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
-
#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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/admin/components_controller.rb', line 69 def ckeditor parameters = { image: params[:upload], biovision_component: @handler.component }.merge(owner_for_entity(true)) @entity = SimpleImage.create!(parameters) render json: { uploaded: 1, fileName: File.basename(@entity.image.path), url: @entity.image.medium_url } end |
#create_image ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/admin/components_controller.rb', line 55 def create_image if @handler.permit?('simple_images.create') @entity = @handler.component.simple_images.new(image_parameters) if @entity.save 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
42 43 44 45 46 47 |
# File 'app/controllers/admin/components_controller.rb', line 42 def delete_parameter @handler.component.parameters.delete(params[:parameter_slug]) @handler.component.save head :no_content end |
#images ⇒ Object
get /admin/components/:slug/images
50 51 52 53 |
# File 'app/controllers/admin/components_controller.rb', line 50 def images list = SimpleImage.in_component(@handler.component).list_for_administration @collection = list.page(current_page) end |
#index ⇒ Object
get /admin/components
9 10 11 |
# File 'app/controllers/admin/components_controller.rb', line 9 def index @collection = BiovisionComponent.list_for_administration end |
#settings ⇒ Object
get /admin/components/:slug/settings
20 21 |
# File 'app/controllers/admin/components_controller.rb', line 20 def settings end |
#show ⇒ Object
get /admin/components/:slug
14 15 16 17 |
# File 'app/controllers/admin/components_controller.rb', line 14 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
32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/components_controller.rb', line 32 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
24 25 26 27 28 29 |
# File 'app/controllers/admin/components_controller.rb', line 24 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 |