vue-datetime icon indicating copy to clipboard operation
vue-datetime copied to clipboard

How to set a default value without modifying initial model

Open simondrabble opened this issue 5 years ago • 0 comments

Versions

  • vue: 2.6.11
  • vue-datetime: 1.0.0-beta.13
  • luxon: 1.24.1

I'd like to set a default value without affecting the current model. If I have to change the model value before displaying the datetime picker, I will introduce other effects, and either have to unset the model's value if the picker is canceled, or track that it was changed in some way.

More detail: I have two dates, one is set by a user (preferredDate), the other selected by an admin (scheduledDate). I cannot schedule dates in the past, but it is possible that by the time the admin gets to scheduling, the preferred date has passed. So I want to set the default value for the scheduledDate picker to the preferredDate if it is in the future, or to today if not - which is easy to achieve via min-datetime. Modifying scheduledDate before opening the picker means I then have to check if it has passed instead of just using min-datetime; I also have to ensure it gets unset (or set to any previous value) if the admin cancels the picker.

TL;DR: modifying a model to allow a default value in the picker is not always easy, suitable, or preferable. There should be a way to set a default value which does not involve modifying the model.

simondrabble avatar Jun 11 '20 22:06 simondrabble