From cb103255cf0c22e1e977ac787c17c377fa2eed4d Mon Sep 17 00:00:00 2001 From: jum0 Date: Thu, 10 Dec 2020 01:14:27 +0900 Subject: [PATCH 01/28] =?UTF-8?q?docs=20:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 147 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..721e2bc50 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,147 @@ +# ๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๋ฏธ์…˜ + +## ๐Ÿ“Œ ํ”„๋กœ์ ํŠธ ๊ฐœ์š” + +์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๋ฏธ์…˜์€ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ํ”„๋กœ์ ํŠธ์ž…๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋žจ ์ƒ๋‹จ์—๋Š” ์ด 4๊ฐ€์ง€์˜ ๋ฉ”๋‰ด๋กœ `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ`, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ` ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ` ๋ฉ”๋‰ด๋Š” ๊ฐ๊ฐ ์ง€ํ•˜์ฒ  ์—ญ, ์ง€ํ•˜์ฒ  ๋…ธ์„ , ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ๋“ฑ๋ก(์ถ”๊ฐ€) ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œ, ์กฐํšŒํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ` ๋ฉ”๋‰ด๋Š” ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๊ธฐ๋Šฅ์„ ํ•ฉ๋‹ˆ๋‹ค. + +## ๐Ÿš€ ๊ธฐ๋Šฅ ์š”๊ตฌ ์‚ฌํ•ญ + +### 1.1 ์ฃผ์–ด์ง„ ์š”๊ตฌ ์‚ฌํ•ญ + +##### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ + +- ์ง€ํ•˜์ฒ  ์—ญ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. (๋‹จ, ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์€ ์‚ญ์ œํ•  ์ˆ˜ ์—†๋‹ค) +- ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ์—ญ ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. +- ์ง€ํ•˜์ฒ  ์—ญ์€ 2๊ธ€์ž ์ด์ƒ์ด์–ด์•ผ ํ•œ๋‹ค. +- ์ง€ํ•˜์ฒ  ์—ญ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. +- ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. +- ๋…ธ์„  ๋“ฑ๋ก ์‹œ ์ƒํ–‰ ์ข…์ ์—ญ๊ณผ ํ•˜ํ–‰ ์ข…์ ์—ญ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๊ตฌ๊ฐ„์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์€ ๋…ธ์„ ์— ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋ผ๊ณ ๋„ ํ•  ์ˆ˜ ์žˆ๋‹ค. + - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. +- ํ•˜๋‚˜์˜ ์—ญ์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋…ธ์„ ์— ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ๋‹ค. +- ์—ญ๊ณผ ์—ญ ์‚ฌ์ด์— ์ƒˆ๋กœ์šด ์—ญ์ด ์ถ”๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค. +- ๋…ธ์„ ์—์„œ ๊ฐˆ๋ž˜๊ธธ์€ ์ƒ๊ธธ ์ˆ˜ ์—†๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์‚ญ์ œ ๊ธฐ๋Šฅ +- ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. +- ์ข…์ ์„ ์ œ๊ฑฐํ•  ๊ฒฝ์šฐ ๋‹ค์Œ ์—ญ์ด ์ข…์ ์ด ๋œ๋‹ค. +- ๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ ์กฐํšŒ ๊ธฐ๋Šฅ +- ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๋ถ€ํ„ฐ ํ•˜ํ–‰ ์ข…์ ๊นŒ์ง€ ์—ฐ๊ฒฐ๋œ ์ˆœ์„œ๋Œ€๋กœ ์—ญ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. + +### 1.2 ๊ธฐ๋Šฅ ๋ชฉ๋ก + +- `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ`, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ถœ๋ ฅ` ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. + +- ์—ญ ๊ด€๋ฆฌ + - ์ถ”๊ฐ€ + - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์€ 2๊ธ€์ž ์ด์ƒ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - ์ค‘๋ณต๋œ ์—ญ ์ด๋ฆ„์€ ๋“ฑ๋กํ•  ์ˆ˜ ์—†๋‹ค. + - ํ•œ๊ธ€๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค. (๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ, ์ž…๋ ฅ๊ฐ’์ด ์—†๋Š” ๊ฒฝ์šฐ, ์•ŒํŒŒ๋ฒณ์ธ ๊ฒฝ์šฐ, ํŠน์ˆ˜ ๋ฌธ์ž์ธ ๊ฒฝ์šฐ ํ™•์ธ) + - ์‚ญ์ œ + - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์—์„œ ์—ญ์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. + - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - ์—ญ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. +- ๋…ธ์„  ๊ด€๋ฆฌ + - ์ถ”๊ฐ€ + - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์„ ๊ฒ€์ฆํ•œ๋‹ค. + - ์ค‘๋ณต๋œ ๋…ธ์„  ์ด๋ฆ„์€ ๋“ฑ๋กํ•  ์ˆ˜ ์—†๋‹ค. + - ์ˆซ์ž์™€ ์•ŒํŒŒ๋ฒณ ๋ฌธ์ž๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค. (๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ, ์ž…๋ ฅ๊ฐ’์ด ์—†๋Š” ๊ฒฝ์šฐ ํ™•์ธ) + - ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์—ญ ๋ชฉ๋ก์—์„œ ๊ฐ€์ ธ์˜จ๋‹ค. + - ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. (๊ณ ๋ฏผ) + - ์‚ญ์ œ + - ์ง€ํ•˜์ฒ  ๋…ธ์„  ๋ชฉ๋ก์—์„œ ๋…ธ์„ ์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. + - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. +- ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ + - ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. + - ๋“ฑ๋ก(์ถ”๊ฐ€) + - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•œ๋‹ค. + - ์ค‘๋ณต๋œ ์—ญ ์ด๋ฆ„์€ ๋“ฑ๋กํ•  ์ˆ˜ ์—†๋‹ค. + - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด(๊ตฌ๊ฐ„)๋งŒ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. (์ƒํ–‰ ์ข…์ ์ด๋‚˜ ํ•˜ํ–‰ ์ข…์  ์ถ”๊ฐ€๋Š” ๋ถˆ๊ฐ€๋Šฅ) + - ์‚ญ์ œ + - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. + - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. + - ๋…ธ์„ ์˜ ๊ตฌ๊ฐ„ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ + - ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์ถœ๋ ฅํ•œ๋‹ค. + +
+ + +## โœ… ๋น„๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ + +### 2.1 ์†์„ฑ ํƒœ๊ทธ ์š”๊ตฌ์‚ฌํ•ญ + +##### ๋ฉ”๋‰ด ๋ฒ„ํŠผ + +- ์—ญ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#station-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ๋…ธ์„  ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#line-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#section-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#map-print-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +##### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ +- ์ง€ํ•˜์ฒ  ์—ญ์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#station-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#station-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#line-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-start-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-end-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#line-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์„ค์ •ํ•  ์—ญ select ํƒœ๊ทธ๋Š” `#section-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#section-order-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ๋“ฑ๋กํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#section-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +##### ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ธฐ๋Šฅ +- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. + +### 2.2 ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ + +##### ๊ธฐ์กด ์š”๊ตฌ์‚ฌํ•ญ + +- ์‚ฌ์šฉ์ž๊ฐ€ ์ž˜๋ชป๋œ ์ž…๋ ฅ ๊ฐ’์„ ์ž‘์„ฑํ•œ ๊ฒฝ์šฐ `alert`์„ ์ด์šฉํ•ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๊ณ , ์žฌ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค. +- ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(jQuery, Lodash ๋“ฑ)๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , ์ˆœ์ˆ˜ Vanilla JS๋กœ๋งŒ ๊ตฌํ˜„ํ•œ๋‹ค. +- **์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ ์ปจ๋ฒค์…˜์„ ์ง€ํ‚ค๋ฉด์„œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ** ํ•œ๋‹ค +- **indent(์ธ๋ดํŠธ, ๋“ค์—ฌ์“ฐ๊ธฐ) depth๋ฅผ 3์ด ๋„˜์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค. 2๊นŒ์ง€๋งŒ ํ—ˆ์šฉ**ํ•œ๋‹ค. +- **ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์†Œ๋“œ)์˜ ๊ธธ์ด๊ฐ€ 15๋ผ์ธ์„ ๋„˜์–ด๊ฐ€์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค.** + - ํ•จ์ˆ˜(๋˜๋Š” ๋ฉ”์†Œ๋“œ)๊ฐ€ ํ•œ ๊ฐ€์ง€ ์ผ๋งŒ ์ž˜ ํ•˜๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค. +- ๋ณ€์ˆ˜ ์„ ์–ธ์‹œ `var` ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. `const` ์™€ `let` ์„ ์‚ฌ์šฉํ•œ๋‹ค. +- `import` ๋ฌธ์„ ์ด์šฉํ•ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ชจ๋“ˆํ™”ํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ ๋‹ค. +- `template literal`์„ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ์™€ html string์„ ๊ฐ€๋…์„ฑ ์ข‹๊ฒŒ ํ‘œํ˜„ํ•œ๋‹ค. + +#### ์ถ”๊ฐ€๋œ ์š”๊ตฌ์‚ฌํ•ญ +- [data](https://developer.mozilla.org/ko/docs/Learn/HTML/Howto/%EB%8D%B0%EC%9D%B4%ED%84%B0_%EC%86%8D%EC%84%B1_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0)์†์„ฑ์„ ํ™œ์šฉํ•˜์—ฌ html ํƒœ๊ทธ์— ์—ญ, ๋…ธ์„ , ๊ตฌ๊ฐ„์˜ ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ๊ฐ’๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค. +- [localStorage](https://developer.mozilla.org/ko/docs/Web/API/Window/localStorage)๋ฅผ ์ด์šฉํ•˜์—ฌ, ์ƒˆ๋กœ๊ณ ์นจํ•˜๋”๋ผ๋„ ๊ฐ€์žฅ ์ตœ๊ทผ์— ์ž‘์—…ํ•œ ์ •๋ณด๋“ค์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. + +## ๐Ÿ’ป ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ๊ฒฐ๊ณผ + +### ์—ญ๊ด€๋ฆฌ + +![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/station_manager.gif?lastModify=1607501706) + +### ๋…ธ์„ ๊ด€๋ฆฌ + +![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/line_manager.gif?lastModify=1607501706) + +### ๊ตฌ๊ฐ„๊ด€๋ฆฌ + +![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/section_manager.gif?lastModify=1607501706) + +### ๋…ธ์„ ๋„ ์ถœ๋ ฅ + +![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/map_print_manager.gif?lastModify=1607501706) \ No newline at end of file From 5e9bad28c922c3a66414d0c42ab0ff116dda77a7 Mon Sep 17 00:00:00 2001 From: jum0 Date: Thu, 10 Dec 2020 01:53:38 +0900 Subject: [PATCH 02/28] =?UTF-8?q?etc=20:=20eslint,=20prettier=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslinrc.json | 16 ++++++++++++++++ .prettierrc | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 .eslinrc.json create mode 100644 .prettierrc diff --git a/.eslinrc.json b/.eslinrc.json new file mode 100644 index 000000000..984c2dc7b --- /dev/null +++ b/.eslinrc.json @@ -0,0 +1,16 @@ +{ + "plugins": ["prettier"], + "extends": ["eslint:recommended", "google", "plugin:prettier/recommended"], + "rules": { + "prettier/prettier": "error" + }, + "env": { + "browser": true, + "node": true, + "es2020": true + }, + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + } +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..598d33228 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "tabWidth": 2, + "useTabs": false, + "semi": true, + "bracketSpacing": true, + "printWidth": 80 +} From 68eccc7a1707ff13c93d5afaf6d649020ab14230 Mon Sep 17 00:00:00 2001 From: jum0 Date: Sat, 12 Dec 2020 20:00:07 +0900 Subject: [PATCH 03/28] =?UTF-8?q?feat=20:=20=EC=97=AD=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?,=20=EB=85=B8=EC=84=A0=20=EA=B4=80=EB=A6=AC,=20=EA=B5=AC?= =?UTF-8?q?=EA=B0=84=20=EA=B4=80=EB=A6=AC,=20=EC=A7=80=ED=95=98=EC=B2=A0?= =?UTF-8?q?=20=EB=85=B8=EC=84=A0=20=EC=B6=9C=EB=A0=A5=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=EC=9D=84=20=EB=88=84=EB=A5=B4=EB=A9=B4=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=9D=84=20=EC=B6=9C=EB=A0=A5=ED=95=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 98 +++++++++++++++++++++++++++++++++++++++++++- src/index.js | 28 +++++++++++++ src/util/constant.js | 18 ++++++++ src/view/element.js | 44 ++++++++++++++++++++ style.css | 42 +++++++++++++++++++ 5 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 src/util/constant.js create mode 100644 src/view/element.js create mode 100644 style.css diff --git a/index.html b/index.html index fc99deac2..57c126192 100644 --- a/index.html +++ b/index.html @@ -2,12 +2,108 @@ + ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ
-

๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ

+

๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ

+ + + +
+ + +
+
+ +
+ + + +

๐Ÿš‰ ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก

+ + + + + + + + +
์—ญ ์ด๋ฆ„์„ค์ •
+
+ + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + +

๐Ÿš‰ ์ง€ํ•˜์ฒ  ๋…ธ์„  ๋ชฉ๋ก

+ + + + + + + + + + +
๋…ธ์„  ์ด๋ฆ„์ƒํ–‰ ์ข…์ ์—ญํ•˜ํ–‰ ์ข…์ ์—ญ์„ค์ •
+
+ + +
+

๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.

+
+ + + +
+ +
+

1ํ˜ธ์„  ๊ด€๋ฆฌ

+

๊ตฌ๊ฐ„ ๋“ฑ๋ก

