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.15 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.36 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.35 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.34 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.33 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.32 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.31 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.30 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.29 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.6 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.4.28 app/controllers/workarea/admin/content_assets_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/content_assets_controller.rb