Class: CatalogsController
- Inherits:
-
FassetsCore::ApplicationController
- Object
- ActionController::Base
- FassetsCore::ApplicationController
- CatalogsController
- Defined in:
- app/controllers/catalogs_controller.rb
Instance Method Summary collapse
- #add_asset ⇒ Object
- #box_content ⇒ Object
- #box_facet ⇒ Object
- #catalog_box ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#add_asset ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/catalogs_controller.rb', line 62 def add_asset @catalog = Catalog.find(params[:catalog_id]) if Classification.where(:catalog_id => params[:catalog_id], :asset_id => params[:asset_id]).exists? flash[:error] = "Asset already in catalog!" redirect_to :back return end classification = Classification.new(:catalog_id => params[:catalog_id], :asset_id => params[:asset_id]); if classification.save flash[:notice] = "Asset successfully added to catalog" else flash[:error] = "Could not add asset to catalog" end redirect_to catalog_path(@catalog) end |
#box_content ⇒ Object
88 89 90 91 92 93 |
# File 'app/controllers/catalogs_controller.rb', line 88 def box_content @filter = LabelFilter.new(params[:filter]) @assets = @catalog.assets.filter(@filter) @counts = 0 render :partial => "box_content" end |
#box_facet ⇒ Object
94 95 96 97 98 |
# File 'app/controllers/catalogs_controller.rb', line 94 def box_facet @filter = LabelFilter.new(params[:filter]) @counts = 0 render :partial => "box_facet", :collection => @catalog.facets, :as => :facet end |
#catalog_box ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/catalogs_controller.rb', line 77 def catalog_box if params[:id] @catalog = Catalog.find(params[:id]) else @catalog = Catalog.first end @filter = LabelFilter.new(params[:filter]) @assets = @catalog.assets.filter(@filter) @counts = 0 render :template => "catalogs/box", :layout => false, :locals => {:selected_catalog => @catalog.id} end |
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/catalogs_controller.rb', line 17 def create @catalog = Catalog.new(params[:catalog]) if @catalog.save create_type_facet() respond_to do |format| format.html do flash[:notice] = "Catalog was successfully created." redirect_to catalogs_path end format.js { render :nothing => true } end else respond_to do |format| format.html do if params[:catalog][:title].blank? flash[:error] = "Catalog could not be created! Title cannot be empty!" else flash[:error] = "Catalog could not be created!" end render :template => 'catalogs/index' end format.js { render :json => {:errors => @catalog.errors.}.to_json, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/catalogs_controller.rb', line 57 def destroy @catalog.destroy flash[:notice] = "Catalog was successfully destroyed." redirect_to root_url end |
#edit ⇒ Object
42 43 44 |
# File 'app/controllers/catalogs_controller.rb', line 42 def edit @catalog = Catalog.find(params[:id]) end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/catalogs_controller.rb', line 5 def index @catalogs = Catalog.all end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/catalogs_controller.rb', line 14 def new @catalog = Catalog.new end |
#show ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/catalogs_controller.rb', line 8 def show @filter = LabelFilter.new(params[:filter]) @assets = @catalog.assets.filter(@filter) @counts = 0 logger.debug "Flash:"+flash.to_s end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/catalogs_controller.rb', line 45 def update if params[:catalog][:title].blank? flash[:error] = "Catalog could not be updated! Title cannot be empty!" redirect_to :back return end if @catalog.update_attributes(params[:catalog]) redirect_to catalog_path(@catalog) else render :action => 'edit' end end |