mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 13:03:39 +08:00
DEV: Don't use attrs
(#24323)
This commit is contained in:
parent
e05dbba845
commit
b1e43425bf
|
@ -116,11 +116,11 @@ export default class AceEditor extends Component {
|
|||
this._skipContentChangeEvent = true;
|
||||
this.set("content", editor.getSession().getValue());
|
||||
});
|
||||
if (this.attrs.save) {
|
||||
if (this.save) {
|
||||
editor.commands.addCommand({
|
||||
name: "save",
|
||||
exec: () => {
|
||||
this.attrs.save();
|
||||
this.save();
|
||||
},
|
||||
bindKey: { mac: "cmd-s", win: "ctrl-s" },
|
||||
});
|
||||
|
|
|
@ -220,11 +220,11 @@ export default class AdminReport extends Component {
|
|||
|
||||
@action
|
||||
refreshReport(options = {}) {
|
||||
if (!this.attrs.onRefresh) {
|
||||
if (!this.onRefresh) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.attrs.onRefresh({
|
||||
this.onRefresh({
|
||||
type: this.get("model.type"),
|
||||
mode: this.currentMode,
|
||||
chartGrouping: options.chartGrouping,
|
||||
|
|
|
@ -45,8 +45,8 @@ export default class ColorInput extends Component {
|
|||
|
||||
@action
|
||||
onHexInput(event) {
|
||||
if (this.attrs.onChangeColor) {
|
||||
this.attrs.onChangeColor(this.normalize(event.target.value || ""));
|
||||
if (this.onChangeColor) {
|
||||
this.onChangeColor(this.normalize(event.target.value || ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ export default class ColorInput extends Component {
|
|||
hexValueChanged() {
|
||||
const hex = this.hexValue;
|
||||
|
||||
if (this.attrs.onChangeColor) {
|
||||
this.attrs.onChangeColor(this.normalize(hex));
|
||||
if (this.onChangeColor) {
|
||||
this.onChangeColor(this.normalize(hex));
|
||||
}
|
||||
|
||||
if (this._valid()) {
|
||||
|
|
|
@ -9,8 +9,8 @@ export default Component.extend({
|
|||
this.setProperties({
|
||||
_table: this.element.querySelector(".directory-table"),
|
||||
_columnCount: this.showTimeRead
|
||||
? this.attrs.columns.value.length + 1
|
||||
: this.attrs.columns.value.length,
|
||||
? this.columns.length + 1
|
||||
: this.columns.length,
|
||||
});
|
||||
|
||||
this._table.style.gridTemplateColumns = `minmax(13em, 3fr) repeat(${this._columnCount}, minmax(max-content, 1fr))`;
|
||||
|
|
|
@ -190,8 +190,8 @@ export default Component.extend({
|
|||
);
|
||||
}
|
||||
|
||||
if (this.attrs.remove) {
|
||||
this.attrs.remove(performResult.remove_reviewable_ids);
|
||||
if (this.remove) {
|
||||
this.remove(performResult.remove_reviewable_ids);
|
||||
} else {
|
||||
return this.store.find("reviewable", reviewable.id);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ export default Component.extend({
|
|||
|
||||
if (
|
||||
!isPresent(this.date) &&
|
||||
!isPresent(this.attrs.hours) &&
|
||||
!isPresent(this.attrs.minutes)
|
||||
!isPresent(this.hours) &&
|
||||
!isPresent(this.minutes)
|
||||
) {
|
||||
this.setProperties({
|
||||
hours: null,
|
||||
|
|
|
@ -127,8 +127,8 @@ export default Component.extend({
|
|||
this.modal.show(JumpToPost, {
|
||||
model: {
|
||||
topic: this.topic,
|
||||
jumpToIndex: this.attrs.jumpToIndex,
|
||||
jumpToDate: this.attrs.jumpToDate,
|
||||
jumpToIndex: this.jumpToIndex,
|
||||
jumpToDate: this.jumpToDate,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -177,6 +177,6 @@ export default Component.extend({
|
|||
|
||||
@action
|
||||
goBack() {
|
||||
this.attrs.jumpToPost(this.get("topic.last_read_post_number"));
|
||||
this.jumpToPost(this.get("topic.last_read_post_number"));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -41,8 +41,8 @@ export default DropdownSelectBoxComponent.extend({
|
|||
_onChange(value, item) {
|
||||
if (item.onChange) {
|
||||
item.onChange(value, item);
|
||||
} else if (this.attrs.onChange) {
|
||||
this.attrs.onChange(value, item);
|
||||
} else if (this.onChange) {
|
||||
this.onChange(value, item);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -33,8 +33,8 @@ export default MultiSelectComponent.extend({
|
|||
const blockedCategories = makeArray(this.blockedCategories);
|
||||
return Category.list().filter((category) => {
|
||||
if (category.isUncategorizedCategory) {
|
||||
if (this.attrs.options?.allowUncategorized !== undefined) {
|
||||
return this.attrs.options.allowUncategorized;
|
||||
if (this.options?.allowUncategorized !== undefined) {
|
||||
return this.options.allowUncategorized;
|
||||
}
|
||||
|
||||
return this.selectKit.options.allowUncategorized;
|
||||
|
@ -70,8 +70,8 @@ export default MultiSelectComponent.extend({
|
|||
|
||||
return await Category.asyncSearch(filter, {
|
||||
includeUncategorized:
|
||||
this.attrs.options?.allowUncategorized !== undefined
|
||||
? this.attrs.options.allowUncategorized
|
||||
this.options?.allowUncategorized !== undefined
|
||||
? this.options.allowUncategorized
|
||||
: this.selectKit.options.allowUncategorized,
|
||||
rejectCategoryIds: Array.from(rejectCategoryIds),
|
||||
});
|
||||
|
|
|
@ -30,12 +30,11 @@ export default ComboBoxComponent.extend({
|
|||
if (value !== "custom" && !isEmpty(value)) {
|
||||
const { time } = this.content.find((x) => x.id === value);
|
||||
if (time) {
|
||||
this.attrs.onChangeInput &&
|
||||
this.attrs.onChangeInput(time.locale("en").format(FORMAT));
|
||||
this.onChangeInput?.(time.locale("en").format(FORMAT));
|
||||
}
|
||||
}
|
||||
|
||||
this.attrs.onChange && this.attrs.onChange(value);
|
||||
this.onChange?.(value);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -97,7 +97,7 @@ export default MultiSelectComponent.extend({
|
|||
item = item.length ? item[0] : null;
|
||||
}
|
||||
|
||||
this.attrs.onChange && this.attrs.onChange(value, item);
|
||||
this.onChange?.(value, item);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ export default DropdownSelectBoxComponent.extend({
|
|||
if (this.action) {
|
||||
this.action(value);
|
||||
} else {
|
||||
this.attrs.onChange && this.attrs.onChange(value);
|
||||
this.onChange?.(value);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -75,7 +75,7 @@ export default Component.extend(
|
|||
this.set(
|
||||
"selectKit",
|
||||
EmberObject.create({
|
||||
uniqueID: this.attrs?.id?.value || this.attrs?.id || guidFor(this),
|
||||
uniqueID: this.id || guidFor(this),
|
||||
valueProperty: this.valueProperty,
|
||||
nameProperty: this.nameProperty,
|
||||
labelProperty: this.labelProperty,
|
||||
|
@ -1128,15 +1128,14 @@ export default Component.extend(
|
|||
|
||||
_deprecateMutations() {
|
||||
this.actions ??= {};
|
||||
this.attrs ??= {};
|
||||
|
||||
if (!this.attrs.onChange && !this.actions.onChange) {
|
||||
if (!this.onChange && !this.actions.onChange) {
|
||||
this._deprecated(
|
||||
"Implicit mutation has been deprecated, please use `onChange` handler"
|
||||
);
|
||||
|
||||
this.actions.onChange =
|
||||
this.attrs.onSelect ||
|
||||
this.onSelect ||
|
||||
this.actions.onSelect ||
|
||||
((value) => this.set("value", value));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user