committed by
Joffrey JAFFEUX
parent
c617e512ad
commit
4b455e741e
@@ -1,5 +1,6 @@
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
/*global Resumable:true */
|
||||
|
||||
@@ -27,18 +28,19 @@ export default Ember.Component.extend(
|
||||
|
||||
rerenderTriggers: ["isUploading", "progress"],
|
||||
|
||||
translatedTitle: function() {
|
||||
const title = this.get("title");
|
||||
return title ? I18n.t(title) : this.get("text");
|
||||
}.property("title", "text"),
|
||||
@computed("title", "text")
|
||||
translatedTitle(title, text) {
|
||||
return title ? I18n.t(title) : text;
|
||||
},
|
||||
|
||||
text: function() {
|
||||
if (this.get("isUploading")) {
|
||||
return this.get("progress") + " %";
|
||||
@computed("isUploading", "progress")
|
||||
text(isUploading, progress) {
|
||||
if (isUploading) {
|
||||
return progress + " %";
|
||||
} else {
|
||||
return this.get("uploadText");
|
||||
}
|
||||
}.property("isUploading", "progress"),
|
||||
},
|
||||
|
||||
buildBuffer(buffer) {
|
||||
const icon = this.get("isUploading") ? "times" : "upload";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||
import { propertyNotEqual } from "discourse/lib/computed";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend(bufferedProperty("model"), {
|
||||
adminBadges: Ember.inject.controller(),
|
||||
@@ -17,14 +18,13 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
||||
readOnly: Ember.computed.alias("buffered.system"),
|
||||
showDisplayName: propertyNotEqual("name", "displayName"),
|
||||
|
||||
hasQuery: function() {
|
||||
const bQuery = this.get("buffered.query");
|
||||
if (bQuery) {
|
||||
return bQuery.trim().length > 0;
|
||||
@computed("model.query", "buffered.query")
|
||||
hasQuery(modelQuery, bufferedQuery) {
|
||||
if (bufferedQuery) {
|
||||
return bufferedQuery.trim().length > 0;
|
||||
}
|
||||
const mQuery = this.get("model.query");
|
||||
return mQuery && mQuery.trim().length > 0;
|
||||
}.property("model.query", "buffered.query"),
|
||||
return modelQuery && modelQuery.trim().length > 0;
|
||||
},
|
||||
|
||||
_resetSaving: function() {
|
||||
this.set("saving", false);
|
||||
|
||||
+4
-3
@@ -1,17 +1,18 @@
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend(bufferedProperty("emailTemplate"), {
|
||||
saved: false,
|
||||
|
||||
hasMultipleSubjects: function() {
|
||||
const buffered = this.get("buffered");
|
||||
@computed("buffered")
|
||||
hasMultipleSubjects(buffered) {
|
||||
if (buffered.getProperties("subject")["subject"]) {
|
||||
return false;
|
||||
} else {
|
||||
return buffered.getProperties("id")["id"];
|
||||
}
|
||||
}.property("buffered"),
|
||||
},
|
||||
|
||||
actions: {
|
||||
saveChanges() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { exportEntity } from "discourse/lib/export-csv";
|
||||
import { outputExportResult } from "discourse/lib/export-result";
|
||||
import StaffActionLog from "admin/models/staff-action-log";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
loading: false,
|
||||
@@ -20,14 +21,14 @@ export default Ember.Controller.extend({
|
||||
}
|
||||
}.observes("filterActionId"),
|
||||
|
||||
actionFilter: function() {
|
||||
var name = this.get("filters.action_name");
|
||||
@computed("filters.action_name")
|
||||
actionFilter(name) {
|
||||
if (name) {
|
||||
return I18n.t("admin.logs.staff_actions.actions." + name);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}.property("filters.action_name"),
|
||||
},
|
||||
|
||||
showInstructions: Ember.computed.gt("model.length", 0),
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
@computed
|
||||
adminRoutes: function() {
|
||||
return this.get("model")
|
||||
.map(p => {
|
||||
@@ -7,7 +10,8 @@ export default Ember.Controller.extend({
|
||||
}
|
||||
})
|
||||
.compact();
|
||||
}.property(),
|
||||
},
|
||||
|
||||
actions: {
|
||||
clearFilter() {
|
||||
this.setProperties({ filter: "", onlyOverridden: false });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import GrantBadgeController from "discourse/mixins/grant-badge-controller";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend(GrantBadgeController, {
|
||||
adminUser: Ember.inject.controller(),
|
||||
@@ -10,7 +11,8 @@ export default Ember.Controller.extend(GrantBadgeController, {
|
||||
sortedBadges: Ember.computed.sort("model", "badgeSortOrder"),
|
||||
badgeSortOrder: ["granted_at:desc"],
|
||||
|
||||
groupedBadges: function() {
|
||||
@computed("model", "model.[]", "model.expandedBadges.[]")
|
||||
groupedBadges() {
|
||||
const allBadges = this.get("model");
|
||||
|
||||
var grouped = _.groupBy(allBadges, badge => badge.badge_id);
|
||||
@@ -46,7 +48,7 @@ export default Ember.Controller.extend(GrantBadgeController, {
|
||||
.sortBy(group => group.granted_at)
|
||||
.reverse()
|
||||
.value();
|
||||
}.property("model", "model.[]", "model.expandedBadges.[]"),
|
||||
},
|
||||
|
||||
actions: {
|
||||
expandGroup: function(userBadge) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import debounce from "discourse/lib/debounce";
|
||||
import { i18n } from "discourse/lib/computed";
|
||||
import AdminUser from "admin/models/admin-user";
|
||||
import CanCheckEmails from "discourse/mixins/can-check-emails";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend(CanCheckEmails, {
|
||||
model: null,
|
||||
@@ -14,9 +15,10 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||
selectAll: false,
|
||||
searchHint: i18n("search_hint"),
|
||||
|
||||
title: function() {
|
||||
return I18n.t("admin.users.titles." + this.get("query"));
|
||||
}.property("query"),
|
||||
@computed("query")
|
||||
title(query) {
|
||||
return I18n.t("admin.users.titles." + query);
|
||||
},
|
||||
|
||||
_filterUsers: debounce(function() {
|
||||
this._refreshUsers();
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
export default Ember.Mixin.create({
|
||||
overridden: function() {
|
||||
let val = this.get("value"),
|
||||
defaultVal = this.get("default");
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Mixin.create({
|
||||
@computed("value", "default")
|
||||
overridden(val, defaultVal) {
|
||||
if (val === null) val = "";
|
||||
if (defaultVal === null) defaultVal = "";
|
||||
|
||||
return val.toString() !== defaultVal.toString();
|
||||
}.property("value", "default"),
|
||||
},
|
||||
|
||||
validValues: function() {
|
||||
@computed("valid_values")
|
||||
validValues(validValues) {
|
||||
const vals = [],
|
||||
translateNames = this.get("translate_names");
|
||||
|
||||
this.get("valid_values").forEach(v => {
|
||||
validValues.forEach(v => {
|
||||
if (v.name && v.name.length > 0 && translateNames) {
|
||||
vals.addObject({ name: I18n.t(v.name), value: v.value });
|
||||
} else {
|
||||
@@ -21,12 +22,12 @@ export default Ember.Mixin.create({
|
||||
}
|
||||
});
|
||||
return vals;
|
||||
}.property("valid_values"),
|
||||
},
|
||||
|
||||
allowsNone: function() {
|
||||
const validValues = this.get("valid_values");
|
||||
@computed("valid_values")
|
||||
allowsNone(validValues) {
|
||||
if (validValues && validValues.indexOf("") >= 0) {
|
||||
return "admin.settings.none";
|
||||
}
|
||||
}.property("valid_values")
|
||||
}
|
||||
});
|
||||
|
||||
@@ -293,17 +293,19 @@ const AdminUser = Discourse.User.extend({
|
||||
});
|
||||
},
|
||||
|
||||
canLockTrustLevel: function() {
|
||||
return this.get("trust_level") < 4;
|
||||
}.property("trust_level"),
|
||||
@computed("trust_level")
|
||||
canLockTrustLevel(trustLevel) {
|
||||
return trustLevel < 4;
|
||||
},
|
||||
|
||||
canSuspend: Ember.computed.not("staff"),
|
||||
|
||||
suspendDuration: function() {
|
||||
const suspended_at = moment(this.suspended_at),
|
||||
suspended_till = moment(this.suspended_till);
|
||||
return suspended_at.format("L") + " - " + suspended_till.format("L");
|
||||
}.property("suspended_till", "suspended_at"),
|
||||
@computed("suspended_till", "suspended_at")
|
||||
suspendDuration(suspendedTill, suspendedAt) {
|
||||
suspendedAt = moment(suspendedAt);
|
||||
suspendedTill = moment(suspendedTill);
|
||||
return suspendedAt.format("L") + " - " + suspendedTill.format("L");
|
||||
},
|
||||
|
||||
suspend(data) {
|
||||
return ajax(`/admin/users/${this.id}/suspend`, {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import ColorSchemeColor from "admin/models/color-scheme-color";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
init: function() {
|
||||
@@ -7,9 +8,10 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
this.startTrackingChanges();
|
||||
},
|
||||
|
||||
description: function() {
|
||||
@computed
|
||||
description() {
|
||||
return "" + this.name;
|
||||
}.property(),
|
||||
},
|
||||
|
||||
startTrackingChanges: function() {
|
||||
this.set("originals", {
|
||||
@@ -44,7 +46,8 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
return newScheme;
|
||||
},
|
||||
|
||||
changed: function() {
|
||||
@computed("name", "colors.@each.changed", "saving")
|
||||
changed() {
|
||||
if (!this.originals) return false;
|
||||
if (this.originals["name"] !== this.get("name")) return true;
|
||||
if (
|
||||
@@ -54,24 +57,23 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
}.property("name", "colors.@each.changed", "saving"),
|
||||
},
|
||||
|
||||
disableSave: function() {
|
||||
@computed("changed")
|
||||
disableSave(changed) {
|
||||
if (this.get("theme_id")) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
!this.get("changed") ||
|
||||
!changed ||
|
||||
this.get("saving") ||
|
||||
_.any(this.get("colors"), function(c) {
|
||||
return !c.get("valid");
|
||||
})
|
||||
);
|
||||
}.property("changed"),
|
||||
},
|
||||
|
||||
newRecord: function() {
|
||||
return !this.get("id");
|
||||
}.property("id"),
|
||||
newRecord: Ember.computed.not("id"),
|
||||
|
||||
save: function(opts) {
|
||||
if (this.get("is_base") || this.get("disableSave")) return;
|
||||
|
||||
@@ -76,25 +76,35 @@ const Report = Discourse.Model.extend({
|
||||
}
|
||||
},
|
||||
|
||||
todayCount: function() {
|
||||
@computed("data", "average")
|
||||
todayCount() {
|
||||
return this.valueAt(0);
|
||||
}.property("data", "average"),
|
||||
yesterdayCount: function() {
|
||||
return this.valueAt(1);
|
||||
}.property("data", "average"),
|
||||
sevenDaysAgoCount: function() {
|
||||
return this.valueAt(7);
|
||||
}.property("data", "average"),
|
||||
thirtyDaysAgoCount: function() {
|
||||
return this.valueAt(30);
|
||||
}.property("data", "average"),
|
||||
},
|
||||
|
||||
lastSevenDaysCount: function() {
|
||||
@computed("data", "average")
|
||||
yesterdayCount() {
|
||||
return this.valueAt(1);
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
sevenDaysAgoCount() {
|
||||
return this.valueAt(7);
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
thirtyDaysAgoCount() {
|
||||
return this.valueAt(30);
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
lastSevenDaysCount() {
|
||||
return this.averageCount(7, this.valueFor(1, 7));
|
||||
}.property("data", "average"),
|
||||
lastThirtyDaysCount: function() {
|
||||
},
|
||||
|
||||
@computed("data", "average")
|
||||
lastThirtyDaysCount() {
|
||||
return this.averageCount(30, this.valueFor(1, 30));
|
||||
}.property("data", "average"),
|
||||
},
|
||||
|
||||
averageCount(count, value) {
|
||||
return this.get("average") ? value / count : value;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const ScreenedEmail = Discourse.Model.extend({
|
||||
actionName: function() {
|
||||
return I18n.t("admin.logs.screened_actions." + this.get("action"));
|
||||
}.property("action"),
|
||||
@computed("action")
|
||||
actionName(action) {
|
||||
return I18n.t("admin.logs.screened_actions." + action);
|
||||
},
|
||||
|
||||
clearBlock: function() {
|
||||
return ajax("/admin/logs/screened_emails/" + this.get("id"), {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
const ScreenedUrl = Discourse.Model.extend({
|
||||
actionName: function() {
|
||||
return I18n.t("admin.logs.screened_actions." + this.get("action"));
|
||||
}.property("action")
|
||||
@computed("action")
|
||||
actionName(action) {
|
||||
return I18n.t("admin.logs.screened_actions." + action);
|
||||
}
|
||||
});
|
||||
|
||||
ScreenedUrl.reopenClass({
|
||||
|
||||
@@ -11,36 +11,7 @@ export default Discourse.Model.extend({
|
||||
return Math.round((minDaysVisited * 100) / timePeriod);
|
||||
},
|
||||
|
||||
met: function() {
|
||||
return {
|
||||
days_visited: this.get("days_visited") >= this.get("min_days_visited"),
|
||||
topics_replied_to:
|
||||
this.get("num_topics_replied_to") >= this.get("min_topics_replied_to"),
|
||||
topics_viewed: this.get("topics_viewed") >= this.get("min_topics_viewed"),
|
||||
posts_read: this.get("posts_read") >= this.get("min_posts_read"),
|
||||
topics_viewed_all_time:
|
||||
this.get("topics_viewed_all_time") >=
|
||||
this.get("min_topics_viewed_all_time"),
|
||||
posts_read_all_time:
|
||||
this.get("posts_read_all_time") >= this.get("min_posts_read_all_time"),
|
||||
flagged_posts:
|
||||
this.get("num_flagged_posts") <= this.get("max_flagged_posts"),
|
||||
flagged_by_users:
|
||||
this.get("num_flagged_by_users") <= this.get("max_flagged_by_users"),
|
||||
likes_given: this.get("num_likes_given") >= this.get("min_likes_given"),
|
||||
likes_received:
|
||||
this.get("num_likes_received") >= this.get("min_likes_received"),
|
||||
likes_received_days:
|
||||
this.get("num_likes_received_days") >=
|
||||
this.get("min_likes_received_days"),
|
||||
likes_received_users:
|
||||
this.get("num_likes_received_users") >=
|
||||
this.get("min_likes_received_users"),
|
||||
level_locked: this.get("trust_level_locked"),
|
||||
silenced: this.get("penalty_counts.silenced") === 0,
|
||||
suspended: this.get("penalty_counts.suspended") === 0
|
||||
};
|
||||
}.property(
|
||||
@computed(
|
||||
"days_visited",
|
||||
"min_days_visited",
|
||||
"num_topics_replied_to",
|
||||
@@ -71,4 +42,34 @@ export default Discourse.Model.extend({
|
||||
"penalty_counts.silenced",
|
||||
"penalty_counts.suspended"
|
||||
)
|
||||
met() {
|
||||
return {
|
||||
days_visited: this.get("days_visited") >= this.get("min_days_visited"),
|
||||
topics_replied_to:
|
||||
this.get("num_topics_replied_to") >= this.get("min_topics_replied_to"),
|
||||
topics_viewed: this.get("topics_viewed") >= this.get("min_topics_viewed"),
|
||||
posts_read: this.get("posts_read") >= this.get("min_posts_read"),
|
||||
topics_viewed_all_time:
|
||||
this.get("topics_viewed_all_time") >=
|
||||
this.get("min_topics_viewed_all_time"),
|
||||
posts_read_all_time:
|
||||
this.get("posts_read_all_time") >= this.get("min_posts_read_all_time"),
|
||||
flagged_posts:
|
||||
this.get("num_flagged_posts") <= this.get("max_flagged_posts"),
|
||||
flagged_by_users:
|
||||
this.get("num_flagged_by_users") <= this.get("max_flagged_by_users"),
|
||||
likes_given: this.get("num_likes_given") >= this.get("min_likes_given"),
|
||||
likes_received:
|
||||
this.get("num_likes_received") >= this.get("min_likes_received"),
|
||||
likes_received_days:
|
||||
this.get("num_likes_received_days") >=
|
||||
this.get("min_likes_received_days"),
|
||||
likes_received_users:
|
||||
this.get("num_likes_received_users") >=
|
||||
this.get("min_likes_received_users"),
|
||||
level_locked: this.get("trust_level_locked"),
|
||||
silenced: this.get("penalty_counts.silenced") === 0,
|
||||
suspended: this.get("penalty_counts.suspended") === 0
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user