2010-02-01 09:24:28 +00:00
|
|
|
class Admin::AssetsController < ApplicationController
|
|
|
|
|
|
|
|
layout "admin"
|
2010-03-04 08:33:26 +00:00
|
|
|
before_filter :authenticate_user!
|
2011-04-13 10:19:51 +00:00
|
|
|
before_filter :is_admin?
|
2010-02-01 09:24:28 +00:00
|
|
|
|
2011-04-13 10:19:51 +00:00
|
|
|
def index
|
|
|
|
@assets = Asset.all.entries
|
2010-02-01 09:24:28 +00:00
|
|
|
end
|
|
|
|
|
2011-04-13 10:19:51 +00:00
|
|
|
def show
|
|
|
|
#TODO
|
2010-02-01 09:24:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@asset = Asset.new
|
2011-12-28 12:49:53 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html {}
|
|
|
|
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/new'} }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@asset = Asset.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {}
|
|
|
|
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/edit'} }
|
|
|
|
end
|
2010-02-01 09:24:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@asset = Asset.new(params[:asset])
|
|
|
|
if @asset.save
|
2011-12-28 12:49:53 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to admin_assets_url }
|
|
|
|
format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'append', :id => 'asset_tbody', :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} }
|
|
|
|
end
|
2010-02-01 09:24:28 +00:00
|
|
|
else
|
2011-12-28 12:49:53 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { render :action => :new }
|
2011-12-29 06:09:06 +00:00
|
|
|
format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}} }
|
2011-12-28 12:49:53 +00:00
|
|
|
end
|
2010-02-01 09:24:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@asset = Asset.find(params[:id])
|
|
|
|
if @asset.update_attributes(params[:asset])
|
2011-12-28 12:49:53 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to admin_assets_url }
|
|
|
|
format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} }
|
|
|
|
end
|
2010-02-01 09:24:28 +00:00
|
|
|
else
|
2011-12-28 12:49:53 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { render :action => :edit }
|
2011-12-29 06:09:06 +00:00
|
|
|
format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} }
|
2011-12-28 12:49:53 +00:00
|
|
|
end
|
2010-02-01 09:24:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@asset = Asset.find(params[:id])
|
|
|
|
@asset.destroy
|
2011-12-28 12:49:53 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.js { render 'js/remove_element', :locals => {:id => "asset_#{@asset.id}"} }
|
|
|
|
end
|
2010-02-01 09:24:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|