+ + + +
+ + + + + + + + + +
์ˆœ์„œ์ด๋ฆ„์„ค์ •
+
+ + +
+ + +
+ diff --git a/src/index.js b/src/index.js index e69de29bb..03d1249cd 100644 --- a/src/index.js +++ b/src/index.js @@ -0,0 +1,28 @@ +import { CONSTANT } from "./util/constant.js"; +import { element, elementControl } from "./view/element.js"; + +export default class SubwayManager { + constructor() { + this.setEventListener(); + } + + setEventListener() { + element.stationManagerButton.addEventListener(CONSTANT.CLICK, () => { + elementControl.showStataionManger(); + }); + + element.lineManagerButton.addEventListener(CONSTANT.CLICK, () => { + elementControl.showLineManager(); + }); + + element.sectionManagerButton.addEventListener(CONSTANT.CLICK, () => { + elementControl.showSectionManager(); + }); + + element.mapPrintManagerButton.addEventListener(CONSTANT.CLICK, () => { + elementControl.showMapPrintManager(); + }); + } +} + +new SubwayManager(); diff --git a/src/util/constant.js b/src/util/constant.js new file mode 100644 index 000000000..bba293049 --- /dev/null +++ b/src/util/constant.js @@ -0,0 +1,18 @@ +export const CONSTANT = { + // querySelector + STATION_MANAGER_BTN_ID: "#station-manager-button", + LINE_MANAGER_BTN_ID: "#line-manager-button", + SECTION_MANAGER_BTN_ID: "#section-manager-button", + MAP_PRINT_MANAGER_BTN_ID: "#map-print-manager-button", + + STATION_CONTAINER_CLASS: ".station-container", + LINE_CONTAINER_CLASS: ".line-container", + SECTION_CONTAINER_CLASS: ".section-container", + MAP_PRINT_CONTAINER_CLASS: ".map-print-container", + + // etc + CLICK: "click", + NONE: "none", + BLOCK: "block", + ZERO_MARGIN: 0, +}; diff --git a/src/view/element.js b/src/view/element.js new file mode 100644 index 000000000..fcf3b7717 --- /dev/null +++ b/src/view/element.js @@ -0,0 +1,44 @@ +import { CONSTANT } from "../util/constant.js"; + +export const element = { + stationManagerButton: document.querySelector(CONSTANT.STATION_MANAGER_BTN_ID), + lineManagerButton: document.querySelector(CONSTANT.LINE_MANAGER_BTN_ID), + sectionManagerButton: document.querySelector(CONSTANT.SECTION_MANAGER_BTN_ID), + mapPrintManagerButton: document.querySelector( + CONSTANT.MAP_PRINT_MANAGER_BTN_ID + ), + + stationContainer: document.querySelector(CONSTANT.STATION_CONTAINER_CLASS), + lineContainer: document.querySelector(CONSTANT.LINE_CONTAINER_CLASS), + sectionContainer: document.querySelector(CONSTANT.SECTION_CONTAINER_CLASS), + mapPrintContainer: document.querySelector(CONSTANT.MAP_PRINT_CONTAINER_CLASS), +}; + +export const elementControl = { + hideAllManagers() { + element.stationContainer.style.display = CONSTANT.NONE; + element.lineContainer.style.display = CONSTANT.NONE; + element.sectionContainer.style.display = CONSTANT.NONE; + element.mapPrintContainer.style.display = CONSTANT.NONE; + }, + + showStataionManger() { + this.hideAllManagers(); + element.stationContainer.style.display = CONSTANT.BLOCK; + }, + + showLineManager() { + this.hideAllManagers(); + element.lineContainer.style.display = CONSTANT.BLOCK; + }, + + showSectionManager() { + this.hideAllManagers(); + element.sectionContainer.style.display = CONSTANT.BLOCK; + }, + + showMapPrintManager() { + this.hideAllManagers(); + element.mapPrintContainer.style.display = CONSTANT.BLOCK; + }, +}; diff --git a/style.css b/style.css new file mode 100644 index 000000000..58c26e40d --- /dev/null +++ b/style.css @@ -0,0 +1,42 @@ +/* table */ +table { + border: 1px solid gray; +} + +th, +td { + border: 1px solid gray; +} + +/* ์—ญ ๊ด€๋ฆฌ */ +.station-container { + padding-top: 20px; + display: none; +} + +/* ๋…ธ์„  ๊ด€๋ฆฌ */ +.line-container { + padding-top: 20px; + display: none; +} + +#line-start-end-station { + padding-top: 20px; + padding-bottom: 20px; +} + +/* ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ */ +.section-container { + padding-top: 20px; + display: none; +} + +#section-table { + margin-top: 40px; +} + +/* ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ */ +.map-print-container { + padding-top: 20px; + display: none; +} From d3db37c761c719f4f049b33b1b7e58db21d57af9 Mon Sep 17 00:00:00 2001 From: jum0 Date: Sat, 12 Dec 2020 22:09:51 +0900 Subject: [PATCH 04/28] =?UTF-8?q?docs=20:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 +++++++-- docs/README.md | 110 ++++++++++++++++++++++++++----------------------- 2 files changed, 75 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index e97a1d649..eafa0409f 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,23 @@ ## ๐Ÿš€ ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ ### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ์—ญ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. (๋‹จ, ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์€ ์‚ญ์ œํ•  ์ˆ˜ ์—†๋‹ค) - ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ์—ญ ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ์€ 2๊ธ€์ž ์ด์ƒ์ด์–ด์•ผ ํ•œ๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. - ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. - ๋…ธ์„  ๋“ฑ๋ก ์‹œ ์ƒํ–‰ ์ข…์ ์—ญ๊ณผ ํ•˜ํ–‰ ์ข…์ ์—ญ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๊ตฌ๊ฐ„์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์€ ๋…ธ์„ ์— ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋ผ๊ณ ๋„ ํ•  ์ˆ˜ ์žˆ๋‹ค. - - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. + - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. - ํ•˜๋‚˜์˜ ์—ญ์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋…ธ์„ ์— ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ๋‹ค. - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด์— ์ƒˆ๋กœ์šด ์—ญ์ด ์ถ”๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค. - ๋…ธ์„ ์—์„œ ๊ฐˆ๋ž˜๊ธธ์€ ์ƒ๊ธธ ์ˆ˜ ์—†๋‹ค. @@ -24,6 +27,7 @@ ### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์‚ญ์ œ ๊ธฐ๋Šฅ + - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. - ์ข…์ ์„ ์ œ๊ฑฐํ•  ๊ฒฝ์šฐ ๋‹ค์Œ ์—ญ์ด ์ข…์ ์ด ๋œ๋‹ค. - ๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. @@ -31,6 +35,7 @@ ### ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ ์กฐํšŒ ๊ธฐ๋Šฅ + - ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๋ถ€ํ„ฐ ํ•˜ํ–‰ ์ข…์ ๊นŒ์ง€ ์—ฐ๊ฒฐ๋œ ์ˆœ์„œ๋Œ€๋กœ ์—ญ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค.
@@ -38,32 +43,38 @@ ## ๐Ÿ’ป ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ๊ฒฐ๊ณผ ### ์—ญ๊ด€๋ฆฌ + ### ๋…ธ์„ ๊ด€๋ฆฌ + ### ๊ตฌ๊ฐ„๊ด€๋ฆฌ + ### ๋…ธ์„ ๋„ ์ถœ๋ ฅ - + ## โœ… ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ ### ๋ฉ”๋‰ด ๋ฒ„ํŠผ + - ์—ญ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#station-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ๋…ธ์„  ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#line-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#section-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#map-print-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ์—ญ์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#station-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#station-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#line-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-start-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-end-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. @@ -71,6 +82,7 @@ - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์„ค์ •ํ•  ์—ญ select ํƒœ๊ทธ๋Š” `#section-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#section-order-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. @@ -78,6 +90,7 @@ - ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ### ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ### ๊ธฐ์กด ์š”๊ตฌ์‚ฌํ•ญ @@ -101,7 +114,8 @@ - [https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals) ### ์ถ”๊ฐ€๋œ ์š”๊ตฌ์‚ฌํ•ญ -- [data](https://developer.mozilla.org/ko/docs/Learn/HTML/Howto/%EB%8D%B0%EC%9D%B4%ED%84%B0_%EC%86%8D%EC%84%B1_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0)์†์„ฑ์„ ํ™œ์šฉํ•˜์—ฌ html ํƒœ๊ทธ์— ์—ญ, ๋…ธ์„ , ๊ตฌ๊ฐ„์˜ ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ๊ฐ’๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค. + +- [data](https://developer.mozilla.org/ko/docs/Learn/HTML/Howto/%EB%8D%B0%EC%9D%B4%ED%84%B0_%EC%86%8D%EC%84%B1_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0)์†์„ฑ์„ ํ™œ์šฉํ•˜์—ฌ html ํƒœ๊ทธ์— ์—ญ, ๋…ธ์„ , ๊ตฌ๊ฐ„์˜ ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ๊ฐ’๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค. - [localStorage](https://developer.mozilla.org/ko/docs/Web/API/Window/localStorage)๋ฅผ ์ด์šฉํ•˜์—ฌ, ์ƒˆ๋กœ๊ณ ์นจํ•˜๋”๋ผ๋„ ๊ฐ€์žฅ ์ตœ๊ทผ์— ์ž‘์—…ํ•œ ์ •๋ณด๋“ค์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.
diff --git a/docs/README.md b/docs/README.md index 721e2bc50..2f307741f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -16,99 +16,104 @@ - ์ง€ํ•˜์ฒ  ์—ญ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ##### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ๋“ฑ๋กํ•˜๊ณ  ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. - ์ค‘๋ณต๋œ ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ด๋ฆ„์ด ๋“ฑ๋ก๋  ์ˆ˜ ์—†๋‹ค. - ๋…ธ์„  ๋“ฑ๋ก ์‹œ ์ƒํ–‰ ์ข…์ ์—ญ๊ณผ ํ•˜ํ–‰ ์ข…์ ์—ญ์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ + - ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๊ตฌ๊ฐ„์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์€ ๋…ธ์„ ์— ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋ผ๊ณ ๋„ ํ•  ์ˆ˜ ์žˆ๋‹ค. - - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. + - ์—ญ๊ณผ ์—ญ์‚ฌ์ด๋ฅผ ๊ตฌ๊ฐ„์ด๋ผ ํ•˜๊ณ  ์ด ๊ตฌ๊ฐ„๋“ค์˜ ๋ชจ์Œ์ด ๋…ธ์„ ์ด๋‹ค. - ํ•˜๋‚˜์˜ ์—ญ์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋…ธ์„ ์— ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ๋‹ค. - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด์— ์ƒˆ๋กœ์šด ์—ญ์ด ์ถ”๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค. - ๋…ธ์„ ์—์„œ ๊ฐˆ๋ž˜๊ธธ์€ ์ƒ๊ธธ ์ˆ˜ ์—†๋‹ค. ##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์‚ญ์ œ ๊ธฐ๋Šฅ + - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. - ์ข…์ ์„ ์ œ๊ฑฐํ•  ๊ฒฝ์šฐ ๋‹ค์Œ ์—ญ์ด ์ข…์ ์ด ๋œ๋‹ค. - ๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. ##### ์ง€ํ•˜์ฒ  ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ ์กฐํšŒ ๊ธฐ๋Šฅ + - ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๋ถ€ํ„ฐ ํ•˜ํ–‰ ์ข…์ ๊นŒ์ง€ ์—ฐ๊ฒฐ๋œ ์ˆœ์„œ๋Œ€๋กœ ์—ญ ๋ชฉ๋ก์„ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ### 1.2 ๊ธฐ๋Šฅ ๋ชฉ๋ก - `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ`, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ถœ๋ ฅ` ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. - - ์—ญ ๊ด€๋ฆฌ - - ์ถ”๊ฐ€ - - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์€ 2๊ธ€์ž ์ด์ƒ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ์ค‘๋ณต๋œ ์—ญ ์ด๋ฆ„์€ ๋“ฑ๋กํ•  ์ˆ˜ ์—†๋‹ค. - - ํ•œ๊ธ€๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค. (๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ, ์ž…๋ ฅ๊ฐ’์ด ์—†๋Š” ๊ฒฝ์šฐ, ์•ŒํŒŒ๋ฒณ์ธ ๊ฒฝ์šฐ, ํŠน์ˆ˜ ๋ฌธ์ž์ธ ๊ฒฝ์šฐ ํ™•์ธ) - - ์‚ญ์ œ - - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์—์„œ ์—ญ์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. - - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - - ์—ญ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - `์—ญ ์ถ”๊ฐ€` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. + - ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด 2๊ธ€์ž ์ด์ƒ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - `์‚ญ์ œ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์‚ญ์ œํ•œ๋‹ค. + - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - ๋…ธ์„  ๊ด€๋ฆฌ - - ์ถ”๊ฐ€ - - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์„ ๊ฒ€์ฆํ•œ๋‹ค. - - ์ค‘๋ณต๋œ ๋…ธ์„  ์ด๋ฆ„์€ ๋“ฑ๋กํ•  ์ˆ˜ ์—†๋‹ค. - - ์ˆซ์ž์™€ ์•ŒํŒŒ๋ฒณ ๋ฌธ์ž๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค. (๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ, ์ž…๋ ฅ๊ฐ’์ด ์—†๋Š” ๊ฒฝ์šฐ ํ™•์ธ) + - `๋…ธ์„  ์ถ”๊ฐ€` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. - ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์—ญ ๋ชฉ๋ก์—์„œ ๊ฐ€์ ธ์˜จ๋‹ค. + - ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. (๊ณ ๋ฏผ) - - ์‚ญ์ œ - - ์ง€ํ•˜์ฒ  ๋…ธ์„  ๋ชฉ๋ก์—์„œ ๋…ธ์„ ์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. - - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - - ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - `์‚ญ์ œ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋…ธ์„ ์„ ์‚ญ์ œํ•œ๋‹ค. + - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ - - ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. - - ๋“ฑ๋ก(์ถ”๊ฐ€) - - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•œ๋‹ค. - - ์ค‘๋ณต๋œ ์—ญ ์ด๋ฆ„์€ ๋“ฑ๋กํ•  ์ˆ˜ ์—†๋‹ค. - - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด(๊ตฌ๊ฐ„)๋งŒ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. (์ƒํ–‰ ์ข…์ ์ด๋‚˜ ํ•˜ํ–‰ ์ข…์  ์ถ”๊ฐ€๋Š” ๋ถˆ๊ฐ€๋Šฅ) - - ์‚ญ์ œ - - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋‹ค. - - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. - - ๋…ธ์„ ์˜ ๊ตฌ๊ฐ„ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ๋ฒ„ํŠผ์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. + - ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. + - ์ œ๋ชฉ์€ `(์„ ํƒ๋œ ๋…ธ์„ ) ๊ด€๋ฆฌ`๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. + - `๋“ฑ๋ก` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๊ตฌ๊ฐ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค. + - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด(๊ตฌ๊ฐ„)์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - `๋…ธ์„ ์—์„œ ์ œ๊ฑฐ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๊ตฌ๊ฐ„์„ ์‚ญ์ œํ•œ๋‹ค. + - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. (๋‘ ๊ฐœ ์ดํ•˜์ธ ๊ฒฝ์šฐ์—๋Š” ์‚ญ์ œ ๋ถˆ๊ฐ€) + - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ - ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์ถœ๋ ฅํ•œ๋‹ค.
- ## โœ… ๋น„๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ ### 2.1 ์†์„ฑ ํƒœ๊ทธ ์š”๊ตฌ์‚ฌํ•ญ ##### ๋ฉ”๋‰ด ๋ฒ„ํŠผ -- ์—ญ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#station-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ๋…ธ์„  ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#line-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#section-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#map-print-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์—ญ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#station-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ๋…ธ์„  ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#line-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#section-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ด€๋ฆฌ button ํƒœ๊ทธ๋Š” `#map-print-manager-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ์—ญ ๊ด€๋ จ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ์—ญ์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#station-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#station-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +- [x] ์ง€ํ•˜์ฒ  ์—ญ์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#station-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#station-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [ ] ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#line-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-start-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-end-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#line-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#line-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-start-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-end-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#line-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [ ] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์„ค์ •ํ•  ์—ญ select ํƒœ๊ทธ๋Š” `#section-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#section-order-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ๋“ฑ๋กํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#section-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. + +- [ ] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์„ค์ •ํ•  ์—ญ select ํƒœ๊ทธ๋Š” `#section-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#section-order-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ๋“ฑ๋กํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#section-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [ ] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ธฐ๋Šฅ -- ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. + +- [ ] ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ### 2.2 ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ @@ -125,23 +130,24 @@ - `template literal`์„ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ์™€ html string์„ ๊ฐ€๋…์„ฑ ์ข‹๊ฒŒ ํ‘œํ˜„ํ•œ๋‹ค. #### ์ถ”๊ฐ€๋œ ์š”๊ตฌ์‚ฌํ•ญ -- [data](https://developer.mozilla.org/ko/docs/Learn/HTML/Howto/%EB%8D%B0%EC%9D%B4%ED%84%B0_%EC%86%8D%EC%84%B1_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0)์†์„ฑ์„ ํ™œ์šฉํ•˜์—ฌ html ํƒœ๊ทธ์— ์—ญ, ๋…ธ์„ , ๊ตฌ๊ฐ„์˜ ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ๊ฐ’๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค. + +- [data](https://developer.mozilla.org/ko/docs/Learn/HTML/Howto/%EB%8D%B0%EC%9D%B4%ED%84%B0_%EC%86%8D%EC%84%B1_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0)์†์„ฑ์„ ํ™œ์šฉํ•˜์—ฌ html ํƒœ๊ทธ์— ์—ญ, ๋…ธ์„ , ๊ตฌ๊ฐ„์˜ ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ๊ฐ’๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค. - [localStorage](https://developer.mozilla.org/ko/docs/Web/API/Window/localStorage)๋ฅผ ์ด์šฉํ•˜์—ฌ, ์ƒˆ๋กœ๊ณ ์นจํ•˜๋”๋ผ๋„ ๊ฐ€์žฅ ์ตœ๊ทผ์— ์ž‘์—…ํ•œ ์ •๋ณด๋“ค์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. ## ๐Ÿ’ป ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ๊ฒฐ๊ณผ ### ์—ญ๊ด€๋ฆฌ -![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/station_manager.gif?lastModify=1607501706) + ### ๋…ธ์„ ๊ด€๋ฆฌ -![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/line_manager.gif?lastModify=1607501706) + ### ๊ตฌ๊ฐ„๊ด€๋ฆฌ -![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/section_manager.gif?lastModify=1607501706) + ### ๋…ธ์„ ๋„ ์ถœ๋ ฅ -![img](file:///Users/hanjunmo/Desktop/javascript-subway-map-precourse/images/map_print_manager.gif?lastModify=1607501706) \ No newline at end of file + From b5f5d6e5a8bd8c0dcfd738f2a0724a814cad0747 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 04:35:38 +0900 Subject: [PATCH 05/28] =?UTF-8?q?feat=20:=20=EC=97=AD=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20=EB=B2=84=ED=8A=BC=EC=9D=84=20=EB=88=8C=EB=9F=AC=20=EC=97=AD?= =?UTF-8?q?=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4=20-=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/station-manager.js | 33 ++++++++++++++++++++ src/index.js | 42 ++++++++++++------------- src/model/station.js | 5 +++ src/util/constant.js | 18 +++++++++-- src/util/validation.js | 33 ++++++++++++++++++++ src/view/element.js | 52 ++++++++++++++++++++----------- src/view/station-view.js | 3 ++ 7 files changed, 142 insertions(+), 44 deletions(-) create mode 100644 src/controller/station-manager.js create mode 100644 src/model/station.js create mode 100644 src/util/validation.js create mode 100644 src/view/station-view.js diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js new file mode 100644 index 000000000..b3dde6d6b --- /dev/null +++ b/src/controller/station-manager.js @@ -0,0 +1,33 @@ +import { Station } from "../model/station.js"; +import { Constant } from "../util/constant.js"; +import { StationValidation } from "../util/validation.js"; +import { Element, ElementControl } from "../view/element.js"; + +export const StationManager = { + isVisited: false, + + init() { + this.isVisited = true; + this.setEventListener(); + }, + + setEventListener() { + // ์ถ”๊ฐ€ + Element.stationAddButton.addEventListener(Constant.CLICK, () => { + this.onClickAddBtn(); + }); + + // ์‚ญ์ œ + }, + + onClickAddBtn() { + const name = Element.stationNameInput.value; + + if (StationValidation.isValidStation(name)) { + // Station.add() + } + ElementControl.clearInput(Element.stationNameInput); + }, + + onClickRemoveBtn() { }, +}; diff --git a/src/index.js b/src/index.js index 03d1249cd..c08c7ffd0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,28 +1,26 @@ -import { CONSTANT } from "./util/constant.js"; -import { element, elementControl } from "./view/element.js"; +import { Constant } from "./util/constant.js"; +import { Element, ElementControl } from "./view/element.js"; -export default class SubwayManager { - constructor() { - this.setEventListener(); - } +const App = () => { + SubwayManager(); +}; - setEventListener() { - element.stationManagerButton.addEventListener(CONSTANT.CLICK, () => { - elementControl.showStataionManger(); - }); +const SubwayManager = () => { + Element.stationManagerButton.addEventListener(Constant.CLICK, () => { + ElementControl.showStataionManger(); + }); - element.lineManagerButton.addEventListener(CONSTANT.CLICK, () => { - elementControl.showLineManager(); - }); + Element.lineManagerButton.addEventListener(Constant.CLICK, () => { + ElementControl.showLineManager(); + }); - element.sectionManagerButton.addEventListener(CONSTANT.CLICK, () => { - elementControl.showSectionManager(); - }); + Element.sectionManagerButton.addEventListener(Constant.CLICK, () => { + ElementControl.showSectionManager(); + }); - element.mapPrintManagerButton.addEventListener(CONSTANT.CLICK, () => { - elementControl.showMapPrintManager(); - }); - } -} + Element.mapPrintManagerButton.addEventListener(Constant.CLICK, () => { + ElementControl.showMapPrintManager(); + }); +}; -new SubwayManager(); +App(); diff --git a/src/model/station.js b/src/model/station.js new file mode 100644 index 000000000..ea887325e --- /dev/null +++ b/src/model/station.js @@ -0,0 +1,5 @@ +export const Station = { + stations: ["์–‘์žฌ", "์ž ์‹ค"], + + add(name) { }, +}; \ No newline at end of file diff --git a/src/util/constant.js b/src/util/constant.js index bba293049..fb06d541d 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -1,18 +1,30 @@ -export const CONSTANT = { - // querySelector +export const Constant = { + // ์ดˆ๊ธฐ ํ™”๋ฉด ๋ฒ„ํŠผ STATION_MANAGER_BTN_ID: "#station-manager-button", LINE_MANAGER_BTN_ID: "#line-manager-button", SECTION_MANAGER_BTN_ID: "#section-manager-button", MAP_PRINT_MANAGER_BTN_ID: "#map-print-manager-button", + // ๊ฐ ํ™”๋ฉด container STATION_CONTAINER_CLASS: ".station-container", LINE_CONTAINER_CLASS: ".line-container", SECTION_CONTAINER_CLASS: ".section-container", MAP_PRINT_CONTAINER_CLASS: ".map-print-container", + // ์—ญ ๊ด€๋ฆฌ + STATION_ADD_BUTTON_ID: "#station-add-button", + STATION_NAME_INPUT_ID: "#station-name-input", + + MINIMUM_NAME_LENGTH: 2, + REGEX_CATCHING_WHITESPACE: /^\s*$/, + // etc CLICK: "click", NONE: "none", BLOCK: "block", - ZERO_MARGIN: 0, +}; + +export const ErrorMessage = { + MINIMUM_NAME_LENGTH: "๊ณต๋ฐฑ์ด ์•„๋‹Œ 2๊ธ€์ž ์ด์ƒ์˜ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + DUPLICATED_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", }; diff --git a/src/util/validation.js b/src/util/validation.js new file mode 100644 index 000000000..e7671f03e --- /dev/null +++ b/src/util/validation.js @@ -0,0 +1,33 @@ +import { Station } from "../model/station.js"; +import { Constant, ErrorMessage } from "./constant.js"; + +export const StationValidation = { + isValidStation(name) { + return this.hasValidName(name); + }, + + hasValidName(name) { + if (!this.hasMinimumLength(name)) { + alert(ErrorMessage.MINIMUM_NAME_LENGTH); + return; + } + + if (!this.isNotDuplicated(name)) { + alert(ErrorMessage.DUPLICATED_NAME); + return; + } + + return true; + }, + + hasMinimumLength(name) { + return ( + name.length >= Constant.MINIMUM_NAME_LENGTH && + !Constant.REGEX_CATCHING_WHITESPACE.test(name) + ); + }, + + isNotDuplicated(name) { + return !Station.stations.includes(name); + }, +}; \ No newline at end of file diff --git a/src/view/element.js b/src/view/element.js index fcf3b7717..c473f1ab4 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -1,44 +1,58 @@ -import { CONSTANT } from "../util/constant.js"; +import { StationManager } from "../controller/station-manager.js"; +import { StationView } from "./station-view.js"; +import { Constant } from "../util/constant.js"; -export const element = { - stationManagerButton: document.querySelector(CONSTANT.STATION_MANAGER_BTN_ID), - lineManagerButton: document.querySelector(CONSTANT.LINE_MANAGER_BTN_ID), - sectionManagerButton: document.querySelector(CONSTANT.SECTION_MANAGER_BTN_ID), +export const Element = { + // ์ดˆ๊ธฐ ํ™”๋ฉด ๋ฒ„ํŠผ + stationManagerButton: document.querySelector(Constant.STATION_MANAGER_BTN_ID), + lineManagerButton: document.querySelector(Constant.LINE_MANAGER_BTN_ID), + sectionManagerButton: document.querySelector(Constant.SECTION_MANAGER_BTN_ID), mapPrintManagerButton: document.querySelector( - CONSTANT.MAP_PRINT_MANAGER_BTN_ID + Constant.MAP_PRINT_MANAGER_BTN_ID ), - stationContainer: document.querySelector(CONSTANT.STATION_CONTAINER_CLASS), - lineContainer: document.querySelector(CONSTANT.LINE_CONTAINER_CLASS), - sectionContainer: document.querySelector(CONSTANT.SECTION_CONTAINER_CLASS), - mapPrintContainer: document.querySelector(CONSTANT.MAP_PRINT_CONTAINER_CLASS), + // ๊ฐ ํ™”๋ฉด container + stationContainer: document.querySelector(Constant.STATION_CONTAINER_CLASS), + lineContainer: document.querySelector(Constant.LINE_CONTAINER_CLASS), + sectionContainer: document.querySelector(Constant.SECTION_CONTAINER_CLASS), + mapPrintContainer: document.querySelector(Constant.MAP_PRINT_CONTAINER_CLASS), + + // ์—ญ ๊ด€๋ฆฌ + stationAddButton: document.querySelector(Constant.STATION_ADD_BUTTON_ID), + stationNameInput: document.querySelector(Constant.STATION_NAME_INPUT_ID), }; -export const elementControl = { +export const ElementControl = { hideAllManagers() { - element.stationContainer.style.display = CONSTANT.NONE; - element.lineContainer.style.display = CONSTANT.NONE; - element.sectionContainer.style.display = CONSTANT.NONE; - element.mapPrintContainer.style.display = CONSTANT.NONE; + Element.stationContainer.style.display = Constant.NONE; + Element.lineContainer.style.display = Constant.NONE; + Element.sectionContainer.style.display = Constant.NONE; + Element.mapPrintContainer.style.display = Constant.NONE; }, showStataionManger() { this.hideAllManagers(); - element.stationContainer.style.display = CONSTANT.BLOCK; + Element.stationContainer.style.display = Constant.BLOCK; + + StationManager.isVisited ? StationView.render() : StationManager.init(); }, showLineManager() { this.hideAllManagers(); - element.lineContainer.style.display = CONSTANT.BLOCK; + Element.lineContainer.style.display = Constant.BLOCK; }, showSectionManager() { this.hideAllManagers(); - element.sectionContainer.style.display = CONSTANT.BLOCK; + Element.sectionContainer.style.display = Constant.BLOCK; }, showMapPrintManager() { this.hideAllManagers(); - element.mapPrintContainer.style.display = CONSTANT.BLOCK; + Element.mapPrintContainer.style.display = Constant.BLOCK; }, + + clearInput(element) { + element.value = ""; + } }; diff --git a/src/view/station-view.js b/src/view/station-view.js new file mode 100644 index 000000000..bd5adb767 --- /dev/null +++ b/src/view/station-view.js @@ -0,0 +1,3 @@ +export const StationView = { + render() {}, +}; From cd59ae490c7d03786600e88f066a1044f7f8e083 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 15:30:22 +0900 Subject: [PATCH 06/28] =?UTF-8?q?refactor=20:=20UI=20=EC=88=98=EC=A0=95(?= =?UTF-8?q?=EB=9D=84=EC=96=B4=EC=93=B0=EA=B8=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 57c126192..1e1cb24b6 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@

๐Ÿš‡ ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ

- + From 63f4749e3d5641fdcf0f79eddd8cc7679ac4e917 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 15:31:17 +0900 Subject: [PATCH 07/28] =?UTF-8?q?docs=20:=20=EC=97=AD=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9=EB=A1=9D=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20-=20localStorage,=20data=EC=86=8D=EC=84=B1=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/README.md b/docs/README.md index 2f307741f..3bf79656f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,12 +42,13 @@ ### 1.2 ๊ธฐ๋Šฅ ๋ชฉ๋ก -- `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ`, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ถœ๋ ฅ` ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. +- [x] `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ`, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ถœ๋ ฅ` ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. - ์—ญ ๊ด€๋ฆฌ - - `์—ญ ์ถ”๊ฐ€` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. - - ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด 2๊ธ€์ž ์ด์ƒ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - `localStorage` ๋ฐ `data`์†์„ฑ์„ ๋ฐ˜์˜ํ•œ๋‹ค. + - [x] `์—ญ ์ถ”๊ฐ€` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. + - [x] ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด 2๊ธ€์ž ์ด์ƒ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - `์‚ญ์ œ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์‚ญ์ œํ•œ๋‹ค. - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. @@ -93,7 +94,7 @@ - [x] ์ง€ํ•˜์ฒ  ์—ญ์„ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#station-name-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - [x] ์ง€ํ•˜์ฒ  ์—ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#station-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- [ ] ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ์—ญ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.station-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ จ ๊ธฐ๋Šฅ From 0a90232ddcd7da3d8bd866edd2fcc70c83831944 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 15:31:54 +0900 Subject: [PATCH 08/28] =?UTF-8?q?feat=20:=20=EC=97=AD=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20=EB=B2=84=ED=8A=BC=EC=9D=84=20=EB=88=8C=EB=9F=AC=20=EC=97=AD?= =?UTF-8?q?=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4=20-=20?= =?UTF-8?q?=EC=A7=80=ED=95=98=EC=B2=A0=20=EC=97=AD=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=97=90=20=EB=B0=98=EC=98=81=ED=95=9C=EB=8B=A4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/station-manager.js | 7 +++++-- src/model/station.js | 8 +++++--- src/util/constant.js | 3 +++ src/util/validation.js | 2 +- src/view/element.js | 17 ++++++++++++----- src/view/station-view.js | 19 ++++++++++++++++++- 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index b3dde6d6b..9a8e3b416 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -2,12 +2,14 @@ import { Station } from "../model/station.js"; import { Constant } from "../util/constant.js"; import { StationValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; +import { StationView } from "../view/station-view.js"; export const StationManager = { isVisited: false, init() { this.isVisited = true; + StationView.render(); this.setEventListener(); }, @@ -24,10 +26,11 @@ export const StationManager = { const name = Element.stationNameInput.value; if (StationValidation.isValidStation(name)) { - // Station.add() + Station.add(name); + StationView.render(); } ElementControl.clearInput(Element.stationNameInput); }, - onClickRemoveBtn() { }, + onClickRemoveBtn() {}, }; diff --git a/src/model/station.js b/src/model/station.js index ea887325e..cfe18ce57 100644 --- a/src/model/station.js +++ b/src/model/station.js @@ -1,5 +1,7 @@ export const Station = { - stations: ["์–‘์žฌ", "์ž ์‹ค"], + stations: ["์–‘์žฌ", "๋งค๋ด‰", "๋„๊ณก"], - add(name) { }, -}; \ No newline at end of file + add(name) { + this.stations.push(name); + }, +}; diff --git a/src/util/constant.js b/src/util/constant.js index fb06d541d..e275a4214 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -22,6 +22,9 @@ export const Constant = { CLICK: "click", NONE: "none", BLOCK: "block", + + // tag + TBODY: "tbody", }; export const ErrorMessage = { diff --git a/src/util/validation.js b/src/util/validation.js index e7671f03e..8b0ca0a1e 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -30,4 +30,4 @@ export const StationValidation = { isNotDuplicated(name) { return !Station.stations.includes(name); }, -}; \ No newline at end of file +}; diff --git a/src/view/element.js b/src/view/element.js index c473f1ab4..d3161b2ac 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -11,15 +11,22 @@ export const Element = { Constant.MAP_PRINT_MANAGER_BTN_ID ), - // ๊ฐ ํ™”๋ฉด container + // ์—ญ ๊ด€๋ฆฌ stationContainer: document.querySelector(Constant.STATION_CONTAINER_CLASS), + stationAddButton: document.querySelector(Constant.STATION_ADD_BUTTON_ID), + stationNameInput: document.querySelector(Constant.STATION_NAME_INPUT_ID), + + // ๋…ธ์„  ๊ด€๋ฆฌ lineContainer: document.querySelector(Constant.LINE_CONTAINER_CLASS), + + // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ sectionContainer: document.querySelector(Constant.SECTION_CONTAINER_CLASS), + + // ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ mapPrintContainer: document.querySelector(Constant.MAP_PRINT_CONTAINER_CLASS), - // ์—ญ ๊ด€๋ฆฌ - stationAddButton: document.querySelector(Constant.STATION_ADD_BUTTON_ID), - stationNameInput: document.querySelector(Constant.STATION_NAME_INPUT_ID), + // html tag ๊ด€๋ จ + querySelectorTbody: document.querySelector(Constant.TBODY), }; export const ElementControl = { @@ -54,5 +61,5 @@ export const ElementControl = { clearInput(element) { element.value = ""; - } + }, }; diff --git a/src/view/station-view.js b/src/view/station-view.js index bd5adb767..80e148e6a 100644 --- a/src/view/station-view.js +++ b/src/view/station-view.js @@ -1,3 +1,20 @@ +import { Station } from "../model/station.js"; +import { Element } from "./element.js"; + export const StationView = { - render() {}, + render() { + let content = ""; + + Station.stations.forEach((station) => { + content += ` + + ${station} + + + + + `; + }); + Element.querySelectorTbody.innerHTML = content; + }, }; From c143f32d841d1bc93b93d302e50f77fc7d35f2c2 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 16:08:10 +0900 Subject: [PATCH 09/28] =?UTF-8?q?feat=20:=20localStorage=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/station-manager.js | 2 ++ src/model/station.js | 7 ++++++- src/util/constant.js | 1 + src/util/storage.js | 9 +++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/util/storage.js diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index 9a8e3b416..457b75877 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -1,5 +1,6 @@ import { Station } from "../model/station.js"; import { Constant } from "../util/constant.js"; +import { Storage } from "../util/storage.js"; import { StationValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; import { StationView } from "../view/station-view.js"; @@ -9,6 +10,7 @@ export const StationManager = { init() { this.isVisited = true; + Station.stations = Storage.load(Station.key); StationView.render(); this.setEventListener(); }, diff --git a/src/model/station.js b/src/model/station.js index cfe18ce57..92dbe1e45 100644 --- a/src/model/station.js +++ b/src/model/station.js @@ -1,7 +1,12 @@ +import { Constant } from "../util/constant.js"; +import { Storage } from "../util/storage.js"; + export const Station = { - stations: ["์–‘์žฌ", "๋งค๋ด‰", "๋„๊ณก"], + key: Constant.STORAGE_KEY_STATION, + stations: [], add(name) { this.stations.push(name); + Storage.save(this.key, this.stations); }, }; diff --git a/src/util/constant.js b/src/util/constant.js index e275a4214..3ae1885dc 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -12,6 +12,7 @@ export const Constant = { MAP_PRINT_CONTAINER_CLASS: ".map-print-container", // ์—ญ ๊ด€๋ฆฌ + STORAGE_KEY_STATION: "stations", STATION_ADD_BUTTON_ID: "#station-add-button", STATION_NAME_INPUT_ID: "#station-name-input", diff --git a/src/util/storage.js b/src/util/storage.js new file mode 100644 index 000000000..3df31279b --- /dev/null +++ b/src/util/storage.js @@ -0,0 +1,9 @@ +export const Storage = { + save(key, array) { + localStorage.setItem(key, JSON.stringify(array)); + }, + + load(key) { + return JSON.parse(localStorage.getItem(key)); + }, +}; From 4d9d82dd297c086daf71b3dc062ee5ac574def5a Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 17:22:24 +0900 Subject: [PATCH 10/28] =?UTF-8?q?feat=20:=20=EC=97=AD=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20-=20=EC=82=AD=EC=A0=9C=20=EB=B2=84=ED=8A=BC=EC=9D=84=20?= =?UTF-8?q?=EB=88=8C=EB=9F=AC=20=EC=97=AD=EC=9D=84=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=9C=EB=8B=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/station-manager.js | 19 +++++++++++++++++-- src/model/station.js | 5 +++++ src/util/constant.js | 5 +++++ src/view/element.js | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index 457b75877..a4b762d57 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -1,5 +1,5 @@ import { Station } from "../model/station.js"; -import { Constant } from "../util/constant.js"; +import { ConfirmMessage, Constant } from "../util/constant.js"; import { Storage } from "../util/storage.js"; import { StationValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; @@ -22,6 +22,14 @@ export const StationManager = { }); // ์‚ญ์ œ + // Element.stationDeleteButton + // document.querySelector(Constant.STATION_DELELE_BUTTON_CLASS).addEventListener(Constant.CLICK, (e) => { + // this.onClickDeleteBtn(e); + // }); + Element.querySelectorTbody.addEventListener(Constant.CLICK, (e) => { + this.onClickDeleteBtn(e); + }) + }, onClickAddBtn() { @@ -34,5 +42,12 @@ export const StationManager = { ElementControl.clearInput(Element.stationNameInput); }, - onClickRemoveBtn() {}, + onClickDeleteBtn(e) { + const name = e.target.dataset.name; + + if (confirm(ConfirmMessage.CHECK_DELETION)) { + Station.delete(name); + StationView.render(); + } + }, }; diff --git a/src/model/station.js b/src/model/station.js index 92dbe1e45..793eaa683 100644 --- a/src/model/station.js +++ b/src/model/station.js @@ -9,4 +9,9 @@ export const Station = { this.stations.push(name); Storage.save(this.key, this.stations); }, + + delete(name) { + this.stations = this.stations.filter(e => e !== name); + Storage.save(this.key, this.stations); + } }; diff --git a/src/util/constant.js b/src/util/constant.js index 3ae1885dc..9c3a55e6a 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -15,6 +15,7 @@ export const Constant = { STORAGE_KEY_STATION: "stations", STATION_ADD_BUTTON_ID: "#station-add-button", STATION_NAME_INPUT_ID: "#station-name-input", + STATION_DELELE_BUTTON_CLASS: ".station-delete-button", MINIMUM_NAME_LENGTH: 2, REGEX_CATCHING_WHITESPACE: /^\s*$/, @@ -32,3 +33,7 @@ export const ErrorMessage = { MINIMUM_NAME_LENGTH: "๊ณต๋ฐฑ์ด ์•„๋‹Œ 2๊ธ€์ž ์ด์ƒ์˜ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", DUPLICATED_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", }; + +export const ConfirmMessage = { + CHECK_DELETION: "์ •๋ง๋กœ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", +} diff --git a/src/view/element.js b/src/view/element.js index d3161b2ac..9e3bcf94d 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -15,6 +15,7 @@ export const Element = { stationContainer: document.querySelector(Constant.STATION_CONTAINER_CLASS), stationAddButton: document.querySelector(Constant.STATION_ADD_BUTTON_ID), stationNameInput: document.querySelector(Constant.STATION_NAME_INPUT_ID), + stationDeleteButton: document.querySelector(Constant.STATION_DELELE_BUTTON_CLASS), // ๋…ธ์„  ๊ด€๋ฆฌ lineContainer: document.querySelector(Constant.LINE_CONTAINER_CLASS), From 67091919803b308d527ec45ba91b38e0c36924a0 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 20:07:06 +0900 Subject: [PATCH 11/28] =?UTF-8?q?docs=20:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=ED=95=9C=20=EA=B8=B0=EB=8A=A5=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/README.md b/docs/README.md index 3bf79656f..3bf654a1e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -44,38 +44,40 @@ - [x] `1. ์—ญ ๊ด€๋ฆฌ`, `2. ๋…ธ์„  ๊ด€๋ฆฌ`, `3. ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ`, `4. ์ง€ํ•˜์ฒ  ๋…ธ์„  ์ถœ๋ ฅ` ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. - ์—ญ ๊ด€๋ฆฌ - - `localStorage` ๋ฐ `data`์†์„ฑ์„ ๋ฐ˜์˜ํ•œ๋‹ค. - - [x] `์—ญ ์ถ”๊ฐ€` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. + - [x] `localStorage` ๋ฐ `data`์†์„ฑ์„ ๋ฐ˜์˜ํ•œ๋‹ค. + - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - `์—ญ ์ถ”๊ฐ€` - [x] ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด 2๊ธ€์ž ์ด์ƒ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - [x] ์ž…๋ ฅํ•œ ์—ญ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - - `์‚ญ์ œ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์—ญ์„ ์‚ญ์ œํ•œ๋‹ค. - - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - - ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - `์‚ญ์ œ` + - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - ๋…ธ์„  ๊ด€๋ฆฌ - - `๋…ธ์„  ์ถ”๊ฐ€` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. - - ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์—ญ ๋ชฉ๋ก์—์„œ ๊ฐ€์ ธ์˜จ๋‹ค. + - ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - `๋…ธ์„  ์ถ”๊ฐ€` + - [x] ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. (๊ณ ๋ฏผ) - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - - `์‚ญ์ œ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋…ธ์„ ์„ ์‚ญ์ œํ•œ๋‹ค. + - `์‚ญ์ œ` - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ - - ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ๋ฒ„ํŠผ์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. - - ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ๊ด€๋ จ ํ™”๋ฉด์„ ์ถœ๋ ฅํ•œ๋‹ค. + - ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. (๋ฒ„ํŠผ์œผ๋กœ ์ถœ๋ ฅ) + - ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ํ•ด๋‹น ๋…ธ์„ ์˜ ๊ตฌ๊ฐ„ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - ์ œ๋ชฉ์€ `(์„ ํƒ๋œ ๋…ธ์„ ) ๊ด€๋ฆฌ`๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. - - `๋“ฑ๋ก` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๊ตฌ๊ฐ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค. + - `๋“ฑ๋ก` - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด(๊ตฌ๊ฐ„)์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - - `๋…ธ์„ ์—์„œ ์ œ๊ฑฐ` ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๊ตฌ๊ฐ„์„ ์‚ญ์ œํ•œ๋‹ค. + - `๋…ธ์„ ์—์„œ ์ œ๊ฑฐ` - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. (๋‘ ๊ฐœ ์ดํ•˜์ธ ๊ฒฝ์šฐ์—๋Š” ์‚ญ์ œ ๋ถˆ๊ฐ€) - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ - - ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์ถœ๋ ฅํ•œ๋‹ค. + - ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์กฐํšŒํ•œ๋‹ค.
From 01e32878b739f4b0bc742f8d067beab9ca8502aa Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 20:07:59 +0900 Subject: [PATCH 12/28] =?UTF-8?q?feat=20:=20=EB=85=B8=EC=84=A0=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EC=83=81=ED=96=89=20=EC=A2=85=EC=A0=90?= =?UTF-8?q?=EA=B3=BC=20=ED=95=98=ED=96=89=20=EC=A2=85=EC=A0=90=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=9D=84=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/line-manager.js | 13 +++++++++++++ src/controller/station-manager.js | 3 +-- src/model/station.js | 4 ++-- src/util/constant.js | 21 ++++++++++++++------- src/view/element.js | 10 +++++++++- src/view/line-view.js | 26 ++++++++++++++++++++++++++ src/view/station-view.js | 13 +++++++------ 7 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 src/controller/line-manager.js create mode 100644 src/view/line-view.js diff --git a/src/controller/line-manager.js b/src/controller/line-manager.js new file mode 100644 index 000000000..db83a4f19 --- /dev/null +++ b/src/controller/line-manager.js @@ -0,0 +1,13 @@ +import { Station } from "../model/station.js"; +import { Storage } from "../util/storage.js"; +import { LineView } from "../view/line-view.js"; + +export const LineManager = { + isVisited: false, + + init() { + this.isVisited = true; + Station.stations = Storage.load(Station.key); + LineView.render(); + }, +}; diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index a4b762d57..e182c96e0 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -28,8 +28,7 @@ export const StationManager = { // }); Element.querySelectorTbody.addEventListener(Constant.CLICK, (e) => { this.onClickDeleteBtn(e); - }) - + }); }, onClickAddBtn() { diff --git a/src/model/station.js b/src/model/station.js index 793eaa683..9b4cc279b 100644 --- a/src/model/station.js +++ b/src/model/station.js @@ -11,7 +11,7 @@ export const Station = { }, delete(name) { - this.stations = this.stations.filter(e => e !== name); + this.stations = this.stations.filter((e) => e !== name); Storage.save(this.key, this.stations); - } + }, }; diff --git a/src/util/constant.js b/src/util/constant.js index 9c3a55e6a..c7afd10e6 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -5,18 +5,25 @@ export const Constant = { SECTION_MANAGER_BTN_ID: "#section-manager-button", MAP_PRINT_MANAGER_BTN_ID: "#map-print-manager-button", - // ๊ฐ ํ™”๋ฉด container - STATION_CONTAINER_CLASS: ".station-container", - LINE_CONTAINER_CLASS: ".line-container", - SECTION_CONTAINER_CLASS: ".section-container", - MAP_PRINT_CONTAINER_CLASS: ".map-print-container", - // ์—ญ ๊ด€๋ฆฌ + STATION_CONTAINER_CLASS: ".station-container", STORAGE_KEY_STATION: "stations", STATION_ADD_BUTTON_ID: "#station-add-button", STATION_NAME_INPUT_ID: "#station-name-input", STATION_DELELE_BUTTON_CLASS: ".station-delete-button", + // ๋…ธ์„  ๊ด€๋ฆฌ + LINE_CONTAINER_CLASS: ".line-container", + LINE_START_STATION_SELECTOR_ID: "#line-start-station-selector", + LINE_END_STATION_SELECTOR_ID: "#line-end-station-selector", + + // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ + SECTION_CONTAINER_CLASS: ".section-container", + + // ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ฆฌ + MAP_PRINT_CONTAINER_CLASS: ".map-print-container", + + // MINIMUM_NAME_LENGTH: 2, REGEX_CATCHING_WHITESPACE: /^\s*$/, @@ -36,4 +43,4 @@ export const ErrorMessage = { export const ConfirmMessage = { CHECK_DELETION: "์ •๋ง๋กœ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", -} +}; diff --git a/src/view/element.js b/src/view/element.js index 9e3bcf94d..6ccb46874 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -1,6 +1,8 @@ import { StationManager } from "../controller/station-manager.js"; import { StationView } from "./station-view.js"; import { Constant } from "../util/constant.js"; +import { LineManager } from "../controller/line-manager.js"; +import { LineView } from "./line-view.js"; export const Element = { // ์ดˆ๊ธฐ ํ™”๋ฉด ๋ฒ„ํŠผ @@ -15,10 +17,14 @@ export const Element = { stationContainer: document.querySelector(Constant.STATION_CONTAINER_CLASS), stationAddButton: document.querySelector(Constant.STATION_ADD_BUTTON_ID), stationNameInput: document.querySelector(Constant.STATION_NAME_INPUT_ID), - stationDeleteButton: document.querySelector(Constant.STATION_DELELE_BUTTON_CLASS), + stationDeleteButton: document.querySelector( + Constant.STATION_DELELE_BUTTON_CLASS + ), // ๋…ธ์„  ๊ด€๋ฆฌ lineContainer: document.querySelector(Constant.LINE_CONTAINER_CLASS), + lineStartStationSelector: document.querySelector(Constant.LINE_START_STATION_SELECTOR_ID), + lineEndStationSelector: document.querySelector(Constant.LINE_END_STATION_SELECTOR_ID), // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ sectionContainer: document.querySelector(Constant.SECTION_CONTAINER_CLASS), @@ -48,6 +54,8 @@ export const ElementControl = { showLineManager() { this.hideAllManagers(); Element.lineContainer.style.display = Constant.BLOCK; + + LineManager.isVisited ? LineView.render() : LineManager.init(); }, showSectionManager() { diff --git a/src/view/line-view.js b/src/view/line-view.js new file mode 100644 index 000000000..90c8f49bf --- /dev/null +++ b/src/view/line-view.js @@ -0,0 +1,26 @@ +import { Station } from "../model/station.js"; +import { Element } from "./element.js"; + +export const LineView = { + render() { + this.renderSelector(); + this.renderTable(); + }, + + renderSelector() { + let content = ""; + + Station.stations.forEach((station) => { + content += ` + + `; + }); + + Element.lineStartStationSelector.innerHTML = content; + Element.lineEndStationSelector.innerHTML = content; + }, + + renderTable() { + + } +} \ No newline at end of file diff --git a/src/view/station-view.js b/src/view/station-view.js index 80e148e6a..87f2d5088 100644 --- a/src/view/station-view.js +++ b/src/view/station-view.js @@ -7,14 +7,15 @@ export const StationView = { Station.stations.forEach((station) => { content += ` - - ${station} - - - - + + ${station} + + + + `; }); + Element.querySelectorTbody.innerHTML = content; }, }; From 2cca0ad5a4c2cf4393d00442d1504e9caebdae25 Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 22:35:33 +0900 Subject: [PATCH 13/28] =?UTF-8?q?docs=20:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=B6=94=EA=B0=80=20=EB=85=B8=EC=84=A0=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EB=85=B8=EC=84=A0=EC=9D=98=20=EC=83=81?= =?UTF-8?q?=ED=96=89=20=EC=A2=85=EC=A0=90=EA=B3=BC=20=ED=95=98=ED=96=89=20?= =?UTF-8?q?=EB=8F=99=EC=A0=90=EC=9D=98=20=EC=A4=91=EB=B3=B5=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 3bf654a1e..56a05d7a7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,8 +57,9 @@ - ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - `๋…ธ์„  ์ถ”๊ฐ€` - [x] ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - - ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. (๊ณ ๋ฏผ) + - [x] ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ๋™์ผํ•œ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - `์‚ญ์ œ` - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. From 825f9f8d493297ba4092c9f7ac1e132c18ca317d Mon Sep 17 00:00:00 2001 From: jum0 Date: Mon, 14 Dec 2020 22:36:21 +0900 Subject: [PATCH 14/28] =?UTF-8?q?feat=20:=20=EC=9E=85=EB=A0=A5=ED=95=9C=20?= =?UTF-8?q?=EB=85=B8=EC=84=A0=20=EC=9D=B4=EB=A6=84=EC=9D=98=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=97=AC=EB=B6=80,=20=EB=85=B8=EC=84=A0=EC=9D=98?= =?UTF-8?q?=20=EC=83=81=ED=96=89=20=EC=A2=85=EC=A0=90=EA=B3=BC=20=ED=95=98?= =?UTF-8?q?=ED=96=89=20=EC=A2=85=EC=A0=90=EC=9D=98=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/line-manager.js | 39 +++++++++++++++++++++++++++++++ src/controller/station-manager.js | 8 +++---- src/model/line.js | 7 ++++++ src/util/constant.js | 14 +++++++++-- src/util/validation.js | 38 ++++++++++++++++++++++++++++++ src/view/element.js | 10 ++++++-- src/view/line-view.js | 6 ++--- 7 files changed, 110 insertions(+), 12 deletions(-) create mode 100644 src/model/line.js diff --git a/src/controller/line-manager.js b/src/controller/line-manager.js index db83a4f19..1e6511c44 100644 --- a/src/controller/line-manager.js +++ b/src/controller/line-manager.js @@ -1,5 +1,8 @@ import { Station } from "../model/station.js"; +import { Constant } from "../util/constant.js"; import { Storage } from "../util/storage.js"; +import { LineValidation } from "../util/validation.js"; +import { Element, ElementControl } from "../view/element.js"; import { LineView } from "../view/line-view.js"; export const LineManager = { @@ -9,5 +12,41 @@ export const LineManager = { this.isVisited = true; Station.stations = Storage.load(Station.key); LineView.render(); + this.setEventListener(); }, + + setEventListener() { + // ์ถ”๊ฐ€ + Element.lineAddButton.addEventListener(Constant.CLICK, () => { + this.onClickAddButton(); + }); + + // ์‚ญ์ œ + }, + + onClickAddButton() { + // const name = Element.stationNameInput.value; + + // if (StationValidation.isValidStation(name)) { + // Station.add(name); + // StationView.render(); + // } + // ElementControl.clearInput(Element.stationNameInput); + const name = Element.lineNameInput.value; + const start = Element.lineStartStationSelector.value; + const end = Element.lineEndStationSelector.value; + + console.log(name); + console.log(start); + console.log(end); + + if (LineValidation.isValidLine(name, start, end)) { + console.log("if"); + } else { + console.log("else"); + } + ElementControl.clearInput(Element.lineNameInput); + }, + + onClickDeleteButton() {}, }; diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index e182c96e0..fb05ea52c 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -18,7 +18,7 @@ export const StationManager = { setEventListener() { // ์ถ”๊ฐ€ Element.stationAddButton.addEventListener(Constant.CLICK, () => { - this.onClickAddBtn(); + this.onClickAddButton(); }); // ์‚ญ์ œ @@ -27,11 +27,11 @@ export const StationManager = { // this.onClickDeleteBtn(e); // }); Element.querySelectorTbody.addEventListener(Constant.CLICK, (e) => { - this.onClickDeleteBtn(e); + this.onClickDeleteButton(e); }); }, - onClickAddBtn() { + onClickAddButton() { const name = Element.stationNameInput.value; if (StationValidation.isValidStation(name)) { @@ -41,7 +41,7 @@ export const StationManager = { ElementControl.clearInput(Element.stationNameInput); }, - onClickDeleteBtn(e) { + onClickDeleteButton(e) { const name = e.target.dataset.name; if (confirm(ConfirmMessage.CHECK_DELETION)) { diff --git a/src/model/line.js b/src/model/line.js new file mode 100644 index 000000000..e5909ba23 --- /dev/null +++ b/src/model/line.js @@ -0,0 +1,7 @@ +import { Constant } from "../util/constant.js"; + +export const Line = { + key: Constant.STORAGE_KEY_LINE, + names: ["3ํ˜ธ์„ "], + stations: [], +}; diff --git a/src/util/constant.js b/src/util/constant.js index c7afd10e6..01adaaea6 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -14,8 +14,11 @@ export const Constant = { // ๋…ธ์„  ๊ด€๋ฆฌ LINE_CONTAINER_CLASS: ".line-container", + STORAGE_KEY_LINE: "lines", LINE_START_STATION_SELECTOR_ID: "#line-start-station-selector", LINE_END_STATION_SELECTOR_ID: "#line-end-station-selector", + LINE_ADD_BUTTON_ID: "#line-add-button", + LINE_NAME_INPUT_ID: "#line-name-input", // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ SECTION_CONTAINER_CLASS: ".section-container", @@ -23,7 +26,7 @@ export const Constant = { // ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ฆฌ MAP_PRINT_CONTAINER_CLASS: ".map-print-container", - // + // MINIMUM_NAME_LENGTH: 2, REGEX_CATCHING_WHITESPACE: /^\s*$/, @@ -37,8 +40,15 @@ export const Constant = { }; export const ErrorMessage = { - MINIMUM_NAME_LENGTH: "๊ณต๋ฐฑ์ด ์•„๋‹Œ 2๊ธ€์ž ์ด์ƒ์˜ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + // ๊ณตํ†ต DUPLICATED_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + + // ์—ญ ๊ด€๋ฆฌ + MINIMUM_NAME_LENGTH: "๊ณต๋ฐฑ์ด ์•„๋‹Œ 2๊ธ€์ž ์ด์ƒ์˜ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + + // ๋…ธ์„  ๊ด€๋ฆฌ + NAME_WHITE_SPACE: "๊ณต๋ฐฑ์ด ์•„๋‹Œ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + SAME_START_END_STATION: "์„œ๋กœ ๋‹ค๋ฅธ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.", }; export const ConfirmMessage = { diff --git a/src/util/validation.js b/src/util/validation.js index 8b0ca0a1e..87ec0e2c9 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -1,3 +1,4 @@ +import { Line } from "../model/line.js"; import { Station } from "../model/station.js"; import { Constant, ErrorMessage } from "./constant.js"; @@ -31,3 +32,40 @@ export const StationValidation = { return !Station.stations.includes(name); }, }; + +export const LineValidation = { + isValidLine(name, start, end) { + return this.hasValidName(name) && this.hasValidStartEndStation(start, end); + }, + + hasValidName(name) { + if (!this.isNotWhiteSpace(name)) { + alert(ErrorMessage.NAME_WHITE_SPACE); + return; + } + + if (!this.isNotDuplicated(name)) { + alert(ErrorMessage.DUPLICATED_NAME); + return; + } + + return true; + }, + + hasValidStartEndStation(start, end) { + if (start === end) { + alert(ErrorMessage.SAME_START_END_STATION); + return; + } + + return true; + }, + + isNotWhiteSpace(name) { + return !Constant.REGEX_CATCHING_WHITESPACE.test(name); + }, + + isNotDuplicated(name) { + return !Line.names.includes(name); + }, +}; diff --git a/src/view/element.js b/src/view/element.js index 6ccb46874..7f092cb6b 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -23,8 +23,14 @@ export const Element = { // ๋…ธ์„  ๊ด€๋ฆฌ lineContainer: document.querySelector(Constant.LINE_CONTAINER_CLASS), - lineStartStationSelector: document.querySelector(Constant.LINE_START_STATION_SELECTOR_ID), - lineEndStationSelector: document.querySelector(Constant.LINE_END_STATION_SELECTOR_ID), + lineStartStationSelector: document.querySelector( + Constant.LINE_START_STATION_SELECTOR_ID + ), + lineEndStationSelector: document.querySelector( + Constant.LINE_END_STATION_SELECTOR_ID + ), + lineAddButton: document.querySelector(Constant.LINE_ADD_BUTTON_ID), + lineNameInput: document.querySelector(Constant.LINE_NAME_INPUT_ID), // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ sectionContainer: document.querySelector(Constant.SECTION_CONTAINER_CLASS), diff --git a/src/view/line-view.js b/src/view/line-view.js index 90c8f49bf..8e2fddca8 100644 --- a/src/view/line-view.js +++ b/src/view/line-view.js @@ -20,7 +20,5 @@ export const LineView = { Element.lineEndStationSelector.innerHTML = content; }, - renderTable() { - - } -} \ No newline at end of file + renderTable() {}, +}; From 018ed69c13777baf7b6e68e0f344233c7e2bce0c Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 01:23:06 +0900 Subject: [PATCH 15/28] =?UTF-8?q?feat=20:=20=EB=85=B8=EC=84=A0=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EB=85=B8=EC=84=A0=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EC=A1=B0=ED=9A=8C=ED=95=98=EA=B3=A0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/line-manager.js | 18 ++++-------------- src/model/line.js | 18 ++++++++++++++++-- src/util/validation.js | 9 ++++++++- src/view/element.js | 3 --- src/view/line-view.js | 21 ++++++++++++++++++++- src/view/station-view.js | 3 ++- 6 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/controller/line-manager.js b/src/controller/line-manager.js index 1e6511c44..65adfc44d 100644 --- a/src/controller/line-manager.js +++ b/src/controller/line-manager.js @@ -1,3 +1,4 @@ +import { Line, LineObject } from "../model/line.js"; import { Station } from "../model/station.js"; import { Constant } from "../util/constant.js"; import { Storage } from "../util/storage.js"; @@ -11,6 +12,7 @@ export const LineManager = { init() { this.isVisited = true; Station.stations = Storage.load(Station.key); + Line.lines = Storage.load(Line.key); LineView.render(); this.setEventListener(); }, @@ -25,25 +27,13 @@ export const LineManager = { }, onClickAddButton() { - // const name = Element.stationNameInput.value; - - // if (StationValidation.isValidStation(name)) { - // Station.add(name); - // StationView.render(); - // } - // ElementControl.clearInput(Element.stationNameInput); const name = Element.lineNameInput.value; const start = Element.lineStartStationSelector.value; const end = Element.lineEndStationSelector.value; - console.log(name); - console.log(start); - console.log(end); - if (LineValidation.isValidLine(name, start, end)) { - console.log("if"); - } else { - console.log("else"); + Line.add(new LineObject(name, start, end)); + LineView.render(); } ElementControl.clearInput(Element.lineNameInput); }, diff --git a/src/model/line.js b/src/model/line.js index e5909ba23..d21b536a2 100644 --- a/src/model/line.js +++ b/src/model/line.js @@ -1,7 +1,21 @@ import { Constant } from "../util/constant.js"; +import { Storage } from "../util/storage.js"; + +export class LineObject { + constructor(name, start, end) { + this.name = name; + this.stations = [start, end]; + } +} export const Line = { key: Constant.STORAGE_KEY_LINE, - names: ["3ํ˜ธ์„ "], - stations: [], + lines: [], + + add(lineObject) { + this.lines.push(lineObject); + Storage.save(this.key, this.lines); + }, + + delete() {}, }; diff --git a/src/util/validation.js b/src/util/validation.js index 87ec0e2c9..a27ecdcec 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -10,11 +10,13 @@ export const StationValidation = { hasValidName(name) { if (!this.hasMinimumLength(name)) { alert(ErrorMessage.MINIMUM_NAME_LENGTH); + return; } if (!this.isNotDuplicated(name)) { alert(ErrorMessage.DUPLICATED_NAME); + return; } @@ -41,11 +43,13 @@ export const LineValidation = { hasValidName(name) { if (!this.isNotWhiteSpace(name)) { alert(ErrorMessage.NAME_WHITE_SPACE); + return; } if (!this.isNotDuplicated(name)) { alert(ErrorMessage.DUPLICATED_NAME); + return; } @@ -55,6 +59,7 @@ export const LineValidation = { hasValidStartEndStation(start, end) { if (start === end) { alert(ErrorMessage.SAME_START_END_STATION); + return; } @@ -66,6 +71,8 @@ export const LineValidation = { }, isNotDuplicated(name) { - return !Line.names.includes(name); + const stationNameArray = Line.lines.map(({ name }) => name); + + return !stationNameArray.includes(name); }, }; diff --git a/src/view/element.js b/src/view/element.js index 7f092cb6b..93a005113 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -37,9 +37,6 @@ export const Element = { // ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ mapPrintContainer: document.querySelector(Constant.MAP_PRINT_CONTAINER_CLASS), - - // html tag ๊ด€๋ จ - querySelectorTbody: document.querySelector(Constant.TBODY), }; export const ElementControl = { diff --git a/src/view/line-view.js b/src/view/line-view.js index 8e2fddca8..74b0e46e8 100644 --- a/src/view/line-view.js +++ b/src/view/line-view.js @@ -1,4 +1,6 @@ +import { Line } from "../model/line.js"; import { Station } from "../model/station.js"; +import { Constant } from "../util/constant.js"; import { Element } from "./element.js"; export const LineView = { @@ -20,5 +22,22 @@ export const LineView = { Element.lineEndStationSelector.innerHTML = content; }, - renderTable() {}, + renderTable() { + let content = ""; + + Line.lines.forEach(({ name, stations }) => { + content += ` + + ${name} + ${stations[0]} + ${stations[stations.length - 1]} + + + + + `; + }); + + Element.lineContainer.querySelector(Constant.TBODY).innerHTML = content; + }, }; diff --git a/src/view/station-view.js b/src/view/station-view.js index 87f2d5088..0a97d72e1 100644 --- a/src/view/station-view.js +++ b/src/view/station-view.js @@ -1,4 +1,5 @@ import { Station } from "../model/station.js"; +import { Constant } from "../util/constant.js"; import { Element } from "./element.js"; export const StationView = { @@ -16,6 +17,6 @@ export const StationView = { `; }); - Element.querySelectorTbody.innerHTML = content; + Element.stationContainer.querySelector(Constant.TBODY).innerHTML = content; }, }; From c668ec5ddcd86dfd5718f5b545a9e2c5ca4cd092 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 02:19:59 +0900 Subject: [PATCH 16/28] =?UTF-8?q?feat=20:=20=EB=85=B8=EC=84=A0=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/line-manager.js | 18 ++++++++++++++---- src/controller/station-manager.js | 8 +++++--- src/model/line.js | 5 ++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/controller/line-manager.js b/src/controller/line-manager.js index 65adfc44d..c09142545 100644 --- a/src/controller/line-manager.js +++ b/src/controller/line-manager.js @@ -1,6 +1,6 @@ import { Line, LineObject } from "../model/line.js"; import { Station } from "../model/station.js"; -import { Constant } from "../util/constant.js"; +import { ConfirmMessage, Constant } from "../util/constant.js"; import { Storage } from "../util/storage.js"; import { LineValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; @@ -18,12 +18,15 @@ export const LineManager = { }, setEventListener() { - // ์ถ”๊ฐ€ Element.lineAddButton.addEventListener(Constant.CLICK, () => { this.onClickAddButton(); }); - // ์‚ญ์ œ + Element.lineContainer + .querySelector(Constant.TBODY) + .addEventListener(Constant.CLICK, (e) => { + this.onClickDeleteButton(e); + }); }, onClickAddButton() { @@ -38,5 +41,12 @@ export const LineManager = { ElementControl.clearInput(Element.lineNameInput); }, - onClickDeleteButton() {}, + onClickDeleteButton(e) { + const name = e.target.dataset.name; + + if (confirm(ConfirmMessage.CHECK_DELETION)) { + Line.delete(name); + LineView.render(); + } + }, }; diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index fb05ea52c..0a47e0830 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -26,9 +26,11 @@ export const StationManager = { // document.querySelector(Constant.STATION_DELELE_BUTTON_CLASS).addEventListener(Constant.CLICK, (e) => { // this.onClickDeleteBtn(e); // }); - Element.querySelectorTbody.addEventListener(Constant.CLICK, (e) => { - this.onClickDeleteButton(e); - }); + Element.stationContainer + .querySelector(Constant.TBODY) + .addEventListener(Constant.CLICK, (e) => { + this.onClickDeleteButton(e); + }); }, onClickAddButton() { diff --git a/src/model/line.js b/src/model/line.js index d21b536a2..44f0871b3 100644 --- a/src/model/line.js +++ b/src/model/line.js @@ -17,5 +17,8 @@ export const Line = { Storage.save(this.key, this.lines); }, - delete() {}, + delete(name) { + this.lines = this.lines.filter((el) => el.name !== name); + Storage.save(this.key, this.lines); + }, }; From ae59b97818afc4c8890cda0e8a6fa56da5404960 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 02:56:59 +0900 Subject: [PATCH 17/28] =?UTF-8?q?feat=20:=20=EA=B5=AC=EA=B0=84=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EA=B5=AC=EA=B0=84=EC=9D=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=A0=20=EB=85=B8=EC=84=A0=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 26 +++++++++++--------------- src/controller/section-manager.js | 15 +++++++++++++++ src/util/constant.js | 1 + src/view/element.js | 5 +++++ src/view/section-view.js | 20 ++++++++++++++++++++ style.css | 4 ++++ 6 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 src/controller/section-manager.js create mode 100644 src/view/section-view.js diff --git a/index.html b/index.html index 1e1cb24b6..410c8e6f1 100644 --- a/index.html +++ b/index.html @@ -73,11 +73,7 @@

๐Ÿš‰ ์ง€ํ•˜์ฒ  ๋…ธ์„  ๋ชฉ๋ก

๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.

-
- - - -
+

1ํ˜ธ์„  ๊ด€๋ฆฌ

@@ -85,17 +81,17 @@

๊ตฌ๊ฐ„ ๋“ฑ๋ก

+ + + + + + + + + +
์ˆœ์„œ์ด๋ฆ„์„ค์ •
- - - - - - - - - -
์ˆœ์„œ์ด๋ฆ„์„ค์ •
diff --git a/src/controller/section-manager.js b/src/controller/section-manager.js new file mode 100644 index 000000000..5567823c3 --- /dev/null +++ b/src/controller/section-manager.js @@ -0,0 +1,15 @@ +import { Line } from "../model/line.js"; +import { Storage } from "../util/storage.js"; +import { SectionView } from "../view/section-view.js"; + +export const SectionManager = { + isVisited: false, + + init() { + this.isVisited = true; + Line.lines = Storage.load(Line.key); + SectionView.render(); + }, + + setEventListener() {}, +}; diff --git a/src/util/constant.js b/src/util/constant.js index 01adaaea6..96ac3058d 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -22,6 +22,7 @@ export const Constant = { // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ SECTION_CONTAINER_CLASS: ".section-container", + SECTION_LINE_MENU_CLASS: ".section-line-menu", // ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ฆฌ MAP_PRINT_CONTAINER_CLASS: ".map-print-container", diff --git a/src/view/element.js b/src/view/element.js index 93a005113..9e2ade236 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -3,6 +3,8 @@ import { StationView } from "./station-view.js"; import { Constant } from "../util/constant.js"; import { LineManager } from "../controller/line-manager.js"; import { LineView } from "./line-view.js"; +import { SectionManager } from "../controller/section-manager.js"; +import { SectionView } from "./section-view.js"; export const Element = { // ์ดˆ๊ธฐ ํ™”๋ฉด ๋ฒ„ํŠผ @@ -34,6 +36,7 @@ export const Element = { // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ sectionContainer: document.querySelector(Constant.SECTION_CONTAINER_CLASS), + sectionLineMenu: document.querySelector(Constant.SECTION_LINE_MENU_CLASS), // ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ mapPrintContainer: document.querySelector(Constant.MAP_PRINT_CONTAINER_CLASS), @@ -64,6 +67,8 @@ export const ElementControl = { showSectionManager() { this.hideAllManagers(); Element.sectionContainer.style.display = Constant.BLOCK; + + SectionManager.isVisited ? SectionView.render() : SectionManager.init(); }, showMapPrintManager() { diff --git a/src/view/section-view.js b/src/view/section-view.js new file mode 100644 index 000000000..49114e1a0 --- /dev/null +++ b/src/view/section-view.js @@ -0,0 +1,20 @@ +import { Line } from "../model/line.js"; +import { Element } from "./element.js"; + +export const SectionView = { + render() { + this.renderLineButton(); + }, + + renderLineButton() { + let content = ""; + + Line.lines.forEach(({ name }) => { + content += ` + + `; + }); + + Element.sectionLineMenu.innerHTML = content; + }, +}; diff --git a/style.css b/style.css index 58c26e40d..331291179 100644 --- a/style.css +++ b/style.css @@ -31,6 +31,10 @@ td { display: none; } +.section-manager { + display: none; +} + #section-table { margin-top: 40px; } From 9f89b53751f2290a1292fd83c1e7e8807b1ece5d Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 06:10:07 +0900 Subject: [PATCH 18/28] =?UTF-8?q?docs=20:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/README.md b/docs/README.md index 56a05d7a7..e8ee81da6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,21 +53,24 @@ - `์‚ญ์ œ` - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - [ ] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๋…ธ์„  ๊ด€๋ฆฌ - - ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - [x] ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - `๋…ธ์„  ์ถ”๊ฐ€` - [x] ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - [x] ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - [x] ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ๋™์ผํ•œ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - [x] ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. - - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - [x] ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - `์‚ญ์ œ` - - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - - ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - [x] ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - [ ] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ - - ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. (๋ฒ„ํŠผ์œผ๋กœ ์ถœ๋ ฅ) - - ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ํ•ด๋‹น ๋…ธ์„ ์˜ ๊ตฌ๊ฐ„ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - - ์ œ๋ชฉ์€ `(์„ ํƒ๋œ ๋…ธ์„ ) ๊ด€๋ฆฌ`๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. + - [x] ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. (๋ฒ„ํŠผ์œผ๋กœ ์ถœ๋ ฅ) + - [x] ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ํ•ด๋‹น ๋…ธ์„ ์˜ ๊ตฌ๊ฐ„ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. + - [x] ์ œ๋ชฉ์€ `(์„ ํƒ๋œ ๋…ธ์„ ) ๊ด€๋ฆฌ`๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. + - [x] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - `๋“ฑ๋ก` - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. @@ -77,6 +80,7 @@ - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. (๋‘ ๊ฐœ ์ดํ•˜์ธ ๊ฒฝ์šฐ์—๋Š” ์‚ญ์ œ ๋ถˆ๊ฐ€) - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ - ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์กฐํšŒํ•œ๋‹ค. @@ -105,15 +109,15 @@ - [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-start-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์˜ ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•˜๋Š” select ํƒœ๊ทธ๋Š” `#line-end-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์ถ”๊ฐ€ํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#line-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- [ ] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์‚ญ์ œํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.line-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ -- [ ] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ์„ ์„ ํƒํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-line-menu-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์„ค์ •ํ•  ์—ญ select ํƒœ๊ทธ๋Š” `#section-station-selector` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” input ํƒœ๊ทธ๋Š” `#section-order-input` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. - [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ๋“ฑ๋กํ•˜๋Š” button ํƒœ๊ทธ๋Š” `#section-add-button` id๊ฐ’์„ ๊ฐ€์ง„๋‹ค. -- [ ] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๊ตฌ๊ฐ„์„ ์ œ๊ฑฐํ•˜๋Š” button ํƒœ๊ทธ๋Š” `.section-delete-button` class๊ฐ’์„ ๊ฐ€์ง„๋‹ค. ##### ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ธฐ๋Šฅ From 8ef1ec11109fe0ccf63c61a84c189ec8f15627a5 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 06:10:54 +0900 Subject: [PATCH 19/28] =?UTF-8?q?feat=20:=20=EA=B5=AC=EA=B0=84=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EB=85=B8=EC=84=A0=EC=9D=84=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=ED=95=98=EB=A9=B4=20=ED=95=B4=EB=8B=B9=20=EB=85=B8?= =?UTF-8?q?=EC=84=A0=EC=9D=98=20=EA=B5=AC=EA=B0=84=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 +- src/controller/section-manager.js | 19 +++++++++- src/index.js | 8 ++-- src/util/constant.js | 4 ++ src/view/element.js | 33 +++++++++++----- src/view/line-view.js | 8 ++-- src/view/section-view.js | 63 +++++++++++++++++++++++++++++-- style.css | 2 +- 8 files changed, 116 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index 410c8e6f1..f6790847a 100644 --- a/index.html +++ b/index.html @@ -76,12 +76,12 @@

๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.

-

1ํ˜ธ์„  ๊ด€๋ฆฌ

+

๊ตฌ๊ฐ„ ๋“ฑ๋ก

- +
diff --git a/src/controller/section-manager.js b/src/controller/section-manager.js index 5567823c3..b3e34b013 100644 --- a/src/controller/section-manager.js +++ b/src/controller/section-manager.js @@ -1,5 +1,8 @@ import { Line } from "../model/line.js"; +import { Station } from "../model/station.js"; +import { Constant } from "../util/constant.js"; import { Storage } from "../util/storage.js"; +import { Element, ElementControl } from "../view/element.js"; import { SectionView } from "../view/section-view.js"; export const SectionManager = { @@ -7,9 +10,23 @@ export const SectionManager = { init() { this.isVisited = true; + Station.stations = Storage.load(Station.key); Line.lines = Storage.load(Line.key); SectionView.render(); + this.setEventListener(); }, - setEventListener() {}, + setEventListener() { + Element.sectionLineMenu.addEventListener(Constant.CLICK, (e) => { + this.onCLickLineButton(e); + }); + }, + + onCLickLineButton(e) { + if (e.target.tagName !== Constant.BUTTON) { + return false; + } + + SectionView.renderSectionManager(e); + }, }; diff --git a/src/index.js b/src/index.js index c08c7ffd0..d0b94168c 100644 --- a/src/index.js +++ b/src/index.js @@ -7,19 +7,19 @@ const App = () => { const SubwayManager = () => { Element.stationManagerButton.addEventListener(Constant.CLICK, () => { - ElementControl.showStataionManger(); + ElementControl.showStationContainer(); }); Element.lineManagerButton.addEventListener(Constant.CLICK, () => { - ElementControl.showLineManager(); + ElementControl.showLineContainer(); }); Element.sectionManagerButton.addEventListener(Constant.CLICK, () => { - ElementControl.showSectionManager(); + ElementControl.showSectionContainer(); }); Element.mapPrintManagerButton.addEventListener(Constant.CLICK, () => { - ElementControl.showMapPrintManager(); + ElementControl.showMapPrintContainer(); }); }; diff --git a/src/util/constant.js b/src/util/constant.js index 96ac3058d..3b5f2903a 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -23,6 +23,9 @@ export const Constant = { // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ SECTION_CONTAINER_CLASS: ".section-container", SECTION_LINE_MENU_CLASS: ".section-line-menu", + SECTION_MANAGER_CLASS: ".section-manager", + SECTION_MANAGER_TITLE_CLASS: ".section-manager-title", + SECTION_STATION_SELECTOR_ID: "#section-station-selector", // ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ฆฌ MAP_PRINT_CONTAINER_CLASS: ".map-print-container", @@ -38,6 +41,7 @@ export const Constant = { // tag TBODY: "tbody", + BUTTON: "BUTTON", }; export const ErrorMessage = { diff --git a/src/view/element.js b/src/view/element.js index 9e2ade236..9bda27cb8 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -37,42 +37,57 @@ export const Element = { // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ sectionContainer: document.querySelector(Constant.SECTION_CONTAINER_CLASS), sectionLineMenu: document.querySelector(Constant.SECTION_LINE_MENU_CLASS), + sectionManager: document.querySelector(Constant.SECTION_MANAGER_CLASS), + sectionManagerTitle: document.querySelector( + Constant.SECTION_MANAGER_TITLE_CLASS + ), + sectionStationSelector: document.querySelector( + Constant.SECTION_STATION_SELECTOR_ID + ), // ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ mapPrintContainer: document.querySelector(Constant.MAP_PRINT_CONTAINER_CLASS), }; export const ElementControl = { - hideAllManagers() { + hideAllContainers() { Element.stationContainer.style.display = Constant.NONE; Element.lineContainer.style.display = Constant.NONE; Element.sectionContainer.style.display = Constant.NONE; Element.mapPrintContainer.style.display = Constant.NONE; }, - showStataionManger() { - this.hideAllManagers(); + showStationContainer() { + this.hideAllContainers(); Element.stationContainer.style.display = Constant.BLOCK; StationManager.isVisited ? StationView.render() : StationManager.init(); }, - showLineManager() { - this.hideAllManagers(); + showLineContainer() { + this.hideAllContainers(); Element.lineContainer.style.display = Constant.BLOCK; LineManager.isVisited ? LineView.render() : LineManager.init(); }, - showSectionManager() { - this.hideAllManagers(); + showSectionContainer() { + this.hideAllContainers(); Element.sectionContainer.style.display = Constant.BLOCK; SectionManager.isVisited ? SectionView.render() : SectionManager.init(); }, - showMapPrintManager() { - this.hideAllManagers(); + showSectionManager() { + Element.sectionManager.style.display = Constant.BLOCK; + }, + + hideSectionManager() { + Element.sectionManager.style.display = Constant.NONE; + }, + + showMapPrintContainer() { + this.hideAllContainers(); Element.mapPrintContainer.style.display = Constant.BLOCK; }, diff --git a/src/view/line-view.js b/src/view/line-view.js index 74b0e46e8..abae4870c 100644 --- a/src/view/line-view.js +++ b/src/view/line-view.js @@ -5,11 +5,11 @@ import { Element } from "./element.js"; export const LineView = { render() { - this.renderSelector(); - this.renderTable(); + this.renderLineStartEndSelector(); + this.renderLineContainerTable(); }, - renderSelector() { + renderLineStartEndSelector() { let content = ""; Station.stations.forEach((station) => { @@ -22,7 +22,7 @@ export const LineView = { Element.lineEndStationSelector.innerHTML = content; }, - renderTable() { + renderLineContainerTable() { let content = ""; Line.lines.forEach(({ name, stations }) => { diff --git a/src/view/section-view.js b/src/view/section-view.js index 49114e1a0..f4c8d8578 100644 --- a/src/view/section-view.js +++ b/src/view/section-view.js @@ -1,20 +1,75 @@ import { Line } from "../model/line.js"; -import { Element } from "./element.js"; +import { Station } from "../model/station.js"; +import { Constant } from "../util/constant.js"; +import { Element, ElementControl } from "./element.js"; export const SectionView = { render() { - this.renderLineButton(); + this.renderSectionLineMenuButton(); + ElementControl.hideSectionManager(); }, - renderLineButton() { + renderSectionLineMenuButton() { let content = ""; Line.lines.forEach(({ name }) => { content += ` - + `; }); Element.sectionLineMenu.innerHTML = content; }, + + renderSectionManager(e) { + const line = e.target.dataset.name; + + this.renderSectionManagerTitle(line); + this.renderSectionStationSelector(); + this.renderSectionContainerTable(line); + + ElementControl.showSectionManager(); + }, + + renderSectionManagerTitle(line) { + const sectionManagerTitleContent = `${line} ๊ด€๋ฆฌ`; + + Element.sectionManagerTitle.innerHTML = sectionManagerTitleContent; + }, + + renderSectionStationSelector() { + let content = ""; + + Station.stations.forEach((station) => { + content += ` + + `; + }); + + Element.sectionStationSelector.innerHTML = content; + }, + + renderSectionContainerTable(line) { + const stationArray = Line.lines.filter(({ name }) => name === line)[0] + .stations; + let content = ""; + + for (let i = 0; i < stationArray.length; i++) { + content += ` + + + + + + `; + } + + Element.sectionContainer.querySelector(Constant.TBODY).innerHTML = content; + }, }; diff --git a/style.css b/style.css index 331291179..5a7579515 100644 --- a/style.css +++ b/style.css @@ -35,7 +35,7 @@ td { display: none; } -#section-table { +#section-container-table { margin-top: 40px; } From 312f015dcae9bdf8c497f48f9481b5d452782d60 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 12:02:21 +0900 Subject: [PATCH 20/28] =?UTF-8?q?feat=20:=20=EA=B5=AC=EA=B0=84=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EB=93=B1=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/controller/section-manager.js | 22 ++++++++++++- src/model/section.js | 20 ++++++++++++ src/util/constant.js | 7 ++++ src/util/validation.js | 53 +++++++++++++++++++++++++++++++ src/view/element.js | 2 ++ src/view/section-view.js | 5 ++- 7 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 src/model/section.js diff --git a/index.html b/index.html index f6790847a..0fd4aa3b3 100644 --- a/index.html +++ b/index.html @@ -79,7 +79,7 @@

๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.

๊ตฌ๊ฐ„ ๋“ฑ๋ก

- +
์ˆœ์„œ
${i}${stationArray[i]} + +
diff --git a/src/controller/section-manager.js b/src/controller/section-manager.js index b3e34b013..ea3ba45bc 100644 --- a/src/controller/section-manager.js +++ b/src/controller/section-manager.js @@ -1,12 +1,16 @@ import { Line } from "../model/line.js"; +import { Section } from "../model/section.js"; import { Station } from "../model/station.js"; import { Constant } from "../util/constant.js"; import { Storage } from "../util/storage.js"; +import { SectionValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; import { SectionView } from "../view/section-view.js"; +import { StationView } from "../view/station-view.js"; export const SectionManager = { isVisited: false, + selectedLine: "", init() { this.isVisited = true; @@ -20,6 +24,10 @@ export const SectionManager = { Element.sectionLineMenu.addEventListener(Constant.CLICK, (e) => { this.onCLickLineButton(e); }); + + Element.sectionAddButton.addEventListener(Constant.CLICK, () => { + this.onClickAddButton(); + }); }, onCLickLineButton(e) { @@ -27,6 +35,18 @@ export const SectionManager = { return false; } - SectionView.renderSectionManager(e); + this.selectedLine = e.target.dataset.name; + SectionView.renderSectionManager(this.selectedLine); + }, + + onClickAddButton() { + const station = Element.sectionStationSelector.value; + const order = Element.sectionOrderInupt.value; + + if (SectionValidation.isValidSection(station, order, this.selectedLine)) { + Section.add(station, order, this.selectedLine); + SectionView.renderSectionManager(this.selectedLine); + } + ElementControl.clearInput(Element.sectionOrderInupt); }, }; diff --git a/src/model/section.js b/src/model/section.js new file mode 100644 index 000000000..77841dc83 --- /dev/null +++ b/src/model/section.js @@ -0,0 +1,20 @@ +import { Storage } from "../util/storage.js"; +import { Line } from "./line.js"; + +export const Section = { + add(station, order, line) { + const stationArray = Line.lines.filter(({ name }) => name === line)[0] + .stations; + + // + stationArray.splice(order, 0, station); + Storage.save(Line.key, Line.lines); + // ์›๋ž˜ index์— ๋„ฃ๊ธฐ - ์ธ๋ฑ์Šค ๊ตฌํ•ด์„œ ๋„ฃ๊ณ  ๋‹ค์Œ ์ธ๋ฑ์Šค ์‚ญ์ œ + // ๊ต์ฒดํ•˜๋ฉด ์•ˆ๋ ๊นŒ? + // console.log(Line.lines); + // Line.lines.forEach(({ name, stations }) => { + // console.log(name, stations); + // }) + // Line.lines = Line.lines.filter(({ name }) => name !== line); + }, +}; diff --git a/src/util/constant.js b/src/util/constant.js index 3b5f2903a..0ec100e05 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -26,6 +26,8 @@ export const Constant = { SECTION_MANAGER_CLASS: ".section-manager", SECTION_MANAGER_TITLE_CLASS: ".section-manager-title", SECTION_STATION_SELECTOR_ID: "#section-station-selector", + SECTION_ADD_BUTTON_ID: "#section-add-button", + SECTION_ORDER_INPUT_ID: "#section-order-input", // ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ฆฌ MAP_PRINT_CONTAINER_CLASS: ".map-print-container", @@ -33,6 +35,7 @@ export const Constant = { // MINIMUM_NAME_LENGTH: 2, REGEX_CATCHING_WHITESPACE: /^\s*$/, + REGEX_CATCHING_INTEGER: /^[0-9 ()+-]+$/, // etc CLICK: "click", @@ -54,6 +57,10 @@ export const ErrorMessage = { // ๋…ธ์„  ๊ด€๋ฆฌ NAME_WHITE_SPACE: "๊ณต๋ฐฑ์ด ์•„๋‹Œ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", SAME_START_END_STATION: "์„œ๋กœ ๋‹ค๋ฅธ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.", + + // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ + NOT_INTEGER_ORDER: "1 ์ด์ƒ ์ •์ˆ˜์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + MINIMUM_ORDER: "1 ์ด์ƒ์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", }; export const ConfirmMessage = { diff --git a/src/util/validation.js b/src/util/validation.js index a27ecdcec..8de6dd04c 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -76,3 +76,56 @@ export const LineValidation = { return !stationNameArray.includes(name); }, }; + +export const SectionValidation = { + isValidSection(station, order, selectedLine) { + return ( + this.hasValidName(station, selectedLine) && + this.hasValidOrder(order, selectedLine) + ); + }, + + hasValidName(station, selectedLine) { + if (!this.isNotDuplicated(station, selectedLine)) { + alert(ErrorMessage.DUPLICATED_NAME); + + return; + } + + return true; + }, + + hasValidOrder(order, selectedLine) { + const stationArray = Line.lines.filter( + ({ name }) => name === selectedLine + )[0].stations; + + if (!Constant.REGEX_CATCHING_INTEGER.test(order)) { + alert(ErrorMessage.NOT_INTEGER_ORDER); + + return; + } + + if (order < 1) { + alert(ErrorMessage.MINIMUM_ORDER); + + return; + } + + if (order > stationArray.length - 1) { + alert(`${stationArray.length - 1} ์ดํ•˜์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.`); + + return; + } + + return true; + }, + + isNotDuplicated(station, selectedLine) { + const stationArray = Line.lines.filter( + ({ name }) => name === selectedLine + )[0].stations; + + return !stationArray.includes(station); + }, +}; diff --git a/src/view/element.js b/src/view/element.js index 9bda27cb8..4c9352e5c 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -44,6 +44,8 @@ export const Element = { sectionStationSelector: document.querySelector( Constant.SECTION_STATION_SELECTOR_ID ), + sectionAddButton: document.querySelector(Constant.SECTION_ADD_BUTTON_ID), + sectionOrderInupt: document.querySelector(Constant.SECTION_ORDER_INPUT_ID), // ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ mapPrintContainer: document.querySelector(Constant.MAP_PRINT_CONTAINER_CLASS), diff --git a/src/view/section-view.js b/src/view/section-view.js index f4c8d8578..4d10950a1 100644 --- a/src/view/section-view.js +++ b/src/view/section-view.js @@ -6,6 +6,7 @@ import { Element, ElementControl } from "./element.js"; export const SectionView = { render() { this.renderSectionLineMenuButton(); + ElementControl.hideSectionManager(); }, @@ -23,9 +24,7 @@ export const SectionView = { Element.sectionLineMenu.innerHTML = content; }, - renderSectionManager(e) { - const line = e.target.dataset.name; - + renderSectionManager(line) { this.renderSectionManagerTitle(line); this.renderSectionStationSelector(); this.renderSectionContainerTable(line); From 7cdbd99951d2f5020bba585d1ac681ac6e5d377a Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 14:03:31 +0900 Subject: [PATCH 21/28] =?UTF-8?q?feat=20:=20=EA=B5=AC=EA=B0=84=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EB=85=B8=EC=84=A0=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/section-manager.js | 31 +++++++++++++++++++++++++++---- src/model/section.js | 8 ++++++++ src/util/constant.js | 7 +++++-- src/util/validation.js | 13 ++++++++++--- src/view/section-view.js | 2 +- 5 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/controller/section-manager.js b/src/controller/section-manager.js index ea3ba45bc..53093fe72 100644 --- a/src/controller/section-manager.js +++ b/src/controller/section-manager.js @@ -1,7 +1,7 @@ import { Line } from "../model/line.js"; import { Section } from "../model/section.js"; import { Station } from "../model/station.js"; -import { Constant } from "../util/constant.js"; +import { ConfirmMessage, Constant, ErrorMessage } from "../util/constant.js"; import { Storage } from "../util/storage.js"; import { SectionValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; @@ -22,19 +22,24 @@ export const SectionManager = { setEventListener() { Element.sectionLineMenu.addEventListener(Constant.CLICK, (e) => { - this.onCLickLineButton(e); + this.onClickLineButton(e); }); Element.sectionAddButton.addEventListener(Constant.CLICK, () => { this.onClickAddButton(); }); + + Element.sectionContainer + .querySelector(Constant.TBODY) + .addEventListener(Constant.CLICK, (e) => { + this.onClickDeleteButton(e); + }); }, - onCLickLineButton(e) { + onClickLineButton(e) { if (e.target.tagName !== Constant.BUTTON) { return false; } - this.selectedLine = e.target.dataset.name; SectionView.renderSectionManager(this.selectedLine); }, @@ -49,4 +54,22 @@ export const SectionManager = { } ElementControl.clearInput(Element.sectionOrderInupt); }, + + onClickDeleteButton(e) { + const idx = e.target.dataset.idx; + + if (e.target.tagName !== Constant.BUTTON) { + return false; + } + + if (confirm(ConfirmMessage.CHECK_DELETION_FROM_LINE)) { + if (!SectionValidation.hasMinimumStations(this.selectedLine)) { + alert(ErrorMessage.MINIMUM_STATIONS); + + return; + } + Section.delete(idx, this.selectedLine); + SectionView.renderSectionManager(this.selectedLine); + } + }, }; diff --git a/src/model/section.js b/src/model/section.js index 77841dc83..63f80097c 100644 --- a/src/model/section.js +++ b/src/model/section.js @@ -17,4 +17,12 @@ export const Section = { // }) // Line.lines = Line.lines.filter(({ name }) => name !== line); }, + + delete(idx, line) { + const stationArray = Line.lines.filter(({ name }) => name === line)[0] + .stations; + + stationArray.splice(idx, 1); + Storage.save(Line.key, Line.lines); + }, }; diff --git a/src/util/constant.js b/src/util/constant.js index 0ec100e05..218d9ebf9 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -32,8 +32,8 @@ export const Constant = { // ์ง€ํ•˜์ฒ  ๋…ธ์„  ๊ด€๋ฆฌ MAP_PRINT_CONTAINER_CLASS: ".map-print-container", - // - MINIMUM_NAME_LENGTH: 2, + // validation + MINIMUM_LENGTH: 2, REGEX_CATCHING_WHITESPACE: /^\s*$/, REGEX_CATCHING_INTEGER: /^[0-9 ()+-]+$/, @@ -61,8 +61,11 @@ export const ErrorMessage = { // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ NOT_INTEGER_ORDER: "1 ์ด์ƒ ์ •์ˆ˜์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", MINIMUM_ORDER: "1 ์ด์ƒ์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + MINIMUM_STATIONS: + "๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", }; export const ConfirmMessage = { CHECK_DELETION: "์ •๋ง๋กœ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", + CHECK_DELETION_FROM_LINE: "์ •๋ง๋กœ ๋…ธ์„ ์—์„œ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", }; diff --git a/src/util/validation.js b/src/util/validation.js index 8de6dd04c..7eac30226 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -25,7 +25,7 @@ export const StationValidation = { hasMinimumLength(name) { return ( - name.length >= Constant.MINIMUM_NAME_LENGTH && + name.length >= Constant.MINIMUM_LENGTH && !Constant.REGEX_CATCHING_WHITESPACE.test(name) ); }, @@ -37,7 +37,7 @@ export const StationValidation = { export const LineValidation = { isValidLine(name, start, end) { - return this.hasValidName(name) && this.hasValidStartEndStation(start, end); + return this.hasValidName(name) && this.hasValidStartEndStations(start, end); }, hasValidName(name) { @@ -56,7 +56,7 @@ export const LineValidation = { return true; }, - hasValidStartEndStation(start, end) { + hasValidStartEndStations(start, end) { if (start === end) { alert(ErrorMessage.SAME_START_END_STATION); @@ -128,4 +128,11 @@ export const SectionValidation = { return !stationArray.includes(station); }, + + hasMinimumStations(selectedLine) { + return ( + Line.lines.filter(({ name }) => name === selectedLine)[0].stations + .length > Constant.MINIMUM_LENGTH + ); + }, }; diff --git a/src/view/section-view.js b/src/view/section-view.js index 4d10950a1..4a2763e51 100644 --- a/src/view/section-view.js +++ b/src/view/section-view.js @@ -61,7 +61,7 @@ export const SectionView = { From 491cc20061630cf10c367e64cddc6e1131641693 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 15:25:30 +0900 Subject: [PATCH 22/28] =?UTF-8?q?docs=20:=20=EA=B5=AC=ED=98=84=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=EB=90=9C=20=EA=B8=B0=EB=8A=A5=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/README.md b/docs/README.md index e8ee81da6..283a986a8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,6 +54,7 @@ - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - [ ] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [ ] ๋…ธ์„ (์ „์ฒด ๊ตฌ๊ฐ„)์— ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๋…ธ์„  ๊ด€๋ฆฌ - [x] ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - `๋…ธ์„  ์ถ”๊ฐ€` @@ -72,17 +73,17 @@ - [x] ์ œ๋ชฉ์€ `(์„ ํƒ๋œ ๋…ธ์„ ) ๊ด€๋ฆฌ`๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. - [x] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - `๋“ฑ๋ก` - - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ์—ญ๊ณผ ์—ญ ์‚ฌ์ด(๊ตฌ๊ฐ„)์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - [x] ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„๊ณผ ์ˆœ์„œ๋ฅผ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ์ž…๋ ฅํ•œ ์—ญ์˜ ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ์—ญ๊ณผ ์—ญ ์‚ฌ์ด(๊ตฌ๊ฐ„)์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - `๋…ธ์„ ์—์„œ ์ œ๊ฑฐ` - - ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. (๋‘ ๊ฐœ ์ดํ•˜์ธ ๊ฒฝ์šฐ์—๋Š” ์‚ญ์ œ ๋ถˆ๊ฐ€) - - `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - - ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - - ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๋…ธ์„ ์— ๋“ฑ๋ก๋œ ์—ญ์ด ๋‘ ๊ฐœ ์ดํ•˜์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. (๋‘ ๊ฐœ ์ดํ•˜์ธ ๊ฒฝ์šฐ์—๋Š” ์‚ญ์ œ ๋ถˆ๊ฐ€) + - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. + - [x] ๊ตฌ๊ฐ„ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. + - [x] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ๊ด€๋ฆฌ - - ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์กฐํšŒํ•œ๋‹ค. + - [x] ๊ฐ ๋…ธ์„ ์˜ ์—ญ๋“ค์„ ์กฐํšŒํ•œ๋‹ค.
@@ -121,7 +122,7 @@ ##### ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๊ธฐ๋Šฅ -- [ ] ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. +- [x] ์ง€ํ•˜์ฒ  ๋…ธ์„ ๋„ ์ถœ๋ ฅ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด `
` ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ํƒœ๊ทธ ๋‚ด๋ถ€์— ๋…ธ์„ ๋„๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ### 2.2 ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ From cf6a422d3d8182a6002b606a73b8beaedd37d3e8 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 15:27:09 +0900 Subject: [PATCH 23/28] =?UTF-8?q?feat=20:=20=EC=A7=80=ED=95=98=EC=B2=A0=20?= =?UTF-8?q?=EB=85=B8=EC=84=A0=EB=8F=84=20=EA=B4=80=EB=A6=AC=20-=20?= =?UTF-8?q?=EA=B0=81=20=EB=85=B8=EC=84=A0=EB=93=A4=EC=9D=98=20=EC=97=AD=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 -- src/controller/map-manager.js | 15 +++++++++++++++ src/view/element.js | 4 ++++ src/view/map-view.js | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/controller/map-manager.js create mode 100644 src/view/map-view.js diff --git a/index.html b/index.html index 0fd4aa3b3..7870cda8d 100644 --- a/index.html +++ b/index.html @@ -96,8 +96,6 @@

๊ตฌ๊ฐ„ ๋“ฑ๋ก

- -
diff --git a/src/controller/map-manager.js b/src/controller/map-manager.js new file mode 100644 index 000000000..0fb3aaaba --- /dev/null +++ b/src/controller/map-manager.js @@ -0,0 +1,15 @@ +import { Line } from "../model/line.js"; +import { Station } from "../model/station.js"; +import { Storage } from "../util/storage.js"; +import { MapView } from "../view/map-view.js"; + +export const MapManager = { + isVisited: false, + + init() { + this.isVisited = true; + Station.stations = Storage.load(Station.key); + Line.lines = Storage.load(Line.key); + MapView.render(); + } +} \ No newline at end of file diff --git a/src/view/element.js b/src/view/element.js index 4c9352e5c..75cd4b1f0 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -5,6 +5,8 @@ import { LineManager } from "../controller/line-manager.js"; import { LineView } from "./line-view.js"; import { SectionManager } from "../controller/section-manager.js"; import { SectionView } from "./section-view.js"; +import { MapView } from "./map-view.js"; +import { MapManager } from "../controller/map-manager.js"; export const Element = { // ์ดˆ๊ธฐ ํ™”๋ฉด ๋ฒ„ํŠผ @@ -91,6 +93,8 @@ export const ElementControl = { showMapPrintContainer() { this.hideAllContainers(); Element.mapPrintContainer.style.display = Constant.BLOCK; + + MapManager.isVisited ? MapView.render() : MapManager.init(); }, clearInput(element) { diff --git a/src/view/map-view.js b/src/view/map-view.js new file mode 100644 index 000000000..ca443f963 --- /dev/null +++ b/src/view/map-view.js @@ -0,0 +1,20 @@ +import { Line } from "../model/line.js" +import { Element } from "./element.js"; + +export const MapView = { + render() { + let content = '
'; + + Line.lines.forEach(({ name, stations }) => { + content += `

${name}

    `; + + stations.forEach((station) => { + content += `
  • ${station}
  • `; + }) + content += '
'; + }) + content += '
'; + + Element.mapPrintContainer.innerHTML = content; + } +} \ No newline at end of file From ecf9b99600d030ad093d5f32184ea2958fb18293 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 18:25:18 +0900 Subject: [PATCH 24/28] =?UTF-8?q?docs=20:=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EC=99=84=EB=A3=8C=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 283a986a8..153892505 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,8 +53,8 @@ - `์‚ญ์ œ` - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - [x] ์ง€ํ•˜์ฒ  ์—ญ ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - - [ ] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - [ ] ๋…ธ์„ (์ „์ฒด ๊ตฌ๊ฐ„)์— ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๋…ธ์„ (์ „์ฒด ๊ตฌ๊ฐ„)์— ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๋…ธ์„  ๊ด€๋ฆฌ - [x] ๋…ธ์„  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - `๋…ธ์„  ์ถ”๊ฐ€` @@ -66,7 +66,7 @@ - `์‚ญ์ œ` - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. - [x] ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - - [ ] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ๋ˆ„๋ฅธ ๊ณณ์ด ๋ฒ„ํŠผ์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ - [x] ๊ตฌ๊ฐ„์„ ์ˆ˜์ •ํ•  ๋…ธ์„ ์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. (๋ฒ„ํŠผ์œผ๋กœ ์ถœ๋ ฅ) - [x] ๋…ธ์„ ์„ ์„ ํƒํ•˜๋ฉด ํ•ด๋‹น ๋…ธ์„ ์˜ ๊ตฌ๊ฐ„ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. From bb6efac993c0b72f5a837f2cd0afdb2631d9adba Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 18:27:18 +0900 Subject: [PATCH 25/28] =?UTF-8?q?feat=20:=20=20=EC=97=AD=EC=9D=B4=20?= =?UTF-8?q?=EB=85=B8=EC=84=A0=EC=97=90=20=ED=8F=AC=ED=95=A8=EB=90=98?= =?UTF-8?q?=EC=96=B4=20=EC=9E=88=EB=8A=94=EC=A7=80=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EB=B0=8F=20null=20guard=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 3 +-- src/controller/line-manager.js | 10 +++++++-- src/controller/map-manager.js | 15 -------------- src/controller/map-print-manager.js | 17 +++++++++++++++ src/controller/section-manager.js | 11 +++++----- src/controller/station-manager.js | 23 ++++++++++++++------- src/model/section.js | 8 ------- src/util/constant.js | 8 +++---- src/util/validation.js | 20 ++++++++++++++++++ src/view/element.js | 6 +++--- src/view/{map-view.js => map-print-view.js} | 16 +++++++------- 11 files changed, 81 insertions(+), 56 deletions(-) delete mode 100644 src/controller/map-manager.js create mode 100644 src/controller/map-print-manager.js rename src/view/{map-view.js => map-print-view.js} (68%) diff --git a/index.html b/index.html index 7870cda8d..d2cda19c3 100644 --- a/index.html +++ b/index.html @@ -95,8 +95,7 @@

๊ตฌ๊ฐ„ ๋“ฑ๋ก

-
-
+
diff --git a/src/controller/line-manager.js b/src/controller/line-manager.js index c09142545..0c30d56e5 100644 --- a/src/controller/line-manager.js +++ b/src/controller/line-manager.js @@ -11,8 +11,10 @@ export const LineManager = { init() { this.isVisited = true; - Station.stations = Storage.load(Station.key); - Line.lines = Storage.load(Line.key); + Station.stations = Storage.load(Station.key) + ? Storage.load(Station.key) + : []; + Line.lines = Storage.load(Line.key) ? Storage.load(Line.key) : []; LineView.render(); this.setEventListener(); }, @@ -44,6 +46,10 @@ export const LineManager = { onClickDeleteButton(e) { const name = e.target.dataset.name; + if (e.target.tagName !== Constant.BUTTON) { + return; + } + if (confirm(ConfirmMessage.CHECK_DELETION)) { Line.delete(name); LineView.render(); diff --git a/src/controller/map-manager.js b/src/controller/map-manager.js deleted file mode 100644 index 0fb3aaaba..000000000 --- a/src/controller/map-manager.js +++ /dev/null @@ -1,15 +0,0 @@ -import { Line } from "../model/line.js"; -import { Station } from "../model/station.js"; -import { Storage } from "../util/storage.js"; -import { MapView } from "../view/map-view.js"; - -export const MapManager = { - isVisited: false, - - init() { - this.isVisited = true; - Station.stations = Storage.load(Station.key); - Line.lines = Storage.load(Line.key); - MapView.render(); - } -} \ No newline at end of file diff --git a/src/controller/map-print-manager.js b/src/controller/map-print-manager.js new file mode 100644 index 000000000..b91ab826c --- /dev/null +++ b/src/controller/map-print-manager.js @@ -0,0 +1,17 @@ +import { Line } from "../model/line.js"; +import { Station } from "../model/station.js"; +import { Storage } from "../util/storage.js"; +import { MapPrintView } from "../view/map-print-view.js"; + +export const MapPrintManager = { + isVisited: false, + + init() { + this.isVisited = true; + Station.stations = Storage.load(Station.key) + ? Storage.load(Station.key) + : []; + Line.lines = Storage.load(Line.key) ? Storage.load(Line.key) : []; + MapPrintView.render(); + }, +}; diff --git a/src/controller/section-manager.js b/src/controller/section-manager.js index 53093fe72..3c7884c3f 100644 --- a/src/controller/section-manager.js +++ b/src/controller/section-manager.js @@ -6,7 +6,6 @@ import { Storage } from "../util/storage.js"; import { SectionValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; import { SectionView } from "../view/section-view.js"; -import { StationView } from "../view/station-view.js"; export const SectionManager = { isVisited: false, @@ -14,8 +13,10 @@ export const SectionManager = { init() { this.isVisited = true; - Station.stations = Storage.load(Station.key); - Line.lines = Storage.load(Line.key); + Station.stations = Storage.load(Station.key) + ? Storage.load(Station.key) + : []; + Line.lines = Storage.load(Line.key) ? Storage.load(Line.key) : []; SectionView.render(); this.setEventListener(); }, @@ -50,8 +51,8 @@ export const SectionManager = { if (SectionValidation.isValidSection(station, order, this.selectedLine)) { Section.add(station, order, this.selectedLine); - SectionView.renderSectionManager(this.selectedLine); } + SectionView.renderSectionManager(this.selectedLine); ElementControl.clearInput(Element.sectionOrderInupt); }, @@ -59,7 +60,7 @@ export const SectionManager = { const idx = e.target.dataset.idx; if (e.target.tagName !== Constant.BUTTON) { - return false; + return; } if (confirm(ConfirmMessage.CHECK_DELETION_FROM_LINE)) { diff --git a/src/controller/station-manager.js b/src/controller/station-manager.js index 0a47e0830..bef65abd3 100644 --- a/src/controller/station-manager.js +++ b/src/controller/station-manager.js @@ -1,5 +1,6 @@ +import { Line } from "../model/line.js"; import { Station } from "../model/station.js"; -import { ConfirmMessage, Constant } from "../util/constant.js"; +import { ConfirmMessage, Constant, ErrorMessage } from "../util/constant.js"; import { Storage } from "../util/storage.js"; import { StationValidation } from "../util/validation.js"; import { Element, ElementControl } from "../view/element.js"; @@ -10,22 +11,19 @@ export const StationManager = { init() { this.isVisited = true; - Station.stations = Storage.load(Station.key); + Station.stations = Storage.load(Station.key) + ? Storage.load(Station.key) + : []; + Line.lines = Storage.load(Line.key) ? Storage.load(Line.key) : []; StationView.render(); this.setEventListener(); }, setEventListener() { - // ์ถ”๊ฐ€ Element.stationAddButton.addEventListener(Constant.CLICK, () => { this.onClickAddButton(); }); - // ์‚ญ์ œ - // Element.stationDeleteButton - // document.querySelector(Constant.STATION_DELELE_BUTTON_CLASS).addEventListener(Constant.CLICK, (e) => { - // this.onClickDeleteBtn(e); - // }); Element.stationContainer .querySelector(Constant.TBODY) .addEventListener(Constant.CLICK, (e) => { @@ -46,7 +44,16 @@ export const StationManager = { onClickDeleteButton(e) { const name = e.target.dataset.name; + if (e.target.tagName !== Constant.BUTTON) { + return; + } + if (confirm(ConfirmMessage.CHECK_DELETION)) { + if (!StationValidation.isValidStatonDeletion(name)) { + alert(ErrorMessage.STATION_RELATED_LINE); + + return; + } Station.delete(name); StationView.render(); } diff --git a/src/model/section.js b/src/model/section.js index 63f80097c..c1c4c9484 100644 --- a/src/model/section.js +++ b/src/model/section.js @@ -6,16 +6,8 @@ export const Section = { const stationArray = Line.lines.filter(({ name }) => name === line)[0] .stations; - // stationArray.splice(order, 0, station); Storage.save(Line.key, Line.lines); - // ์›๋ž˜ index์— ๋„ฃ๊ธฐ - ์ธ๋ฑ์Šค ๊ตฌํ•ด์„œ ๋„ฃ๊ณ  ๋‹ค์Œ ์ธ๋ฑ์Šค ์‚ญ์ œ - // ๊ต์ฒดํ•˜๋ฉด ์•ˆ๋ ๊นŒ? - // console.log(Line.lines); - // Line.lines.forEach(({ name, stations }) => { - // console.log(name, stations); - // }) - // Line.lines = Line.lines.filter(({ name }) => name !== line); }, delete(idx, line) { diff --git a/src/util/constant.js b/src/util/constant.js index 218d9ebf9..0b0c23545 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -37,12 +37,10 @@ export const Constant = { REGEX_CATCHING_WHITESPACE: /^\s*$/, REGEX_CATCHING_INTEGER: /^[0-9 ()+-]+$/, - // etc + // tag ๊ด€๋ จ CLICK: "click", NONE: "none", BLOCK: "block", - - // tag TBODY: "tbody", BUTTON: "BUTTON", }; @@ -53,6 +51,7 @@ export const ErrorMessage = { // ์—ญ ๊ด€๋ฆฌ MINIMUM_NAME_LENGTH: "๊ณต๋ฐฑ์ด ์•„๋‹Œ 2๊ธ€์ž ์ด์ƒ์˜ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + STATION_RELATED_LINE: "๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์€ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", // ๋…ธ์„  ๊ด€๋ฆฌ NAME_WHITE_SPACE: "๊ณต๋ฐฑ์ด ์•„๋‹Œ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", @@ -61,8 +60,7 @@ export const ErrorMessage = { // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ NOT_INTEGER_ORDER: "1 ์ด์ƒ ์ •์ˆ˜์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", MINIMUM_ORDER: "1 ์ด์ƒ์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", - MINIMUM_STATIONS: - "๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", + MINIMUM_STATIONS: "๋…ธ์„ ์— ํฌํ•จ๋œ ์—ญ์ด ๋‘๊ฐœ ์ดํ•˜์ผ ๋•Œ๋Š” ์—ญ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", }; export const ConfirmMessage = { diff --git a/src/util/validation.js b/src/util/validation.js index 7eac30226..2fc6ed235 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -33,6 +33,18 @@ export const StationValidation = { isNotDuplicated(name) { return !Station.stations.includes(name); }, + + isValidStatonDeletion(station) { + let isValid = true; + + Line.lines.forEach(({ stations }) => { + if (stations.includes(station)) { + isValid = false; + } + }); + + return isValid; + }, }; export const LineValidation = { @@ -106,6 +118,14 @@ export const SectionValidation = { return; } + if (!this.hasValidNumberRange(order, stationArray)) { + return; + } + + return true; + }, + + hasValidNumberRange(order, stationArray) { if (order < 1) { alert(ErrorMessage.MINIMUM_ORDER); diff --git a/src/view/element.js b/src/view/element.js index 75cd4b1f0..4fe778790 100644 --- a/src/view/element.js +++ b/src/view/element.js @@ -5,8 +5,8 @@ import { LineManager } from "../controller/line-manager.js"; import { LineView } from "./line-view.js"; import { SectionManager } from "../controller/section-manager.js"; import { SectionView } from "./section-view.js"; -import { MapView } from "./map-view.js"; -import { MapManager } from "../controller/map-manager.js"; +import { MapPrintView } from "./map-print-view.js"; +import { MapPrintManager } from "../controller/map-print-manager.js"; export const Element = { // ์ดˆ๊ธฐ ํ™”๋ฉด ๋ฒ„ํŠผ @@ -94,7 +94,7 @@ export const ElementControl = { this.hideAllContainers(); Element.mapPrintContainer.style.display = Constant.BLOCK; - MapManager.isVisited ? MapView.render() : MapManager.init(); + MapPrintManager.isVisited ? MapPrintView.render() : MapPrintManager.init(); }, clearInput(element) { diff --git a/src/view/map-view.js b/src/view/map-print-view.js similarity index 68% rename from src/view/map-view.js rename to src/view/map-print-view.js index ca443f963..3a047c2b8 100644 --- a/src/view/map-view.js +++ b/src/view/map-print-view.js @@ -1,7 +1,7 @@ -import { Line } from "../model/line.js" +import { Line } from "../model/line.js"; import { Element } from "./element.js"; -export const MapView = { +export const MapPrintView = { render() { let content = '
'; @@ -10,11 +10,11 @@ export const MapView = { stations.forEach((station) => { content += `
  • ${station}
  • `; - }) - content += ''; - }) - content += '
    '; + }); + content += ""; + }); + content += ""; Element.mapPrintContainer.innerHTML = content; - } -} \ No newline at end of file + }, +}; From 48bd8ba2c3bc4d382a6cedd376ba41cd2cabe99e Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 19:59:46 +0900 Subject: [PATCH 26/28] =?UTF-8?q?docs=20:=20=EB=85=B8=EC=84=A0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20=EC=9D=B4=EB=A6=84=EC=9D=B4=20=EB=8B=AC?= =?UTF-8?q?=EB=9D=BC=EB=8F=84=20=EC=83=81=ED=96=89=20=EC=A2=85=EC=A0=90=20?= =?UTF-8?q?=EB=98=90=EB=8A=94=20=ED=95=98=ED=96=89=20=EC=A2=85=EC=A0=90?= =?UTF-8?q?=EC=9D=B4=20=EC=A4=91=EB=B3=B5=EB=90=A0=20=EC=88=98=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9=EB=A1=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EA=B5=AC=ED=98=84=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 153892505..e3527a893 100644 --- a/docs/README.md +++ b/docs/README.md @@ -61,7 +61,10 @@ - [x] ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์  ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. - [x] ์ž…๋ ฅํ•œ ๋…ธ์„  ์ด๋ฆ„์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - [x] ๋…ธ์„ ์˜ ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ๋™์ผํ•œ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - - [x] ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ค๋ฅด๋ฉด ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์žˆ๋‹ค. + - [x] ๋…ธ์„ ์˜ ์ด๋ฆ„์ด ๋‹ฌ๋ผ๋„ ์ƒํ–‰ ์ข…์  ๋˜๋Š” ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต๋  ์ˆ˜ ์—†๋‹ค. + - [x] ์ƒํ–‰ ์ข…์ ์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ํ•˜ํ–‰ ์ข…์ ์ด ์ค‘๋ณต์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. + - [x] ์ƒํ–‰ ์ข…์ ๊ณผ ํ•˜ํ–‰ ์ข…์ ์˜ ๋ฐฉํ–ฅ์ด ๋ฐ˜๋Œ€์ธ์ง€ ๊ฒ€์ฆํ•ด์•ผ ํ•œ๋‹ค. - [x] ๋…ธ์„  ๋ชฉ๋ก์— ๋ฐ˜์˜ํ•œ๋‹ค. - `์‚ญ์ œ` - [x] `alert`๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋ฌผ์–ด๋ณธ๋‹ค. From 289573873b76e0df9d3336b388ee8001d21070d9 Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 20:00:28 +0900 Subject: [PATCH 27/28] =?UTF-8?q?feat=20:=20=EB=85=B8=EC=84=A0=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EC=A2=85=EC=A0=90=EC=9D=B4=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=85=B8=EC=84=A0=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/line-manager.js | 2 +- src/util/constant.js | 4 +++- src/util/validation.js | 36 ++++++++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/controller/line-manager.js b/src/controller/line-manager.js index 0c30d56e5..a55410ce7 100644 --- a/src/controller/line-manager.js +++ b/src/controller/line-manager.js @@ -38,8 +38,8 @@ export const LineManager = { if (LineValidation.isValidLine(name, start, end)) { Line.add(new LineObject(name, start, end)); - LineView.render(); } + LineView.render(); ElementControl.clearInput(Element.lineNameInput); }, diff --git a/src/util/constant.js b/src/util/constant.js index 0b0c23545..cffe4378e 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -47,7 +47,7 @@ export const Constant = { export const ErrorMessage = { // ๊ณตํ†ต - DUPLICATED_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", + DUPLICATED_STATION_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", // ์—ญ ๊ด€๋ฆฌ MINIMUM_NAME_LENGTH: "๊ณต๋ฐฑ์ด ์•„๋‹Œ 2๊ธ€์ž ์ด์ƒ์˜ ์—ญ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", @@ -56,6 +56,8 @@ export const ErrorMessage = { // ๋…ธ์„  ๊ด€๋ฆฌ NAME_WHITE_SPACE: "๊ณต๋ฐฑ์ด ์•„๋‹Œ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", SAME_START_END_STATION: "์„œ๋กœ ๋‹ค๋ฅธ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.", + DUPLICATED_START_END_STATION: "๊ธฐ์กด ๋…ธ์„ ๊ณผ ๋‹ค๋ฅธ ์ƒํ–‰, ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.", + DUPLICATED_LINE_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ NOT_INTEGER_ORDER: "1 ์ด์ƒ ์ •์ˆ˜์˜ ์ˆœ์„œ๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", diff --git a/src/util/validation.js b/src/util/validation.js index 2fc6ed235..dc8e6afbb 100644 --- a/src/util/validation.js +++ b/src/util/validation.js @@ -15,7 +15,7 @@ export const StationValidation = { } if (!this.isNotDuplicated(name)) { - alert(ErrorMessage.DUPLICATED_NAME); + alert(ErrorMessage.DUPLICATED_STATION_NAME); return; } @@ -60,7 +60,7 @@ export const LineValidation = { } if (!this.isNotDuplicated(name)) { - alert(ErrorMessage.DUPLICATED_NAME); + alert(ErrorMessage.DUPLICATED_LINE_NAME); return; } @@ -69,12 +69,18 @@ export const LineValidation = { }, hasValidStartEndStations(start, end) { - if (start === end) { + if (this.isSameStartEndStation(start, end)) { alert(ErrorMessage.SAME_START_END_STATION); return; } + if (this.isDuplicatedStartEndStation(start, end)) { + alert(ErrorMessage.DUPLICATED_START_END_STATION); + + return; + } + return true; }, @@ -87,6 +93,28 @@ export const LineValidation = { return !stationNameArray.includes(name); }, + + isSameStartEndStation(start, end) { + return start === end; + }, + + isDuplicatedStartEndStation(start, end) { + let isValid = false; + + Line.lines.forEach(({ stations }) => { + if (stations[0] === start) { + isValid = true; + } + if (stations[stations.length - 1] === end) { + isValid = true; + } + if (stations[0] === end && stations[stations.length - 1] === start) { + isValid = true; + } + }); + + return isValid; + } }; export const SectionValidation = { @@ -99,7 +127,7 @@ export const SectionValidation = { hasValidName(station, selectedLine) { if (!this.isNotDuplicated(station, selectedLine)) { - alert(ErrorMessage.DUPLICATED_NAME); + alert(ErrorMessage.DUPLICATED_STATION_NAME); return; } From acfd94caf642a6434612d235fe4e13405490c68f Mon Sep 17 00:00:00 2001 From: jum0 Date: Tue, 15 Dec 2020 20:07:47 +0900 Subject: [PATCH 28/28] =?UTF-8?q?refactor=20:=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/constant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/constant.js b/src/util/constant.js index cffe4378e..d76025eab 100644 --- a/src/util/constant.js +++ b/src/util/constant.js @@ -56,7 +56,7 @@ export const ErrorMessage = { // ๋…ธ์„  ๊ด€๋ฆฌ NAME_WHITE_SPACE: "๊ณต๋ฐฑ์ด ์•„๋‹Œ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", SAME_START_END_STATION: "์„œ๋กœ ๋‹ค๋ฅธ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.", - DUPLICATED_START_END_STATION: "๊ธฐ์กด ๋…ธ์„ ๊ณผ ๋‹ค๋ฅธ ์ƒํ–‰, ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.", + DUPLICATED_START_END_STATION: "๊ธฐ์กด ๋…ธ์„ ๊ณผ ๋‹ค๋ฅธ ์ƒํ–‰, ํ•˜ํ–‰ ์ข…์ ์„ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.\n๋˜ํ•œ, ์ข…์  ๋ฐฉํ–ฅ๋งŒ ๋‹ค๋ฅธ ๊ฒฝ์šฐ ๋™์ผํ•œ ๋…ธ์„ ์œผ๋กœ ๊ฐ„์ฃผ๋ฉ๋‹ˆ๋‹ค.", DUPLICATED_LINE_NAME: "์ค‘๋ณต๋˜์ง€ ์•Š์€ ๋…ธ์„  ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.", // ๊ตฌ๊ฐ„ ๊ด€๋ฆฌ
    ${i} ${stationArray[i]} -