FIX: Several fixes related to category reorder

- Move "New Category" and "Reorder Categories" into a dropdown
 - Always show "New Topic" on categories page, even for admins
 - Make category reorder modal full-height (.full-height-modal)
 - Move category reorder stylesheet out of admin stylesheet
This commit is contained in:
Kane York 2015-09-10 13:42:10 -07:00
parent 0c5fb207e9
commit c038758f8c
8 changed files with 80 additions and 44 deletions

View File

@ -0,0 +1,37 @@
import { iconHTML } from 'discourse/helpers/fa-icon';
import DropdownButton from 'discourse/components/dropdown-button';
import computed from "ember-addons/ember-computed-decorators";
export default DropdownButton.extend({
buttonExtraClasses: 'no-text',
title: '',
text: iconHTML('bars') + ' ' + iconHTML('caret-down'),
classNames: ['category-notification-menu', 'category-admin-menu'],
@computed()
dropDownContent() {
const includeReorder = this.get('siteSettings.fixed_category_positions');
const items = [
{ id: 'createCategory',
title: I18n.t('category.create'),
description: I18n.t('category.create_long'),
styleClasses: 'fa fa-plus' }
];
if (includeReorder) {
items.push({
id: 'reorderCategories',
title: I18n.t('categories.reorder.title'),
description: I18n.t('categories.reorder.title_long'),
styleClasses: 'fa fa-random'
});
}
return items;
},
// sendAction() is pretty silly if you ask me
actionFor_createCategory: 'createCategory',
actionFor_reorderCategories: 'reorderCategories',
clicked(id) {
this.sendAction('actionFor_' + id);
}
});

View File

@ -29,9 +29,7 @@ export default Ember.Component.extend(StringBuffer, {
buffer.push("<h4 class='title'>" + title + "</h4>"); buffer.push("<h4 class='title'>" + title + "</h4>");
} }
buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>"); buffer.push(`<button class='btn standard dropdown-toggle ${this.get('buttonExtraClasses')}' data-toggle='dropdown'>${this.get('text')}</button>`);
buffer.push(this.get('text'));
buffer.push("</button>");
buffer.push("<ul class='dropdown-menu'>"); buffer.push("<ul class='dropdown-menu'>");
const contents = this.get('dropDownContent'); const contents = this.get('dropDownContent');

View File

