forked from jappel/leistungsbilanz-ts
Show circuit protection in saved layouts
This commit is contained in:
parent
f4bfef9071
commit
2964205a27
3 changed files with 87 additions and 7 deletions
|
|
@ -129,6 +129,8 @@ export const defaultVisibleColumnKeys = allColumns
|
|||
.map((column) => column.key);
|
||||
|
||||
const projectColumnLayoutStoragePrefix =
|
||||
"circuitTreeEditor.columnLayout.v3";
|
||||
const legacyProjectColumnLayoutStoragePrefix =
|
||||
"circuitTreeEditor.columnLayout.v2";
|
||||
|
||||
export interface CircuitColumnLayout {
|
||||
|
|
@ -162,6 +164,12 @@ export function getProjectColumnLayoutStorageKey(
|
|||
return `${projectColumnLayoutStoragePrefix}.${projectId}`;
|
||||
}
|
||||
|
||||
export function getLegacyProjectColumnLayoutStorageKey(
|
||||
projectId: string
|
||||
): string {
|
||||
return `${legacyProjectColumnLayoutStoragePrefix}.${projectId}`;
|
||||
}
|
||||
|
||||
export function normalizeColumnOrder(keys: CellKey[]): CellKey[] {
|
||||
const unique = [...new Set(keys)];
|
||||
const allKeys = allColumns.map((column) => column.key);
|
||||
|
|
@ -225,6 +233,28 @@ export function parseStoredColumnLayout(
|
|||
}
|
||||
}
|
||||
|
||||
export function migrateLegacyColumnLayout(
|
||||
layout: CircuitColumnLayout
|
||||
): CircuitColumnLayout {
|
||||
const newlyVisibleKey: CellKey = "protectionSummary";
|
||||
const order = layout.order.filter(
|
||||
(key) => key !== newlyVisibleKey
|
||||
) as CellKey[];
|
||||
const totalPowerIndex = order.indexOf("rowTotalPower");
|
||||
order.splice(
|
||||
totalPowerIndex >= 0 ? totalPowerIndex + 1 : order.length,
|
||||
0,
|
||||
newlyVisibleKey
|
||||
);
|
||||
|
||||
return {
|
||||
order,
|
||||
visible: layout.visible.includes(newlyVisibleKey)
|
||||
? layout.visible
|
||||
: [...layout.visible, newlyVisibleKey],
|
||||
};
|
||||
}
|
||||
|
||||
const deviceOnlyColumns = new Set<CellKey>([
|
||||
"quantity",
|
||||
"powerPerUnit",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue