2013-03-01 01:16:04 +00:00
|
|
|
class MappingsController < ApplicationController
|
2013-03-01 01:41:30 +00:00
|
|
|
respond_to :js, :html
|
|
|
|
|
2013-03-01 00:56:27 +00:00
|
|
|
# GET mappings
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET mappings/new
|
|
|
|
def new
|
|
|
|
@mapping = Mapping.new
|
|
|
|
@user = current_user
|
|
|
|
respond_with(@mapping)
|
|
|
|
end
|
|
|
|
|
|
|
|
# POST mappings
|
|
|
|
def create
|
2013-03-01 01:56:57 +00:00
|
|
|
@user = current_user
|
|
|
|
if @user
|
|
|
|
@mapping = Mapping.new()
|
|
|
|
|
|
|
|
@mapping.user = @user
|
|
|
|
@mapping.xloc = params[:xloc] if params[:xloc]
|
|
|
|
@mapping.yloc = params[:yloc] if params[:yloc]
|
|
|
|
|
|
|
|
if params[:map]
|
|
|
|
if params[:map][:id]
|
|
|
|
@map = Map.find(params[:map][:id])
|
|
|
|
@mapping.map = @map
|
|
|
|
end
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
2013-03-01 01:56:57 +00:00
|
|
|
if params[:topic]
|
|
|
|
if params[:topic][:id]
|
|
|
|
@topic = Topic.find(params[:topic][:id])
|
|
|
|
@mapping.topic = @topic
|
|
|
|
@mapping.category = "Topic"
|
|
|
|
end
|
|
|
|
elsif params[:synapse]
|
|
|
|
if params[:synapse][:id]
|
|
|
|
@topic = Synapse.find(params[:synapse][:id])
|
|
|
|
@mapping.synapse = @synapse
|
|
|
|
@mapping.category = "Synapse"
|
|
|
|
end
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
2013-03-01 01:56:57 +00:00
|
|
|
@mapping.save()
|
2013-04-26 04:07:29 +00:00
|
|
|
|
|
|
|
#push add to map to realtime viewers of the map
|
|
|
|
@mapping.message 'create',@user.id
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /mappings/:id
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /mappings/:id/edit
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
# PUT /mappings/:id
|
|
|
|
def update
|
|
|
|
end
|
|
|
|
|
|
|
|
# DELETE /mappings/:id
|
|
|
|
def destroy
|
|
|
|
end
|
|
|
|
end
|