Skip to content

Commit

Permalink
Merge pull request #19 from alejost848/master
Browse files Browse the repository at this point in the history
Add minDate and maxDate properties
  • Loading branch information
ronnyroeller authored May 13, 2017
2 parents 93ce49a + bed91f1 commit 3c95b6e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<paper-datetime-picker-item icon="icons:today" placeholder="Add date and time, custom format" date-format="DD/MM/YYYY" time-format="h:mm:ss a" locale="[[locale]]"></paper-datetime-picker-item>
<paper-datetime-picker-item icon="icons:today" placeholder="Add date, time defaults to 9AM" default-time="09:00" locale="[[locale]]"></paper-datetime-picker-item>
<paper-datetime-picker-item icon="icons:today" placeholder="Disabled datetime picker" locale="[[locale]]" disabled></paper-datetime-picker-item>
<paper-datetime-picker-item icon="icons:today" placeholder="Add a date between today and within 7 days" min-date="[[minDate]]" max-date="[[maxDate]]"></paper-datetime-picker-item>

<paper-dropdown-menu label="Locale">
<paper-listbox class="dropdown-content" attr-for-selected="label" selected="[[locale]]" on-iron-select="setLocale">
Expand All @@ -38,6 +39,8 @@
scope.setLocale = function(e) {
scope.locale = e.detail.item.label;
}
scope.minDate = moment().startOf('day');
scope.maxDate = moment().add(7, 'days').endOf('day');
</script>
</body>
</html>
16 changes: 14 additions & 2 deletions paper-date-picker-behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@
value: function() {
return moment.locale();
}
}
},

/**
* The minimum allowed date
*/
minDate: Date,

/**
* The maximum allowed date
*/
maxDate: Date
},

_edit: function(dialogId) {
Expand All @@ -88,9 +98,11 @@
// Localize text
dialog.cancelButton = this.cancelButton;
dialog.okButton = this.okButton;

dialog.locale = this.locale;

dialog.minDate = this.minDate;
dialog.maxDate = this.maxDate;

// Capture date if the user saved the dialog
dialog.addEventListener('paper-date-picker-edit-dialog-save', function(e) {
this._changeDate(e.detail);
Expand Down
12 changes: 11 additions & 1 deletion paper-date-picker-edit-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<style include="paper-date-picker-dialog-style"></style>

<paper-dialog id="dialog" class="paper-date-picker-dialog" modal on-iron-overlay-closed="_onClosed">
<paper-date-picker id="datePicker" date="{{date}}" force-narrow locale="[[locale]]"></paper-date-picker>
<paper-date-picker id="datePicker" date="{{date}}" force-narrow locale="[[locale]]" min-date="[[minDate]]" max-date="[[maxDate]]"></paper-date-picker>
<div class="buttons">
<paper-button dialog-dismiss>[[cancelButton]]</paper-button>
<paper-button dialog-confirm on-tap="_save">[[okButton]]</paper-button>
Expand Down Expand Up @@ -55,6 +55,16 @@
* Locale used for formatting dates
*/
locale: String,

/**
* The minimum allowed date
*/
minDate: Date,

/**
* The maximum allowed date
*/
maxDate: Date
},

/**
Expand Down
4 changes: 3 additions & 1 deletion paper-datetime-picker-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@
// Localize text
dialog.cancelButton = this.cancelButton;
dialog.okButton = this.okButton;

dialog.locale = this.locale;

dialog.minDate = this.minDate;
dialog.maxDate = this.maxDate;

// Capture date if the user saved the dialog
dialog.addEventListener('paper-date-picker-edit-dialog-save', function(e) {
var newDate = e.detail;
Expand Down

0 comments on commit 3c95b6e

Please sign in to comment.