Skip to content

Commit 93fb9ff

Browse files
committed
Simplify JS
1 parent 3da6d19 commit 93fb9ff

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

src/main/js/add-item.js

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,6 @@ document.addEventListener("DOMContentLoaded", () => {
214214
});
215215
});
216216

217-
// Focus
218-
document.querySelector("#add-item-panel #name").focus();
219-
220217
// Init NameField
221218
function nameFieldEvent() {
222219
if (!isItemNameEmpty()) {
@@ -259,44 +256,17 @@ document.addEventListener("DOMContentLoaded", () => {
259256
cleanItemSelection();
260257
copyRadio.setAttribute("checked", true);
261258
setFieldValidationStatus("from", true);
262-
if (!getFieldValidationStatus("name")) {
263-
setTimeout(function () {
264-
var parentName = copyFromInput.value;
265-
266-
fetch("job/" + parentName + "/api/json?tree=name").then(
267-
(response) => {
268-
response.json().then((data) => {
269-
if (data.name === parentName) {
270-
//if "name" is invalid, but "from" is a valid job, then switch focus to "name"
271-
nameInput.focus();
272-
}
273-
});
274-
},
275-
);
276-
}, 400);
277-
} else {
278-
refreshSubmitButtonState();
279-
}
259+
refreshSubmitButtonState();
280260
}
281261
}
282262

283263
copyFromInput?.addEventListener("blur", copyFromFieldEvent);
284264
copyFromInput?.addEventListener("input", copyFromFieldEvent);
285265

286-
// Client-side validation
287-
document
288-
.querySelector("#createItem")
289-
.addEventListener("submit", function (event) {
290-
if (!getFormValidationStatus()) {
291-
event.preventDefault();
292-
if (!getFieldValidationStatus("name")) {
293-
activateValidationMessage(getI18n("empty-name"));
294-
nameInput.focus();
295-
}
296-
}
297-
});
266+
// Focus the Name input on load
267+
document.querySelector("#add-item-panel #name").focus();
298268

299-
// Disable the submit button
269+
// Disable the Submit button on load
300270
refreshSubmitButtonState();
301271
});
302272

0 commit comments

Comments
 (0)