Class: TrayPositionsController
- Inherits:
-
FassetsCore::ApplicationController
- Object
- ActionController::Base
- FassetsCore::ApplicationController
- TrayPositionsController
- Defined in:
- app/controllers/tray_positions_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#index ⇒ Object
redirect_to :back.
-
#replace ⇒ Object
redirect_to :back.
Instance Method Details
#create ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/tray_positions_controller.rb', line 3 def create if current_user.tray_positions.maximum(:position) params[:tray_position][:position] = current_user.tray_positions.maximum(:position)+1 else params[:tray_position][:position] = 1 end tp = TrayPosition.new(params[:tray_position]) tp.clipboard_type.capitalize! if tp.clipboard_type tp.save render :nothing => true #redirect_to :back end |
#destroy ⇒ Object
18 19 20 21 22 23 |
# File 'app/controllers/tray_positions_controller.rb', line 18 def destroy tp = TrayPosition.find(params[:id]) tp.destroy() render :nothing => true #redirect_to :back end |
#index ⇒ Object
redirect_to :back
15 16 17 |
# File 'app/controllers/tray_positions_controller.rb', line 15 def index render :partial => "shared/tray" end |
#replace ⇒ Object
redirect_to :back
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/tray_positions_controller.rb', line 24 def replace respond_to do |format| if params[:del] format.html do current_user.tray_positions.find(params[:del]).each do |tp| # if !tp.clipboard_type && (tp.asset.classifications_count || 0) == 0 # tp.asset.content.destroy # else # tp.destroy # end tp.destroy end flash[:notice] = "Tray has been updated!" redirect_to :back end end if params[:tp] format.json do new_tp = nil params[:tp].each_with_index do |id, position| if id == "0" new_tp = TrayPosition.new(:user_id => current_user.id, :position => position+1) if params[:add_type] == 'asset' new_tp.asset_id = params[:add_id] else new_tp.clipboard_id = params[:add_id] new_tp.clipboard_type = params[:add_type].capitalize end new_tp.save else TrayPosition.update(id, :position => position+1) end end if new_tp render :json => new_tp.to_json(:include => :clipboard) else render :json => {} end end end if params["asset_id"] and params["asset_id"] != "undefined" unless TrayPosition.where(:user_id => current_user.id, :asset_id => params["asset_id"]).exists? if current_user.tray_positions.maximum(:position) position = current_user.tray_positions.maximum(:position)+1 else position = 1 end new_tp = TrayPosition.new(:user_id => current_user.id, :asset_id => params["asset_id"],:position => position) new_tp.save end end format.html do #redirect_to :back end end end |