mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -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 { buildCategoryPanel } from "discourse/components/edit-category-panel";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
|
const categorySortCriteria = [];
|
||||||
|
export function addCategorySortCriteria(criteria) {
|
||||||
|
categorySortCriteria.push(criteria);
|
||||||
|
}
|
||||||
|
|
||||||
export default buildCategoryPanel("settings", {
|
export default buildCategoryPanel("settings", {
|
||||||
emailInEnabled: setting("email_in"),
|
emailInEnabled: setting("email_in"),
|
||||||
showPositionInput: setting("fixed_category_positions"),
|
showPositionInput: setting("fixed_category_positions"),
|
||||||
@ -64,10 +69,9 @@ export default buildCategoryPanel("settings", {
|
|||||||
"category",
|
"category",
|
||||||
"created"
|
"created"
|
||||||
]
|
]
|
||||||
|
.concat(categorySortCriteria)
|
||||||
.map(s => ({ name: I18n.t("category.sort_options." + s), value: s }))
|
.map(s => ({ name: I18n.t("category.sort_options." + s), value: s }))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
return a.name > b.name;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
|
@ -41,9 +41,10 @@ import { disableNameSuppression } from "discourse/widgets/poster-name";
|
|||||||
import { registerCustomPostMessageCallback as registerCustomPostMessageCallback1 } from "discourse/controllers/topic";
|
import { registerCustomPostMessageCallback as registerCustomPostMessageCallback1 } from "discourse/controllers/topic";
|
||||||
import Sharing from "discourse/lib/sharing";
|
import Sharing from "discourse/lib/sharing";
|
||||||
import { addComposerUploadHandler } from "discourse/components/composer-editor";
|
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
|
// 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 {
|
class PluginApi {
|
||||||
constructor(version, container) {
|
constructor(version, container) {
|
||||||
@ -801,7 +802,6 @@ class PluginApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Registers a function to handle uploads for specified file types
|
* Registers a function to handle uploads for specified file types
|
||||||
* The normal uploading functionality will be bypassed if function returns
|
* The normal uploading functionality will be bypassed if function returns
|
||||||
* a falsy value.
|
* a falsy value.
|
||||||
@ -817,6 +817,18 @@ class PluginApi {
|
|||||||
addComposerUploadHandler(extensions, method);
|
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.
|
* Registers a renderer that overrides the display of category links.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user