fix(adminui): auto-generate ScriptId (SC-…) + drop the Language picker on ScriptEdit
v2-ci / build (push) Failing after 39s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
v2-ci / build (push) Failing after 39s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
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.
This commit is contained in:
@@ -35,20 +35,19 @@ else
|
|||||||
<div class="panel-head">Identity</div>
|
<div class="panel-head">Identity</div>
|
||||||
<div style="padding:1rem">
|
<div style="padding:1rem">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
@* ScriptId is system-generated (SC-…) on create, never operator-supplied —
|
||||||
<label class="form-label">ScriptId</label>
|
shown read-only when editing an existing script, hidden on the New page. *@
|
||||||
<InputText @bind-Value="_form.ScriptId" disabled="@(!IsNew)" class="form-control form-control-sm mono" />
|
@if (!IsNew)
|
||||||
</div>
|
{
|
||||||
<div class="col-md-4 mb-3">
|
<div class="col-md-5 mb-3">
|
||||||
|
<label class="form-label">ScriptId</label>
|
||||||
|
<input value="@_form.ScriptId" disabled class="form-control form-control-sm mono" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="@(IsNew ? "col-md-12" : "col-md-7") mb-3">
|
||||||
<label class="form-label">Name</label>
|
<label class="form-label">Name</label>
|
||||||
<InputText @bind-Value="_form.Name" class="form-control form-control-sm" />
|
<InputText @bind-Value="_form.Name" class="form-control form-control-sm" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
|
||||||
<label class="form-label">Language</label>
|
|
||||||
<InputSelect @bind-Value="_form.Language" class="form-select form-select-sm">
|
|
||||||
<option value="CSharp">CSharp</option>
|
|
||||||
</InputSelect>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -93,7 +92,6 @@ else
|
|||||||
{
|
{
|
||||||
ScriptId = _existing.ScriptId,
|
ScriptId = _existing.ScriptId,
|
||||||
Name = _existing.Name,
|
Name = _existing.Name,
|
||||||
Language = _existing.Language,
|
|
||||||
SourceCode = _existing.SourceCode,
|
SourceCode = _existing.SourceCode,
|
||||||
RowVersion = _existing.RowVersion,
|
RowVersion = _existing.RowVersion,
|
||||||
};
|
};
|
||||||
@@ -111,13 +109,13 @@ else
|
|||||||
await using var db = await DbFactory.CreateDbContextAsync();
|
await using var db = await DbFactory.CreateDbContextAsync();
|
||||||
if (IsNew)
|
if (IsNew)
|
||||||
{
|
{
|
||||||
if (await db.Scripts.AnyAsync(s => s.ScriptId == _form.ScriptId))
|
// ScriptId is system-generated (mirrors EquipmentId's "EQ-{12 hex}" convention);
|
||||||
{ _error = $"Script '{_form.ScriptId}' already exists."; return; }
|
// Language is always CSharp.
|
||||||
db.Scripts.Add(new Script
|
db.Scripts.Add(new Script
|
||||||
{
|
{
|
||||||
ScriptId = _form.ScriptId,
|
ScriptId = $"SC-{Guid.NewGuid().ToString("N")[..12]}",
|
||||||
Name = _form.Name,
|
Name = _form.Name,
|
||||||
Language = _form.Language,
|
Language = "CSharp",
|
||||||
SourceCode = _form.SourceCode,
|
SourceCode = _form.SourceCode,
|
||||||
SourceHash = sourceHash,
|
SourceHash = sourceHash,
|
||||||
});
|
});
|
||||||
@@ -128,7 +126,6 @@ else
|
|||||||
if (entity is null) { _error = "Row no longer exists."; return; }
|
if (entity is null) { _error = "Row no longer exists."; return; }
|
||||||
db.Entry(entity).Property(e => e.RowVersion).OriginalValue = _form.RowVersion;
|
db.Entry(entity).Property(e => e.RowVersion).OriginalValue = _form.RowVersion;
|
||||||
entity.Name = _form.Name;
|
entity.Name = _form.Name;
|
||||||
entity.Language = _form.Language;
|
|
||||||
entity.SourceCode = _form.SourceCode;
|
entity.SourceCode = _form.SourceCode;
|
||||||
entity.SourceHash = sourceHash;
|
entity.SourceHash = sourceHash;
|
||||||
}
|
}
|
||||||
@@ -164,9 +161,9 @@ else
|
|||||||
|
|
||||||
private sealed class FormModel
|
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 Name { get; set; } = "";
|
||||||
[Required] public string Language { get; set; } = "CSharp";
|
|
||||||
[Required] public string SourceCode { get; set; } = "";
|
[Required] public string SourceCode { get; set; } = "";
|
||||||
public byte[] RowVersion { get; set; } = [];
|
public byte[] RowVersion { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user