mirror of
https://github.com/discourse/discourse.git
synced 2025-03-30 13:55:39 +08:00
Add extensibility endpoints for clicking on topic list item rows
This commit is contained in:
parent
3ae9d91d86
commit
ea9c1e5cf8
app/assets/javascripts/discourse/components
@ -1,7 +1,21 @@
|
||||
import { showEntrance } from "discourse/components/topic-list-item";
|
||||
import { showEntrance, navigateToTopic } from "discourse/components/topic-list-item";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
click: showEntrance,
|
||||
attributeBindings: ['topic.id:data-topic-id'],
|
||||
classNameBindings: [':latest-topic-list-item', 'topic.archived', 'topic.visited']
|
||||
classNameBindings: [':latest-topic-list-item', 'topic.archived', 'topic.visited'],
|
||||
|
||||
showEntrance,
|
||||
navigateToTopic,
|
||||
|
||||
click(e) {
|
||||
// for events undefined has a different meaning than false
|
||||
if (this.showEntrance(e) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.unhandledRowClick(e, this.get('topic'));
|
||||
},
|
||||
|
||||
// Can be overwritten by plugins to handle clicks on other parts of the row
|
||||
unhandledRowClick() { },
|
||||
});
|
||||
|
@ -20,6 +20,12 @@ export function showEntrance(e) {
|
||||
}
|
||||
}
|
||||
|
||||
export function navigateToTopic(topic, href) {
|
||||
this.appEvents.trigger('header:update-topic', topic);
|
||||
DiscourseURL.routeTo(href || topic.get('url'));
|
||||
return false;
|
||||
}
|
||||
|
||||
export default Ember.Component.extend(bufferedRender({
|
||||
rerenderTriggers: ['bulkSelectEnabled', 'topic.pinned'],
|
||||
tagName: 'tr',
|
||||
@ -107,8 +113,10 @@ export default Ember.Component.extend(bufferedRender({
|
||||
return false;
|
||||
}.property(),
|
||||
|
||||
showEntrance,
|
||||
|
||||
click(e) {
|
||||
const result = showEntrance.call(this, e);
|
||||
const result = this.showEntrance(e);
|
||||
if (result === false) { return result; }
|
||||
|
||||
const topic = this.get('topic');
|
||||
@ -124,19 +132,23 @@ export default Ember.Component.extend(bufferedRender({
|
||||
}
|
||||
|
||||
if (target.hasClass('raw-topic-link')) {
|
||||
if (wantsNewWindow(e)) { return true; }
|
||||
|
||||
this.appEvents.trigger('header:update-topic', topic);
|
||||
DiscourseURL.routeTo(target.attr('href'));
|
||||
return false;
|
||||
if (wantsNewWindow(e)) { return true; }
|
||||
return this.navigateToTopic(topic, target.attr('href'));
|
||||
}
|
||||
|
||||
if (target.closest('a.topic-status').length === 1) {
|
||||
this.get('topic').togglePinnedForUser();
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.unhandledRowClick(e, topic);
|
||||
},
|
||||
|
||||
navigateToTopic,
|
||||
|
||||
// Can be overwritten by plugins to handle clicks on other parts of the row
|
||||
unhandledRowClick() { },
|
||||
|
||||
highlight(opts = { isLastViewedTopic: false }) {
|
||||
const $topic = this.$();
|
||||
$topic
|
||||
|
Loading…
x
Reference in New Issue
Block a user