mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 12:13:58 -06:00
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:
parent
0c5fb207e9
commit
c038758f8c
@ -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);
|
||||
}
|
||||
});
|
@ -29,9 +29,7 @@ export default Ember.Component.extend(StringBuffer, {
|
||||
buffer.push("<h4 class='title'>" + title + "</h4>");
|
||||
}
|
||||
|
||||
buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>");
|
||||
buffer.push(this.get('text'));
|
||||
buffer.push("</button>");
|
||||
buffer.push(`<button class='btn standard dropdown-toggle ${this.get('buttonExtraClasses')}' data-toggle='dropdown'>${this.get('text')}</button>`);
|
||||
buffer.push("<ul class='dropdown-menu'>");
|
||||
|
||||
const contents = this.get('dropDownContent');
|
||||
|
@ -34,9 +34,8 @@ const DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, {
|
||||
setupController(controller, 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("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);
|
||||
},
|
||||
|
@ -1,35 +1,33 @@
|
||||
<div>
|
||||
<div class="modal-body reorder-categories">
|
||||
<div id="rc-scroll-anchor"></div>
|
||||
<table>
|
||||
<thead>
|
||||
<th class="th-pos">Position</th>
|
||||
<th class="th-cat">Category</th>
|
||||
</thead>
|
||||
{{#each categoriesOrdered as |cat|}}
|
||||
<tr data-category-id="{{cat.id}}">
|
||||
<td>
|
||||
{{number-field number=cat.position}}
|
||||
{{d-button class="no-text" action="moveUp" actionParam=cat icon="arrow-up"}}
|
||||
{{d-button class="no-text" action="moveDown" actionParam=cat icon="arrow-down"}}
|
||||
{{#if cat.hasBufferedChanges}}
|
||||
{{d-button class="no-text" action="commit" icon="check"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>{{category-badge cat allowUncategorized="true"}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
<div id="rc-scroll-bottom"></div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
{{#if showFixIndices}}
|
||||
{{d-button action="fixIndices" icon="random" label="categories.reorder.fix_order" title="categories.reorder.fix_order_tooltip"}}
|
||||
{{/if}}
|
||||
{{#if showApplyAll}}
|
||||
{{d-button action="commit" icon="check" label="categories.reorder.apply_all"}}
|
||||
{{/if}}
|
||||
{{d-button class="btn-primary" disabled=saveDisabled action="saveOrder" label="categories.reorder.save"}}
|
||||
</div>
|
||||
<div class="modal-body reorder-categories full-height-modal">
|
||||
<div id="rc-scroll-anchor"></div>
|
||||
<table>
|
||||
<thead>
|
||||
<th class="th-pos">Position</th>
|
||||
<th class="th-cat">Category</th>
|
||||
</thead>
|
||||
{{#each categoriesOrdered as |cat|}}
|
||||
<tr data-category-id="{{cat.id}}">
|
||||
<td>
|
||||
{{number-field number=cat.position}}
|
||||
{{d-button class="no-text" action="moveUp" actionParam=cat icon="arrow-up"}}
|
||||
{{d-button class="no-text" action="moveDown" actionParam=cat icon="arrow-down"}}
|
||||
{{#if cat.hasBufferedChanges}}
|
||||
{{d-button class="no-text" action="commit" icon="check"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>{{category-badge cat allowUncategorized="true"}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
<div id="rc-scroll-bottom"></div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
{{#if showFixIndices}}
|
||||
{{d-button action="fixIndices" icon="random" label="categories.reorder.fix_order" title="categories.reorder.fix_order_tooltip"}}
|
||||
{{/if}}
|
||||
{{#if showApplyAll}}
|
||||
{{d-button action="commit" icon="check" label="categories.reorder.apply_all"}}
|
||||
{{/if}}
|
||||
{{d-button class="btn-primary" disabled=saveDisabled action="saveOrder" label="categories.reorder.save"}}
|
||||
</div>
|
||||
|
@ -3,10 +3,7 @@
|
||||
{{navigation-bar navItems=navItems filterMode=filterMode}}
|
||||
|
||||
{{#if canCreateCategory}}
|
||||
{{d-button action="createCategory" icon="plus" label="category.create"}}
|
||||
{{#if siteSettings.fixed_category_positions}}
|
||||
{{d-button action="reorderCategories" icon="random" label="category.reorder"}}
|
||||
{{/if}}
|
||||
{{categories-admin-dropdown}}
|
||||
{{/if}}
|
||||
{{#if canCreateTopic}}
|
||||
<button id="create-topic" class='btn btn-default' {{action "createTopic"}}><i class='fa fa-plus'></i>{{i18n 'topic.create'}}</button>
|
||||
|
@ -26,3 +26,6 @@
|
||||
padding-bottom: 150px;
|
||||
}
|
||||
}
|
||||
.category-admin-menu ul {
|
||||
width: 320px;
|
||||
}
|
@ -129,6 +129,9 @@
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
&.full-height-modal {
|
||||
max-height: calc(100vh - 150px);
|
||||
}
|
||||
textarea {
|
||||
width: 99%;
|
||||
height: 80px;
|
||||
|
@ -370,6 +370,7 @@ en:
|
||||
category: "Category"
|
||||
reorder:
|
||||
title: "Reorder Categories"
|
||||
title_long: "Reorganize the category list"
|
||||
fix_order: "Fix Positions"
|
||||
fix_order_tooltip: "Not all categories have a unique position number, which may cause unexpected results."
|
||||
save: "Save Order"
|
||||
@ -1519,6 +1520,7 @@ en:
|
||||
topic_template: "Topic Template"
|
||||
delete: 'Delete Category'
|
||||
create: 'New Category'
|
||||
create_long: 'Create a new category'
|
||||
save: 'Save Category'
|
||||
slug: 'Category Slug'
|
||||
slug_placeholder: '(Optional) dashed-words for url'
|
||||
@ -1554,7 +1556,6 @@ en:
|
||||
add_permission: "Add Permission"
|
||||
this_year: "this year"
|
||||
position: "position"
|
||||
reorder: "Reorder"
|
||||
default_position: "Default Position"
|
||||
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.'
|
||||
|
Loading…
Reference in New Issue
Block a user