Path: redb/redb.PropsEditor/Components/RedbObjectEditor.razor Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.PropsEditor/Components/RedbObjectEditor.razor ---- @using redb.Core @using redb.Core.Models.Entities @using redb.PropsEditor.Services @using Microsoft.FluentUI.AspNetCore.Components @inject PropsMetadataService MetadataService @typeparam TProps where TProps : class, new() @* Full RedbObject editor with base fields + Props *@

@GetTypeName()

@if (ShowSaveButton) { @(IsSaving ? "Saving..." : "Save") }
@if (Value == null) {
No data to edit.
} else { @* Base Fields Section *@
@(baseFieldsCollapsed ? "▶" : "▼") Base Fields RedbObject
@if (!baseFieldsCollapsed) {
@* ID - read only *@
ID
@if (IsNew) { (New - auto) } else { }
@* name *@
name
@* value_string *@
value_string
@* value_long *@
value_long
@* parent_id *@
parent_id
@* key *@
key
@* note *@
note
@* Dates - read only *@ @if (!IsNew) {
date_create
@Value.date_create.ToString("yyyy-MM-dd HH:mm:ss")
date_modify
@Value.date_modify.ToString("yyyy-MM-dd HH:mm:ss")
}
}
@* Props Section *@
@(propsCollapsed ? "▶" : "▼") Properties @GetTypeName()
@if (!propsCollapsed) {
@foreach (var group in GetGroupedProperties()) { @if (string.IsNullOrEmpty(group.Key)) { @foreach (var prop in group) { } } else { var groupName = group.Key; var isExpanded = !collapsedGroups.Contains(groupName);
@(isExpanded ? "▼" : "▶") @groupName
@if (isExpanded) {
@foreach (var prop in group) { }
}
} }
}
}
@code { /// /// The RedbObject to edit. /// [Parameter] public RedbObject? Value { get; set; } /// /// Called when any value changes. /// [Parameter] public EventCallback> ValueChanged { get; set; } /// /// Called when Save button is clicked. /// [Parameter] public EventCallback OnSave { get; set; } /// /// Whether to show the Save button. /// [Parameter] public bool ShowSaveButton { get; set; } = true; /// /// Whether save is in progress. /// [Parameter] public bool IsSaving { get; set; } private bool baseFieldsCollapsed = false; private bool propsCollapsed = false; private HashSet collapsedGroups = []; private IEnumerable? properties; private bool IsNew => Value?.id == 0; protected override void OnParametersSet() { properties = MetadataService.GetProperties(); foreach (var prop in properties.Where(p => p.GroupCollapsed && !string.IsNullOrEmpty(p.GroupName))) { collapsedGroups.Add(prop.GroupName!); } } private string GetTypeName() => typeof(TProps).Name; private IEnumerable> GetGroupedProperties() { return properties? .GroupBy(p => p.GroupName) .OrderBy(g => string.IsNullOrEmpty(g.Key) ? 0 : 1) .ThenBy(g => g.Key) ?? Enumerable.Empty>(); } private void ToggleGroup(string groupName) { if (collapsedGroups.Contains(groupName)) collapsedGroups.Remove(groupName); else collapsedGroups.Add(groupName); } private async Task NotifyChanged() { if (Value != null) { await ValueChanged.InvokeAsync(Value); } } private async Task HandleSave() { await OnSave.InvokeAsync(); } }