mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
DEV: Allow topics to register default topic order criteria. (#7158)
This commit is contained in:
parent
c773f82ba1
commit
91bd0becaa
@ -2,6 +2,11 @@ import { setting } from "discourse/lib/computed";
|
||||
import { buildCategoryPanel } from "discourse/components/edit-category-panel";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const categorySortCriteria = [];
|
||||
export function addCategorySortCriteria(criteria) {
|
||||
categorySortCriteria.push(criteria);
|
||||
}
|
||||
|
||||
export default buildCategoryPanel("settings", {
|
||||
emailInEnabled: setting("email_in"),
|
||||
showPositionInput: setting("fixed_category_positions"),
|
||||
@ -64,10 +69,9 @@ export default buildCategoryPanel("settings", {
|
||||
"category",
|
||||
"created"
|
||||
]
|
||||
.concat(categorySortCriteria)
|
||||
.map(s => ({ name: I18n.t("category.sort_options." + s), value: s }))
|
||||
.sort((a, b) => {
|
||||
return a.name > b.name;
|
||||
});
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
},
|
||||
|
||||
@computed
|
||||
|
@ -41,9 +41,10 @@ import { disableNameSuppression } from "discourse/widgets/poster-name";
|
||||
import { registerCustomPostMessageCallback as registerCustomPostMessageCallback1 } from "discourse/controllers/topic";
|
||||
import Sharing from "discourse/lib/sharing";
|
||||
import { addComposerUploadHandler } from "discourse/components/composer-editor";
|
||||
import { addCategorySortCriteria } from "discourse/components/edit-category-settings";
|
||||
|
||||
// If you add any methods to the API ensure you bump up this number
|
||||
const PLUGIN_API_VERSION = "0.8.29";
|
||||
const PLUGIN_API_VERSION = "0.8.30";
|
||||
|
||||
class PluginApi {
|
||||
constructor(version, container) {
|
||||
@ -801,7 +802,6 @@ class PluginApi {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Registers a function to handle uploads for specified file types
|
||||
* The normal uploading functionality will be bypassed if function returns
|
||||
* a falsy value.
|
||||
@ -817,6 +817,18 @@ class PluginApi {
|
||||
addComposerUploadHandler(extensions, method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a criteria that can be used as default topic order on category
|
||||
* pages.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* categorySortCriteria("votes");
|
||||
*/
|
||||
addCategorySortCriteria(criteria) {
|
||||
addCategorySortCriteria(criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a renderer that overrides the display of category links.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user