From a0ebb4e149670a59b5fd6a02dac7bf2bcec56f76 Mon Sep 17 00:00:00 2001 From: Christian Bastian Date: Tue, 27 Feb 2024 18:18:11 -0500 Subject: [PATCH] Old model name in rename window prompt. --- web/model-manager.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/model-manager.js b/web/model-manager.js index d69ea05..fcfc111 100644 --- a/web/model-manager.js +++ b/web/model-manager.js @@ -1617,18 +1617,18 @@ class ModelInfoView { $el("button.icon-button", { textContent: "✎", onclick: async(e) => { - const name = window.prompt("New model name:"); + const container = this.elements.info; + const oldFile = container.dataset.path; + const [oldFilePath, oldFileName] = SearchPath.split(oldFile); + const oldName = SearchPath.splitExtension(oldFileName)[0]; + const newName = window.prompt("New model name:", oldName); let renamed = false; - if (name !== null && name !== "") { - const container = this.elements.info; - const oldFile = container.dataset.path; - const [oldFilePath, oldFileName] = SearchPath.split(oldFile); - const [_, extension] = SearchPath.splitExtension(oldFile); + if (newName !== null && newName !== "" && newName != oldName) { const newFile = ( oldFilePath + searchSeparator + - name + - extension + newName + + SearchPath.splitExtension(oldFile)[1] ); renamed = await request( `/model-manager/model/move`,