${topic.get('acceptedAnswerHtml')}
<\/div>
${topic.get('accepted_answer').excerpt}
`
var cooked = new PostCooked({cooked:rawhtml});
var html = cooked.init();
return dec.rawHtml(html);
}
}
}
});
api.attachWidgetAction('post', 'acceptAnswer', function() {
const post = this.model;
const current = post.get('topic.postStream.posts').filter(p => {
return p.get('post_number') === 1 || p.get('accepted_answer');
});
acceptPost(post);
current.forEach(p => this.appEvents.trigger('post-stream:refresh', { id: p.id }));
});
api.attachWidgetAction('post', 'unacceptAnswer', function() {
const post = this.model;
const op = post.get('topic.postStream.posts').find(p => p.get('post_number') === 1);
unacceptPost(post);
this.appEvents.trigger('post-stream:refresh', { id: op.get('id') });
});
if (api.registerConnectorClass) {
api.registerConnectorClass('user-activity-bottom', 'solved-list', {
shouldRender(args, component) {
return component.siteSettings.solved_enabled;
},
});
api.registerConnectorClass('user-summary-stat', 'solved-count', {
shouldRender(args, component) {
return component.siteSettings.solved_enabled && args.model.solved_count > 0;
},
setupComponent() {
this.set('classNames', ['linked-stat']);
}
});
}
}
export default {
name: 'extend-for-solved-button',
initialize() {
Topic.reopen({
// keeping this here cause there is complex localization
acceptedAnswerHtml: function() {
const username = this.get('accepted_answer.username');
const postNumber = this.get('accepted_answer.post_number');
if (!username || !postNumber) {
return "";
}
return I18n.t("solved.accepted_html", {
username_lower: username.toLowerCase(),
username,
post_path: this.get('url') + "/" + postNumber,
post_number: postNumber,
user_path: User.create({username: username}).get('path')
});
}.property('accepted_answer', 'id')
});
TopicStatus.reopen({
statuses: function(){
const results = this._super();
if (this.topic.has_accepted_answer) {
results.push({
openTag: 'span',
closeTag: 'span',
title: I18n.t('solved.has_accepted_answer'),
icon: 'check-square-o'
});
}else if(this.topic.can_have_answer && this.siteSettings.solved_enabled && this.siteSettings.empty_box_on_unsolved){
results.push({
openTag: 'span',
closeTag: 'span',
title: I18n.t('solved.has_no_accepted_answer'),
icon: 'square-o'
});
}
return results;
}.property()
});
withPluginApi('0.1', initializeWithApi, { noApi: oldPluginCode });
}
};