-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
DatePicker: add attribute defaultTime #9094
Conversation
@wacky6 @Leopoldthecoder Plz review. And, should I update document files in this PR? |
CI failed for some reasons. Can you check it? |
Yes, you can update the document. Just write English or Chinese (or both), the Spanish one will be translated afterwards. I prefer a separate section explaining the two new behaviors (do not reset & reset to defaultTime). Each should have a demo. |
Ok, I will check it and add docs when free. |
859fd64
to
e73aaac
Compare
816f192
to
d10425a
Compare
c2b4848
to
d65f185
Compare
@wacky6 I fixed the CI. Also I added some docs and an example for the attribute I've run into a strange problem that the test case fails in Travis if I use Can you plz check if it is fine to do so, or if there is any better solution. |
The cause of Also, there are improvements I would like to address / discuss. See PR reviews. |
@wacky6 I can not find reviews or comments. Have you submitted them? |
View on github. You should see comments in changes. |
@wacky6 No comments in the If there are reviews, they will appear among our conversations. |
@wacky6 I couldn't find comments either. Could you have a check? |
@@ -480,17 +497,24 @@ | |||
}, | |||
|
|||
handleRangePick(val, close = true) { | |||
if (this.maxDate === val.maxDate && this.minDate === val.minDate) { | |||
console.log('range pick:', val.minDate, val.maxDate) |
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.
console.log删掉吧
examples/docs/en-US/date-picker.md
Outdated
value11: '', | ||
value12: '', | ||
value13: '', | ||
defaultTimeWithMin: [new Date(2018, 1, 1, 12)], |
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.
I prefer to write these in code, not in data()
How about only requiring time strings?
<el-date-picker type="datetimerange" :default-time="['08:00:00', '18:00:00']" />
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.
It will be easier for users to provide time string instead of Date
parsable object. But it will introduce a new format of time data and parse behavior, which means extra API & realization complexity. I'm not sure if it deserves that.
I found another problem of this PR: it is impossible to configure millisecond value of defaultTime
now (because I'm using modifyTime
). I will fix that.
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.
I think fecha's parse method can handle time alone. (dateUtil in 'date-picker/util/index.js')
You can also refer to time-select panel's parseTime.
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.
I don't think millisecond value is an issue since it is not respected in any picker panels (They may reset millisecond to 0).
Also I don't think there are compelling use cases for it. For example, using half-open intervals link [00:00:00.000, +1 days 00:00:00.000)
instead of closed interval [00:00:00.000, 23:59:59.999]
eliminates the need of millisecond values.
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, I'll check it.
examples/docs/en-US/date-picker.md
Outdated
@@ -394,6 +444,7 @@ This feature is at alpha stage. Feedback welcome. | |||
| picker-options | additional options, check the table below | object | — | {} | | |||
| range-separator | range separator | string | — | '-' | | |||
| default-value | optional, default date of the calendar | Date | anything accepted by `new Date()` | — | | |||
| default-time | optional, the time value to use when select datetime range in date table (type `datetimerange`) | Date[] | Array with length 1 or 2, each item accepted by `new Date()`. The first item for the start datetime and then second item for the end datetime | — | |
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.
How about ask for an array with length 2. e.g: `['08:00:00', null]
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.
Agree.
test/unit/specs/date-picker.spec.js
Outdated
|
||
const vmWithDefaultTime = createTest(DatePicker, { | ||
type: 'datetimerange', | ||
value: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)], |
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.
Use createVue. value
is read-only in createTest, may result in failure to update internal states
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.
OK.
Sorry. Seems I forgot to submit it. |
d1c4501
to
676cf66
Compare
@wacky6 Fixed. |
LGTM, DEMO: https://jsfiddle.net/kxmnmLej/ TODOs:
|
Yes, can merge. |
@nighca This PR breaks the hovering background color when picking a range: The correct behavior is: Could you take another look? |
@Leopoldthecoder Sure. |
Should update tests to check picking hover behavior. |
@Leopoldthecoder @wacky6 I created another PR to fix this, in which I also added some assertions to test this behavior. Plz review. |
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.Details: #7646