mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 11:21:26 +08:00
FEATURE: unified UI for pinning/banner topics
REFACTOR: ES6ified all the modals
This commit is contained in:
@ -0,0 +1,49 @@
|
||||
export default Ember.Controller.extend({
|
||||
needs: ['modal'],
|
||||
|
||||
sample: Em.computed.alias('model.sample'),
|
||||
errors: Em.computed.alias('model.errors'),
|
||||
count: Em.computed.alias('model.grant_count'),
|
||||
|
||||
count_warning: function() {
|
||||
if (this.get('count') <= 10) {
|
||||
return this.get('sample.length') !== this.get('count');
|
||||
} else {
|
||||
return this.get('sample.length') !== 10;
|
||||
}
|
||||
}.property('count', 'sample.length'),
|
||||
|
||||
has_query_plan: function() {
|
||||
return !!this.get('model.query_plan');
|
||||
}.property('model.query_plan'),
|
||||
|
||||
query_plan_html: function() {
|
||||
var raw = this.get('model.query_plan'),
|
||||
returned = "<pre class='badge-query-plan'>";
|
||||
|
||||
_.each(raw, function(linehash) {
|
||||
returned += Handlebars.Utils.escapeExpression(linehash["QUERY PLAN"]);
|
||||
returned += "<br>";
|
||||
});
|
||||
|
||||
returned += "</pre>";
|
||||
return returned;
|
||||
}.property('model.query_plan'),
|
||||
|
||||
processed_sample: Ember.computed.map('model.sample', function(grant) {
|
||||
var i18nKey = 'admin.badges.preview.grant.with',
|
||||
i18nParams = { username: Handlebars.Utils.escapeExpression(grant.username) };
|
||||
|
||||
if (grant.post_id) {
|
||||
i18nKey += "_post";
|
||||
i18nParams.link = "<a href='/p/" + grant.post_id + "' data-auto-route='true'>" + Handlebars.Utils.escapeExpression(grant.title) + "</a>";
|
||||
}
|
||||
|
||||
if (grant.granted_at) {
|
||||
i18nKey += "_time";
|
||||
i18nParams.time = Handlebars.Utils.escapeExpression(moment(grant.granted_at).format(I18n.t('dates.long_with_year')));
|
||||
}
|
||||
|
||||
return I18n.t(i18nKey, i18nParams);
|
||||
})
|
||||
});
|
Reference in New Issue
Block a user