FIX: Clicking the lock icon was running the "pin" logic
This commit is contained in:
parent
76fe24251c
commit
ada633f084
|
@ -1,3 +1,4 @@
|
||||||
|
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||||
import StringBuffer from 'discourse/mixins/string-buffer';
|
import StringBuffer from 'discourse/mixins/string-buffer';
|
||||||
|
|
||||||
export default Ember.Component.extend(StringBuffer, {
|
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'],
|
rerenderTriggers: ['topic.archived', 'topic.closed', 'topic.pinned', 'topic.visible', 'topic.unpinned', 'topic.is_warning'],
|
||||||
|
|
||||||
click: function() {
|
click(e) {
|
||||||
var topic = this.get('topic');
|
if ($(e.target).hasClass('fa-thumb-tack')) {
|
||||||
|
const topic = this.get('topic');
|
||||||
|
|
||||||
// only pin unpin for now
|
// only pin unpin for now
|
||||||
if (topic.get('pinned')) {
|
if (topic.get('pinned')) {
|
||||||
|
@ -14,6 +16,7 @@ export default Ember.Component.extend(StringBuffer, {
|
||||||
} else {
|
} else {
|
||||||
topic.rePin();
|
topic.rePin();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -22,24 +25,26 @@ export default Ember.Component.extend(StringBuffer, {
|
||||||
return Discourse.User.current() && !this.get('disableActions');
|
return Discourse.User.current() && !this.get('disableActions');
|
||||||
}.property('disableActions'),
|
}.property('disableActions'),
|
||||||
|
|
||||||
renderString: function(buffer) {
|
renderString(buffer) {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
var self = this;
|
const renderIconIf = function(conditionProp, name, key, actionable) {
|
||||||
|
|
||||||
var renderIconIf = function(conditionProp, name, key, actionable) {
|
|
||||||
if (!self.get(conditionProp)) { return; }
|
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.is_warning', 'envelope', 'warning');
|
||||||
renderIconIf('topic.closed', 'lock', 'locked');
|
renderIconIf('topic.closed', 'lock', 'locked');
|
||||||
renderIconIf('topic.archived', 'lock', 'archived');
|
renderIconIf('topic.archived', 'lock', 'archived');
|
||||||
renderIconIf('topic.pinned', 'thumb-tack', 'pinned', self.get("canAct") );
|
renderIconIf('topic.pinned', 'thumb-tack', 'pinned', this.get("canAct") );
|
||||||
renderIconIf('topic.unpinned', 'thumb-tack unpinned', 'unpinned', self.get("canAct"));
|
renderIconIf('topic.unpinned', 'thumb-tack', 'unpinned', this.get("canAct"));
|
||||||
renderIconIf('topic.invisible', 'eye-slash', 'invisible');
|
renderIconIf('topic.invisible', 'eye-slash', 'invisible');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
<ul class='icons clearfix' role='navigation'>
|
<ul class='icons clearfix' role='navigation'>
|
||||||
{{#if currentUser}}
|
{{#if currentUser}}
|
||||||
<li class='notifications'>
|
<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"}}
|
{{fa-icon "comment" label="notifications.title"}}
|
||||||
</a>
|
</a>
|
||||||
{{#if currentUser.unread_notifications}}
|
{{#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}}
|
||||||
{{#if currentUser.unread_private_messages}}
|
{{#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}}
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Loading…
Reference in New Issue