DEV: Don't use attrs (#24323)

This commit is contained in:
Jarek Radosz 2023-11-27 12:16:31 +01:00 committed by GitHub
parent e05dbba845
commit b1e43425bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 30 additions and 32 deletions

View File

@ -116,11 +116,11 @@ export default class AceEditor extends Component {
this._skipContentChangeEvent = true; this._skipContentChangeEvent = true;
this.set("content", editor.getSession().getValue()); this.set("content", editor.getSession().getValue());
}); });
if (this.attrs.save) { if (this.save) {
editor.commands.addCommand({ editor.commands.addCommand({
name: "save", name: "save",
exec: () => { exec: () => {
this.attrs.save(); this.save();
}, },
bindKey: { mac: "cmd-s", win: "ctrl-s" }, bindKey: { mac: "cmd-s", win: "ctrl-s" },
}); });

View File

@ -220,11 +220,11 @@ export default class AdminReport extends Component {
@action @action
refreshReport(options = {}) { refreshReport(options = {}) {
if (!this.attrs.onRefresh) { if (!this.onRefresh) {
return; return;
} }
this.attrs.onRefresh({ this.onRefresh({
type: this.get("model.type"), type: this.get("model.type"),
mode: this.currentMode, mode: this.currentMode,
chartGrouping: options.chartGrouping, chartGrouping: options.chartGrouping,

View File

@ -45,8 +45,8 @@ export default class ColorInput extends Component {
@action @action
onHexInput(event) { onHexInput(event) {
if (this.attrs.onChangeColor) { if (this.onChangeColor) {
this.attrs.onChangeColor(this.normalize(event.target.value || "")); this.onChangeColor(this.normalize(event.target.value || ""));
} }
} }
@ -59,8 +59,8 @@ export default class ColorInput extends Component {
hexValueChanged() { hexValueChanged() {
const hex = this.hexValue; const hex = this.hexValue;
if (this.attrs.onChangeColor) { if (this.onChangeColor) {
this.attrs.onChangeColor(this.normalize(hex)); this.onChangeColor(this.normalize(hex));
} }
if (this._valid()) { if (this._valid()) {

View File

@ -9,8 +9,8 @@ export default Component.extend({
this.setProperties({ this.setProperties({
_table: this.element.querySelector(".directory-table"), _table: this.element.querySelector(".directory-table"),
_columnCount: this.showTimeRead _columnCount: this.showTimeRead
? this.attrs.columns.value.length + 1 ? this.columns.length + 1
: this.attrs.columns.value.length, : this.columns.length,
}); });
this._table.style.gridTemplateColumns = `minmax(13em, 3fr) repeat(${this._columnCount}, minmax(max-content, 1fr))`; this._table.style.gridTemplateColumns = `minmax(13em, 3fr) repeat(${this._columnCount}, minmax(max-content, 1fr))`;

View File

@ -190,8 +190,8 @@ export default Component.extend({
); );
} }
if (this.attrs.remove) { if (this.remove) {
this.attrs.remove(performResult.remove_reviewable_ids); this.remove(performResult.remove_reviewable_ids);
} else { } else {
return this.store.find("reviewable", reviewable.id); return this.store.find("reviewable", reviewable.id);
} }

View File

@ -53,8 +53,8 @@ export default Component.extend({
if ( if (
!isPresent(this.date) && !isPresent(this.date) &&
!isPresent(this.attrs.hours) && !isPresent(this.hours) &&
!isPresent(this.attrs.minutes) !isPresent(this.minutes)
) { ) {
this.setProperties({ this.setProperties({
hours: null, hours: null,

View File

@ -127,8 +127,8 @@ export default Component.extend({
this.modal.show(JumpToPost, { this.modal.show(JumpToPost, {
model: { model: {
topic: this.topic, topic: this.topic,
jumpToIndex: this.attrs.jumpToIndex, jumpToIndex: this.jumpToIndex,
jumpToDate: this.attrs.jumpToDate, jumpToDate: this.jumpToDate,
}, },
}); });
} }

View File

@ -177,6 +177,6 @@ export default Component.extend({
@action @action
goBack() { goBack() {
this.attrs.jumpToPost(this.get("topic.last_read_post_number")); this.jumpToPost(this.get("topic.last_read_post_number"));
}, },
}); });

View File

@ -41,8 +41,8 @@ export default DropdownSelectBoxComponent.extend({
_onChange(value, item) { _onChange(value, item) {
if (item.onChange) { if (item.onChange) {
item.onChange(value, item); item.onChange(value, item);
} else if (this.attrs.onChange) { } else if (this.onChange) {
this.attrs.onChange(value, item); this.onChange(value, item);
} }
}, },
}); });

View File

@ -33,8 +33,8 @@ export default MultiSelectComponent.extend({
const blockedCategories = makeArray(this.blockedCategories); const blockedCategories = makeArray(this.blockedCategories);
return Category.list().filter((category) => { return Category.list().filter((category) => {
if (category.isUncategorizedCategory) { if (category.isUncategorizedCategory) {
if (this.attrs.options?.allowUncategorized !== undefined) { if (this.options?.allowUncategorized !== undefined) {
return this.attrs.options.allowUncategorized; return this.options.allowUncategorized;
} }
return this.selectKit.options.allowUncategorized; return this.selectKit.options.allowUncategorized;
@ -70,8 +70,8 @@ export default MultiSelectComponent.extend({
return await Category.asyncSearch(filter, { return await Category.asyncSearch(filter, {
includeUncategorized: includeUncategorized:
this.attrs.options?.allowUncategorized !== undefined this.options?.allowUncategorized !== undefined
? this.attrs.options.allowUncategorized ? this.options.allowUncategorized
: this.selectKit.options.allowUncategorized, : this.selectKit.options.allowUncategorized,
rejectCategoryIds: Array.from(rejectCategoryIds), rejectCategoryIds: Array.from(rejectCategoryIds),
}); });

View File

@ -30,12 +30,11 @@ export default ComboBoxComponent.extend({
if (value !== "custom" && !isEmpty(value)) { if (value !== "custom" && !isEmpty(value)) {
const { time } = this.content.find((x) => x.id === value); const { time } = this.content.find((x) => x.id === value);
if (time) { if (time) {
this.attrs.onChangeInput && this.onChangeInput?.(time.locale("en").format(FORMAT));
this.attrs.onChangeInput(time.locale("en").format(FORMAT));
} }
} }
this.attrs.onChange && this.attrs.onChange(value); this.onChange?.(value);
}, },
}, },
}); });

View File

@ -97,7 +97,7 @@ export default MultiSelectComponent.extend({
item = item.length ? item[0] : null; item = item.length ? item[0] : null;
} }
this.attrs.onChange && this.attrs.onChange(value, item); this.onChange?.(value, item);
}, },
}, },
}); });

View File

@ -29,7 +29,7 @@ export default DropdownSelectBoxComponent.extend({
if (this.action) { if (this.action) {
this.action(value); this.action(value);
} else { } else {
this.attrs.onChange && this.attrs.onChange(value); this.onChange?.(value);
} }
}, },
}, },

View File

@ -75,7 +75,7 @@ export default Component.extend(
this.set( this.set(
"selectKit", "selectKit",
EmberObject.create({ EmberObject.create({
uniqueID: this.attrs?.id?.value || this.attrs?.id || guidFor(this), uniqueID: this.id || guidFor(this),
valueProperty: this.valueProperty, valueProperty: this.valueProperty,
nameProperty: this.nameProperty, nameProperty: this.nameProperty,
labelProperty: this.labelProperty, labelProperty: this.labelProperty,
@ -1128,15 +1128,14 @@ export default Component.extend(
_deprecateMutations() { _deprecateMutations() {
this.actions ??= {}; this.actions ??= {};
this.attrs ??= {};
if (!this.attrs.onChange && !this.actions.onChange) { if (!this.onChange && !this.actions.onChange) {
this._deprecated( this._deprecated(
"Implicit mutation has been deprecated, please use `onChange` handler" "Implicit mutation has been deprecated, please use `onChange` handler"
); );
this.actions.onChange = this.actions.onChange =
this.attrs.onSelect || this.onSelect ||
this.actions.onSelect || this.actions.onSelect ||
((value) => this.set("value", value)); ((value) => this.set("value", value));
} }