2016-12-05 18:34:36 +08:00
|
|
|
class UserSamplesController < ApplicationController
|
|
|
|
def save_samples_table_status
|
|
|
|
samples_table = SamplesTable.where(user: @current_user,
|
2017-01-24 23:57:14 +08:00
|
|
|
team: params[:team])
|
2016-12-05 18:34:36 +08:00
|
|
|
if samples_table
|
|
|
|
samples_table.first.update(status: params[:state])
|
|
|
|
else
|
|
|
|
SamplesTable.create(user: @current_user,
|
2017-01-24 23:57:14 +08:00
|
|
|
team: params[:team],
|
2016-12-05 18:34:36 +08:00
|
|
|
status: params[:state])
|
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
status: :ok
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_samples_table_status
|
|
|
|
@samples_table_state = SamplesTable.find_status(current_user,
|
2017-01-24 23:57:14 +08:00
|
|
|
current_team).first
|
2016-12-13 17:56:13 +08:00
|
|
|
|
2016-12-05 18:34:36 +08:00
|
|
|
respond_to do |format|
|
|
|
|
if @samples_table_state
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
state: @samples_table_state
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|