date-picker: add am/pm mode in time selector#8620
date-picker: add am/pm mode in time selector#8620Leopoldthecoder merged 8 commits intoElemeFE:devfrom
Conversation
|
@firesh Thanks for contribution! Could you add some test cases for this feature? |
|
I will. |
| if (!shouldShowAmPm) return ''; | ||
| let isCapital = this.amPmMode === 'A'; | ||
| let content = ' '; | ||
| if (shouldShowAmPm) content = content.concat((hour < 12) ? 'am' : 'pm'); |
There was a problem hiding this comment.
Here if (shouldShowAmPm) is not necessary since the method returns if !shouldShowAmPm. And content = content.concat((hour < 12) ? 'am' : 'pm'); can move to the previous line.
| :class="{ 'active': hour === hours, 'disabled': hoursList[hour] }" | ||
| v-for="hour in arrowHourList"> | ||
| {{ hour === undefined ? '' : ('0' + hour).slice(-2) }} | ||
| {{ ('0' + (amPmMode ? (hour % 12 || 12) : hour )).slice(-2) }}{{amPm(hour)}} |
There was a problem hiding this comment.
You should handle hour === undefined here
There was a problem hiding this comment.
Sorry for it. Revised.
| if (!shouldShowAmPm) return ''; | ||
| let isCapital = this.amPmMode === 'A'; | ||
| let content = (hour < 12) ? ' am' : ' pm'; | ||
| if (isCapital) content = content.toUpperCase(); |
There was a problem hiding this comment.
Is it a good idea to change isCapital to isUpperCase to match the JavaScript function called toUpperCase()?
There was a problem hiding this comment.
I think it's fine to use === 'A', because amPmMode only have 2 options: ['a', 'A'].
|
Hello @firesh , How can I add the name of the input elements for both the time picker in time range? Currently if I am trying to use time range with name="field_name", then it's only taking the first two letter of the name given.For example: In this case, 'f' for first timepicker in range" and 'i' for second timepicker in range.... So, how are we going to solve it? |
|
@kcpal-qode Use an array. https://jsfiddle.net/rz9b603h/ |
Please make sure these boxes are checked before submitting your PR, thank you!
devbranch.#8270