mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 09:57:25 +08:00
FIX: adds support for name changes tracking
This commit is contained in:
@ -60,6 +60,7 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
|
|||||||
content: null,
|
content: null,
|
||||||
computedContent: null,
|
computedContent: null,
|
||||||
limitMatches: 100,
|
limitMatches: 100,
|
||||||
|
nameChanges: false,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super();
|
this._super();
|
||||||
@ -74,6 +75,14 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
|
|||||||
if ((this.site && this.site.isMobileDevice) || $(window).outerWidth(false) <= 420) {
|
if ((this.site && this.site.isMobileDevice) || $(window).outerWidth(false) <= 420) {
|
||||||
this.setProperties({ filterable: false, autoFilterable: false });
|
this.setProperties({ filterable: false, autoFilterable: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.get("nameChanges")) {
|
||||||
|
this.addObserver(`content.@each.${this.get("nameProperty")}`, this, this._compute);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
this.removeObserver(`content.@each.${this.get("nameProperty")}`, this, this._compute);
|
||||||
},
|
},
|
||||||
|
|
||||||
willComputeAttributes() {},
|
willComputeAttributes() {},
|
||||||
|
@ -398,3 +398,28 @@ componentTest('support modifying on select behavior through plugin api', {
|
|||||||
andThen(() => clearCallbacks());
|
andThen(() => clearCallbacks());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest('with nameChanges', {
|
||||||
|
template: '{{single-select content=content nameChanges=true}}',
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.set("robin", { id: "1", name: "robin"});
|
||||||
|
this.set("content", [this.get("robin")]);
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
expandSelectKit();
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
assert.equal(selectKit().header.name(), "robin");
|
||||||
|
});
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
this.set("robin.name", "robin2");
|
||||||
|
});
|
||||||
|
|
||||||
|
andThen(() => {
|
||||||
|
assert.equal(selectKit().header.name(), "robin2");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user