@using Rms.Risk.Mango.Pivot.Core
@*
* dbMango
*
* Copyright 2025 Deutsche Bank AG
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*@
@code {
[Parameter] public string Class { get; set; } = "";
[Parameter]
public PivotDefinition? Pivot
{
get;
set
{
if (field == value)
return;
field = value;
CurrentDrilldownDef = field?.Drilldown.FirstOrDefault();
InvokeAsync(StateHasChanged);
}
} = null!;
[Parameter] public List AllPivots { get; set; } = [];
private PivotDefinition.DrilldownDef? CurrentDrilldownDef { get; set; }
private string CurrentField => CurrentDrilldownDef?.ColumnName ?? "";
private string _rowClass = "";
private Task SelectDrilldown(PivotDefinition.DrilldownDef? d)
{
if (d == null)
return Task.CompletedTask;
CurrentDrilldownDef = d;
return InvokeAsync(StateHasChanged);
}
private Task SelectDrilldownPivot(string? pivotName)
{
if (CurrentDrilldownDef == null)
return Task.CompletedTask;
CurrentDrilldownDef.DrilldownPivot = pivotName ?? Pivot?.Name ?? "";
return InvokeAsync(StateHasChanged);
}
private Task OnDelete()
{
if (IsDeleteDisabled || Pivot == null)
return Task.CompletedTask;
Pivot.Drilldown.Remove(CurrentDrilldownDef!);
CurrentDrilldownDef = Pivot.Drilldown.FirstOrDefault();
return InvokeAsync(StateHasChanged);
}
public bool IsDeleteDisabled => (Pivot?.Drilldown?.Count ?? 0) == 0;
private Task OnAdd()
{
if (Pivot == null)
return Task.CompletedTask;
var d = new PivotDefinition.DrilldownDef
{
ColumnName = "Type column name here",
DrilldownPivot = Pivot.Name
};
Pivot.Drilldown.Add(d);
CurrentDrilldownDef = d;
return InvokeAsync(StateHasChanged);
}
}