DEV: Add data-topic-id to more elements containing titles.

This commit is contained in:
Dan Ungureanu 2018-11-04 11:23:45 +02:00 committed by Sam
parent 8837fe47d7
commit 1f9f00a629
6 changed files with 18 additions and 7 deletions

View File

@ -66,9 +66,9 @@ export default Ember.Component.extend({
},
_formatReplyToTopic(link) {
return `<a class="topic-link" href="${link.href}">${
link.anchor
}</a>`.htmlSafe();
return `<a class="topic-link" href="${link.href}" data-topic-id="${this.get(
"model.topic.id"
)}">${link.anchor}</a>`.htmlSafe();
},
_formatReplyToUserPost(avatar, link) {

View File

@ -11,6 +11,6 @@ registerUnbound("topic-link", (topic, args) => {
args.class.split(" ").forEach(c => classes.push(c));
}
const result = `<a href='${url}' class='${classes.join(" ")}'>${title}</a>`;
const result = `<a href='${url}' class='${classes.join(" ")}' data-topic-id='${topic.id}'>${title}</a>`;
return new Handlebars.SafeString(result);
});

View File

@ -44,7 +44,7 @@
</div>
{{else}}
<h1>
<h1 data-topic-id="{{unbound model.id}}">
{{#unless model.is_warning}}
{{#if siteSettings.enable_personal_messages}}
<a href={{pmPath}}>

View File

@ -40,6 +40,7 @@ export default createWidget("header-topic-info", {
className: "topic-link",
action: "jumpToTopPost",
href,
attributes: { "data-topic-id": topic.get("id") },
contents: () => titleHTML
})
);

View File

@ -35,12 +35,18 @@ export default createWidget("link", {
},
buildAttributes(attrs) {
return {
const ret = {
href: this.href(attrs),
title: attrs.title
? I18n.t(attrs.title, attrs.titleOptions)
: this.label(attrs)
};
if (attrs.attributes) {
Object.keys(attrs.attributes).forEach(
k => (ret[k] = attrs.attributes[k])
);
}
return ret;
},
label(attrs) {

View File

@ -464,7 +464,11 @@ createWidget("post-article", {
},
buildAttributes(attrs) {
return { "data-post-id": attrs.id, "data-user-id": attrs.user_id };
return {
"data-post-id": attrs.id,
"data-topic-id": attrs.topicId,
"data-user-id": attrs.user_id
};
},
html(attrs, state) {