DEV: Move computed to discourseComputed (#8312)

This commit is contained in:
Mark VanLandingham
2019-11-07 15:38:28 -06:00
committed by GitHub
parent d74546f50e
commit 6275c05c0d
395 changed files with 1770 additions and 1649 deletions

View File

@@ -1,4 +1,4 @@
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
const { isEmpty } = Ember;
import SelectKitFilterComponent from "select-kit/components/select-kit/select-kit-filter";
@@ -6,8 +6,8 @@ export default SelectKitFilterComponent.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-filter",
classNames: ["multi-select-filter"],
@computed("placeholder", "hasSelection")
computedPlaceholder(placeholder, hasSelection) {
@discourseComputed("placeholder", "hasSelection")
discourseComputedPlaceholder(placeholder, hasSelection) {
if (hasSelection) return "";
return isEmpty(placeholder) ? "" : I18n.t(placeholder);
}

View File

@@ -1,6 +1,6 @@
import { makeArray } from "discourse-common/lib/helpers";
import { on } from "ember-addons/ember-computed-decorators";
import computed from "ember-addons/ember-computed-decorators";
import { on } from "discourse-common/utils/decorators";
import discourseComputed from "discourse-common/utils/decorators";
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
export default SelectKitHeaderComponent.extend({
@@ -38,14 +38,14 @@ export default SelectKitHeaderComponent.extend({
$filter.width(availableSpace - parentRightPadding * 4);
},
@computed("computedContent.selection.[]")
@discourseComputed("computedContent.selection.[]")
names(selection) {
return makeArray(selection)
.map(s => s.name)
.join(",");
},
@computed("computedContent.selection.[]")
@discourseComputed("computedContent.selection.[]")
values(selection) {
return makeArray(selection)
.map(s => s.value)

View File

@@ -1,12 +1,12 @@
import SelectedNameComponent from "select-kit/components/multi-select/selected-name";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
export default SelectedNameComponent.extend({
classNames: "selected-category",
layoutName: "select-kit/templates/components/multi-select/selected-category",
@computed("computedContent.originalContent")
@discourseComputed("computedContent.originalContent")
badge(category) {
return categoryBadgeHTML(category, {
allowUncategorized: true,

View File

@@ -1,10 +1,10 @@
import SelectedNameComponent from "select-kit/components/multi-select/selected-name";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default SelectedNameComponent.extend({
classNames: "selected-color",
@computed("name")
@discourseComputed("name")
footerContent(name) {
return `<span class="color-preview" style="background:#${name}"></span>`.htmlSafe();
}

View File

@@ -1,5 +1,5 @@
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
attributeBindings: [
@@ -16,14 +16,14 @@ export default Component.extend({
tagName: "span",
tabindex: -1,
@computed("computedContent")
@discourseComputed("computedContent")
guid(computedContent) {
return Ember.guidFor(computedContent);
},
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
@computed("computedContent.title", "name")
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
if (computedContentTitle) return computedContentTitle;
if (name) return name;
@@ -41,7 +41,7 @@ export default Component.extend({
return this.getWithDefault("computedContent.locked", false);
}),
@computed("computedContent", "highlightedSelection.[]")
@discourseComputed("computedContent", "highlightedSelection.[]")
isHighlighted(computedContent, highlightedSelection) {
return highlightedSelection.includes(this.computedContent);
},