Skip to content

Commit 28bc767

Browse files
committed
Switch to custom vex prompt
1 parent c493cb3 commit 28bc767

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/renderer/components/HelmetProject/HelmetProject.jsx

+33-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ const HelmetProject = ({
5454

5555
const _handleClickNewScenario = () => {
5656
const promptCreation = (previousError) => {
57-
vex.dialog.prompt({
57+
vex.dialog.open({
5858
message: (previousError ? previousError : "") + "Anna uuden skenaarion nimike:",
59-
placeholder: '',
59+
input: `
60+
<div class="vex-custom-field-wrapper">
61+
<div class="vex-custom-input-wrapper">
62+
<input name="scenarioName" type="text" value="" autofocus />
63+
</div>
64+
</div>
65+
`,
6066
callback: (inputScenarioName) => {
6167
let error = "";
6268
// Check for cancel button press
@@ -78,7 +84,31 @@ const HelmetProject = ({
7884
}
7985
}
8086
});
81-
document.getElementsByName("vex")[0].focus();
87+
/* vex.dialog.prompt({
88+
message: (previousError ? previousError : "") + "Anna uuden skenaarion nimike:",
89+
placeholder: '',
90+
callback: (inputScenarioName) => {
91+
let error = "";
92+
// Check for cancel button press
93+
if (inputScenarioName === false) {
94+
return;
95+
}
96+
// Check input for initial errors
97+
if (inputScenarioName === "") {
98+
error = "Nimike on pakollinen, tallennettavaa tiedostonime\u00e4 varten. ";
99+
}
100+
if (scenarios.map((s) => s.name).includes(inputScenarioName)) {
101+
error = "Nimike on jo olemassa, valitse toinen nimi tai poista olemassa oleva ensin. ";
102+
}
103+
// Handle recursively any input errors (mandated by the async library since prompt isn't natively supported in Electron)
104+
if (error) {
105+
promptCreation(error);
106+
} else {
107+
_createScenario(inputScenarioName);
108+
}
109+
}
110+
}); */
111+
// document.getElementsByName("vex")[0].focus();
82112
};
83113
promptCreation();
84114
};

0 commit comments

Comments
 (0)