REFACTOR: Remove Ember.get

This commit is contained in:
Robin Ward 2019-10-31 16:28:10 -04:00
parent 89f602f66b
commit 640a05c4ee
31 changed files with 84 additions and 56 deletions

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { or, gt } from "@ember/object/computed"; import { or, gt } from "@ember/object/computed";
import RestModel from "discourse/models/rest"; import RestModel from "discourse/models/rest";
@ -243,7 +244,7 @@ const Theme = RestModel.extend({
@computed("childThemes.[]") @computed("childThemes.[]")
child_theme_ids(childThemes) { child_theme_ids(childThemes) {
if (childThemes) { if (childThemes) {
return childThemes.map(theme => Ember.get(theme, "id")); return childThemes.map(theme => get(theme, "id"));
} }
}, },

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import Badge from "discourse/models/badge"; import Badge from "discourse/models/badge";
@ -5,7 +6,7 @@ import showModal from "discourse/lib/show-modal";
export default Route.extend({ export default Route.extend({
serialize(m) { serialize(m) {
return { badge_id: Ember.get(m, "id") || "new" }; return { badge_id: get(m, "id") || "new" };
}, },
model(params) { model(params) {

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import AdminUser from "admin/models/admin-user"; import AdminUser from "admin/models/admin-user";
@ -10,7 +11,7 @@ export default DiscourseRoute.extend({
}, },
model(params) { model(params) {
return AdminUser.find(Ember.get(params, "user_id")); return AdminUser.find(get(params, "user_id"));
}, },
renderTemplate() { renderTemplate() {

View File

@ -1,10 +1,11 @@
import { get } from "@ember/object";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
model(params) { model(params) {
return this.store.findAll( return this.store.findAll(
"web-hook-event", "web-hook-event",
Ember.get(params, "web_hook_id") get(params, "web_hook_id")
); );
}, },

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
@ -10,7 +11,7 @@ export default DiscourseRoute.extend({
if (params.web_hook_id === "new") { if (params.web_hook_id === "new") {
return this.store.createRecord("web-hook"); return this.store.createRecord("web-hook");
} }
return this.store.find("web-hook", Ember.get(params, "web_hook_id")); return this.store.find("web-hook", get(params, "web_hook_id"));
}, },
setupController(controller, model) { setupController(controller, model) {

View File

@ -1,4 +1,4 @@
import { get } from "discourse-common/lib/raw-handlebars"; import { rawGet } from "discourse-common/lib/raw-handlebars";
export function htmlHelper(fn) { export function htmlHelper(fn) {
return Ember.Helper.helper(function(...args) { return Ember.Helper.helper(function(...args) {
@ -39,7 +39,7 @@ function resolveParams(ctx, options) {
) { ) {
params[k] = hash[k]; params[k] = hash[k];
} else if (type === "ID" || type === "PathExpression") { } else if (type === "ID" || type === "PathExpression") {
params[k] = get(ctx, hash[k], options); params[k] = rawGet(ctx, hash[k], options);
} }
}); });
} else { } else {
@ -59,7 +59,7 @@ export function registerUnbound(name, fn) {
options.types && options.types &&
(options.types[i] === "ID" || options.types[i] === "PathExpression") (options.types[i] === "ID" || options.types[i] === "PathExpression")
) { ) {
properties[i] = get(this, properties[i], options); properties[i] = rawGet(this, properties[i], options);
} }
} }

View File

@ -1,3 +1,5 @@
import { get } from "@ember/object";
// This is a mechanism for quickly rendering templates which is Ember aware // This is a mechanism for quickly rendering templates which is Ember aware
// templates are highly compatible with Ember so you don't need to worry about calling "get" // templates are highly compatible with Ember so you don't need to worry about calling "get"
// and computed properties function, additionally it uses stringParams like Ember does // and computed properties function, additionally it uses stringParams like Ember does
@ -24,7 +26,7 @@ RawHandlebars.helpers["get"] = function(context, options) {
context = context.slice(context.indexOf(".") + 1); context = context.slice(context.indexOf(".") + 1);
} }
return val === undefined ? Ember.get(firstContext, context) : val; return val === undefined ? get(firstContext, context) : val;
}; };
// adds compatability so this works with stringParams // adds compatability so this works with stringParams
@ -45,7 +47,7 @@ RawHandlebars.registerHelper("each", function(
contextName, contextName,
options options
) { ) {
var list = Ember.get(this, contextName); var list = get(this, contextName);
var output = []; var output = [];
var innerContext = objectCreate(this); var innerContext = objectCreate(this);
for (var i = 0; i < list.length; i++) { for (var i = 0; i < list.length; i++) {
@ -178,7 +180,7 @@ RawHandlebars.get = function(ctx, property, options) {
? view.getStream(property).value() ? view.getStream(property).value()
: view.getAttr(property); : view.getAttr(property);
} else { } else {
return Ember.get(ctx, property); return get(ctx, property);
} }
}; };
@ -194,7 +196,7 @@ export function compile() {
return RawHandlebars.compile.apply(this, arguments); return RawHandlebars.compile.apply(this, arguments);
} }
export function get() { export function rawGet() {
return RawHandlebars.get.apply(this, arguments); return RawHandlebars.get.apply(this, arguments);
} }

View File

@ -11,7 +11,10 @@ var define, requirejs;
default: Ember.Controller, default: Ember.Controller,
inject: Ember.inject.controller inject: Ember.inject.controller
}, },
"@ember/object": { default: Ember.Object }, "@ember/object": {
default: Ember.Object,
get: Ember.get
},
"@ember/object/computed": { "@ember/object/computed": {
default: Ember.computed, default: Ember.computed,
alias: Ember.computed.alias, alias: Ember.computed.alias,

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import Component from "@ember/component"; import Component from "@ember/component";
@ -57,7 +58,7 @@ export default Component.extend({
actions: { actions: {
chooseMessage(message) { chooseMessage(message) {
const messageId = Ember.get(message, "id"); const messageId = get(message, "id");
this.set("selectedTopicId", messageId); this.set("selectedTopicId", messageId);
next(() => $(`#choose-message-${messageId}`).prop("checked", "true")); next(() => $(`#choose-message-${messageId}`).prop("checked", "true"));
return false; return false;

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
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 { categoryBadgeHTML } from "discourse/helpers/category-link"; import { categoryBadgeHTML } from "discourse/helpers/category-link";
@ -35,7 +36,7 @@ export default Component.extend({
if ( if (
category && category &&
Ember.get(category, "id") === get(category, "id") ===
Discourse.Site.currentProp("uncategorized_category_id") Discourse.Site.currentProp("uncategorized_category_id")
) { ) {
category = null; category = null;

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { htmlHelper } from "discourse-common/lib/helpers"; import { htmlHelper } from "discourse-common/lib/helpers";
import { avatarImg } from "discourse/lib/utilities"; import { avatarImg } from "discourse/lib/utilities";
@ -8,6 +9,6 @@ export default htmlHelper((user, size) => {
return "<div class='avatar-placeholder'></div>"; return "<div class='avatar-placeholder'></div>";
} }
const avatarTemplate = Ember.get(user, "avatar_template"); const avatarTemplate = get(user, "avatar_template");
return avatarImg(addExtraUserClasses(user, { size, avatarTemplate })); return avatarImg(addExtraUserClasses(user, { size, avatarTemplate }));
}); });

View File

@ -1,10 +1,9 @@
import { get } from "@ember/object";
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
import { isRTL } from "discourse/lib/text-direction"; import { isRTL } from "discourse/lib/text-direction";
import { iconHTML } from "discourse-common/lib/icon-library"; import { iconHTML } from "discourse-common/lib/icon-library";
var get = Ember.get, let escapeExpression = Handlebars.Utils.escapeExpression;
escapeExpression = Handlebars.Utils.escapeExpression;
let _renderer = defaultCategoryLinkRenderer; let _renderer = defaultCategoryLinkRenderer;
export function replaceCategoryLinkRenderer(fn) { export function replaceCategoryLinkRenderer(fn) {
@ -32,7 +31,7 @@ export function categoryBadgeHTML(category, opts) {
if ( if (
!category || !category ||
(!opts.allowUncategorized && (!opts.allowUncategorized &&
Ember.get(category, "id") === get(category, "id") ===
Discourse.Site.currentProp("uncategorized_category_id") && Discourse.Site.currentProp("uncategorized_category_id") &&
Discourse.SiteSettings.suppress_uncategorized_badge) Discourse.SiteSettings.suppress_uncategorized_badge)
) )

View File

@ -1,10 +1,11 @@
import { get } from "@ember/object";
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") {
fieldId = "category.id"; fieldId = "category.id";
} }
let value = Ember.get(reviewable, fieldId); let value = get(reviewable, fieldId);
// If it's an array, say tags, make a copy so we aren't mutating the original // If it's an array, say tags, make a copy so we aren't mutating the original
if (Array.isArray(value)) { if (Array.isArray(value)) {

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
import { avatarImg, formatUsername } from "discourse/lib/utilities"; import { avatarImg, formatUsername } from "discourse/lib/utilities";
@ -30,9 +31,9 @@ function renderAvatar(user, options) {
options = options || {}; options = options || {};
if (user) { if (user) {
const name = Ember.get(user, options.namePath || "name"); const name = get(user, options.namePath || "name");
const username = Ember.get(user, options.usernamePath || "username"); const username = get(user, options.usernamePath || "username");
const avatarTemplate = Ember.get( const avatarTemplate = get(
user, user,
options.avatarTemplatePath || "avatar_template" options.avatarTemplatePath || "avatar_template"
); );
@ -46,11 +47,11 @@ function renderAvatar(user, options) {
let title = options.title; let title = options.title;
if (!title && !options.ignoreTitle) { if (!title && !options.ignoreTitle) {
// first try to get a title // first try to get a title
title = Ember.get(user, "title"); title = get(user, "title");
// if there was no title provided // if there was no title provided
if (!title) { if (!title) {
// try to retrieve a description // try to retrieve a description
const description = Ember.get(user, "description"); const description = get(user, "description");
// if a description has been provided // if a description has been provided
if (description && description.length > 0) { if (description && description.length > 0) {
// preprend the username before the description // preprend the username before the description
@ -61,7 +62,7 @@ function renderAvatar(user, options) {
return avatarImg({ return avatarImg({
size: options.imageSize, size: options.imageSize,
extraClasses: Ember.get(user, "extras") || options.extraClasses, extraClasses: get(user, "extras") || options.extraClasses,
title: title || displayName, title: title || displayName,
avatarTemplate: avatarTemplate avatarTemplate: avatarTemplate
}); });

View File

@ -463,7 +463,7 @@ class PluginApi {
```javascript ```javascript
api.customUserAvatarClasses(user => { api.customUserAvatarClasses(user => {
if (Ember.get(user, 'primary_group_name') === 'managers') { if (get(user, 'primary_group_name') === 'managers') {
return ['managers']; return ['managers'];
} }
}); });

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import RestModel from "discourse/models/rest"; import RestModel from "discourse/models/rest";
import computed from "ember-addons/ember-computed-decorators"; import computed from "ember-addons/ember-computed-decorators";
@ -232,15 +233,15 @@ Category.reopenClass({
slugFor(category, separator = "/") { slugFor(category, separator = "/") {
if (!category) return ""; if (!category) return "";
const parentCategory = Ember.get(category, "parentCategory"); const parentCategory = get(category, "parentCategory");
let result = ""; let result = "";
if (parentCategory) { if (parentCategory) {
result = Category.slugFor(parentCategory) + separator; result = Category.slugFor(parentCategory) + separator;
} }
const id = Ember.get(category, "id"), const id = get(category, "id"),
slug = Ember.get(category, "slug"); slug = get(category, "slug");
return !slug || slug.trim().length === 0 return !slug || slug.trim().length === 0
? `${result}${id}-category` ? `${result}${id}-category`

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { or, not, and } from "@ember/object/computed"; import { or, not, and } from "@ember/object/computed";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
@ -882,12 +883,12 @@ export default RestModel.extend({
than you supplied if the post has already been loaded. than you supplied if the post has already been loaded.
**/ **/
storePost(post) { storePost(post) {
// Calling `Ember.get(undefined)` raises an error // Calling `get(undefined)` raises an error
if (!post) { if (!post) {
return; return;
} }
const postId = Ember.get(post, "id"); const postId = get(post, "id");
if (postId) { if (postId) {
const existing = this._identityMap[post.get("id")]; const existing = this._identityMap[post.get("id")];
@ -931,7 +932,7 @@ export default RestModel.extend({
this.set("topic.suggested_topics", result.suggested_topics); this.set("topic.suggested_topics", result.suggested_topics);
} }
const posts = Ember.get(result, "post_stream.posts"); const posts = get(result, "post_stream.posts");
if (posts) { if (posts) {
posts.forEach(p => { posts.forEach(p => {
@ -971,7 +972,7 @@ export default RestModel.extend({
this.set("topic.suggested_topics", result.suggested_topics); this.set("topic.suggested_topics", result.suggested_topics);
} }
const posts = Ember.get(result, "post_stream.posts"); const posts = get(result, "post_stream.posts");
if (posts) { if (posts) {
posts.forEach(p => this.storePost(store.createRecord("post", p))); posts.forEach(p => this.storePost(store.createRecord("post", p)));

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { equal, and, or, not } from "@ember/object/computed"; import { equal, and, or, not } from "@ember/object/computed";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
@ -282,7 +283,7 @@ const Post = RestModel.extend({
if (key === "reply_to_user" && value && oldValue) { if (key === "reply_to_user" && value && oldValue) {
skip = skip =
value.username === oldValue.username || value.username === oldValue.username ||
Ember.get(value, "username") === Ember.get(oldValue, "username"); get(value, "username") === get(oldValue, "username");
} }
if (!skip) { if (!skip) {

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { alias, sort } from "@ember/object/computed"; import { alias, sort } from "@ember/object/computed";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
@ -110,7 +111,7 @@ const Site = RestModel.extend({
updateCategory(newCategory) { updateCategory(newCategory) {
const categories = this.categories; const categories = this.categories;
const categoryId = Ember.get(newCategory, "id"); const categoryId = get(newCategory, "id");
const existingCategory = categories.findBy("id", categoryId); const existingCategory = categories.findBy("id", categoryId);
// Don't update null permissions // Don't update null permissions

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { NotificationLevels } from "discourse/lib/notification-levels"; import { NotificationLevels } from "discourse/lib/notification-levels";
import { import {
@ -390,8 +391,8 @@ const TopicTrackingState = Discourse.Model.extend({
); );
} }
let categoryId = category ? Ember.get(category, "id") : null; let categoryId = category ? get(category, "id") : null;
let categoryName = category ? Ember.get(category, "name") : null; let categoryName = category ? get(category, "name") : null;
if (name === "new") { if (name === "new") {
return this.countNew(categoryId); return this.countNew(categoryId);

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { not, notEmpty, equal, and, or } from "@ember/object/computed"; import { not, notEmpty, equal, and, or } from "@ember/object/computed";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
@ -378,7 +379,7 @@ const Topic = RestModel.extend({
this.set("bookmarking", true); this.set("bookmarking", true);
const stream = this.postStream; const stream = this.postStream;
const posts = Ember.get(stream, "posts"); const posts = get(stream, "posts");
const firstPost = const firstPost =
posts && posts[0] && posts[0].get("post_number") === 1 && posts[0]; posts && posts[0] && posts[0].get("post_number") === 1 && posts[0];
const bookmark = !this.bookmarked; const bookmark = !this.bookmarked;

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
export function buildGroupPage(type) { export function buildGroupPage(type) {
@ -9,7 +10,7 @@ export function buildGroupPage(type) {
}, },
model(params, transition) { model(params, transition) {
let categoryId = Ember.get(transition.to, "queryParams.category_id"); let categoryId = get(transition.to, "queryParams.category_id");
return this.modelFor("group").findPosts({ type, categoryId }); return this.modelFor("group").findPosts({ type, categoryId });
}, },

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { cancel } from "@ember/runloop"; import { cancel } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop"; import { scheduleOnce } from "@ember/runloop";
@ -215,9 +216,9 @@ const TopicRoute = DiscourseRoute.extend({
setupParams(topic, params) { setupParams(topic, params) {
const postStream = topic.get("postStream"); const postStream = topic.get("postStream");
postStream.set("summary", Ember.get(params, "filter") === "summary"); postStream.set("summary", get(params, "filter") === "summary");
const usernames = Ember.get(params, "username_filters"), const usernames = get(params, "username_filters"),
userFilters = postStream.get("userFilters"); userFilters = postStream.get("userFilters");
userFilters.clear(); userFilters.clear();

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { import {
default as computed, default as computed,
@ -19,7 +20,7 @@ export default EmberObject.extend({
contextType: { contextType: {
get(searchContext) { get(searchContext) {
if (searchContext) { if (searchContext) {
return Ember.get(searchContext, "type"); return get(searchContext, "type");
} }
}, },
set(value, searchContext) { set(value, searchContext) {

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import Service from "@ember/service"; import Service from "@ember/service";
export default Service.extend({ export default Service.extend({
@ -14,7 +15,7 @@ export default Service.extend({
getSetting(themeId, settingsKey) { getSetting(themeId, settingsKey) {
if (this._settings[themeId]) { if (this._settings[themeId]) {
return Ember.get(this._settings[themeId], settingsKey); return get(this._settings[themeId], settingsKey);
} }
return null; return null;
}, },

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { schedule } from "@ember/runloop"; import { schedule } from "@ember/runloop";
import { createWidget } from "discourse/widgets/widget"; import { createWidget } from "discourse/widgets/widget";
import { iconNode } from "discourse-common/lib/icon-library"; import { iconNode } from "discourse-common/lib/icon-library";
@ -558,7 +559,7 @@ export default createWidget("header", {
if (service) { if (service) {
const ctx = service.get("searchContext"); const ctx = service.get("searchContext");
if (ctx) { if (ctx) {
return Ember.get(ctx, "type"); return get(ctx, "type");
} }
} }
} }

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { searchContextDescription } from "discourse/lib/search"; import { searchContextDescription } from "discourse/lib/search";
import { h } from "virtual-dom"; import { h } from "virtual-dom";
import { createWidget } from "discourse/widgets/widget"; import { createWidget } from "discourse/widgets/widget";
@ -52,8 +53,8 @@ createWidget("search-context", {
const result = []; const result = [];
if (ctx) { if (ctx) {
const description = searchContextDescription( const description = searchContextDescription(
Ember.get(ctx, "type"), get(ctx, "type"),
Ember.get(ctx, "user.username") || Ember.get(ctx, "category.name") get(ctx, "user.username") || get(ctx, "category.name")
); );
result.push( result.push(
h("label", [ h("label", [

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { debounce } from "@ember/runloop"; import { debounce } from "@ember/runloop";
import { later } from "@ember/runloop"; import { later } from "@ember/runloop";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
@ -99,7 +100,7 @@ export default createWidget("search-menu", {
const contextEnabled = searchData.contextEnabled; const contextEnabled = searchData.contextEnabled;
const ctx = contextEnabled ? this.searchContext() : null; const ctx = contextEnabled ? this.searchContext() : null;
const type = ctx ? Ember.get(ctx, "type") : null; const type = ctx ? get(ctx, "type") : null;
let url = "/search"; let url = "/search";
const params = []; const params = [];

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { makeArray } from "discourse/lib/utilities"; import { makeArray } from "discourse/lib/utilities";
import MultiSelectComponent from "select-kit/components/multi-select"; import MultiSelectComponent from "select-kit/components/multi-select";
import Category from "discourse/models/category"; import Category from "discourse/models/category";
@ -39,7 +40,7 @@ export default MultiSelectComponent.extend({
filterComputedContent(computedContent, computedValues, filter) { filterComputedContent(computedContent, computedValues, filter) {
const regex = new RegExp(filter, "i"); const regex = new RegExp(filter, "i");
return computedContent.filter(category => return computedContent.filter(category =>
this._normalize(Ember.get(category, "name")).match(regex) this._normalize(get(category, "name")).match(regex)
); );
}, },

View File

@ -1,3 +1,5 @@
import { isEmpty } from "@ember/utils";
import { get } from "@ember/object";
import { makeArray } from "discourse/lib/utilities"; import { makeArray } from "discourse/lib/utilities";
import Category from "discourse/models/category"; import Category from "discourse/models/category";
import ComboBox from "select-kit/components/combo-box"; import ComboBox from "select-kit/components/combo-box";
@ -6,7 +8,6 @@ import { default as computed } from "ember-addons/ember-computed-decorators";
import renderTag from "discourse/lib/render-tag"; import renderTag from "discourse/lib/render-tag";
import { escapeExpression } from "discourse/lib/utilities"; import { escapeExpression } from "discourse/lib/utilities";
import { iconHTML } from "discourse-common/lib/icon-library"; import { iconHTML } from "discourse-common/lib/icon-library";
const { get, isEmpty, run } = Ember;
export default ComboBox.extend(TagsMixin, { export default ComboBox.extend(TagsMixin, {
allowContentReplacement: true, allowContentReplacement: true,
@ -168,9 +169,7 @@ export default ComboBox.extend(TagsMixin, {
computeHeaderContent() { computeHeaderContent() {
let content = this._super(...arguments); let content = this._super(...arguments);
const joinedTags = this.selection const joinedTags = this.selection.map(s => get(s, "value")).join(", ");
.map(s => Ember.get(s, "value"))
.join(", ");
if (isEmpty(this.selection)) { if (isEmpty(this.selection)) {
content.label = I18n.t("tagging.choose_for_topic"); content.label = I18n.t("tagging.choose_for_topic");
@ -198,7 +197,7 @@ export default ComboBox.extend(TagsMixin, {
if (this.selection) { if (this.selection) {
data.selected_tags = this.selection data.selected_tags = this.selection
.map(s => Ember.get(s, "value")) .map(s => get(s, "value"))
.slice(0, 100); .slice(0, 100);
} }

View File

@ -1,3 +1,4 @@
import { get } from "@ember/object";
import { makeArray } from "discourse/lib/utilities"; import { makeArray } from "discourse/lib/utilities";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { throttle } from "@ember/runloop"; import { throttle } from "@ember/runloop";
@ -298,7 +299,7 @@ export default Mixin.create({
.slice() .slice()
.reverse() .reverse()
.some(selection => { .some(selection => {
if (!Ember.get(selection, "locked")) { if (!get(selection, "locked")) {
this.highlightSelection(selection); this.highlightSelection(selection);
return true; return true;
} }