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

feat: add API for range setting #61

Merged
merged 5 commits into from
Jun 4, 2021
Merged

feat: add API for range setting #61

merged 5 commits into from
Jun 4, 2021

Conversation

jajugoguma
Copy link
Contributor

Please check if the PR fulfills these requirements

  • It's submitted to right branch according to our branching model
  • It's right issue type on title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has description for the breaking change

Description

  • add range setting API

화면 기록 2021-05-31 오후 9 36 17


Thank you for your contribution to TOAST UI product. 🎉 😘 ✨

Copy link
Contributor

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

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

리뷰완료합니다.

<!DOCTYPE html>
<head lang="en">
<meta charset="UTF-8">
<title>3. Using meridiem</title>
Copy link
Contributor

Choose a reason for hiding this comment

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

안바꼈네요

Comment on lines 526 to 527
var disabledItems;
disabledItems = this._disabledMinutes[hour] ? this._disabledMinutes[hour] : [];
Copy link
Contributor

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] || [];로 해도 될 것 같습니다.


disabledHours = util.getRangeArr(0, beginHour - 1);
disabledMinRanges.push({
begin: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

0, 59는 상수로 빼도 될 것 같아요.

Copy link
Contributor

Choose a reason for hiding this comment

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

23이나 12도 마찬가지입니다!

Comment on lines 781 to 785
if (hour < 0 || hour > 23) {
return false;
}

if (minute < 0 || minute > 59) {
Copy link
Contributor

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
Comment on lines 112 to 114
for (i = 0; i < 60; i += 1) {
arr.push(false);
}
Copy link
Member

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
Comment on lines 116 to 120
forEachArray(enableRanges, function(enableRange) {
for (i = enableRange.begin; i <= enableRange.end; i += 1) {
arr[i] = true;
}
});
Copy link
Member

Choose a reason for hiding this comment

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

그럼 여기도 같이 사용할 수 있을것 같아요.

* @returns {boolean} result of range validation
* @private
*/
_CompareTimes: function(begin, end) {
Copy link
Member

Choose a reason for hiding this comment

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

저희 언더바 프리픽스 사용하지 않습니다!

Copy link
Member

Choose a reason for hiding this comment

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

메서드명이 대문자로 시작하네요

Comment on lines 781 to 787
if (hour < 0 || hour > 23) {
return false;
}

if (minute < 0 || minute > 59) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

어려운 로직이 아니여서 그냥 한번에 분기문을 작성해도 괜찮을 것 같아요.

Comment on lines 762 to 770
if (!this._isValidTime(endHour, endMin)) {
return false;
}

if (this._CompareTimes(begin, end) <= 0) {
return false;
}

return true;
Copy link
Member

Choose a reason for hiding this comment

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

이 부분도 한번에 줄여서 반환해줄수 있겠네요

Comment on lines 687 to 690
var endHour;
var endMin;

var disabledHours;
Copy link
Member

Choose a reason for hiding this comment

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

var endHour, endMin, disabledHours로 바로 작성해도 되겠네요

Comment on lines 703 to 730
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);
Copy link
Member

Choose a reason for hiding this comment

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

이 메서드에서 너무 많은 일을 하고 있는것 같은데 조금 메서드를 분리해서 작성해보는건 어때요?

Copy link
Member

@jung-han jung-han left a comment

Choose a reason for hiding this comment

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

완료입니다

@@ -510,6 +522,13 @@ var TimePicker = defineClass(
this._hourInput.setDisabledItems(disabledItems);
},

_setDisabledMinutes: function(hour) {
var disabledItems;
disabledItems = this._disabledMinutes[hour] ? this._disabledMinutes[hour] : [];

Choose a reason for hiding this comment

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

this._disabledMinutes[hour] ?? []

Comment on lines 762 to 768
if (!this._isValidTime(endHour, endMin)) {
return false;
}

if (this._CompareTimes(begin, end) <= 0) {
return false;
}

Choose a reason for hiding this comment

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

두개 조건 합쳐서 if문만들수있어요

Copy link

@jungeun-cho jungeun-cho left a 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한번확인해주세요~

Copy link
Member

@shiren shiren left a comment

Choose a reason for hiding this comment

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

수고하셨어요

}

return true;
},
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋ 이 표기법은 뭔가 이쁘면서도 오묘하게 거슬리네 ㅋㅋ

Copy link
Member

Choose a reason for hiding this comment

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

ElElementelement가 모두 공존해서 그런가보네요 ㅋㅋ

* @returns {Array}
*/
fill: function(start, end, value, target) {
var arr = target || [];
Copy link
Member

@shiren shiren Jun 3, 2021

Choose a reason for hiding this comment

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

디폴트 파라메터를 쓰면 될 것 같아요.

Copy link
Contributor

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

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

리뷰완료합니다.

Comment on lines 801 to 805
if (!this.isValidTime(endHour, endMin) || this.compareTimes(begin, end) <= 0) {
return false;
}

return true;
Copy link
Contributor

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

Choose a reason for hiding this comment

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

i가 replaceEnd부터 시작하는데 시작 조건에 명시적으로 적어줘도 좋을 것 같습니다.

Copy link
Member

@jung-han jung-han left a comment

Choose a reason for hiding this comment

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

완료입니다~

@jungeun-cho
Copy link

확인했습니다~

@jajugoguma jajugoguma merged commit 34b6f8e into master Jun 4, 2021
@jajugoguma jajugoguma deleted the feat/set-range branch June 4, 2021 01:58
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.

5 participants