FIX: In Ember 2.0 you can't bind Query Parametrs like this
This commit is contained in:
parent
2d126cff8f
commit
95c8d66fe0
|
@ -1,38 +1,14 @@
|
|||
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
let lastSearch;
|
||||
let lastOverridden;
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
_q: null,
|
||||
searching: false,
|
||||
siteTexts: null,
|
||||
preferred: false,
|
||||
_overridden: null,
|
||||
queryParams: ['q', 'overridden'],
|
||||
|
||||
@computed
|
||||
overridden: {
|
||||
set(value) {
|
||||
if (!value || value === "false") { value = false; }
|
||||
this._overridden = value;
|
||||
return value;
|
||||
},
|
||||
get() {
|
||||
return this._overridden;
|
||||
}
|
||||
},
|
||||
|
||||
@computed
|
||||
q: {
|
||||
set(value) {
|
||||
if (Ember.isEmpty(value)) { value = null; }
|
||||
this._q = value;
|
||||
return value;
|
||||
},
|
||||
get() {
|
||||
return this._q;
|
||||
}
|
||||
},
|
||||
q: null,
|
||||
overridden: null,
|
||||
|
||||
_performSearch() {
|
||||
this.store.find('site-text', this.getProperties('q', 'overridden')).then(results => {
|
||||
|
@ -46,11 +22,14 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
search(overridden) {
|
||||
this.set('overridden', overridden);
|
||||
|
||||
const q = this.get('q');
|
||||
if (q !== lastSearch || overridden) {
|
||||
if (q !== lastSearch || overridden !== lastOverridden) {
|
||||
this.set('searching', true);
|
||||
Ember.run.debounce(this, this._performSearch, 400);
|
||||
lastSearch = q;
|
||||
lastOverridden = overridden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,23 @@ import { on } from "ember-addons/ember-computed-decorators";
|
|||
export default Ember.Component.extend({
|
||||
tagName: 'label',
|
||||
|
||||
@on('didInsertElement')
|
||||
_watchChanges() {
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
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.sendAction('change', true));
|
||||
Ember.run.scheduleOnce('afterRender', () => this.sendAction('change', this.$('input').prop('checked')));
|
||||
});
|
||||
},
|
||||
|
||||
@on('willDestroyElement')
|
||||
_stopWatching() {
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
this.$('input').off('click.d-checkbox');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
{{input type="checkbox" checked=checked}}
|
||||
<input type='checkbox'>
|
||||
{{i18n label}}
|
||||
|
|
Loading…
Reference in New Issue