Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,23 @@ actions: {
}
```

### changeMonth

The changeMonth action is triggered when the view month changes (e.g. user click on "prev"/"next" buttons).
Action called has new view date as first argument.

```handlebars
{{bootstrap-datepicker changeMonth="changeMonthAction"}}
```

```javascript
actions: {
changeDateAction(date) {
// do sth with the new view date
}
}
```

#### clearDate

The clearDate action is triggered when the date is cleared (e.g. when the "clear" button is clicked).
Expand Down
3 changes: 3 additions & 0 deletions addon/components/datepicker-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default Ember.Mixin.create({
this._didChangeDate(event);
});
}).
on('changeMonth', event => {
this.sendAction('changeMonth', event.date);
}).
on('focusout', event => {
this.sendAction('focus-out', this, event);
}).
Expand Down
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ember-cli-bootstrap-datepicker",
"dependencies": {
"ember": "1.13.7",
"ember": "1.13.13",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.13.8",
Expand All @@ -14,6 +14,7 @@
"qunit": "~1.18.0"
},
"devDependencies": {
"bootstrap-datepicker": "~1.4.0"
"bootstrap-datepicker": "~1.6.4",
"bootstrap": "~3.3.7"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,27 @@ test('triggers hide action when date datepicker is hidden', function(assert) {

assert.ok(actionIsTriggered, 'action is triggered');
});

test('triggers changeMonth when month is changed', function(assert) {
assert.expect(6);

var lastDate;
this.on('myAction', (date) => {
assert.ok(true, 'action is triggered');
lastDate = date;
});

this.render(hbs`
{{bootstrap-datepicker-inline changeMonth="myAction"}}
`);

// there are several not visibile datepickers having .next; only trigger the visible one
this.$('.next:visible').trigger('click');
assert.ok(lastDate instanceof Date, 'date is passed to action as argument');
// by default view date is today; so after a click on "next" it should be a date in the next month
assert.equal(lastDate.getMonth(), new Date().getMonth() + 1, 'passed date is correct');

this.$('.prev:visible').trigger('click');
assert.ok(lastDate instanceof Date, 'date is passed to action as argument');
assert.equal(lastDate.getMonth(), new Date().getMonth(), 'passed date is correct');
});