Temp fix for tools endpoint
parent
3e90e9e792
commit
56449bb1f0
|
@ -31,7 +31,15 @@ private
|
|||
end
|
||||
|
||||
def create_params
|
||||
{name: params[:name], tool_slot: tool_slot }
|
||||
if @create_params
|
||||
@create_params
|
||||
else
|
||||
tsid = params[:tool_slot_id]
|
||||
@create_params = { name: params[:name],
|
||||
device: current_device }
|
||||
@create_params[:tool_slot_id] = tsid if tsid
|
||||
@create_params
|
||||
end
|
||||
end
|
||||
|
||||
def q
|
||||
|
|
|
@ -2,11 +2,25 @@ module Tools
|
|||
class Create < Mutations::Command
|
||||
required do
|
||||
string :name
|
||||
model :tool_slot, class: ToolSlot
|
||||
model :device, class: Device
|
||||
end
|
||||
|
||||
optional do
|
||||
integer :tool_slot_id
|
||||
end
|
||||
|
||||
def validate
|
||||
puts "TODO: Validate user authorizations"
|
||||
end
|
||||
|
||||
def execute
|
||||
Tool.create!(inputs)
|
||||
Tool.create!(inputs.except(:device))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def query
|
||||
@query ||= ToolBay::DeviceQuery.new(device)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue