mirror of
https://github.com/discourse/discourse.git
synced 2025-04-30 11:24:33 +08:00
FIX: introduces onSelectAny (regroup onSelect and onSelectNone) (#7594)
This commit is contained in:
parent
f4a471f0eb
commit
049561ac49
@ -223,6 +223,10 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
topicCategoryChanged(selection) {
|
||||||
|
this.set("buffered.category_id", selection.value);
|
||||||
|
},
|
||||||
|
|
||||||
deletePending(pending) {
|
deletePending(pending) {
|
||||||
return ajax(`/review/${pending.id}`, { type: "DELETE" })
|
return ajax(`/review/${pending.id}`, { type: "DELETE" })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
{{category-chooser
|
{{category-chooser
|
||||||
class="small"
|
class="small"
|
||||||
value=(unbound buffered.category_id)
|
value=(unbound buffered.category_id)
|
||||||
onSelect=(action (mut buffered.category_id))}}
|
onSelectAny=(action "topicCategoryChanged")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if canEditTags}}
|
{{#if canEditTags}}
|
||||||
|
@ -223,6 +223,7 @@ export default SelectKitComponent.extend({
|
|||||||
);
|
);
|
||||||
|
|
||||||
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
||||||
|
this._boundaryActionHandler("onSelectAny", computedContentItem);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +240,7 @@ export default SelectKitComponent.extend({
|
|||||||
this
|
this
|
||||||
);
|
);
|
||||||
this._boundaryActionHandler("onSelectNone");
|
this._boundaryActionHandler("onSelectNone");
|
||||||
|
this._boundaryActionHandler("onSelectAny", computedContentItem);
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -291,6 +293,7 @@ export default SelectKitComponent.extend({
|
|||||||
);
|
);
|
||||||
|
|
||||||
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
this._boundaryActionHandler("onSelect", computedContentItem.value);
|
||||||
|
this._boundaryActionHandler("onSelectAny", computedContentItem);
|
||||||
|
|
||||||
this.autoHighlight();
|
this.autoHighlight();
|
||||||
});
|
});
|
||||||
|
@ -924,3 +924,37 @@ componentTest("noopRow", {
|
|||||||
assert.equal(this.get("value"), "green");
|
assert.equal(this.get("value"), "green");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest("onSelectAny", {
|
||||||
|
template: `<div class='test-external-action'></div>{{single-select none="none" content=content onSelectAny=(action externalAction)}}`,
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.set("externalAction", actual => {
|
||||||
|
find(".test-external-action").text(actual.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.set("content", ["blue"]);
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
await this.get("subject").expand();
|
||||||
|
await this.get("subject").selectRowByValue("blue");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".test-external-action")
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
"blue"
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.get("subject").expand();
|
||||||
|
await this.get("subject").selectNoneRow();
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".test-external-action")
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
"__none__"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user