From e0adac3735d0e371f3f5cca3210d4614576236ee Mon Sep 17 00:00:00 2001 From: dje Date: Sun, 22 Mar 2020 20:09:27 +0100 Subject: [PATCH 1/2] Optimization State Form Add Mode (#415) (#416) --- modules/ui/states-editor.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/ui/states-editor.js b/modules/ui/states-editor.js index 144f03f9..17b3e149 100644 --- a/modules/ui/states-editor.js +++ b/modules/ui/states-editor.js @@ -217,6 +217,15 @@ function editStates() { } function editStateName(state) { + + //Reset input value and close add mode + stateNameEditorCustomForm.value = ""; + const addModeActive = stateNameEditorCustomForm.style.display === "inline-block"; + if (addModeActive) { + stateNameEditorCustomForm.style.display = "none"; + stateNameEditorSelectForm.style.display = "inline-block"; + } + const s = pack.states[state]; document.getElementById("stateNameEditor").dataset.state = state; document.getElementById("stateNameEditorShort").value = s.name || ""; @@ -254,10 +263,11 @@ function editStates() { function addCustomForm() { const value = stateNameEditorCustomForm.value; - const displayed = stateNameEditorCustomForm.style.display === "inline-block"; - stateNameEditorCustomForm.style.display = displayed ? "none" : "inline-block"; - stateNameEditorSelectForm.style.display = displayed ? "inline-block" : "none"; - if (displayed) applyOption(stateNameEditorSelectForm, value); + const addModeActive = stateNameEditorCustomForm.style.display === "inline-block"; + stateNameEditorCustomForm.style.display = addModeActive ? "none" : "inline-block"; + stateNameEditorSelectForm.style.display = addModeActive ? "inline-block" : "none"; + if (addModeActive) applyOption(stateNameEditorSelectForm, value); + stateNameEditorCustomForm.value = ""; } function regenerateFullName() { From 738ffee75f4adffc38c48f04707fa5efe229fdd3 Mon Sep 17 00:00:00 2001 From: dje Date: Sat, 28 Mar 2020 19:24:15 +0100 Subject: [PATCH 2/2] Enhancement (#420) * Optimization State Form Add Mode (#415) * Cannot sort list entries in diplomacy editor #419 --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index c698a03b..b6ec21d2 100644 --- a/index.html +++ b/index.html @@ -2777,6 +2777,8 @@
Relations 
+
+
Ally
Friendly
@@ -2789,8 +2791,6 @@
Suzerain
-
-