Drop target rel path field from script upload
Every T5 script lands in the flat sp/ directory, so the target path is always just the uploaded filename. Removed the field from the Scripts upload form and the server derives targetRelPath from file.name. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
|
||||
// Form state for creating a new script.
|
||||
let newName = $state('');
|
||||
let newTargetRelPath = $state('');
|
||||
let newScopeType = $state<'none' | 'game' | 'map'>('none');
|
||||
let newScopeValue = $state('');
|
||||
let newFile = $state<File | null>(null);
|
||||
@@ -45,18 +44,18 @@
|
||||
function pickFile(e: Event): void {
|
||||
const t = e.target as HTMLInputElement;
|
||||
newFile = t.files?.[0] ?? null;
|
||||
if (!newTargetRelPath && newFile) newTargetRelPath = newFile.name;
|
||||
// Every T5 script lands in a flat sp/ directory, so target rel path is
|
||||
// just the filename — no need to ask the user.
|
||||
if (!newName && newFile) newName = newFile.name.replace(/\.[^.]+$/, '');
|
||||
}
|
||||
|
||||
async function createScript(e: Event): Promise<void> {
|
||||
e.preventDefault();
|
||||
if (uploading || !newFile || !newName.trim() || !newTargetRelPath.trim()) return;
|
||||
if (uploading || !newFile || !newName.trim()) return;
|
||||
uploading = true;
|
||||
flash = null;
|
||||
const form = new FormData();
|
||||
form.append('name', newName.trim());
|
||||
form.append('targetRelPath', newTargetRelPath.trim());
|
||||
form.append('scopeType', newScopeType);
|
||||
if (newScopeValue.trim()) form.append('scopeValue', newScopeValue.trim());
|
||||
if (newNotes.trim()) form.append('notes', newNotes.trim());
|
||||
@@ -69,7 +68,6 @@
|
||||
return;
|
||||
}
|
||||
newName = '';
|
||||
newTargetRelPath = '';
|
||||
newScopeType = 'none';
|
||||
newScopeValue = '';
|
||||
newNotes = '';
|
||||
@@ -95,10 +93,6 @@
|
||||
<span class="k">name</span>
|
||||
<input type="text" bind:value={newName} placeholder="hud tweaks" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">target rel path</span>
|
||||
<input type="text" bind:value={newTargetRelPath} placeholder="maps/mp_zom_theater/hud.gsc" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">scope</span>
|
||||
<div class="scope-row">
|
||||
@@ -120,7 +114,7 @@
|
||||
<span class="k">file</span>
|
||||
<input type="file" onchange={pickFile} disabled={uploading} />
|
||||
</label>
|
||||
<button type="submit" class="primary" disabled={uploading || !newFile || !newName || !newTargetRelPath}>
|
||||
<button type="submit" class="primary" disabled={uploading || !newFile || !newName}>
|
||||
{uploading ? 'uploading…' : 'upload script'}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user