Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.

Commit 695d727

Browse files
committed
adds support for multidate and multidateSeparator options of bootstrap-datepicker
if multidate is true, value is an array
1 parent c8bfc38 commit 695d727

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

addon/components/datepicker-support.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default Ember.Mixin.create({
2020
keyboardNavigation: this.get('keyboardNavigation'),
2121
language: this.get('language'),
2222
minViewMode: this.get('minViewMode'),
23+
multidate: this.get('multidate'),
24+
multidateSeparator: this.get('multidateSeparator'),
2325
orientation: this.get('orientation'),
2426
startDate: this.get('startDate'),
2527
startView: this.get('startView'),
@@ -46,7 +48,15 @@ export default Ember.Mixin.create({
4648
var isoDate = null;
4749

4850
if (event.date) {
49-
isoDate = this.$().datepicker('getUTCDate').toISOString();
51+
if (this.get('multidate')) {
52+
// set value to array if multidate
53+
isoDate = this.$().datepicker('getUTCDates').map(function(date) {
54+
return date.toISOString();
55+
});
56+
}
57+
else {
58+
isoDate = this.$().datepicker('getUTCDate').toISOString();
59+
}
5060
}
5161

5262
this.set('value', isoDate);

tests/dummy/app/templates/index.hbs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,46 @@ ember generate bootstrap-datepicker</pre>
248248
</div>
249249
</div>
250250

251+
<h3>multidate</h3>
252+
<div class="panel panel-default">
253+
<div class="panel-heading">
254+
<pre><code>&#123;&#123;bootstrap-datepicker multidate=true placeholder="Click to play" class="form-control"&#125;&#125;</code></pre>
255+
</div>
256+
<div class="panel-body">
257+
<p>
258+
Type: <code>Boolean</code> or <code>Number</code><br>
259+
Default: <code>false</code></code>
260+
</p>
261+
<p>If multidate is <code>true</code>, <code>value</code> is an array.</p>
262+
<p>Please, read more about possible values <a href="http://bootstrap-datepicker.readthedocs.org/en/release/options.html#multidate">here</a>.</p>
263+
</div>
264+
<div class="panel-footer">
265+
{{bootstrap-datepicker multidate=true
266+
placeholder="Click to play"
267+
class="form-control"}}
268+
</div>
269+
</div>
270+
271+
<h3>multidateSeparator</h3>
272+
<div class="panel panel-default">
273+
<div class="panel-heading">
274+
<pre><code>&#123;&#123;bootstrap-datepicker multidate=true multidateSeparator=";" placeholder="Click to play" class="form-control"&#125;&#125;</code></pre>
275+
</div>
276+
<div class="panel-body">
277+
<p>
278+
Type: <code>String</code><br>
279+
Default: <code>,</code></code>
280+
</p>
281+
<p>Please, read more about possible values <a href="https://bootstrap-datepicker.readthedocs.org/en/release/options.html#multidateseparator">here</a>.</p>
282+
</div>
283+
<div class="panel-footer">
284+
{{bootstrap-datepicker multidate=true
285+
multidateSeparator=";"
286+
placeholder="Click to play"
287+
class="form-control"}}
288+
</div>
289+
</div>
290+
251291
<h3>orientation</h3>
252292
<div class="panel panel-default">
253293
<div class="panel-heading">

0 commit comments

Comments
 (0)