vuestic-ui
vuestic-ui copied to clipboard
[va-date] should support string as model value
Vuestic-ui version: 1.3.4
Steps to reproduce https://codesandbox.io/s/gallant-khorana-gf1nl?file=/src/App.vue
What is the expected behavior? date input should support string as model value, in most scenarios which data come from the server by JSON, the date will be a plain string, with that says, we must covert string to Date manually in javascript, that's not makesence.
What is the current behavior?
Other information
Thanks. I see your point!
We have a couple of props (formatDate
, parseDate
), but I'm not sure if these achieve what we need to. Which is:
- [ ] Date picker should not break when string is passed (it should attempt to convert it)
- [ ] There should be a way to configure datepicker to work with any kind of string input (some conversion function prop, and maybe another for emit). These could be configured in global config giving user ultimate convenience. :)
- [ ] We need to have this example in docs and demos.
Should be something like this:
<va-date-input/ v-model="dateFromBackend" ...>
<p>{{dateFromBackend}}</p> <!-- 23.03.2022 -->
Also some props are missing descriptions in docs, so we can improve this as well in scope of this issue.
@asvae I think we could support ISO 8601 by dafault or go a hard (and painful) way and implement something like format parsing similar to moment. parseDate and formatDate actually looks redundant to me since you can achieve same result simply by handling value and input instead of using v-model.
parseDate
and formatDate
are ui methods, they are used to convert date to string in the input. We use Date object because it is universal, which can not be said about string.
Let's support strings made with JSON.parse() as modelValue as well as Date object.
Probably this is already implemented. Check if it works both for VaTimeInput and VaDateInput. Maybe this also must work for VaTimePicker and VaDatePicker.
Also, would be nice to have it implemented in scope of this task: https://github.com/epicmaxco/vuestic-ui/issues/1942
DM me for details.
See https://github.com/epicmaxco/vuestic-ui/issues/1942