Sha256: 914d62a79276964758ee081e3445e36a84106cdddf7ef9d6e92dff8135bc3a06

Contents?: true

Size: 1.64 KB

Versions: 51

Compression:

Stored size: 1.64 KB

Contents

module Workarea
  class Admin::ContentAssetsController < Admin::ApplicationController
    required_permissions :store

    before_action :find_asset, only: [:show, :edit, :update, :destroy]
    before_action :new_asset, only: [:new, :create]
    after_action :track_index_filters, only: :index

    def index
      DirectUpload.ensure_cors!(request.url) if Configuration::S3.configured?

      search = Search::AdminAssets.new(params)
      @search = Admin::SearchViewModel.new(search, view_model_options)
    end
    alias_method :insert, :index

    def tags
      @tags = if Content::Asset.empty?
                []
              else
                Content::Asset.all_tags(type: params[:type])
              end
    end

    def show
    end

    def new; end

    def create
      if @asset.save
        flash[:success] = t('workarea.admin.content_assets.flash_messages.created')
        redirect_to content_asset_path(@asset)
      else
        render :new, status: :unprocessable_entity
      end
    end

    def edit; end

    def update
      if @asset.update_attributes(params[:asset])
        flash[:success] = t('workarea.admin.content_assets.flash_messages.saved')
        redirect_to content_asset_path(@asset)
      else
        render :edit, status: :unprocessable_entity
      end
    end

    def destroy
      @asset.destroy
      flash[:success] = t('workarea.admin.content_assets.flash_messages.removed')
      redirect_to content_assets_path
    end

    private

    def new_asset
      @asset = Content::Asset.new(params[:asset])
    end

    def find_asset
      @asset = Admin::AssetViewModel.new(Content::Asset.find(params[:id]))
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.45 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.44 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.43 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.42 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.41 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.40 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.39 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.38 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.37 app/controllers/workarea/admin/content_assets_controller.rb