-
Notifications
You must be signed in to change notification settings - Fork 533
new: new field 'input' #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for your PR. I need more time to check it, ok? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the type to input
instead of html5
I think, we can't handle all types with one field. Because for Do you have any idea how to solve it? |
A simple check to see the this.schema.format could be enough: if (typeof this.schema.format !== "undefined" && value != null) {
return moment(value, this.schema.format).format(this.getDateFormat());
}
return value; If the user don't want to format the date or if there is no reason to use format (for non date like input), it simply return the raw value. |
Not enough, because current date fields (datePicker, pickaday) are stored the data in Unix format without I created a fiddle to check the raw values of HTML5 date fields: https://jsfiddle.net/ndz05ku4/2/ |
What about using if (value != null) {
if (this.schema.inputType === date ||
this.schema.inputType === datetime ||
this.schema.inputType === datetimelocal ||
this.schema.inputType === time ||
this.schema.inputType === week ||
this.schema.inputType === month) {
if (typeof this.schema.format === "undefined"){
// Unix formating
}else{
return moment(value, this.schema.format).format(this.getDateFormat());
}
}
}
return value; |
Ok, but skip |
I'm skipping @icebob can you validate this ?
|
Progress: methods: {
formatValueToField(value) {
switch(this.schema.inputType){
case "date":
return moment(value).format("YYYY-MM-DD");
case "datetime":
return moment(value).format();
case "datetime-local":
return moment(value).format("YYYY-MM-DDTHH:mm:ss");
default:
return value;
}
},
formatValueToModel(value) {
console.log(this.schema.inputType, typeof value);
if (value != null) {
if (this.schema.inputType === "date" ||
this.schema.inputType === "datetime" ||
this.schema.inputType === "datetimelocal") {
return new Date(value).getTime();
}else{
return value;
}
} else {
return value;
}
}
} |
Great thank you! |
@icebob Can I add a new schema to the commit ? |
Sure :) |
@icebob I think it is ready to merge, no ? |
} | ||
}, | ||
formatValueToModel(value) { | ||
console.log(this.schema.inputType, typeof value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this log message and after it I will merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to merge, no ? I think you just approved the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just waited the green lights :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I did not get it 👍
#50 this is my proposal for this fields.
The test are not amazing for now (they accept any attribute regardless of the input type).