Skip to content

Commit c582e5f

Browse files
kimorkimusbsync
and
usbsync
authored
이슈 5591 처리 (#391)
Co-authored-by: usbsync <[email protected]>
1 parent 9508c2c commit c582e5f

File tree

4 files changed

+71
-15
lines changed

4 files changed

+71
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
"chroma-js": "^1.4.0",
132132
"classnames": "^2.2.6",
133133
"clipboard": "^2.0.11",
134-
"entry_sheet": "https://8a14b1ce074335d7a7d9099b4a0807cc40fc9434:[email protected]/ria/entry_sheet.git",
134+
"entry_sheet": "https://8a14b1ce074335d7a7d9099b4a0807cc40fc9434:[email protected]/ria/entry_sheet.git#v0.0.0.26",
135135
"jest": "^26.0.1",
136136
"moment": "^2.24.0",
137137
"react-cookies": "^0.1.0",

src/components/editor/dataAnalytics/TableEditor.jsx

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import { downloadXLSX } from '@utils/dataAnalytics';
99

1010
const TableEditor = () => {
1111
const theme = Theme.getStyle('popup');
12-
const [showAlert, setShowAlert] = useState(false);
1312
const { dataAnalytics, dispatch } = useContext(DataAnalyticsContext);
1413
const { selected = {}, gridRef } = dataAnalytics;
1514
const { table = [[]] } = selected;
1615

16+
const [alertMsg, setAlertMsg] = useState({
17+
title: '',
18+
content: '',
19+
isShow: false,
20+
});
21+
1722
const handleColumnEdit = useCallback(
1823
({ editType, index }) => {
1924
if (editType === 'ADD') {
@@ -31,15 +36,52 @@ const TableEditor = () => {
3136
[dispatch]
3237
);
3338

39+
const handleRowEdit = useCallback(
40+
({ editType, index }) => {
41+
if (editType === 'ADD') {
42+
dispatch({
43+
type: 'ADD_ROW',
44+
index,
45+
});
46+
} else if (editType === 'REMOVE') {
47+
dispatch({
48+
type: 'DELETE_ROW',
49+
index,
50+
});
51+
}
52+
},
53+
[dispatch]
54+
);
55+
3456
const saveExcel = () => {
3557
const { name } = selected;
3658
const sheet = gridRef?.current?.getSheetData().data;
3759
downloadXLSX(sheet, name);
3860
};
3961

40-
const handleCellAdd = () => {
41-
setShowAlert(true);
42-
};
62+
const handleCellAdd = useCallback(() => {
63+
setAlertMsg({
64+
title: CommonUtils.getLang('DataAnalytics.limit_cell_count_title'),
65+
content: CommonUtils.getLang('DataAnalytics.limit_cell_count_content'),
66+
isShow: true,
67+
});
68+
}, [setAlertMsg]);
69+
70+
const handleCellRemove = useCallback(() => {
71+
setAlertMsg({
72+
title: CommonUtils.getLang('General.alert_title'),
73+
content: CommonUtils.getLang('DataAnalytics.must_have_one_row_content'),
74+
isShow: true,
75+
});
76+
}, [setAlertMsg]);
77+
78+
const handleCloseAlert = useCallback(() => {
79+
setAlertMsg({
80+
title: '',
81+
content: '',
82+
isShow: false,
83+
});
84+
}, [setAlertMsg]);
4385

4486
return (
4587
<>
@@ -58,7 +100,9 @@ const TableEditor = () => {
58100
callBack: {
59101
saveExcel,
60102
onColumnEdit: handleColumnEdit,
103+
onRowEdit: handleRowEdit,
61104
maxCellPopup: handleCellAdd,
105+
minCellPopup: handleCellRemove,
62106
},
63107
config: {
64108
maxCell: 30000,
@@ -86,19 +130,15 @@ const TableEditor = () => {
86130
}}
87131
/>
88132
</div>
89-
{showAlert ? (
133+
{alertMsg.isShow && (
90134
<AlertModal
91-
content={CommonUtils.getLang('DataAnalytics.limit_cell_count_content')}
92-
title={CommonUtils.getLang('DataAnalytics.limit_cell_count_title')}
93-
onEvent={() => {
94-
setShowAlert(false);
95-
}}
135+
title={alertMsg.title}
136+
content={alertMsg.content}
137+
onEvent={handleCloseAlert}
96138
options={{
97139
positiveButtonText: CommonUtils.getLang('DataAnalytics.confirm'),
98140
}}
99141
/>
100-
) : (
101-
''
102142
)}
103143
</>
104144
);

src/reducers/dataAnalytics.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,22 @@ export const dataAnalyticsReducer = (state, action) => {
257257
isChanged: true,
258258
};
259259
}
260+
case 'ADD_ROW': {
261+
const { selected } = state;
262+
return {
263+
...state,
264+
selected,
265+
isChanged: true,
266+
};
267+
}
268+
case 'DELETE_ROW': {
269+
const { selected } = state;
270+
return {
271+
...state,
272+
selected,
273+
isChanged: true,
274+
};
275+
}
260276
case 'SAVE': {
261277
const { list, selectedIndex, selected, onSubmitDataAnalytics } = state;
262278
const { table } = action;

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6909,9 +6909,9 @@ entities@^4.2.0, entities@^4.3.0, entities@^4.4.0:
69096909
resolved "https://registry.yarnpkg.com/entities/-/entities-4.4.0.tgz#97bdaba170339446495e653cfd2db78962900174"
69106910
integrity sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==
69116911

6912-
"entry_sheet@https://8a14b1ce074335d7a7d9099b4a0807cc40fc9434:[email protected]/ria/entry_sheet.git":
6912+
"entry_sheet@https://8a14b1ce074335d7a7d9099b4a0807cc40fc9434:[email protected]/ria/entry_sheet.git#v0.0.0.26":
69136913
version "1.0.0"
6914-
resolved "https://8a14b1ce074335d7a7d9099b4a0807cc40fc9434:[email protected]/ria/entry_sheet.git#74a00415221df674502750869ff482b9c31da71a"
6914+
resolved "https://8a14b1ce074335d7a7d9099b4a0807cc40fc9434:[email protected]/ria/entry_sheet.git#237ef30da0a3f2031ededde9f754c991704facc0"
69156915
dependencies:
69166916
"@emotion/core" "^10.1.1"
69176917
"@emotion/styled" "^10.0.27"

0 commit comments

Comments
 (0)