-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: add API for range setting #61
Conversation
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.
리뷰완료합니다.
examples/example05-using-range.html
Outdated
<!DOCTYPE html> | ||
<head lang="en"> | ||
<meta charset="UTF-8"> | ||
<title>3. Using meridiem</title> |
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.
안바꼈네요
src/js/timepicker/index.js
Outdated
var disabledItems; | ||
disabledItems = this._disabledMinutes[hour] ? this._disabledMinutes[hour] : []; |
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.
var disabledItems = this._disabledMonutes[hour] || [];
로 해도 될 것 같습니다.
src/js/timepicker/index.js
Outdated
|
||
disabledHours = util.getRangeArr(0, beginHour - 1); | ||
disabledMinRanges.push({ | ||
begin: 0, |
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.
0
, 59
는 상수로 빼도 될 것 같아요.
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.
23
이나 12
도 마찬가지입니다!
src/js/timepicker/index.js
Outdated
if (hour < 0 || hour > 23) { | ||
return false; | ||
} | ||
|
||
if (minute < 0 || minute > 59) { |
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.
0
, 23
, 59
도 상수처리하는게 좋을 것 같습니다.
src/js/util.js
Outdated
for (i = 0; i < 60; i += 1) { | ||
arr.push(false); | ||
} |
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.
fill 유틸 메서드 하나 만들어서 사용하면 좋겠네요 ㅎ
src/js/util.js
Outdated
forEachArray(enableRanges, function(enableRange) { | ||
for (i = enableRange.begin; i <= enableRange.end; i += 1) { | ||
arr[i] = true; | ||
} | ||
}); |
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.
그럼 여기도 같이 사용할 수 있을것 같아요.
src/js/timepicker/index.js
Outdated
* @returns {boolean} result of range validation | ||
* @private | ||
*/ | ||
_CompareTimes: function(begin, end) { |
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.
저희 언더바 프리픽스 사용하지 않습니다!
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.
메서드명이 대문자로 시작하네요
src/js/timepicker/index.js
Outdated
if (hour < 0 || hour > 23) { | ||
return false; | ||
} | ||
|
||
if (minute < 0 || minute > 59) { | ||
return false; | ||
} |
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.
어려운 로직이 아니여서 그냥 한번에 분기문을 작성해도 괜찮을 것 같아요.
src/js/timepicker/index.js
Outdated
if (!this._isValidTime(endHour, endMin)) { | ||
return false; | ||
} | ||
|
||
if (this._CompareTimes(begin, end) <= 0) { | ||
return false; | ||
} | ||
|
||
return true; |
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.
이 부분도 한번에 줄여서 반환해줄수 있겠네요
src/js/timepicker/index.js
Outdated
var endHour; | ||
var endMin; | ||
|
||
var disabledHours; |
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.
var endHour, endMin, disabledHours로 바로 작성해도 되겠네요
src/js/timepicker/index.js
Outdated
if (end) { | ||
endHour = end.hour; | ||
endMin = end.minute; | ||
disabledHours = disabledHours.concat(util.getRangeArr(endHour + 1, 23)); | ||
|
||
disabledMinRanges.push({ | ||
begin: endMin, | ||
end: 59 | ||
}); | ||
} | ||
|
||
if (disabledMinRanges.length > 1 && beginHour === endHour) { | ||
this._disabledMinutes[beginHour] = util.getDisabledMinuteArr(disabledMinRanges).concat(); | ||
} else { | ||
this._disabledMinutes[beginHour] = util.getDisabledMinuteArr([disabledMinRanges[0]]).concat(); | ||
this._disabledMinutes[endHour] = util.getDisabledMinuteArr([disabledMinRanges[1]]).concat(); | ||
} | ||
|
||
this._disabledHours = disabledHours.concat(); | ||
|
||
this.setTime(beginHour, beginMin); | ||
this._setDisabledHours(); | ||
|
||
if (this._showMeridiem) { | ||
this._syncToMeridiemElements(); | ||
|
||
util.setDisabled(this._amEl, beginHour >= 12); | ||
util.setDisabled(this._pmEl, endHour < 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.
이 메서드에서 너무 많은 일을 하고 있는것 같은데 조금 메서드를 분리해서 작성해보는건 어때요?
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.
완료입니다
src/js/timepicker/index.js
Outdated
@@ -510,6 +522,13 @@ var TimePicker = defineClass( | |||
this._hourInput.setDisabledItems(disabledItems); | |||
}, | |||
|
|||
_setDisabledMinutes: function(hour) { | |||
var disabledItems; | |||
disabledItems = this._disabledMinutes[hour] ? this._disabledMinutes[hour] : []; |
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.
this._disabledMinutes[hour] ?? []
src/js/timepicker/index.js
Outdated
if (!this._isValidTime(endHour, endMin)) { | ||
return false; | ||
} | ||
|
||
if (this._CompareTimes(begin, end) <= 0) { | ||
return false; | ||
} |
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.
두개 조건 합쳐서 if문만들수있어요
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.
리뷰완료합니다.
배포전 $ npm run doc:dev
돌려서 doc한번확인해주세요~
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.
수고하셨어요
} | ||
|
||
return true; | ||
}, |
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.
첫번째 탈출 조건을 반대로 해서 리턴하면 리턴문 하나로 쓸 수 있지 않을까요?
= this.element | ||
= this.meridiemElement | ||
= this.amEl | ||
= this.pmEl |
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.
ㅋㅋ 이 표기법은 뭔가 이쁘면서도 오묘하게 거슬리네 ㅋㅋ
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.
El
과 Element
와 element
가 모두 공존해서 그런가보네요 ㅋㅋ
* @returns {Array} | ||
*/ | ||
fill: function(start, end, value, target) { | ||
var arr = target || []; |
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.
디폴트 파라메터를 쓰면 될 것 같아요.
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.
리뷰완료합니다.
src/js/timepicker/index.js
Outdated
if (!this.isValidTime(endHour, endMin) || this.compareTimes(begin, end) <= 0) { | ||
return false; | ||
} | ||
|
||
return true; |
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.
이 부분은 return (this.isValidTime(endHour, endMin) && this.compareTimes(begin, end) > 0);
으로 바꿀 수 있을 거 같아요.
src/js/util.js
Outdated
arr[i] = value; | ||
} | ||
|
||
for (; i <= end; i += 1) { |
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가 replaceEnd
부터 시작하는데 시작 조건에 명시적으로 적어줘도 좋을 것 같습니다.
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 check if the PR fulfills these requirements
fix #xxx[,#xxx]
, where "xxx" is the issue number)Description
Thank you for your contribution to TOAST UI product. 🎉 😘 ✨