Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from pdvluca/master
Browse files Browse the repository at this point in the history
Allow to propagate date changes only if "Apply" button has been pressed
  • Loading branch information
MikaelEdebro authored Mar 24, 2018
2 parents 59948c1 + 8206c52 commit ef36890
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:start-open="false"
@date-one-selected="val => { inputDateOne = val }"
@date-two-selected="val => { inputDateTwo = val }"
@closed="onClosed"
/>
</div>
</div>
Expand Down Expand Up @@ -96,6 +97,10 @@ export default {
formattedDates += ' - ' + format(dateTwo, this.dateFormat)
}
return formattedDates
},
onClosed() {
var datesStr = this.formatDates(this.inputDateOne, this.inputDateTwo)
console.log('Dates Selected: ' + datesStr)
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/components/AirbnbStyleDatepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</transition-group>
</div>
<div class="action-buttons" v-if="mode !== 'single'">
<button @click="closeDatepicker">{{ texts.cancel }}</button>
<button @click="closeDatepickerCancel">{{ texts.cancel }}</button>
<button @click="closeDatepicker" :style="{color: colors.selected}">{{ texts.apply }}</button>
</div>
</div>
Expand Down Expand Up @@ -464,11 +464,23 @@ export default {
this.positionDatepicker()
this.setStartDates()
this.showDatepicker = true
this.initialDate1 = this.dateOne
this.initialDate2 = this.dateTwo
},
closeDatepickerCancel() {
if (this.showDatepicker) {
this.selectedDate1 = this.initialDate1
this.selectedDate2 = this.initialDate2
this.closeDatepicker()
}
},
closeDatepicker() {
if (this.inline) {
return
}
if (this.showDatepicker) {
this.$nextTick(() => this.$emit('closed'))
}
this.showDatepicker = false
},
positionDatepicker() {
Expand Down

0 comments on commit ef36890

Please sign in to comment.