DEV: Import set, setProperties, helper, and string functions (#8297)
This commit is contained in:
parent
61b1f9c36b
commit
edc135d9c5
|
@ -1,6 +1,7 @@
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { on } from "ember-addons/ember-computed-decorators";
|
import { on } from "ember-addons/ember-computed-decorators";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNameBindings: [":value-list", ":secret-value-list"],
|
classNameBindings: [":value-list", ":secret-value-list"],
|
||||||
|
@ -67,7 +68,7 @@ export default Component.extend({
|
||||||
|
|
||||||
_replaceValue(index, newValue, keyName) {
|
_replaceValue(index, newValue, keyName) {
|
||||||
let item = this.collection[index];
|
let item = this.collection[index];
|
||||||
Ember.set(item, keyName, newValue);
|
set(item, keyName, newValue);
|
||||||
|
|
||||||
this._saveValues();
|
this._saveValues();
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { userPath } from "discourse/lib/url";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
import { fmt } from "discourse/lib/computed";
|
import { fmt } from "discourse/lib/computed";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
|
|
||||||
export default Controller.extend(CanCheckEmails, {
|
export default Controller.extend(CanCheckEmails, {
|
||||||
adminTools: service(),
|
adminTools: service(),
|
||||||
|
@ -47,7 +48,7 @@ export default Controller.extend(CanCheckEmails, {
|
||||||
automaticGroups(automaticGroups) {
|
automaticGroups(automaticGroups) {
|
||||||
return automaticGroups
|
return automaticGroups
|
||||||
.map(group => {
|
.map(group => {
|
||||||
const name = Ember.String.htmlSafe(group.name);
|
const name = htmlSafe(group.name);
|
||||||
return `<a href="/g/${name}">${name}</a>`;
|
return `<a href="/g/${name}">${name}</a>`;
|
||||||
})
|
})
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
router: service(),
|
router: service(),
|
||||||
|
@ -27,7 +28,7 @@ export default Controller.extend({
|
||||||
segment !== "admin"
|
segment !== "admin"
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.map(Ember.String.dasherize)
|
.map(dasherize)
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
// this is done to avoid breaking css customizations
|
// this is done to avoid breaking css customizations
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
} from "ember-addons/ember-computed-decorators";
|
} from "ember-addons/ember-computed-decorators";
|
||||||
import { THEMES, COMPONENTS } from "admin/models/theme";
|
import { THEMES, COMPONENTS } from "admin/models/theme";
|
||||||
import { POPULAR_THEMES } from "discourse-common/helpers/popular-themes";
|
import { POPULAR_THEMES } from "discourse-common/helpers/popular-themes";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
const MIN_NAME_LENGTH = 4;
|
const MIN_NAME_LENGTH = 4;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
themes(installedThemes) {
|
themes(installedThemes) {
|
||||||
return POPULAR_THEMES.map(t => {
|
return POPULAR_THEMES.map(t => {
|
||||||
if (installedThemes.includes(t.name)) {
|
if (installedThemes.includes(t.name)) {
|
||||||
Ember.set(t, "installed", true);
|
set(t, "installed", true);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
|
import Helper from "@ember/component/helper";
|
||||||
|
|
||||||
export default Ember.Helper.extend({
|
export default Helper.extend({
|
||||||
compute([disposition]) {
|
compute([disposition]) {
|
||||||
if (!disposition) {
|
if (!disposition) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import Helper from "@ember/component/helper";
|
||||||
|
|
||||||
function postActionTitle([id, nameKey]) {
|
function postActionTitle([id, nameKey]) {
|
||||||
let title = I18n.t(`admin.flags.short_names.${nameKey}`, {
|
let title = I18n.t(`admin.flags.short_names.${nameKey}`, {
|
||||||
defaultValue: null
|
defaultValue: null
|
||||||
|
@ -11,4 +13,4 @@ function postActionTitle([id, nameKey]) {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ember.Helper.helper(postActionTitle);
|
export default Helper.helper(postActionTitle);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { get } from "@ember/object";
|
import { get } from "@ember/object";
|
||||||
|
import Helper from "@ember/component/helper";
|
||||||
|
|
||||||
export function makeArray(obj) {
|
export function makeArray(obj) {
|
||||||
if (obj === null || obj === undefined) {
|
if (obj === null || obj === undefined) {
|
||||||
|
@ -8,7 +9,7 @@ export function makeArray(obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function htmlHelper(fn) {
|
export function htmlHelper(fn) {
|
||||||
return Ember.Helper.helper(function(...args) {
|
return Helper.helper(function(...args) {
|
||||||
args =
|
args =
|
||||||
args.length > 1 ? args[0].concat({ hash: args[args.length - 1] }) : args;
|
args.length > 1 ? args[0].concat({ hash: args[args.length - 1] }) : args;
|
||||||
return new Handlebars.SafeString(fn.apply(this, args) || "");
|
return new Handlebars.SafeString(fn.apply(this, args) || "");
|
||||||
|
@ -29,7 +30,7 @@ function rawGet(ctx, property, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerHelper(name, fn) {
|
export function registerHelper(name, fn) {
|
||||||
_helpers[name] = Ember.Helper.helper(fn);
|
_helpers[name] = Helper.helper(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findHelper(name) {
|
export function findHelper(name) {
|
||||||
|
@ -84,7 +85,7 @@ export function registerUnbound(name, fn) {
|
||||||
return fn.call(this, ...properties, resolveParams(this, options));
|
return fn.call(this, ...properties, resolveParams(this, options));
|
||||||
};
|
};
|
||||||
|
|
||||||
_helpers[name] = Ember.Helper.extend({
|
_helpers[name] = Helper.extend({
|
||||||
compute: (params, args) => fn(...params, args)
|
compute: (params, args) => fn(...params, args)
|
||||||
});
|
});
|
||||||
Handlebars.registerHelper(name, func);
|
Handlebars.registerHelper(name, func);
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { findHelper } from "discourse-common/lib/helpers";
|
import { findHelper } from "discourse-common/lib/helpers";
|
||||||
import { get } from "@ember/object";
|
import { get } from "@ember/object";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import { classify, dasherize } from "@ember/string";
|
||||||
/* global requirejs, require */
|
|
||||||
var classify = Ember.String.classify;
|
|
||||||
|
|
||||||
const _options = {};
|
const _options = {};
|
||||||
|
|
||||||
|
@ -63,7 +61,7 @@ export function buildResolver(baseName) {
|
||||||
split[1] = split[1].replace(".templates", "").replace("/templates", "");
|
split[1] = split[1].replace(".templates", "").replace("/templates", "");
|
||||||
|
|
||||||
// Try slashes
|
// Try slashes
|
||||||
let dashed = Ember.String.dasherize(split[1].replace(/\./g, "/"));
|
let dashed = dasherize(split[1].replace(/\./g, "/"));
|
||||||
if (
|
if (
|
||||||
requirejs.entries[appBase + dashed] ||
|
requirejs.entries[appBase + dashed] ||
|
||||||
requirejs.entries[adminBase + dashed]
|
requirejs.entries[adminBase + dashed]
|
||||||
|
@ -72,7 +70,7 @@ export function buildResolver(baseName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try with dashes instead of slashes
|
// Try with dashes instead of slashes
|
||||||
dashed = Ember.String.dasherize(split[1].replace(/\./g, "-"));
|
dashed = dasherize(split[1].replace(/\./g, "-"));
|
||||||
if (
|
if (
|
||||||
requirejs.entries[appBase + dashed] ||
|
requirejs.entries[appBase + dashed] ||
|
||||||
requirejs.entries[adminBase + dashed]
|
requirejs.entries[adminBase + dashed]
|
||||||
|
@ -86,7 +84,7 @@ export function buildResolver(baseName) {
|
||||||
customResolve(parsedName) {
|
customResolve(parsedName) {
|
||||||
// If we end with the name we want, use it. This allows us to define components within plugins.
|
// If we end with the name we want, use it. This allows us to define components within plugins.
|
||||||
const suffix = parsedName.type + "s/" + parsedName.fullNameWithoutType,
|
const suffix = parsedName.type + "s/" + parsedName.fullNameWithoutType,
|
||||||
dashed = Ember.String.dasherize(suffix),
|
dashed = dasherize(suffix),
|
||||||
moduleName = Object.keys(requirejs.entries).find(function(e) {
|
moduleName = Object.keys(requirejs.entries).find(function(e) {
|
||||||
return (
|
return (
|
||||||
e.indexOf(suffix, e.length - suffix.length) !== -1 ||
|
e.indexOf(suffix, e.length - suffix.length) !== -1 ||
|
||||||
|
|
|
@ -14,7 +14,9 @@ var define, requirejs;
|
||||||
"@ember/object": {
|
"@ember/object": {
|
||||||
default: Ember.Object,
|
default: Ember.Object,
|
||||||
get: Ember.get,
|
get: Ember.get,
|
||||||
getProperties: Ember.getProperties
|
getProperties: Ember.getProperties,
|
||||||
|
set: Ember.set,
|
||||||
|
setProperties: Ember.setProperties
|
||||||
},
|
},
|
||||||
"@ember/object/computed": {
|
"@ember/object/computed": {
|
||||||
default: Ember.computed,
|
default: Ember.computed,
|
||||||
|
@ -78,8 +80,23 @@ var define, requirejs;
|
||||||
Promise: Ember.RSVP.Promise,
|
Promise: Ember.RSVP.Promise,
|
||||||
hash: Ember.RSVP.hash,
|
hash: Ember.RSVP.hash,
|
||||||
all: Ember.RSVP.all
|
all: Ember.RSVP.all
|
||||||
|
},
|
||||||
|
"@ember/string": {
|
||||||
|
dasherize: Ember.String.dasherize,
|
||||||
|
classify: Ember.String.classify,
|
||||||
|
underscore: Ember.String.underscore,
|
||||||
|
camelize: Ember.String.camelize
|
||||||
|
},
|
||||||
|
"@ember/template": {
|
||||||
|
htmlSafe: Ember.String.htmlSafe
|
||||||
|
},
|
||||||
|
"@ember/application": {
|
||||||
|
setOwner: Ember.setOwner,
|
||||||
|
getOwner: Ember.getOwner
|
||||||
|
},
|
||||||
|
"@ember/component/helper": {
|
||||||
|
default: Ember.Helper
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import RestAdapter from "discourse/adapters/rest";
|
import RestAdapter from "discourse/adapters/rest";
|
||||||
import { Result } from "discourse/adapters/rest";
|
import { Result } from "discourse/adapters/rest";
|
||||||
|
import { underscore } from "@ember/string";
|
||||||
|
|
||||||
export default RestAdapter.extend({
|
export default RestAdapter.extend({
|
||||||
find(store, type, findArgs) {
|
find(store, type, findArgs) {
|
||||||
|
@ -10,7 +11,7 @@ export default RestAdapter.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
createRecord(store, type, args) {
|
createRecord(store, type, args) {
|
||||||
const typeField = Ember.String.underscore(type);
|
const typeField = underscore(type);
|
||||||
args.nested_post = true;
|
args.nested_post = true;
|
||||||
return ajax(this.pathFor(store, type), { method: "POST", data: args }).then(
|
return ajax(this.pathFor(store, type), { method: "POST", data: args }).then(
|
||||||
function(json) {
|
function(json) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { hashString } from "discourse/lib/hash";
|
import { hashString } from "discourse/lib/hash";
|
||||||
|
import { underscore } from "@ember/string";
|
||||||
|
|
||||||
const ADMIN_MODELS = [
|
const ADMIN_MODELS = [
|
||||||
"plugin",
|
"plugin",
|
||||||
|
@ -66,7 +67,7 @@ export default EmberObject.extend({
|
||||||
pathFor(store, type, findArgs) {
|
pathFor(store, type, findArgs) {
|
||||||
let path =
|
let path =
|
||||||
this.basePath(store, type, findArgs) +
|
this.basePath(store, type, findArgs) +
|
||||||
Ember.String.underscore(store.pluralize(this.apiNameFor(type)));
|
underscore(store.pluralize(this.apiNameFor(type)));
|
||||||
return this.appendQueryParams(path, findArgs);
|
return this.appendQueryParams(path, findArgs);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ export default EmberObject.extend({
|
||||||
|
|
||||||
update(store, type, id, attrs) {
|
update(store, type, id, attrs) {
|
||||||
const data = {};
|
const data = {};
|
||||||
const typeField = Ember.String.underscore(this.apiNameFor(type));
|
const typeField = underscore(this.apiNameFor(type));
|
||||||
data[typeField] = attrs;
|
data[typeField] = attrs;
|
||||||
|
|
||||||
return ajax(
|
return ajax(
|
||||||
|
@ -121,7 +122,7 @@ export default EmberObject.extend({
|
||||||
|
|
||||||
createRecord(store, type, attrs) {
|
createRecord(store, type, attrs) {
|
||||||
const data = {};
|
const data = {};
|
||||||
const typeField = Ember.String.underscore(this.apiNameFor(type));
|
const typeField = underscore(this.apiNameFor(type));
|
||||||
data[typeField] = attrs;
|
data[typeField] = attrs;
|
||||||
return ajax(this.pathFor(store, type), this.getPayload("POST", data)).then(
|
return ajax(this.pathFor(store, type), this.getPayload("POST", data)).then(
|
||||||
function(json) {
|
function(json) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: "",
|
tagName: "",
|
||||||
|
@ -12,7 +13,7 @@ export default Component.extend({
|
||||||
@computed("width", "height")
|
@computed("width", "height")
|
||||||
style(width, height) {
|
style(width, height) {
|
||||||
if (width && height) {
|
if (width && height) {
|
||||||
return Ember.String.htmlSafe(`--aspect-ratio: ${width / height};`);
|
return htmlSafe(`--aspect-ratio: ${width / height};`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { observes } from "ember-addons/ember-computed-decorators";
|
||||||
import { escapeExpression } from "discourse/lib/utilities";
|
import { escapeExpression } from "discourse/lib/utilities";
|
||||||
import { convertIconClass } from "discourse-common/lib/icon-library";
|
import { convertIconClass } from "discourse-common/lib/icon-library";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["group-flair-inputs"],
|
classNames: ["group-flair-inputs"],
|
||||||
|
@ -77,7 +78,7 @@ export default Component.extend({
|
||||||
|
|
||||||
if (flairHexColor) style += `color: #${flairHexColor};`;
|
if (flairHexColor) style += `color: #${flairHexColor};`;
|
||||||
|
|
||||||
return Ember.String.htmlSafe(style);
|
return htmlSafe(style);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("model.flairBackgroundHexColor")
|
@computed("model.flairBackgroundHexColor")
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { WidgetClickHook } from "discourse/widgets/hooks";
|
||||||
import { queryRegistry } from "discourse/widgets/widget";
|
import { queryRegistry } from "discourse/widgets/widget";
|
||||||
import { getRegister } from "discourse-common/lib/get-owner";
|
import { getRegister } from "discourse-common/lib/get-owner";
|
||||||
import DirtyKeys from "discourse/lib/dirty-keys";
|
import DirtyKeys from "discourse/lib/dirty-keys";
|
||||||
|
import { camelize } from "@ember/string";
|
||||||
|
|
||||||
let _cleanCallbacks = {};
|
let _cleanCallbacks = {};
|
||||||
export function addWidgetCleanCallback(widgetName, fn) {
|
export function addWidgetCleanCallback(widgetName, fn) {
|
||||||
|
@ -80,7 +81,7 @@ export default Component.extend({
|
||||||
afterPatch() {},
|
afterPatch() {},
|
||||||
|
|
||||||
eventDispatched(eventName, key, refreshArg) {
|
eventDispatched(eventName, key, refreshArg) {
|
||||||
const onRefresh = Ember.String.camelize(eventName.replace(/:/, "-"));
|
const onRefresh = camelize(eventName.replace(/:/, "-"));
|
||||||
this.dirtyKeys.keyDirty(key, { onRefresh, refreshArg });
|
this.dirtyKeys.keyDirty(key, { onRefresh, refreshArg });
|
||||||
this.queueRerender();
|
this.queueRerender();
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,8 @@ import computed from "ember-addons/ember-computed-decorators";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import optionalService from "discourse/lib/optional-service";
|
import optionalService from "discourse/lib/optional-service";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
let _components = {};
|
let _components = {};
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ export default Component.extend({
|
||||||
return _components[type];
|
return _components[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
let dasherized = Ember.String.dasherize(type);
|
let dasherized = dasherize(type);
|
||||||
let templatePath = `components/${dasherized}`;
|
let templatePath = `components/${dasherized}`;
|
||||||
let template =
|
let template =
|
||||||
Ember.TEMPLATES[`${templatePath}`] ||
|
Ember.TEMPLATES[`${templatePath}`] ||
|
||||||
|
@ -185,7 +187,7 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
valueChanged(fieldId, event) {
|
valueChanged(fieldId, event) {
|
||||||
Ember.set(this._updates, fieldId, event.target.value);
|
set(this._updates, fieldId, event.target.value);
|
||||||
},
|
},
|
||||||
|
|
||||||
perform(action) {
|
perform(action) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import CanCheckEmails from "discourse/mixins/can-check-emails";
|
||||||
import CardContentsBase from "discourse/mixins/card-contents-base";
|
import CardContentsBase from "discourse/mixins/card-contents-base";
|
||||||
import CleansUp from "discourse/mixins/cleans-up";
|
import CleansUp from "discourse/mixins/cleans-up";
|
||||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
||||||
elementId: "user-card",
|
elementId: "user-card",
|
||||||
|
@ -76,7 +77,7 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
|
||||||
.filterBy("show_on_user_card", true)
|
.filterBy("show_on_user_card", true)
|
||||||
.sortBy("position")
|
.sortBy("position")
|
||||||
.map(field => {
|
.map(field => {
|
||||||
Ember.set(field, "dasherized_name", field.get("name").dasherize());
|
set(field, "dasherized_name", field.get("name").dasherize());
|
||||||
const value = userFields ? userFields[field.get("id")] : null;
|
const value = userFields ? userFields[field.get("id")] : null;
|
||||||
return isEmpty(value) ? null : EmberObject.create({ value, field });
|
return isEmpty(value) ? null : EmberObject.create({ value, field });
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { reads } from "@ember/object/computed";
|
||||||
import { inject } from "@ember/controller";
|
import { inject } from "@ember/controller";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import DiscoveryController from "discourse/controllers/discovery";
|
import DiscoveryController from "discourse/controllers/discovery";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
const subcategoryStyleComponentNames = {
|
const subcategoryStyleComponentNames = {
|
||||||
rows: "categories_only",
|
rows: "categories_only",
|
||||||
|
@ -44,7 +45,7 @@ export default DiscoveryController.extend({
|
||||||
parentCategory && style === "categories_and_latest_topics"
|
parentCategory && style === "categories_and_latest_topics"
|
||||||
? "categories_only"
|
? "categories_only"
|
||||||
: style;
|
: style;
|
||||||
return Ember.String.dasherize(componentName);
|
return dasherize(componentName);
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
refresh() {
|
refresh() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import TopicTimer from "discourse/models/topic-timer";
|
import TopicTimer from "discourse/models/topic-timer";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
import { setProperties } from "@ember/object";
|
||||||
|
|
||||||
export const CLOSE_STATUS_TYPE = "close";
|
export const CLOSE_STATUS_TYPE = "close";
|
||||||
export const OPEN_STATUS_TYPE = "open";
|
export const OPEN_STATUS_TYPE = "open";
|
||||||
|
@ -78,7 +79,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
if (time) {
|
if (time) {
|
||||||
this.send("closeModal");
|
this.send("closeModal");
|
||||||
|
|
||||||
Ember.setProperties(this.topicTimer, {
|
setProperties(this.topicTimer, {
|
||||||
execute_at: result.execute_at,
|
execute_at: result.execute_at,
|
||||||
duration: result.duration,
|
duration: result.duration,
|
||||||
category_id: result.category_id
|
category_id: result.category_id
|
||||||
|
|
|
@ -9,6 +9,7 @@ import computed from "ember-addons/ember-computed-decorators";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import optionalService from "discourse/lib/optional-service";
|
import optionalService from "discourse/lib/optional-service";
|
||||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
export default Controller.extend(CanCheckEmails, {
|
export default Controller.extend(CanCheckEmails, {
|
||||||
indexStream: false,
|
indexStream: false,
|
||||||
|
@ -115,7 +116,7 @@ export default Controller.extend(CanCheckEmails, {
|
||||||
.filterBy("show_on_profile", true)
|
.filterBy("show_on_profile", true)
|
||||||
.sortBy("position")
|
.sortBy("position")
|
||||||
.map(field => {
|
.map(field => {
|
||||||
Ember.set(field, "dasherized_name", field.get("name").dasherize());
|
set(field, "dasherized_name", field.get("name").dasherize());
|
||||||
const value = userFields
|
const value = userFields
|
||||||
? userFields[field.get("id").toString()]
|
? userFields[field.get("id").toString()]
|
||||||
: null;
|
: null;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import Helper from "@ember/component/helper";
|
||||||
|
|
||||||
function dasherize([value]) {
|
function dasherize([value]) {
|
||||||
return (value || "").replace(".", "-").dasherize();
|
return (value || "").replace(".", "-").dasherize();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ember.Helper.helper(dasherize);
|
export default Helper.helper(dasherize);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { get } from "@ember/object";
|
import { get } from "@ember/object";
|
||||||
|
import Helper from "@ember/component/helper";
|
||||||
|
|
||||||
export function formatCurrency([reviewable, fieldId]) {
|
export function formatCurrency([reviewable, fieldId]) {
|
||||||
// The field `category_id` corresponds to `category`
|
// The field `category_id` corresponds to `category`
|
||||||
if (fieldId === "category_id") {
|
if (fieldId === "category_id") {
|
||||||
|
@ -15,4 +17,4 @@ export function formatCurrency([reviewable, fieldId]) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ember.Helper.helper(formatCurrency);
|
export default Helper.helper(formatCurrency);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
unsubscribe as unsubscribePushNotifications,
|
unsubscribe as unsubscribePushNotifications,
|
||||||
isPushNotificationsEnabled
|
isPushNotificationsEnabled
|
||||||
} from "discourse/lib/push-notifications";
|
} from "discourse/lib/push-notifications";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "subscribe-user-notifications",
|
name: "subscribe-user-notifications",
|
||||||
|
@ -120,7 +121,7 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
bus.subscribe("/client_settings", data =>
|
bus.subscribe("/client_settings", data =>
|
||||||
Ember.set(siteSettings, data.name, data.value)
|
set(siteSettings, data.name, data.value)
|
||||||
);
|
);
|
||||||
bus.subscribe("/refresh_client", data =>
|
bus.subscribe("/refresh_client", data =>
|
||||||
Discourse.set("assetVersion", data)
|
Discourse.set("assetVersion", data)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default function(name, opts) {
|
export default function(name, opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
const container = Discourse.__container__;
|
const container = Discourse.__container__;
|
||||||
|
@ -13,7 +15,7 @@ export default function(name, opts) {
|
||||||
modalController.set("name", controllerName);
|
modalController.set("name", controllerName);
|
||||||
|
|
||||||
let controller = container.lookup("controller:" + controllerName);
|
let controller = container.lookup("controller:" + controllerName);
|
||||||
const templateName = opts.templateName || Ember.String.dasherize(name);
|
const templateName = opts.templateName || dasherize(name);
|
||||||
|
|
||||||
const renderArgs = { into: "modal", outlet: "modalBody" };
|
const renderArgs = { into: "modal", outlet: "modalBody" };
|
||||||
if (controller) {
|
if (controller) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { escapeExpression, tinyAvatar } from "discourse/lib/utilities";
|
||||||
import { propertyNotEqual } from "discourse/lib/computed";
|
import { propertyNotEqual } from "discourse/lib/computed";
|
||||||
import throttle from "discourse/lib/throttle";
|
import throttle from "discourse/lib/throttle";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
// The actions the composer can take
|
// The actions the composer can take
|
||||||
export const CREATE_TOPIC = "createTopic",
|
export const CREATE_TOPIC = "createTopic",
|
||||||
|
@ -859,7 +860,7 @@ const Composer = RestModel.extend({
|
||||||
Object.keys(serializer).forEach(f => {
|
Object.keys(serializer).forEach(f => {
|
||||||
const val = this.get(serializer[f]);
|
const val = this.get(serializer[f]);
|
||||||
if (typeof val !== "undefined") {
|
if (typeof val !== "undefined") {
|
||||||
Ember.set(dest, f, val);
|
set(dest, f, val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
import ResultSet from "discourse/models/result-set";
|
import ResultSet from "discourse/models/result-set";
|
||||||
import { getRegister } from "discourse-common/lib/get-owner";
|
import { getRegister } from "discourse-common/lib/get-owner";
|
||||||
|
import { underscore } from "@ember/string";
|
||||||
|
import { set } from "@ember/object";
|
||||||
|
|
||||||
let _identityMap;
|
let _identityMap;
|
||||||
|
|
||||||
|
@ -96,7 +98,7 @@ export default EmberObject.extend({
|
||||||
const apiName = this.adapterFor(type).apiNameFor(type);
|
const apiName = this.adapterFor(type).apiNameFor(type);
|
||||||
return this._hydrate(
|
return this._hydrate(
|
||||||
type,
|
type,
|
||||||
result[Ember.String.underscore(apiName)],
|
result[underscore(apiName)],
|
||||||
result
|
result
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +156,7 @@ export default EmberObject.extend({
|
||||||
refreshResults(resultSet, type, url) {
|
refreshResults(resultSet, type, url) {
|
||||||
const adapter = this.adapterFor(type);
|
const adapter = this.adapterFor(type);
|
||||||
return ajax(url).then(result => {
|
return ajax(url).then(result => {
|
||||||
const typeName = Ember.String.underscore(
|
const typeName = underscore(
|
||||||
this.pluralize(adapter.apiNameFor(type))
|
this.pluralize(adapter.apiNameFor(type))
|
||||||
);
|
);
|
||||||
const content = result[typeName].map(obj =>
|
const content = result[typeName].map(obj =>
|
||||||
|
@ -167,7 +169,7 @@ export default EmberObject.extend({
|
||||||
appendResults(resultSet, type, url) {
|
appendResults(resultSet, type, url) {
|
||||||
const adapter = this.adapterFor(type);
|
const adapter = this.adapterFor(type);
|
||||||
return ajax(url).then(result => {
|
return ajax(url).then(result => {
|
||||||
const typeName = Ember.String.underscore(
|
const typeName = underscore(
|
||||||
this.pluralize(adapter.apiNameFor(type))
|
this.pluralize(adapter.apiNameFor(type))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -223,7 +225,7 @@ export default EmberObject.extend({
|
||||||
|
|
||||||
_resultSet(type, result, findArgs) {
|
_resultSet(type, result, findArgs) {
|
||||||
const adapter = this.adapterFor(type);
|
const adapter = this.adapterFor(type);
|
||||||
const typeName = Ember.String.underscore(
|
const typeName = underscore(
|
||||||
this.pluralize(adapter.apiNameFor(type))
|
this.pluralize(adapter.apiNameFor(type))
|
||||||
);
|
);
|
||||||
const content = result[typeName].map(obj =>
|
const content = result[typeName].map(obj =>
|
||||||
|
@ -327,7 +329,7 @@ export default EmberObject.extend({
|
||||||
obj[subType] = hydrated;
|
obj[subType] = hydrated;
|
||||||
delete obj[k];
|
delete obj[k];
|
||||||
} else {
|
} else {
|
||||||
Ember.set(obj, subType, null);
|
set(obj, subType, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
|
import { setOwner, getOwner } from '@ember/application';
|
||||||
|
|
||||||
export default class ComponentConnector {
|
export default class ComponentConnector {
|
||||||
constructor(widget, componentName, opts, trackedProperties) {
|
constructor(widget, componentName, opts, trackedProperties) {
|
||||||
this.widget = widget;
|
this.widget = widget;
|
||||||
|
@ -27,8 +29,8 @@ export default class ComponentConnector {
|
||||||
view._compute();
|
view._compute();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ember.setOwner) {
|
if (setOwner) {
|
||||||
Ember.setOwner(view, Ember.getOwner(mounted));
|
setOwner(view, getOwner(mounted));
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted._connected.push(view);
|
mounted._connected.push(view);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import { setOwner, getOwner } from "@ember/application";
|
||||||
|
|
||||||
export default class Connector {
|
export default class Connector {
|
||||||
constructor(widget, opts) {
|
constructor(widget, opts) {
|
||||||
|
@ -52,8 +53,8 @@ export default class Connector {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
if (Ember.setOwner) {
|
if (setOwner) {
|
||||||
Ember.setOwner(view, Ember.getOwner(mounted));
|
setOwner(view, getOwner(mounted));
|
||||||
}
|
}
|
||||||
mounted._connected.push(view);
|
mounted._connected.push(view);
|
||||||
view.renderer.appendTo(view, $elem[0]);
|
view.renderer.appendTo(view, $elem[0]);
|
||||||
|
|
|
@ -7,6 +7,8 @@ import {
|
||||||
REPLY,
|
REPLY,
|
||||||
EDIT
|
EDIT
|
||||||
} from "discourse/models/composer";
|
} from "discourse/models/composer";
|
||||||
|
import { camelize } from "@ember/string";
|
||||||
|
import { empty } from "@ember/object/computed";
|
||||||
|
|
||||||
// Component can get destroyed and lose state
|
// Component can get destroyed and lose state
|
||||||
let _topicSnapshot = null;
|
let _topicSnapshot = null;
|
||||||
|
@ -26,7 +28,7 @@ export default DropdownSelectBoxComponent.extend({
|
||||||
allowInitialValueMutation: false,
|
allowInitialValueMutation: false,
|
||||||
allowAutoSelectFirst: false,
|
allowAutoSelectFirst: false,
|
||||||
showFullTitle: false,
|
showFullTitle: false,
|
||||||
isHidden: Ember.computed.empty("content"),
|
isHidden: empty("content"),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
@ -292,7 +294,7 @@ export default DropdownSelectBoxComponent.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onSelect(value) {
|
onSelect(value) {
|
||||||
let action = `${Ember.String.camelize(value)}Selected`;
|
let action = `${camelize(value)}Selected`;
|
||||||
if (this[action]) {
|
if (this[action]) {
|
||||||
let model = this.composerModel;
|
let model = this.composerModel;
|
||||||
this[action](
|
this[action](
|
||||||
|
|
|
@ -3,6 +3,7 @@ import getUrl from "discourse-common/lib/get-url";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import { getToken } from "wizard/lib/ajax";
|
import { getToken } from "wizard/lib/ajax";
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: ["wizard-image-row"],
|
classNames: ["wizard-image-row"],
|
||||||
|
@ -10,7 +11,7 @@ export default Component.extend({
|
||||||
|
|
||||||
@computed("field.id")
|
@computed("field.id")
|
||||||
previewComponent(id) {
|
previewComponent(id) {
|
||||||
const componentName = `image-preview-${Ember.String.dasherize(id)}`;
|
const componentName = `image-preview-${dasherize(id)}`;
|
||||||
const exists = getOwner(this).lookup(`component:${componentName}`);
|
const exists = getOwner(this).lookup(`component:${componentName}`);
|
||||||
return exists ? componentName : "wizard-image-preview";
|
return exists ? componentName : "wizard-image-preview";
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNameBindings: [":wizard-field", "typeClass", "field.invalid"],
|
classNameBindings: [":wizard-field", "typeClass", "field.invalid"],
|
||||||
|
|
||||||
@computed("field.type")
|
@computed("field.type")
|
||||||
typeClass: type => `${Ember.String.dasherize(type)}-field`,
|
typeClass: type => `${dasherize(type)}-field`,
|
||||||
|
|
||||||
@computed("field.id")
|
@computed("field.id")
|
||||||
fieldClass: id => `field-${Ember.String.dasherize(id)} wizard-focusable`,
|
fieldClass: id => `field-${dasherize(id)} wizard-focusable`,
|
||||||
|
|
||||||
@computed("field.type", "field.id")
|
@computed("field.type", "field.id")
|
||||||
inputComponentName(type, id) {
|
inputComponentName(type, id) {
|
||||||
return type === "component"
|
return type === "component"
|
||||||
? Ember.String.dasherize(id)
|
? dasherize(id)
|
||||||
: `wizard-field-${type}`;
|
: `wizard-field-${type}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
default as computed,
|
default as computed,
|
||||||
observes
|
observes
|
||||||
} from "ember-addons/ember-computed-decorators";
|
} from "ember-addons/ember-computed-decorators";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
|
|
||||||
jQuery.fn.wiggle = function(times, duration) {
|
jQuery.fn.wiggle = function(times, duration) {
|
||||||
if (times > 0) {
|
if (times > 0) {
|
||||||
|
@ -89,7 +90,7 @@ export default Component.extend({
|
||||||
ratio = 1;
|
ratio = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ember.String.htmlSafe(`width: ${ratio * 200}px`);
|
return htmlSafe(`width: ${ratio * 200}px`);
|
||||||
},
|
},
|
||||||
|
|
||||||
autoFocus() {
|
autoFocus() {
|
||||||
|
|
Loading…
Reference in New Issue