mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 15:56:39 +08:00
Update topic status to use more ES6 features, clean up
This commit is contained in:
parent
e8307ac24c
commit
5f08630c27
@ -1,54 +1,58 @@
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.Object.extend({
|
||||
renderDiv: function(){
|
||||
|
||||
@computed
|
||||
renderDiv() {
|
||||
return this.get('statuses').length > 0 && !this.noDiv;
|
||||
}.property(),
|
||||
statuses: function(){
|
||||
var topic = this.get("topic");
|
||||
var results = [];
|
||||
var self = this;
|
||||
},
|
||||
|
||||
@computed
|
||||
statuses() {
|
||||
const topic = this.get("topic");
|
||||
const results = [];
|
||||
|
||||
// TODO, custom statuses? via override?
|
||||
|
||||
if(topic.get('is_warning')){
|
||||
if (topic.get('is_warning')) {
|
||||
results.push({icon: 'envelope', key: 'warning'});
|
||||
}
|
||||
|
||||
if(topic.get('bookmarked')){
|
||||
var url = topic.get('url');
|
||||
var postNumbers = topic.get('bookmarked_post_numbers');
|
||||
var extraClasses = "";
|
||||
if(postNumbers && postNumbers[0] > 1) {
|
||||
if (topic.get('bookmarked')) {
|
||||
const postNumbers = topic.get('bookmarked_post_numbers');
|
||||
let url = topic.get('url');
|
||||
let extraClasses = "";
|
||||
if (postNumbers && postNumbers[0] > 1) {
|
||||
url += '/' + postNumbers[0];
|
||||
} else {
|
||||
extraClasses = "op-bookmark";
|
||||
}
|
||||
|
||||
results.push({extraClasses: extraClasses, icon: 'bookmark', key: 'bookmarked', href: url});
|
||||
results.push({ extraClasses, icon: 'bookmark', key: 'bookmarked', href: url });
|
||||
}
|
||||
|
||||
if (topic.get('closed') && topic.get('archived')) {
|
||||
results.push({icon: 'lock', key: 'locked_and_archived'});
|
||||
} else if(topic.get('closed')){
|
||||
} else if (topic.get('closed')) {
|
||||
results.push({icon: 'lock', key: 'locked'});
|
||||
} else if(topic.get('archived')){
|
||||
} else if (topic.get('archived')) {
|
||||
results.push({icon: 'lock', key: 'archived'});
|
||||
}
|
||||
|
||||
if(topic.get('pinned')){
|
||||
if (topic.get('pinned')) {
|
||||
results.push({icon: 'thumb-tack', key: 'pinned'});
|
||||
}
|
||||
|
||||
if(topic.get('unpinned')){
|
||||
if (topic.get('unpinned')) {
|
||||
results.push({icon: 'thumb-tack unpinned', key: 'unpinned'});
|
||||
}
|
||||
|
||||
if(topic.get('invisible')){
|
||||
if (topic.get('invisible')) {
|
||||
results.push({icon: 'eye-slash', key: 'invisible'});
|
||||
}
|
||||
|
||||
_.each(results, function(result){
|
||||
result.title = I18n.t("topic_statuses." + result.key + ".help");
|
||||
if(!self.disableActions && (result.key === "pinned" ||result.key === "unpinned")){
|
||||
results.forEach(result => {
|
||||
result.title = I18n.t(`topic_statuses.${result.key}.help`);
|
||||
if (!self.disableActions && (result.key === "pinned" ||result.key === "unpinned")) {
|
||||
result.openTag = 'a href';
|
||||
result.closeTag = 'a';
|
||||
} else {
|
||||
@ -58,6 +62,5 @@ export default Ember.Object.extend({
|
||||
});
|
||||
|
||||
return results;
|
||||
}.property()
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user