Skip to content
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

Merged
merged 3 commits into from
Jan 16, 2018

Conversation

nighca
Copy link
Contributor

@nighca nighca commented Jan 2, 2018

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow Element's contributing guide (中文 | English | Español).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

Details: #7646

@nighca
Copy link
Contributor Author

nighca commented Jan 2, 2018

@wacky6 @Leopoldthecoder Plz review. And, should I update document files in this PR?

@wacky6
Copy link
Contributor

wacky6 commented Jan 2, 2018

CI failed for some reasons. Can you check it?

@wacky6
Copy link
Contributor

wacky6 commented Jan 2, 2018

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.

@nighca
Copy link
Contributor Author

nighca commented Jan 2, 2018

Ok, I will check it and add docs when free.

@nighca nighca force-pushed the date-picker-optimize branch from 859fd64 to e73aaac Compare January 8, 2018 05:42
@nighca nighca closed this Jan 8, 2018
@nighca nighca reopened this Jan 8, 2018
@nighca nighca force-pushed the date-picker-optimize branch 6 times, most recently from 816f192 to d10425a Compare January 11, 2018 16:13
@nighca nighca force-pushed the date-picker-optimize branch from c2b4848 to d65f185 Compare January 11, 2018 16:31
@nighca
Copy link
Contributor Author

nighca commented Jan 11, 2018

@wacky6 I fixed the CI. Also I added some docs and an example for the attribute defaultTime. Plz review.

I've run into a strange problem that the test case fails in Travis if I use DELAY here, while it passes on my own computer. I have to use a longer delay time(DELAY * 2) to make it work in Travis environment.

Can you plz check if it is fine to do so, or if there is any better solution.

@wacky6
Copy link
Contributor

wacky6 commented Jan 13, 2018

The cause of DELAY * 2 is strange. createVue / createTest should not require additional time to complete. In fact all other tests work well without *2.

Also, there are improvements I would like to address / discuss. See PR reviews.

@nighca
Copy link
Contributor Author

nighca commented Jan 15, 2018

@wacky6 I can not find reviews or comments. Have you submitted them?

@wacky6
Copy link
Contributor

wacky6 commented Jan 15, 2018

View on github. You should see comments in changes.

@nighca
Copy link
Contributor Author

nighca commented Jan 15, 2018

@wacky6 No comments in the Files Changed tab, either.

If there are reviews, they will appear among our conversations.

@Leopoldthecoder
Copy link
Contributor

@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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log删掉吧

value11: '',
value12: '',
value13: '',
defaultTimeWithMin: [new Date(2018, 1, 1, 12)],
Copy link
Contributor

@wacky6 wacky6 Jan 11, 2018

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']" />

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -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 | — |
Copy link
Contributor

@wacky6 wacky6 Jan 11, 2018

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]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.


const vmWithDefaultTime = createTest(DatePicker, {
type: 'datetimerange',
value: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
Copy link
Contributor

@wacky6 wacky6 Jan 13, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@wacky6
Copy link
Contributor

wacky6 commented Jan 15, 2018

Sorry. Seems I forgot to submit it.

@nighca nighca force-pushed the date-picker-optimize branch from d1c4501 to 676cf66 Compare January 15, 2018 13:27
@nighca
Copy link
Contributor Author

nighca commented Jan 15, 2018

@wacky6 Fixed.

@wacky6
Copy link
Contributor

wacky6 commented Jan 15, 2018

LGTM, DEMO: https://jsfiddle.net/kxmnmLej/

TODOs:

@Leopoldthecoder
Copy link
Contributor

@nighca Thanks for contributing.

Actually default-time also affects pickers with type="daterange" (not only "on the date panel with type datetimerange"), which is a good thing, so after merging I'll update the docs to reflect this.

Are we good to merge this PR now? @wacky6

@wacky6
Copy link
Contributor

wacky6 commented Jan 16, 2018

Yes, can merge.
Can finish Todos afterwards

@Leopoldthecoder Leopoldthecoder merged commit 94f18ab into ElemeFE:dev Jan 16, 2018
@Leopoldthecoder
Copy link
Contributor

@nighca This PR breaks the hovering background color when picking a range:

untitled

The correct behavior is:

untitled1

Could you take another look?

@nighca
Copy link
Contributor Author

nighca commented Jan 16, 2018

@Leopoldthecoder Sure.

@wacky6
Copy link
Contributor

wacky6 commented Jan 16, 2018

Should update tests to check picking hover behavior.

@nighca
Copy link
Contributor Author

nighca commented Jan 17, 2018

@Leopoldthecoder @wacky6 I created another PR to fix this, in which I also added some assertions to test this behavior. Plz review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants