DEV: Add `topic-list-header-sortable-column` transformer (#29917)

For conditionally disabling ability to sort on specific columns in the topic list.
This commit is contained in:
Jarek Radosz 2024-11-29 21:32:48 +01:00 committed by GitHub
parent a2c8177a4c
commit 2f932812e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 6 deletions

View File

@ -1,8 +1,15 @@
import { hash } from "@ember/helper";
import { applyValueTransformer } from "discourse/lib/transformer";
const Header = <template>
<tr>
{{#each @columns as |entry|}}
<entry.value.header
@sortable={{@sortable}}
@sortable={{applyValueTransformer
"topic-list-header-sortable-column"
@sortable
(hash category=@category name=@name)
}}
@activeOrder={{@order}}
@changeSort={{@changeSort}}
@ascending={{@ascending}}

View File

@ -121,10 +121,6 @@ export default class TopicList extends Component {
return !this.bulkSelectEnabled && this.args.canBulkSelect;
}
get sortable() {
return !!this.args.changeSort;
}
get showTopicPostBadges() {
return this.args.showTopicPostBadges ?? true;
}
@ -189,7 +185,7 @@ export default class TopicList extends Component {
@order={{@order}}
@changeSort={{@changeSort}}
@ascending={{@ascending}}
@sortable={{this.sortable}}
@sortable={{@changeSort}}
@listTitle={{or @listTitle "topic.title"}}
@bulkSelectHelper={{@bulkSelectHelper}}
@bulkSelectEnabled={{this.bulkSelectEnabled}}

View File

@ -16,4 +16,5 @@ export const VALUE_TRANSFORMERS = Object.freeze([
"post-menu-buttons",
"small-user-attrs",
"topic-list-columns",
"topic-list-header-sortable-column",
]);