|
|
@ -9,7 +9,7 @@ class Admins::TagDisciplinesController < Admins::BaseController
|
|
|
|
name = params[:name].to_s.strip
|
|
|
|
name = params[:name].to_s.strip
|
|
|
|
return render_error('名称重复') if current_sub_discipline.tag_disciplines.where(name: name).exists?
|
|
|
|
return render_error('名称重复') if current_sub_discipline.tag_disciplines.where(name: name).exists?
|
|
|
|
TagDiscipline.create!(name: name, sub_discipline_id: current_sub_discipline.id, user_id: current_user.id,
|
|
|
|
TagDiscipline.create!(name: name, sub_discipline_id: current_sub_discipline.id, user_id: current_user.id,
|
|
|
|
position: current_sub_discipline.tag_disciplines.pluck(:position).max + 1)
|
|
|
|
position: current_sub_discipline.tag_disciplines.pluck(:position).max.to_i + 1)
|
|
|
|
render_ok
|
|
|
|
render_ok
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +42,7 @@ class Admins::TagDisciplinesController < Admins::BaseController
|
|
|
|
|
|
|
|
|
|
|
|
def adjust_position
|
|
|
|
def adjust_position
|
|
|
|
sub_discipline = current_tag_discipline.sub_discipline
|
|
|
|
sub_discipline = current_tag_discipline.sub_discipline
|
|
|
|
max_position = sub_discipline.tag_disciplines.pluck(:position).max
|
|
|
|
max_position = sub_discipline.tag_disciplines.pluck(:position).max.to_i
|
|
|
|
opr = params[:opr] || "down"
|
|
|
|
opr = params[:opr] || "down"
|
|
|
|
if (params[:opr] == "up" && current_tag_discipline.position == 1) || (params[:opr] == "down" && current_tag_discipline.position == max_position)
|
|
|
|
if (params[:opr] == "up" && current_tag_discipline.position == 1) || (params[:opr] == "down" && current_tag_discipline.position == max_position)
|
|
|
|
@message = "超出范围"
|
|
|
|
@message = "超出范围"
|
|
|
|