Allow categories with null position, which means sort them based on activity. Mix absolutely positioned (position is not null) categories with null position categories.

This commit is contained in:
Neil Lalonde
2013-12-16 15:13:43 -05:00
parent f1a7b63afc
commit 341adc93a4
11 changed files with 154 additions and 43 deletions

View File

@ -60,7 +60,9 @@ class CategoriesController < ApplicationController
def update
guardian.ensure_can_edit!(@category)
json_result(@category, serializer: CategorySerializer) { |cat|
cat.move_to(category_params[:position].to_i) if category_params[:position]
if category_params[:position]
category_params[:position] == 'default' ? cat.use_default_position : cat.move_to(category_params[:position].to_i)
end
category_params.delete(:position)
cat.update_attributes(category_params)
}