@ -34,9 +34,8 @@ const DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, {
setupController(controller, model) { setupController(controller, model) {
controller.set("model", model); controller.set("model", model);
// Only show either the Create Category or Create Topic button
this.controllerFor("navigation/categories").set("canCreateCategory", model.get("can_create_category")); this.controllerFor("navigation/categories").set("canCreateCategory", model.get("can_create_category"));
this.controllerFor("navigation/categories").set("canCreateTopic", model.get("can_create_topic") && !model.get("can_create_category")); this.controllerFor("navigation/categories").set("canCreateTopic", model.get("can_create_topic"));
this.openTopicDraft(model); this.openTopicDraft(model);
}, },

View File

@ -1,35 +1,33 @@
<div> <div class="modal-body reorder-categories full-height-modal">
<div class="modal-body reorder-categories"> <div id="rc-scroll-anchor"></div>
<div id="rc-scroll-anchor"></div> <table>
<table> <thead>
<thead> <th class="th-pos">Position</th>
<th class="th-pos">Position</th> <th class="th-cat">Category</th>
<th class="th-cat">Category</th> </thead>
</thead> {{#each categoriesOrdered as |cat|}}
{{#each categoriesOrdered as |cat|}} <tr data-category-id="{{cat.id}}">
<tr data-category-id="{{cat.id}}"> <td>
<td> {{number-field number=cat.position}}
{{number-field number=cat.position}} {{d-button class="no-text" action="moveUp" actionParam=cat icon="arrow-up"}}
{{d-button class="no-text" action="moveUp" actionParam=cat icon="arrow-up"}} {{d-button class="no-text" action="moveDown" actionParam=cat icon="arrow-down"}}
{{d-button class="no-text" action="moveDown" actionParam=cat icon="arrow-down"}} {{#if cat.hasBufferedChanges}}
{{#if cat.hasBufferedChanges}} {{d-button class="no-text" action="commit" icon="check"}}
{{d-button class="no-text" action="commit" icon="check"}} {{/if}}
{{/if}} </td>
</td> <td>{{category-badge cat allowUncategorized="true"}}</td>
<td>{{category-badge cat allowUncategorized="true"}}</td> </tr>
</tr> {{/each}}
{{/each}} </table>
</table> <div id="rc-scroll-bottom"></div>
<div id="rc-scroll-bottom"></div> </div>
</div>
<div class="modal-footer">
<div class="modal-footer"> {{#if showFixIndices}}
{{#if showFixIndices}} {{d-button action="fixIndices" icon="random" label="categories.reorder.fix_order" title="categories.reorder.fix_order_tooltip"}}
{{d-button action="fixIndices" icon="random" label="categories.reorder.fix_order" title="categories.reorder.fix_order_tooltip"}} {{/if}}
{{/if}} {{#if showApplyAll}}
{{#if showApplyAll}} {{d-button action="commit" icon="check" label="categories.reorder.apply_all"}}
{{d-button action="commit" icon="check" label="categories.reorder.apply_all"}} {{/if}}
{{/if}} {{d-button class="btn-primary" disabled=saveDisabled action="saveOrder" label="categories.reorder.save"}}
{{d-button class="btn-primary" disabled=saveDisabled action="saveOrder" label="categories.reorder.save"}}
</div>
</div> </div>

View File

@ -3,10 +3,7 @@
{{navigation-bar navItems=navItems filterMode=filterMode}} {{navigation-bar navItems=navItems filterMode=filterMode}}
{{#if canCreateCategory}} {{#if canCreateCategory}}
{{d-button action="createCategory" icon="plus" label="category.create"}} {{categories-admin-dropdown}}
{{#if siteSettings.fixed_category_positions}}
{{d-button action="reorderCategories" icon="random" label="category.reorder"}}
{{/if}}
{{/if}} {{/if}}
{{#if canCreateTopic}} {{#if canCreateTopic}}
<button id="create-topic" class='btn btn-default' {{action "createTopic"}}><i class='fa fa-plus'></i>{{i18n 'topic.create'}}</button> <button id="create-topic" class='btn btn-default' {{action "createTopic"}}><i class='fa fa-plus'></i>{{i18n 'topic.create'}}</button>

View File

@ -26,3 +26,6 @@
padding-bottom: 150px; padding-bottom: 150px;
} }
} }
.category-admin-menu ul {
width: 320px;
}

View File

@ -129,6 +129,9 @@
} }
.modal-body { .modal-body {
&.full-height-modal {
max-height: calc(100vh - 150px);
}
textarea { textarea {
width: 99%; width: 99%;
height: 80px; height: 80px;

View File

@ -370,6 +370,7 @@ en:
category: "Category" category: "Category"
reorder: reorder:
title: "Reorder Categories" title: "Reorder Categories"
title_long: "Reorganize the category list"
fix_order: "Fix Positions" fix_order: "Fix Positions"
fix_order_tooltip: "Not all categories have a unique position number, which may cause unexpected results." fix_order_tooltip: "Not all categories have a unique position number, which may cause unexpected results."
save: "Save Order" save: "Save Order"
@ -1519,6 +1520,7 @@ en:
topic_template: "Topic Template" topic_template: "Topic Template"
delete: 'Delete Category' delete: 'Delete Category'
create: 'New Category' create: 'New Category'
create_long: 'Create a new category'
save: 'Save Category' save: 'Save Category'
slug: 'Category Slug' slug: 'Category Slug'
slug_placeholder: '(Optional) dashed-words for url' slug_placeholder: '(Optional) dashed-words for url'
@ -1554,7 +1556,6 @@ en:
add_permission: "Add Permission" add_permission: "Add Permission"
this_year: "this year" this_year: "this year"
position: "position" position: "position"
reorder: "Reorder"
default_position: "Default Position" default_position: "Default Position"
position_disabled: "Categories will be displayed in order of activity. To control the order of categories in lists, " position_disabled: "Categories will be displayed in order of activity. To control the order of categories in lists, "
position_disabled_click: 'enable the "fixed category positions" setting.' position_disabled_click: 'enable the "fixed category positions" setting.'