DEV: Remove `d-checkbox` component
Replaces the last occurrence of `d-checkbox` with a regular input element. Includes a minor refactor of admin site text search.
This commit is contained in:
parent
1dee71d760
commit
74ed72e825
|
@ -1,5 +1,4 @@
|
|||
let lastSearch;
|
||||
let lastOverridden;
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
searching: false,
|
||||
|
@ -8,7 +7,7 @@ export default Ember.Controller.extend({
|
|||
queryParams: ["q", "overridden"],
|
||||
|
||||
q: null,
|
||||
overridden: null,
|
||||
overridden: false,
|
||||
|
||||
_performSearch() {
|
||||
this.store
|
||||
|
@ -24,14 +23,18 @@ export default Ember.Controller.extend({
|
|||
this.transitionToRoute("adminSiteText.edit", siteText.get("id"));
|
||||
},
|
||||
|
||||
search(overridden) {
|
||||
if (typeof overridden === "boolean") this.set("overridden", overridden);
|
||||
toggleOverridden() {
|
||||
this.toggleProperty("overridden");
|
||||
this.set("searching", true);
|
||||
Ember.run.debounce(this, this._performSearch, 400);
|
||||
},
|
||||
|
||||
search() {
|
||||
const q = this.get("q");
|
||||
if (q !== lastSearch || overridden !== lastOverridden) {
|
||||
if (q !== lastSearch) {
|
||||
this.set("searching", true);
|
||||
Ember.run.debounce(this, this._performSearch, 400);
|
||||
lastSearch = q;
|
||||
lastOverridden = overridden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
key-up=(action "search")}}
|
||||
|
||||
<div class='extra-options'>
|
||||
{{d-checkbox label="admin.site_text.show_overriden" checked=overridden change=(action "search")}}
|
||||
<label>
|
||||
{{input type="checkbox" checked=overridden click=(action "toggleOverridden")}}
|
||||
{{i18n 'admin.site_text.show_overriden'}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import { on } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
tagName: "label",
|
||||
|
||||
@on("didInsertElement")
|
||||
_init() {
|
||||
const checked = this.get("checked");
|
||||
if (checked && checked !== "false") {
|
||||
this.$("input").prop("checked", true);
|
||||
}
|
||||
|
||||
// In Ember 13.3 we can use action on the checkbox `{{input}}` but not in 1.11
|
||||
this.$("input").on("click.d-checkbox", () => {
|
||||
Ember.run.scheduleOnce("afterRender", () =>
|
||||
this.change(this.$("input").prop("checked"))
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
@on("willDestroyElement")
|
||||
_clear() {
|
||||
this.$("input").off("click.d-checkbox");
|
||||
}
|
||||
});
|
|
@ -1,2 +0,0 @@
|
|||
<input type='checkbox' disabled={{disabled}}>
|
||||
{{i18n label}}
|
Loading…
Reference in New Issue