FIX: Clicking the lock icon was running the "pin" logic

This commit is contained in:
Robin Ward 2015-03-27 12:55:19 -04:00
parent 76fe24251c
commit ada633f084
2 changed files with 25 additions and 20 deletions

View File

@ -1,3 +1,4 @@
import { iconHTML } from 'discourse/helpers/fa-icon';
import StringBuffer from 'discourse/mixins/string-buffer';
export default Ember.Component.extend(StringBuffer, {
@ -5,8 +6,9 @@ export default Ember.Component.extend(StringBuffer, {
rerenderTriggers: ['topic.archived', 'topic.closed', 'topic.pinned', 'topic.visible', 'topic.unpinned', 'topic.is_warning'],
click: function() {
var topic = this.get('topic');
click(e) {
if ($(e.target).hasClass('fa-thumb-tack')) {
const topic = this.get('topic');
// only pin unpin for now
if (topic.get('pinned')) {
@ -14,6 +16,7 @@ export default Ember.Component.extend(StringBuffer, {
} else {
topic.rePin();
}
}
return false;
},
@ -22,24 +25,26 @@ export default Ember.Component.extend(StringBuffer, {
return Discourse.User.current() && !this.get('disableActions');
}.property('disableActions'),
renderString: function(buffer) {
renderString(buffer) {
const self = this;
var self = this;
var renderIconIf = function(conditionProp, name, key, actionable) {
const renderIconIf = function(conditionProp, name, key, actionable) {
if (!self.get(conditionProp)) { return; }
var title = Handlebars.Utils.escapeExpression(I18n.t("topic_statuses." + key + ".help"));
var startTag = actionable ? "a href" : "span";
var endTag = actionable ? "a" : "span";
buffer.push("<" + startTag + " title='" + title + "' class='topic-status'><i class='fa fa-" + name + "'></i></" + endTag + ">");
const title = Handlebars.Utils.escapeExpression(I18n.t("topic_statuses." + key + ".help")),
startTag = actionable ? "a href" : "span",
endTag = actionable ? "a" : "span",
iconArgs = key === 'unpinned' ? { 'class': 'unpinned' } : null,
icon = iconHTML(name, iconArgs);
buffer.push("<" + startTag + " title='" + title + "' class='topic-status'>" + icon + "</" + endTag + ">");
};
renderIconIf('topic.is_warning', 'envelope', 'warning');
renderIconIf('topic.closed', 'lock', 'locked');
renderIconIf('topic.archived', 'lock', 'archived');
renderIconIf('topic.pinned', 'thumb-tack', 'pinned', self.get("canAct") );
renderIconIf('topic.unpinned', 'thumb-tack unpinned', 'unpinned', self.get("canAct"));
renderIconIf('topic.pinned', 'thumb-tack', 'pinned', this.get("canAct") );
renderIconIf('topic.unpinned', 'thumb-tack', 'unpinned', this.get("canAct"));
renderIconIf('topic.invisible', 'eye-slash', 'invisible');
}
});

View File

@ -13,14 +13,14 @@
<ul class='icons clearfix' role='navigation'>
{{#if currentUser}}
<li class='notifications'>
<a class='icon' href="#" {{action "showNotifications" target="view"}} data-notifications="notifications-dropdown" id='user-notifications' title='{{i18n 'notifications.title'}}'>
<a class='icon' href {{action "showNotifications" target="view"}} data-notifications="notifications-dropdown" id='user-notifications' title='{{i18n 'notifications.title'}}'>
{{fa-icon "comment" label="notifications.title"}}
</a>
{{#if currentUser.unread_notifications}}
<a href='#' class='badge-notification unread-notifications'>{{currentUser.unread_notifications}}</a>
<a href class='badge-notification unread-notifications'>{{currentUser.unread_notifications}}</a>
{{/if}}
{{#if currentUser.unread_private_messages}}
<a href='#' class='badge-notification unread-private-messages'>{{currentUser.unread_private_messages}}</a>
<a href class='badge-notification unread-private-messages'>{{currentUser.unread_private_messages}}</a>
{{/if}}
</li>
{{/if}}