UX: Combine closed and archived icon.

This commit is contained in:
Guo Xiang Tan 2015-08-31 09:21:58 +08:00
parent 82148fc200
commit d39cfe9068
3 changed files with 22 additions and 11 deletions

View File

@ -28,21 +28,30 @@ export default Ember.Component.extend(StringBuffer, {
renderString(buffer) { renderString(buffer) {
const self = this; const self = this;
const renderIconIf = function(conditionProp, name, key, actionable) { const renderIcon = function(name, key, actionable) {
if (!self.get(conditionProp)) { return; } const title = Handlebars.Utils.escapeExpression(I18n.t(`topic_statuses.${key}.help`)),
const title = Handlebars.Utils.escapeExpression(I18n.t("topic_statuses." + key + ".help")),
startTag = actionable ? "a href" : "span", startTag = actionable ? "a href" : "span",
endTag = actionable ? "a" : "span", endTag = actionable ? "a" : "span",
iconArgs = key === 'unpinned' ? { 'class': 'unpinned' } : null, iconArgs = key === 'unpinned' ? { 'class': 'unpinned' } : null,
icon = iconHTML(name, iconArgs); icon = iconHTML(name, iconArgs);
buffer.push("<" + startTag + " title='" + title + "' class='topic-status'>" + icon + "</" + endTag + ">"); buffer.push(`<${startTag} title='${title}' class='topic-status'>${icon}</${endTag}>`);
};
const renderIconIf = function(conditionProp, name, key, actionable) {
if (!self.get(conditionProp)) { return; }
renderIcon(name, key, actionable);
}; };
renderIconIf('topic.is_warning', 'envelope', 'warning'); renderIconIf('topic.is_warning', 'envelope', 'warning');
if (this.get('topic.closed') && this.get('topic.archived')) {
renderIcon('lock', 'locked_and_archived');
} else {
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', this.get("canAct") ); renderIconIf('topic.pinned', 'thumb-tack', 'pinned', this.get("canAct") );
renderIconIf('topic.unpinned', 'thumb-tack', 'unpinned', this.get("canAct")); renderIconIf('topic.unpinned', 'thumb-tack', 'unpinned', this.get("canAct"));
renderIconIf('topic.invisible', 'eye-slash', 'invisible'); renderIconIf('topic.invisible', 'eye-slash', 'invisible');

View File

@ -26,11 +26,11 @@ export default Ember.Object.extend({
results.push({extraClasses: extraClasses, icon: 'bookmark', key: 'bookmarked', href: url}); results.push({extraClasses: extraClasses, icon: 'bookmark', key: 'bookmarked', href: url});
} }
if(topic.get('closed')){ if (topic.get('closed') && topic.get('archived')) {
results.push({icon: 'lock', key: 'locked_and_archived'});
} else if(topic.get('closed')){
results.push({icon: 'lock', key: 'locked'}); results.push({icon: 'lock', key: 'locked'});
} } else if(topic.get('archived')){
if(topic.get('archived')){
results.push({icon: 'lock', key: 'archived'}); results.push({icon: 'lock', key: 'archived'});
} }

View File

@ -1593,6 +1593,8 @@ en:
help: "This topic is closed; it no longer accepts new replies" help: "This topic is closed; it no longer accepts new replies"
archived: archived:
help: "This topic is archived; it no longer accepts new replies" help: "This topic is archived; it no longer accepts new replies"
locked_and_archived:
help: "This topic is closed and archived; it no longer accepts new replies"
unpinned: unpinned:
title: "Unpinned" title: "Unpinned"
help: "This topic is unpinned for you; it will display in regular order" help: "This topic is unpinned for you; it will display in regular order"