mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Export the default behaviour of a topic-list-item so it can be reused by the discourse-assign plugin (#7433)
This commit is contained in:
parent
e0db323efb
commit
404666c9e9
@ -29,17 +29,8 @@ export function navigateToTopic(topic, href) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ember.Component.extend(
|
export const ListItemDefaults = {
|
||||||
bufferedRender({
|
|
||||||
rerenderTriggers: ["bulkSelectEnabled", "topic.pinned"],
|
|
||||||
tagName: "tr",
|
tagName: "tr",
|
||||||
classNameBindings: [
|
|
||||||
":topic-list-item",
|
|
||||||
"unboundClassNames",
|
|
||||||
"topic.visited"
|
|
||||||
],
|
|
||||||
attributeBindings: ["data-topic-id"],
|
|
||||||
"data-topic-id": Ember.computed.alias("topic.id"),
|
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
newDotText() {
|
newDotText() {
|
||||||
@ -48,21 +39,6 @@ export default Ember.Component.extend(
|
|||||||
: I18n.t("filters.new.lower_title");
|
: I18n.t("filters.new.lower_title");
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
|
||||||
toggleBookmark() {
|
|
||||||
this.get("topic")
|
|
||||||
.toggleBookmark()
|
|
||||||
.finally(() => this.rerenderBuffer());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
buildBuffer(buffer) {
|
|
||||||
const template = findRawTemplate("list/topic-list-item");
|
|
||||||
if (template) {
|
|
||||||
buffer.push(template(this));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
@computed("topic", "lastVisitedTopic")
|
@computed("topic", "lastVisitedTopic")
|
||||||
unboundClassNames(topic, lastVisitedTopic) {
|
unboundClassNames(topic, lastVisitedTopic) {
|
||||||
let classes = [];
|
let classes = [];
|
||||||
@ -125,10 +101,7 @@ export default Ember.Component.extend(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (this.get("expandGloballyPinned") && this.get("topic.pinned_globally")) {
|
||||||
this.get("expandGloballyPinned") &&
|
|
||||||
this.get("topic.pinned_globally")
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,9 +149,6 @@ export default Ember.Component.extend(
|
|||||||
|
|
||||||
navigateToTopic,
|
navigateToTopic,
|
||||||
|
|
||||||
// Can be overwritten by plugins to handle clicks on other parts of the row
|
|
||||||
unhandledRowClick() {},
|
|
||||||
|
|
||||||
highlight(opts = { isLastViewedTopic: false }) {
|
highlight(opts = { isLastViewedTopic: false }) {
|
||||||
const $topic = this.$();
|
const $topic = this.$();
|
||||||
$topic
|
$topic
|
||||||
@ -199,5 +169,36 @@ export default Ember.Component.extend(
|
|||||||
this.highlight();
|
this.highlight();
|
||||||
}
|
}
|
||||||
}.on("didInsertElement")
|
}.on("didInsertElement")
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Ember.Component.extend(
|
||||||
|
ListItemDefaults,
|
||||||
|
bufferedRender({
|
||||||
|
rerenderTriggers: ["bulkSelectEnabled", "topic.pinned"],
|
||||||
|
classNameBindings: [
|
||||||
|
":topic-list-item",
|
||||||
|
"unboundClassNames",
|
||||||
|
"topic.visited"
|
||||||
|
],
|
||||||
|
attributeBindings: ["data-topic-id"],
|
||||||
|
"data-topic-id": Ember.computed.alias("topic.id"),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
toggleBookmark() {
|
||||||
|
this.get("topic")
|
||||||
|
.toggleBookmark()
|
||||||
|
.finally(() => this.rerenderBuffer());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
buildBuffer(buffer) {
|
||||||
|
const template = findRawTemplate("list/topic-list-item");
|
||||||
|
if (template) {
|
||||||
|
buffer.push(template(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Can be overwritten by plugins to handle clicks on other parts of the row
|
||||||
|
unhandledRowClick() {}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user