From 16ffd19b85a9a2540b729ef36343d39861998494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=84=EC=A3=BC?= Date: Thu, 19 Jun 2025 10:47:32 +0900 Subject: [PATCH] =?UTF-8?q?[FO]=20=EC=9D=BC=EA=B3=84=EB=B6=80=20=EB=8F=99?= =?UTF-8?q?=EB=A0=A5=20=EC=82=AC=EC=9A=A9=EC=8B=9C=EA=B0=84=20List,=20?= =?UTF-8?q?=EA=B8=B0=ED=83=80=20=EA=B3=B5=ED=86=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/RecordCalendarDao.java | 27 +++--- .../application/domain/RecordCalendar.java | 1 + .../resources/static/assets/json/2025-01.json | 2 +- .../resources/static/assets/json/2025-02.json | 3 +- .../resources/static/assets/json/2025-03.json | 2 +- .../resources/static/assets/json/2025-05.json | 2 +- .../assets/scripts/temp/hooks/concat.js | 2 +- .../resources/templates/record/calendar.html | 93 +++++++++++++------ .../templates/record/daily/done.html | 4 +- .../templates/record/expense/index.html | 17 ++-- .../templates/record/income/index.html | 19 ++-- .../templates/record/power/form.html | 2 +- .../templates/record/power/index.html | 81 +++++----------- 13 files changed, 129 insertions(+), 126 deletions(-) diff --git a/front/src/main/java/app/module/front/usecase/daily/calendar/adapters/persistence/RecordCalendarDao.java b/front/src/main/java/app/module/front/usecase/daily/calendar/adapters/persistence/RecordCalendarDao.java index 076a2ab6..2a02a008 100644 --- a/front/src/main/java/app/module/front/usecase/daily/calendar/adapters/persistence/RecordCalendarDao.java +++ b/front/src/main/java/app/module/front/usecase/daily/calendar/adapters/persistence/RecordCalendarDao.java @@ -32,6 +32,19 @@ public class RecordCalendarDao implements RecordCalendarPortOut { String pathFormat = "/record/%s/%s/%s"; + List monthlyList = new ArrayList<>(); + monthlyList.add(new CalendarChildren( + "MONTHLY", + "임산물 현황 등록", + monthlyStatus.isForestNone() ? 0 : 1, + monthlyStatus.isForestNone() ? "/info/monthly" : String.format("/info/monthly/month/%s", command.getSearchMonth()))); + + monthlyList.add(new CalendarChildren( + "BANK", + "은행 자동이체 내역 등록", + monthlyStatus.isBankNone() ? 0 : 1, + (LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM")).equals(command.getSearchMonth())) ? "/info/bank" : null)); + List refineList = new ArrayList<>(); for (DailyRecordCalendarDto calendar : calendarList) { RecordCalendar refine = new RecordCalendar(); @@ -97,20 +110,8 @@ public class RecordCalendarDao implements RecordCalendarPortOut { } } - childList.add(new CalendarChildren( - "MONTHLY", - "임산물 현황 등록", - monthlyStatus.isForestNone() ? 0 : 1, - String.format("/info/monthly/month/%s", command.getSearchMonth()))); - - childList.add(new CalendarChildren( - "BANK", - "은행 자동이체 내역 등록", - monthlyStatus.isBankNone() ? 0 : 1, - (LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM")).equals(command.getSearchMonth())) ? "/info/bank" : null)); - refine.setChildren(childList); - + refine.setMonthly(monthlyList); refineList.add(refine); } diff --git a/front/src/main/java/app/module/front/usecase/daily/calendar/ports/application/domain/RecordCalendar.java b/front/src/main/java/app/module/front/usecase/daily/calendar/ports/application/domain/RecordCalendar.java index 0f961128..16202a87 100644 --- a/front/src/main/java/app/module/front/usecase/daily/calendar/ports/application/domain/RecordCalendar.java +++ b/front/src/main/java/app/module/front/usecase/daily/calendar/ports/application/domain/RecordCalendar.java @@ -15,4 +15,5 @@ public class RecordCalendar { private Integer start; private Integer end; private List children; + private List monthly; } diff --git a/front/src/main/resources/static/assets/json/2025-01.json b/front/src/main/resources/static/assets/json/2025-01.json index 7117198c..9065b7b8 100644 --- a/front/src/main/resources/static/assets/json/2025-01.json +++ b/front/src/main/resources/static/assets/json/2025-01.json @@ -15,5 +15,5 @@ {"no":14, "start":24, "end":25, "children": [{}, {}]}, {"no":15, "start":26, "end":27, "children": [{}, {}, {}, {}]}, {"no":16, "start":28, "end":29, "children": []}, - {"no":17, "start":30, "end":30, "children": []} + {"no":17, "start":30, "end":31, "children": []} ] diff --git a/front/src/main/resources/static/assets/json/2025-02.json b/front/src/main/resources/static/assets/json/2025-02.json index 7117198c..8f9df2e1 100644 --- a/front/src/main/resources/static/assets/json/2025-02.json +++ b/front/src/main/resources/static/assets/json/2025-02.json @@ -14,6 +14,5 @@ {"no":13, "start":22, "end":23, "children": []}, {"no":14, "start":24, "end":25, "children": [{}, {}]}, {"no":15, "start":26, "end":27, "children": [{}, {}, {}, {}]}, - {"no":16, "start":28, "end":29, "children": []}, - {"no":17, "start":30, "end":30, "children": []} + {"no":16, "start":28, "end":28, "children": []} ] diff --git a/front/src/main/resources/static/assets/json/2025-03.json b/front/src/main/resources/static/assets/json/2025-03.json index 7117198c..9065b7b8 100644 --- a/front/src/main/resources/static/assets/json/2025-03.json +++ b/front/src/main/resources/static/assets/json/2025-03.json @@ -15,5 +15,5 @@ {"no":14, "start":24, "end":25, "children": [{}, {}]}, {"no":15, "start":26, "end":27, "children": [{}, {}, {}, {}]}, {"no":16, "start":28, "end":29, "children": []}, - {"no":17, "start":30, "end":30, "children": []} + {"no":17, "start":30, "end":31, "children": []} ] diff --git a/front/src/main/resources/static/assets/json/2025-05.json b/front/src/main/resources/static/assets/json/2025-05.json index 7117198c..9065b7b8 100644 --- a/front/src/main/resources/static/assets/json/2025-05.json +++ b/front/src/main/resources/static/assets/json/2025-05.json @@ -15,5 +15,5 @@ {"no":14, "start":24, "end":25, "children": [{}, {}]}, {"no":15, "start":26, "end":27, "children": [{}, {}, {}, {}]}, {"no":16, "start":28, "end":29, "children": []}, - {"no":17, "start":30, "end":30, "children": []} + {"no":17, "start":30, "end":31, "children": []} ] diff --git a/front/src/main/resources/static/assets/scripts/temp/hooks/concat.js b/front/src/main/resources/static/assets/scripts/temp/hooks/concat.js index 63b12a67..81544099 100644 --- a/front/src/main/resources/static/assets/scripts/temp/hooks/concat.js +++ b/front/src/main/resources/static/assets/scripts/temp/hooks/concat.js @@ -176,7 +176,7 @@ function useDataset($target) { value = false; } else if(typeof value === 'string' && value.includes('{')){ value = JSON.parse(value); - } else if(!isNaN(value)) { + } else if(!isNaN(value) && !value.startsWith('0')) { value = parseFloat(value); } diff --git a/front/src/main/resources/templates/record/calendar.html b/front/src/main/resources/templates/record/calendar.html index 65b058e1..157d8691 100644 --- a/front/src/main/resources/templates/record/calendar.html +++ b/front/src/main/resources/templates/record/calendar.html @@ -137,7 +137,7 @@ maxView: 0, minDate: this.data.minDate, maxDate: this.data.maxDate, - beforeShowDay: this._beforeShowDay.bind(this) + beforeShowDay: (date) => this._beforeShowDay(date) }) this.instances.datepicker = this.instances.datepickerComp.getDatepickerInstance() @@ -182,12 +182,12 @@ _setupEventListeners() { // // Bind methods to maintain context this.boundMethods = { - handleDateChange: this._handleDateChange.bind(this), - handleMonthChange: this._handleMonthChange.bind(this), - handleWeekChange: this._handleWeekChange.bind(this), - handlePrevWeek: this._handlePrevWeek.bind(this), - handleNextWeek: this._handleNextWeek.bind(this), - handleModeToggle: this._handleModeToggle.bind(this) + handleDateChange: ({ detail }) => this._handleDateChange({ detail }), + handleMonthChange: ({ detail }) => this._handleMonthChange({ detail }), + handleWeekChange: ({ detail }) => this._handleWeekChange({ detail }), + handlePrevWeek: () => this._handlePrevWeek(), + handleNextWeek: () => this._handleNextWeek(), + handleModeToggle: () => this._handleModeToggle() } // // Add event listeners @@ -291,8 +291,14 @@ } _initializeWeekMode() { - this.state.weekPaging = 0 + const selectedDate = this.instances.datepicker.getDate() + const selectedDay = selectedDate.getDate() + + // // 선택된 날짜가 포함된 주차 계산 + this.state.weekPaging = Math.floor((selectedDay - 1) / DatepickerComponent.CONSTANTS.DAYS_PER_WEEK) + this._weekPagination() + this._updateWeekNavigationButtons() } _initializeMonthMode() { @@ -310,21 +316,47 @@ this._weekPagination(direction) } + _updateWeekNavigationButtons() { + if (this.state.mode !== 'week') return + + const currentDate = this.instances.datepicker.getDate() + + // // 이전주 버튼 상태 확인 + const prevWeekDate = this._getPrevWeekDate(currentDate) + const isPrevDisabled = prevWeekDate <= this.data.minDate + this._toggleButtonDisabled(this.elements.prevWeek, isPrevDisabled) + + // // 다음주 버튼 상태 확인 + const nextWeekDate = this._getNextWeekDate(currentDate) + const isNextDisabled = nextWeekDate >= this.data.maxDate + this._toggleButtonDisabled(this.elements.nextWeek, isNextDisabled) + } + + _getPrevWeekDate(currentDate) { + const endWeekDate = this.state.weekPaging * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK - 6 + return new Date(currentDate.getFullYear(), currentDate.getMonth(), endWeekDate) + } + + _getNextWeekDate(currentDate) { + const endWeekDate = (this.state.weekPaging + 2) * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK + return new Date(currentDate.getFullYear(), currentDate.getMonth(), endWeekDate) + } + _weekPagingPrev() { const currentDate = this.instances.datepicker.getDate() - const endWeekDate = this.state.weekPaging * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK - 6 - const date = new Date(currentDate.getFullYear(), currentDate.getMonth(), endWeekDate) - - this._disablePrevNextButtons('prev', date) + // // 현재 주가 1주차(weekPaging = 0)라면 이전 달로 이동 if (this.state.weekPaging <= 0) { this._moveToPreviousMonth() return } + // // 이전 주로 이동 this.state.weekPaging -= 1 this._clickFirstVisibleCell() this._dispatchWeekChangeEvent('prev', currentDate) + this._weekPagination('prev') + this._updateWeekNavigationButtons() } _weekPagingNext() { @@ -414,6 +446,7 @@ this.state.weekPaging = lastWeekOfPrevMonth this._weekPagination('prev') this._clickFirstVisibleCell() + this._updateWeekNavigationButtons() } _moveToNextMonth() { @@ -426,6 +459,7 @@ // // 주 모드에서 월 이동 시 적절한 날짜가 선택되도록 loadMonthData 호출 // // changeMonth 이벤트가 자동으로 발생하여 loadMonthData가 호출됨 this._weekPagination('next') + this._updateWeekNavigationButtons() } _setFirstDateDay(date) { @@ -451,6 +485,7 @@ // // Month setup and data loading _setupMonth(date) { this.state.currentMonth = this._getMonthKey(date) + console.log('this.state.currentMonth', this.state.currentMonth, date) const allCells = this._getAllCells() const thisMonthCells = this._getThisMonthCells() @@ -518,9 +553,9 @@ } async _finalizeDateLoading(date) { - const today = new Date() - this._setupMonth(today) + // this._setupMonth(date) + const today = new Date() const targetDate = this._getTargetDate(date, today) this.instances.datepicker.setDate(targetDate) @@ -600,7 +635,6 @@ // TODO //const response = await fetch(`http://localhost:8888/assets/json/${month}.json`) const response = await fetch(`/api/record/calendar/${month}`) - return await response.json() } @@ -664,13 +698,12 @@ // data: {no: 2, start: 3, end: 4, children: Array(2)} // currentDate: {start: '2025.06.15', end: '2025.06.16'} // viewDate: instanceof Date - kri.logger.debug('changeDateCallback', data, currentDate, viewDate); + console.log('changeDateCallback', data, currentDate, viewDate); // TODO formControl.setDetail(data, currentDate, viewDate); - }, function(monthKey, currentDate){ - kri.logger.debug('changeMonthCallback', monthKey, currentDate); + console.log('changeMonthCallback', monthKey, currentDate); }); @@ -701,24 +734,24 @@ let formControl = { setDetail(rowdata, currentDate, viewDate) { const searchMonth = viewDate.getFullYear().toString() + (viewDate.getMonth() + 1).toString().padStart(2, '0'); - let rowList = []; - let etcList = []; + let childList = rowdata.children; + let monthlyList = rowdata.monthly; if (rowdata == null) { kri.logger.error('달력 선택 데이터 없음.') } - if (rowdata != null && typeof rowdata === 'object' && rowdata.children !== undefined) { - rowList = rowdata.children.filter(f => !(f.code === 'MONTHLY' || f.code === 'BANK')); - etcList = rowdata.children.filter(f => f.code === 'MONTHLY' || f.code === 'BANK'); - } + // if (rowdata != null && typeof rowdata === 'object' && rowdata.children !== undefined) { + // rowList = rowdata.children.filter(f => !(f.code === 'MONTHLY' || f.code === 'BANK')); + // monthlyList = rowdata.children.filter(f => f.code === 'MONTHLY' || f.code === 'BANK'); + // } let tmpl = $.templates('#dailyNoneTmpl'); let html = ''; - if (rowList === undefined || rowList.length === 0) { + if (childList === undefined || childList.length === 0) { html = tmpl.render({ month: searchMonth, no: rowdata.no, date: currentDate, - etcList: etcList, + monthlyList: monthlyList, }); } else { tmpl = $.templates('#dailyListTmpl'); @@ -726,8 +759,8 @@ month: searchMonth, no: rowdata.no, date: currentDate, - list: rowList, - etcList: etcList, + list: childList, + monthlyList: monthlyList, }); } @@ -779,8 +812,10 @@