Skip to content

Commit 6b34e54

Browse files
committed
chore: vue 코드에 주석 추가
1 parent b39af57 commit 6b34e54

24 files changed

+444
-22
lines changed

my-garden-fe/src/components/boards/common/SearchForm.vue

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const pageSize = ref(props.queryParameter.pageSize);
2727
const sort = ref(props.queryParameter.sort);
2828
const order = ref(props.queryParameter.order);
2929
30+
/**
31+
* 검색
32+
*/
3033
function search() {
3134
emits("search", {
3235
startDate: startDate.value,
@@ -40,6 +43,9 @@ function search() {
4043
});
4144
}
4245
46+
/**
47+
* 검색 조건 변경 감지
48+
*/
4349
watch(() => props.queryParameter, () => {
4450
if (Object.keys(props.queryParameter).length === 0) {
4551
return;

my-garden-fe/src/components/dailyRoutine/draw/DrawDailyRoutine.vue

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ function createTimeBlock(block, startTime, endTime, partOfDay) {
9090
return scheduleDefaultData;
9191
}
9292
93+
/**
94+
* 조회 날짜가 변경되면, 해당 날짜의 루틴을 조회한다.
95+
*/
9396
watch(() => store.getters.getViewDate, (newDate) => {
9497
const {targetStartDateTime, targetEndDateTime} = getTargetDateTimeRange(newDate);
9598

my-garden-fe/src/components/dailyRoutine/draw/DrawStatisticsChart.vue

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ onMounted(() => {
166166
);
167167
});
168168
169+
/**
170+
* 시간 블록 배열이 업데이트되면, 통계 데이터를 계산하고, Chart.js의 DataSet을 업데이트한다.
171+
*/
169172
watch(() => store.getters.getTimeBlockArray, (timeBlockArray) => {
170173
const statisticData = {};
171174

my-garden-fe/src/components/dailyRoutine/input/ContentInput.vue

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const props = defineProps({
77
content: String
88
});
99
10+
/**
11+
* 일과 내용
12+
*/
1013
const content = ref(props.content);
1114
1215
const emit = defineEmits(['changeContent', 'submit'])

my-garden-fe/src/components/dailyRoutine/input/DateInput.vue

+7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ const props = defineProps({
88
});
99
1010
const emit = defineEmits(['changeDate'])
11+
12+
/**
13+
* 일과 시간
14+
*/
1115
const dateTime = ref('');
1216
17+
/**
18+
* 일과 시간 변경 감지
19+
*/
1320
watch(() => [props.startDateTime, props.endDateTime], (newValue) => {
1421
if (props.inputName === '시작 시간') {
1522
dateTime.value = newValue[0];

my-garden-fe/src/components/dailyRoutine/input/InputDailyRoutine.vue

+49-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ import {deleteDailyRoutineApi, postDailyRoutineApi, updateDailyRoutineApi} from
88
import {store} from "@/scripts/store.js";
99
import {getTodayDate} from "@/components/dailyRoutine/api/util.js";
1010
11+
/**
12+
* 하루 일과 입력에 필요한 내용
13+
*/
1114
const startDate = ref('');
1215
const endDate = ref('');
1316
const content = ref('');
1417
const routineType = ref('STUDY');
1518
const isUpdateMode = ref(false);
1619
17-
onMounted(() => {
18-
getLastStartDateTime();
19-
});
20-
20+
/**
21+
* 오늘 마지막 시작 시간을 가져온다.
22+
*/
2123
function getLastStartDateTime() {
2224
let todayLastStartDateTime = localStorage.getItem("todayLastStartDateTime");
2325
const todayDate = getTodayDate();
@@ -30,6 +32,10 @@ function getLastStartDateTime() {
3032
startDate.value = todayLastStartDateTime;
3133
}
3234
35+
/**
36+
* 버튼을 누르거나, Ctrl + Enter를 눌렀을 때 실행되는 함수<br>
37+
* 일과 등록 유효성 검사 후, 일과 등록 또는 수정을 실행한다.
38+
*/
3339
function submit() {
3440
if (!validate()) {
3541
return;
@@ -41,6 +47,9 @@ function submit() {
4147
postRoutine();
4248
}
4349
50+
/**
51+
* 일과 등록 유효성 검사
52+
*/
4453
function validate() {
4554
//시작 날짜가 끝 날짜보다 늦을 수 없다.
4655
function validateStartDateIsBeforeEndDate() {
@@ -56,7 +65,10 @@ function validate() {
5665
return false;
5766
}
5867
59-
//두 날짜는 1일이상 차이가 날 수 없다.
68+
/**
69+
* 두 날짜의 차이가 1일 이상 나는지 검증한다.
70+
* @returns {boolean}
71+
*/
6072
function validateDateDifferenceIsSmaller1() {
6173
// Calculate the time difference in milliseconds
6274
const timeDifference = new Date(endDate.value) - new Date(startDate.value);
@@ -77,7 +89,9 @@ function validate() {
7789
return false;
7890
}
7991
80-
//content는 255자를 넘을 수 없다.
92+
/**
93+
* content의 길이가 255자를 넘지 않는지 검증한다.
94+
*/
8195
function validateContentLength() {
8296
if (content.value.length > 255) {
8397
alert("content는 255자를 넘을 수 없습니다.")
@@ -90,6 +104,9 @@ function validate() {
90104
return validateContentLength();
91105
}
92106
107+
/**
108+
* 일과 등록
109+
*/
93110
function postRoutine() {
94111
if (!validate()) {
95112
return;
@@ -100,6 +117,9 @@ function postRoutine() {
100117
localStorage.setItem("todayLastStartDateTime", endDate.value);
101118
}
102119
120+
/**
121+
* 일과 수정
122+
*/
103123
function updateRoutine() {
104124
if (!updateValidate()) {
105125
return;
@@ -108,28 +128,37 @@ function updateRoutine() {
108128
updateDailyRoutineApi(store.getters.getEditBlock.id, startDate.value, endDate.value, routineType.value, content.value);
109129
}
110130
131+
/**
132+
* 일과 수정 유효성 검사
133+
*/
111134
function updateValidate() {
112135
if (!validate()) {
113136
return false;
114137
}
115138
116-
function isNotDateToday() {
117-
//오늘내의 날짜로만 수정이 가능하다.
118-
const todayDate = getTodayDate(); // Assuming getTodayDate() returns a String
139+
/**
140+
* 수정 하려는 날짜가 오늘 날짜인지 검증한다.
141+
* @returns {boolean} 오늘 내의 날짜가 아니면 false, 아니면 true
142+
*/
143+
function isNotTodayDate() {
144+
const todayDate = getTodayDate();
119145
const tempStartDate = startDate.value.split("T")[0];
120146
const tempEndDate = endDate.value.split("T")[0];
121147
122148
return tempStartDate !== todayDate || tempEndDate !== todayDate;
123149
}
124150
125-
if (isNotDateToday()) {
151+
if (isNotTodayDate()) {
126152
alert("오늘 내의 날짜만 수정이 가능합니다.");
127153
return false;
128154
}
129155
130156
return true;
131157
}
132158
159+
/**
160+
* 수정 취소
161+
*/
133162
function cancelUpdate() {
134163
isUpdateMode.value = false;
135164
getLastStartDateTime();
@@ -138,10 +167,20 @@ function cancelUpdate() {
138167
content.value = '';
139168
}
140169
170+
/**
171+
* 일과 삭제
172+
*/
141173
function deleteRoutine() {
142174
deleteDailyRoutineApi(store.getters.getEditBlock.id);
143175
}
144176
177+
onMounted(() => {
178+
getLastStartDateTime();
179+
});
180+
181+
/**
182+
* 수정 모드로 변경
183+
*/
145184
watch(() => store.getters.getEditBlock, (newVal) => {
146185
const updateStartDateTime = newVal.startDate + 'T' + newVal.displayStartTime;
147186

my-garden-fe/src/components/dailyRoutine/input/TypeInput.vue

+21-8
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ const props = defineProps({
77
});
88
99
const emit = defineEmits(['changeType'])
10-
const selectValue = ref('');
1110
12-
watch(() => props.routineType, (newValue) => {
13-
const type = convertRoutineTypeToSelectValue(newValue);
14-
15-
selectValue.value = type;
16-
emit('changeType', type)
17-
}, {immediate: true}
18-
);
11+
/**
12+
* 일과 타입
13+
*/
14+
const selectValue = ref('');
1915
16+
/**
17+
* 루틴 타입을 select value로 변경
18+
*
19+
* @param inputString 루틴 타입
20+
* @returns {*|string} select value
21+
*/
2022
function convertRoutineTypeToSelectValue(inputString) {
2123
switch (inputString) {
2224
case '공부':
@@ -38,6 +40,17 @@ function convertRoutineTypeToSelectValue(inputString) {
3840
}
3941
}
4042
43+
/**
44+
* 일과 타입 변경 감지
45+
*/
46+
watch(() => props.routineType, (newValue) => {
47+
const type = convertRoutineTypeToSelectValue(newValue);
48+
49+
selectValue.value = type;
50+
emit('changeType', type)
51+
}, {immediate: true}
52+
);
53+
4154
</script>
4255

4356
<template>

my-garden-fe/src/components/dailyRoutine/popup/SelectDatePopUp.vue

+26
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,53 @@ import {convertDateFormat} from "@/components/dailyRoutine/api/util.js";
44
import {store} from "@/scripts/store.js";
55
import {router} from "@/scripts/router.js";
66
7+
/**
8+
* 모달을 보여줄지 여부
9+
*/
710
const showModal = ref(false);
11+
12+
/**
13+
* 조회 날짜
14+
*/
815
const inputDate = ref(new Date());
916
17+
/**
18+
* 모달 열기
19+
*/
1020
function openModal() {
1121
showModal.value = true;
1222
}
1323
24+
/**
25+
* 모달 닫기
26+
*/
1427
function closeModal() {
1528
showModal.value = false;
1629
}
1730
31+
/**
32+
* 조회 날짜 변경
33+
*
34+
* @param date 변경할 날짜
35+
*/
1836
function updateDate(date) {
1937
inputDate.value = date;
2038
closeModal();
2139
store.commit("setViewDate", convertDateFormat(date));
2240
}
2341
42+
/**
43+
* 일과 통계 페이지로 이동
44+
*/
2445
function goToStatistics() {
2546
router.push('/daily-routine/statistics');
2647
}
2748
49+
/**
50+
* 모달 바깥쪽 클릭 시 모달 닫기
51+
*
52+
* @param event 클릭 이벤트
53+
*/
2854
function handleClickOutside(event) {
2955
const modalContent = document.querySelector('.modal-content');
3056
if (!modalContent.contains(event.target)) {

my-garden-fe/src/components/dailyRoutine/statistics/SelectDateWithCalendar.vue

+12
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@ import {convertDateFormat, getTodayDate} from "@/components/dailyRoutine/api/uti
44
55
const emit = defineEmits(['updateSelectDate']);
66
7+
/**
8+
* 조회 날짜
9+
*/
710
const inputDate = ref({
811
start: getTodayDate(),
912
end: getTodayDate()
1013
});
14+
15+
/**
16+
* 캘린더 날짜
17+
*/
1118
const inputCalendarDate = ref({
1219
start: new Date(inputDate.value.start),
1320
end: new Date(inputDate.value.end)
1421
});
1522
23+
/**
24+
* 조회 날짜 변경
25+
*
26+
* @param date 변경할 날짜
27+
*/
1628
function updateDate(date) {
1729
inputDate.value.start = convertDateFormat(date.start);
1830
inputDate.value.end = convertDateFormat(date.end);

0 commit comments

Comments
 (0)