From ac1e1dfd12fbde7de18af4a78dfc163170477c6a Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 10 Jun 2026 09:07:38 -0400 Subject: [PATCH] =?UTF-8?q?fix(adminui):=20auto-generate=20ScriptId=20(SC-?= =?UTF-8?q?=E2=80=A6)=20+=20drop=20the=20Language=20picker=20on=20ScriptEd?= =?UTF-8?q?it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ScriptId is now system-generated on create (mirrors EquipmentId's EQ-{12 hex} convention, never operator-supplied) and shown read-only when editing. Language is always CSharp, so the single-option dropdown is removed entirely and set on save. --- .../Components/Pages/ScriptEdit.razor | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/ScriptEdit.razor b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/ScriptEdit.razor index 0010d172..21cbd53c 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/ScriptEdit.razor +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/ScriptEdit.razor @@ -35,20 +35,19 @@ else
Identity
-
- - -
-
+ @* ScriptId is system-generated (SC-…) on create, never operator-supplied — + shown read-only when editing an existing script, hidden on the New page. *@ + @if (!IsNew) + { +
+ + +
+ } +
-
- - - - -
@@ -93,7 +92,6 @@ else { ScriptId = _existing.ScriptId, Name = _existing.Name, - Language = _existing.Language, SourceCode = _existing.SourceCode, RowVersion = _existing.RowVersion, }; @@ -111,13 +109,13 @@ else await using var db = await DbFactory.CreateDbContextAsync(); if (IsNew) { - if (await db.Scripts.AnyAsync(s => s.ScriptId == _form.ScriptId)) - { _error = $"Script '{_form.ScriptId}' already exists."; return; } + // ScriptId is system-generated (mirrors EquipmentId's "EQ-{12 hex}" convention); + // Language is always CSharp. db.Scripts.Add(new Script { - ScriptId = _form.ScriptId, + ScriptId = $"SC-{Guid.NewGuid().ToString("N")[..12]}", Name = _form.Name, - Language = _form.Language, + Language = "CSharp", SourceCode = _form.SourceCode, SourceHash = sourceHash, }); @@ -128,7 +126,6 @@ else if (entity is null) { _error = "Row no longer exists."; return; } db.Entry(entity).Property(e => e.RowVersion).OriginalValue = _form.RowVersion; entity.Name = _form.Name; - entity.Language = _form.Language; entity.SourceCode = _form.SourceCode; entity.SourceHash = sourceHash; } @@ -164,9 +161,9 @@ else private sealed class FormModel { - [Required, RegularExpression("^[A-Za-z0-9_-]+$")] public string ScriptId { get; set; } = ""; + // ScriptId is system-generated, display-only (not user-entered) — no validation. + public string ScriptId { get; set; } = ""; [Required] public string Name { get; set; } = ""; - [Required] public string Language { get; set; } = "CSharp"; [Required] public string SourceCode { get; set; } = ""; public byte[] RowVersion { get; set; } = []; }