damienroche / vue-mj-daterangepicker

🗓Vue.js date range picker with multiples ranges and presets (vue 2.x)
https://damienroche.github.io/vue-mj-daterangepicker/
60 stars 39 forks source link

added a preset default prop to allow #49

Open shaylavi opened 3 years ago

shaylavi commented 3 years ago

Allowing user to modify the default preset value

damienroche commented 3 years ago

Thanks for submitting. But i'm thinking about the following case.

Imagine there is a from and a to values set by v-model, Maybe the defaultPreset could be wrong regarding to those 2 values :

eg: from => tuesday and to => wednesday will be inconsistent with defaultPreset to week

I'm my opinion you should write something like this :

if (this.to || this.from) {
   this.preset = 'custom'
} else {
   this.preset = this.defaultPreset
}
shaylavi commented 3 years ago

Thanks for submitting. But i'm thinking about the following case.

Imagine there is a from and a to values set by v-model, Maybe the defaultPreset could be wrong regarding to those 2 values :

eg: from => tuesday and to => wednesday will be inconsistent with defaultPreset to week

I'm my opinion you should write something like this :

if (this.to || this.from) {
   this.preset = 'custom'
} else {
   this.preset = this.defaultPreset
}

Yeah I didn't really go through all edge-cases, it was more about allowing that functionality first and on the dev's responsibility to make sure it works, but sure I'll push that change you suggested. I'm sure there's room for many other improvements.