`;
From 1f8038c727a0b5fc9e6babeee5aeb18a39b941fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EA=B6=8C=EC=84=B8=EC=A7=84?= <0307kwon@gmail.com>
Date: Sat, 12 Dec 2020 20:57:29 +0900
Subject: [PATCH 44/82] =?UTF-8?q?feat:=20=EC=84=A0=ED=83=9D=EB=90=9C=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=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=97=AD?=
=?UTF-8?q?=EB=93=A4=EB=A7=8C=20=EC=BD=A4=EB=B3=B4=20=EB=B0=95=EC=8A=A4?=
=?UTF-8?q?=EC=9D=98=20=EC=98=B5=EC=85=98=EC=9C=BC=EB=A1=9C=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
---
src/station-info-manager.js | 9 ++++++
src/ui/contents-ui/line-manager-ui.js | 33 ++++++++++-----------
src/ui/contents-ui/section-manager-ui.js | 37 ++++++++++++++++++++----
src/ui/contents-ui/station-manager-ui.js | 4 +--
4 files changed, 58 insertions(+), 25 deletions(-)
diff --git a/src/station-info-manager.js b/src/station-info-manager.js
index 0940ccf2b..2f606e3cb 100644
--- a/src/station-info-manager.js
+++ b/src/station-info-manager.js
@@ -11,6 +11,15 @@ export default class StationINFOManager {
};
this.stations_.push(newStation);
}
+ getStationsByCondition(condition) {
+ const returnStations = [];
+ this.stations_.forEach((station) => {
+ if (condition(station)) {
+ returnStations.push(station.name);
+ }
+ });
+ return returnStations;
+ }
getStationsNames() {
const stationNames = [];
this.stations_.forEach(({ name }) => {
diff --git a/src/ui/contents-ui/line-manager-ui.js b/src/ui/contents-ui/line-manager-ui.js
index 96c5c7427..3a3c52dbe 100644
--- a/src/ui/contents-ui/line-manager-ui.js
+++ b/src/ui/contents-ui/line-manager-ui.js
@@ -23,7 +23,7 @@ export default class LineManagerUI {
const tableContainer = document.getElementById(TABLE_ID);
let innerHTMLOfTable = TABLE_HEADER_TEMPLATE;
linesINFOs.forEach((lineINFOs) => {
- innerHTMLOfTable += this.createNewTableRowHTML_(lineINFOs);
+ innerHTMLOfTable += this.makeNewTableRowHTML_(lineINFOs);
});
tableContainer.innerHTML = innerHTMLOfTable;
this.addEventToAllTableDeleteButton_();
@@ -31,20 +31,7 @@ export default class LineManagerUI {
setStationSelector_(selectorID) {
const selector = document.getElementById(selectorID);
- selector.innerHTML = this.createSelectorInnerHTML_();
- }
- createSelectorInnerHTML_() {
- const stationNames = this.stationINFOManager_.getStationsNames();
- let selectorInnerHTML = "";
- stationNames.forEach((name) => {
- selectorInnerHTML += this.createNewSelectorOptionHTML_(name);
- });
- return selectorInnerHTML;
- }
- createNewSelectorOptionHTML_(name) {
- return `
-
- `;
+ selector.innerHTML = this.makeSelectorInnerHTML_();
}
addEventToLineAddButton_() {
const button = document.getElementById(LINE_ADD_BUTTON_ID);
@@ -67,7 +54,6 @@ export default class LineManagerUI {
this.updateLinesTable();
});
}
-
isValidLineInput_(lineName, startStationName, endStationName) {
const condition1 = isValidLine(lineName, startStationName, endStationName);
const condition2 = this.stationINFOManager_.isNotOverlapNameInLinesArray(lineName);
@@ -93,7 +79,7 @@ export default class LineManagerUI {
});
});
}
- createNewTableRowHTML_({ name, startStationName, endStationName }) {
+ makeNewTableRowHTML_({ name, startStationName, endStationName }) {
return `
`;
}
+ makeSelectorInnerHTML_() {
+ const stationNames = this.stationINFOManager_.getStationsNames();
+ let selectorInnerHTML = "";
+ stationNames.forEach((name) => {
+ selectorInnerHTML += this.makeNewSelectorOptionHTML_(name);
+ });
+ return selectorInnerHTML;
+ }
+ makeNewSelectorOptionHTML_(name) {
+ return `
+
+ `;
+ }
}
const NAME_INPUT_ID = "line-name-input";
diff --git a/src/ui/contents-ui/section-manager-ui.js b/src/ui/contents-ui/section-manager-ui.js
index 6bd84df99..cfc3ab2cc 100644
--- a/src/ui/contents-ui/section-manager-ui.js
+++ b/src/ui/contents-ui/section-manager-ui.js
@@ -27,7 +27,10 @@ export default class SectionManagerUI {
);
Array.prototype.forEach.call(buttons, (button) => {
button.addEventListener("click", (e) => {
- this.sectionRegisterUI = new SectionRegisterUI(e.target.dataset.name);
+ this.sectionRegisterUI = new SectionRegisterUI(
+ e.target.dataset.name,
+ this.stationINFOManager_
+ );
});
});
}
@@ -39,26 +42,48 @@ export default class SectionManagerUI {
}
class SectionRegisterUI {
- constructor(lineName) {
- this.lineName = lineName;
+ constructor(lineName, stationINFOManager) {
+ this.lineName_ = lineName;
+ this.stationINFOManager_ = stationINFOManager;
this.setContentsHTML();
}
setContentsHTML() {
const manageDiv = document.getElementById(SECTION_REGISTER_DIV_ID);
manageDiv.innerHTML =
- this.makeTitleHTML(this.lineName) + SECTION_REGISTER_TEMPLATE;
+ this.makeTitleHTML_(this.lineName_) + SECTION_REGISTER_TEMPLATE;
+ this.setComboboxOption_();
+ }
+ setComboboxOption_() {
+ const seletor = document.getElementById(SECTION_STATION_SELECTOR_ID);
+ const optionNames = this.stationINFOManager_.getStationsByCondition(
+ (station) => {
+ return !station.linesOfStation.has(this.lineName_);
+ }
+ );
+ let seletorInnerHTML = "";
+ optionNames.forEach((optionName) => {
+ seletorInnerHTML += this.makeNewOptionHTML_(optionName);
+ });
+ seletor.innerHTML = seletorInnerHTML;
+ }
+
+ makeNewOptionHTML_(name) {
+ return `
+
+ `;
}
- makeTitleHTML(name) {
+ makeTitleHTML_(name) {
return `${name} ๊ด๋ฆฌ`;
}
}
const SECTION_REGISTER_DIV_ID = "section-register-div";
+const SECTION_STATION_SELECTOR_ID = "section-station-selector";
const SECTION_REGISTER_TEMPLATE = `
๊ตฌ๊ฐ ๋ฑ๋ก
-