diff --git a/addon/components/datepicker-support.js b/addon/components/datepicker-support.js index 792c2c5..e54596b 100644 --- a/addon/components/datepicker-support.js +++ b/addon/components/datepicker-support.js @@ -18,7 +18,6 @@ export default Mixin.create({ }, setupBootstrapDatepicker: on('didInsertElement', function() { - this.$(). datepicker({ autoclose: this.get('autoclose'), @@ -55,13 +54,19 @@ export default Mixin.create({ }); }). on('changeMonth', event => { - this.sendAction('changeMonth', event.date); + if (this.changeMonth) { + this.changeMonth(event.date); + } }). on('focusout', event => { - this.sendAction('focus-out', this, event); + if (this.focusOut) { + this.focusOut(this, event); + } }). on('focusin', event => { - this.sendAction('focus-in', this, event); + if (this.focusIn) { + this.focusIn(this, event); + } }). on('clearDate', event => { run(() => { @@ -69,10 +74,14 @@ export default Mixin.create({ }); }). on('show', () => { - this.sendAction('show'); + if (this.show) { + this.show(); + } }). on('hide', () => { - this.sendAction('hide'); + if (this.hide) { + this.hide(); + } }); this._updateDatepicker(); @@ -97,12 +106,14 @@ export default Mixin.create({ } } - this.set('mustUpdateInput', false); - this.set('value', value); if (event.type === 'clearDate') { - this.sendAction('clearDate'); + if (this.clearDate) { + this.clearDate(); + } } else { - this.sendAction('changeDate', value); + if (this.changeDate) { + this.changeDate(value); + } } }, diff --git a/tests/integration/components/bootstrap-datepicker-integration-test.js b/tests/integration/components/bootstrap-datepicker-integration-test.js index 334496f..9b912bf 100644 --- a/tests/integration/components/bootstrap-datepicker-integration-test.js +++ b/tests/integration/components/bootstrap-datepicker-integration-test.js @@ -8,15 +8,15 @@ moduleForComponent('bootstrap-datepicker', 'BootstrapDatepickerComponent', { test('triggers specified action on focusout event', function (assert) { assert.expect(1); - this.render(hbs` - {{bootstrap-datepicker focus-out="focusOutAction"}} - `); - var actionIsTriggered = false; this.on('focusOutAction', () => { actionIsTriggered = true; }); + this.render(hbs` + {{bootstrap-datepicker focusOut=(action "focusOutAction")}} + `); + this.$('input.ember-text-field').trigger('focusout'); assert.ok(actionIsTriggered, 'action is triggered on focusout'); @@ -25,15 +25,15 @@ test('triggers specified action on focusout event', function (assert) { test('triggers specified action on focusin event', function (assert) { assert.expect(1); - this.render(hbs` - {{bootstrap-datepicker focus-in="focusInAction"}} - `); - var actionIsTriggered = false; this.on('focusInAction', () => { actionIsTriggered = true; }); + this.render(hbs` + {{bootstrap-datepicker focusIn=(action "focusInAction")}} + `); + this.$('input.ember-text-field').trigger('focusin'); assert.ok(actionIsTriggered, 'action is triggered on focusin'); @@ -50,7 +50,7 @@ test('triggers changeDate action when date selection changes', function(assert) }); this.render(hbs` - {{bootstrap-datepicker value=myDate changeDate="myAction"}} + {{bootstrap-datepicker value=myDate changeDate=(action "myAction")}} `); var input = this.$('input.ember-text-field'); @@ -70,7 +70,7 @@ test('triggers clearDate action when date selection is cleared', function(assert }); this.render(hbs` - {{bootstrap-datepicker value=myDate clearDate="myAction"}} + {{bootstrap-datepicker value=myDate clearDate=(action "myAction")}} `); var input = this.$('input.ember-text-field'); @@ -88,7 +88,7 @@ test('triggers show action when date datepicker is displayed', function(assert) }); this.render(hbs` - {{bootstrap-datepicker show="myAction"}} + {{bootstrap-datepicker show=(action "myAction")}} `); this.$('input.ember-text-field').trigger('show'); @@ -105,7 +105,7 @@ test('triggers hide action when date datepicker is hidden', function(assert) { }); this.render(hbs` - {{bootstrap-datepicker hide="myAction"}} + {{bootstrap-datepicker hide=(action "myAction")}} `); this.$('input.ember-text-field').trigger('hide'); @@ -123,7 +123,7 @@ test('triggers changeMonth when month is changed', function(assert) { }); this.render(hbs` - {{bootstrap-datepicker-inline changeMonth="myAction"}} + {{bootstrap-datepicker-inline changeMonth=(action "myAction")}} `); // there are several not visibile datepickers having .next; only trigger the visible one