mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
allow ordering categories in the edit category ui
This commit is contained in:
parent
f0862a5c2e
commit
e7a037709f
5 changed files with 26 additions and 12 deletions
|
@ -57,7 +57,8 @@ Discourse.Category = Discourse.Model.extend({
|
||||||
hotness: this.get('hotness'),
|
hotness: this.get('hotness'),
|
||||||
secure: this.get('secure'),
|
secure: this.get('secure'),
|
||||||
permissions: this.get('permissionsForUpdate'),
|
permissions: this.get('permissionsForUpdate'),
|
||||||
auto_close_days: this.get('auto_close_days')
|
auto_close_days: this.get('auto_close_days'),
|
||||||
|
position: this.get('position')
|
||||||
},
|
},
|
||||||
type: this.get('id') ? 'PUT' : 'POST'
|
type: this.get('id') ? 'PUT' : 'POST'
|
||||||
});
|
});
|
||||||
|
|
|
@ -86,6 +86,11 @@
|
||||||
{{autoCloseForm autoCloseDays=auto_close_days labelKey="category.auto_close_label"}}
|
{{autoCloseForm autoCloseDays=auto_close_days labelKey="category.auto_close_label"}}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class='field'>
|
||||||
|
<label>{{i18n category.position}}</label>
|
||||||
|
{{textField value=position}}
|
||||||
|
</section>
|
||||||
|
|
||||||
<section class='field'>
|
<section class='field'>
|
||||||
<label>{{i18n category.hotness}}</label>
|
<label>{{i18n category.hotness}}</label>
|
||||||
{{view Discourse.HotnessView hotnessBinding="hotness"}}
|
{{view Discourse.HotnessView hotnessBinding="hotness"}}
|
||||||
|
|
|
@ -52,12 +52,17 @@ class CategoriesController < ApplicationController
|
||||||
@category = Category.create(category_params.merge(user: current_user))
|
@category = Category.create(category_params.merge(user: current_user))
|
||||||
return render_json_error(@category) unless @category.save
|
return render_json_error(@category) unless @category.save
|
||||||
|
|
||||||
|
@category.move_to(category_params[:position].to_i) if category_params[:position]
|
||||||
|
|
||||||
render_serialized(@category, CategorySerializer)
|
render_serialized(@category, CategorySerializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
guardian.ensure_can_edit!(@category)
|
guardian.ensure_can_edit!(@category)
|
||||||
json_result(@category, serializer: CategorySerializer) { |cat| cat.update_attributes(category_params) }
|
json_result(@category, serializer: CategorySerializer) { |cat|
|
||||||
|
cat.update_attributes(category_params)
|
||||||
|
cat.move_to(category_params[:position].to_i) if category_params[:position]
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -74,6 +79,7 @@ class CategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def category_params
|
def category_params
|
||||||
|
@category_params ||= begin
|
||||||
required_param_keys.each do |key|
|
required_param_keys.each do |key|
|
||||||
params.require(key)
|
params.require(key)
|
||||||
end
|
end
|
||||||
|
@ -84,7 +90,8 @@ class CategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
params.permit(*required_param_keys, :hotness, :auto_close_days, :permissions => [*p.try(:keys)])
|
params.permit(*required_param_keys, :position, :hotness, :auto_close_days, :permissions => [*p.try(:keys)])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_category
|
def fetch_category
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class CategorySerializer < BasicCategorySerializer
|
class CategorySerializer < BasicCategorySerializer
|
||||||
|
|
||||||
attributes :read_restricted, :available_groups, :auto_close_days, :group_permissions
|
attributes :read_restricted, :available_groups, :auto_close_days, :group_permissions, :position
|
||||||
|
|
||||||
def group_permissions
|
def group_permissions
|
||||||
@group_permissions ||= begin
|
@group_permissions ||= begin
|
||||||
|
|
|
@ -975,6 +975,7 @@ en:
|
||||||
edit_permissions: "Edit Permissions"
|
edit_permissions: "Edit Permissions"
|
||||||
add_permission: "Add Permission"
|
add_permission: "Add Permission"
|
||||||
this_year: "this year"
|
this_year: "this year"
|
||||||
|
position: "position"
|
||||||
|
|
||||||
flagging:
|
flagging:
|
||||||
title: 'Why are you flagging this post?'
|
title: 'Why are you flagging this post?'
|
||||||
|
|
Loading…
Reference in a new issue