Skip to content

Commit

Permalink
Pass panelLock on serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
slavamuravey committed Aug 5, 2024
1 parent bd59522 commit 741c1ef
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 38 deletions.
12 changes: 6 additions & 6 deletions es/DockData.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ export interface PanelBase {
w?: number;
/** float mode only */
h?: number;
/**
* addition information of a panel,
* This prevents the panel from being removed when there is no tab inside
* a locked panel can not be moved to float layer either
*/
panelLock?: PanelLock;
}
export interface BoxBase {
/**
Expand Down Expand Up @@ -204,12 +210,6 @@ interface PanelLock {
export interface PanelData extends PanelBase, BoxChild {
parent?: BoxData;
tabs: TabData[];
/**
* addition information of a panel,
* This prevents the panel from being removed when there is no tab inside
* a locked panel can not be moved to float layer either
*/
panelLock?: PanelLock;
}
export interface TabPaneCache {
id: string;
Expand Down
12 changes: 6 additions & 6 deletions es/Serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export function saveLayoutData(layout, saveTab, afterPanelSaved) {
tabs.push(savedTab);
}
}
let { id, size, activeId, group } = panelData;
let { id, size, activeId, group, panelLock } = panelData;
let savedPanel;
if (panelData.parent.mode === 'float' || panelData.parent.mode === 'window') {
let { x, y, z, w, h } = panelData;
savedPanel = { id, size, tabs, group, activeId, x, y, z, w, h };
savedPanel = { id, size, tabs, group, activeId, panelLock, x, y, z, w, h };
}
else {
savedPanel = { id, size, tabs, group, activeId };
savedPanel = { id, size, tabs, group, activeId, panelLock };
}
if (afterPanelSaved) {
afterPanelSaved(savedPanel, panelData);
Expand Down Expand Up @@ -97,7 +97,7 @@ export function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLo
return null;
}
function loadPanelData(savedPanel) {
let { id, size, activeId, x, y, z, w, h, group } = savedPanel;
let { id, size, activeId, x, y, z, w, h, group, panelLock } = savedPanel;
let tabs = [];
for (let savedTab of savedPanel.tabs) {
let tabData = loadTabData(savedTab);
Expand All @@ -107,10 +107,10 @@ export function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLo
}
let panelData;
if (w || h || x || y || z) {
panelData = { id, size, activeId, group, x, y, z, w, h, tabs };
panelData = { id, size, activeId, group, x, y, z, w, h, tabs, panelLock };
}
else {
panelData = { id, size, activeId, group, tabs };
panelData = { id, size, activeId, group, tabs, panelLock };
}
if (savedPanel.id === maximePlaceHolderId) {
panelData.panelLock = {};
Expand Down
12 changes: 6 additions & 6 deletions lib/DockData.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ export interface PanelBase {
w?: number;
/** float mode only */
h?: number;
/**
* addition information of a panel,
* This prevents the panel from being removed when there is no tab inside
* a locked panel can not be moved to float layer either
*/
panelLock?: PanelLock;
}
export interface BoxBase {
/**
Expand Down Expand Up @@ -204,12 +210,6 @@ interface PanelLock {
export interface PanelData extends PanelBase, BoxChild {
parent?: BoxData;
tabs: TabData[];
/**
* addition information of a panel,
* This prevents the panel from being removed when there is no tab inside
* a locked panel can not be moved to float layer either
*/
panelLock?: PanelLock;
}
export interface TabPaneCache {
id: string;
Expand Down
12 changes: 6 additions & 6 deletions lib/Serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ function saveLayoutData(layout, saveTab, afterPanelSaved) {
tabs.push(savedTab);
}
}
let { id, size, activeId, group } = panelData;
let { id, size, activeId, group, panelLock } = panelData;
let savedPanel;
if (panelData.parent.mode === 'float' || panelData.parent.mode === 'window') {
let { x, y, z, w, h } = panelData;
savedPanel = { id, size, tabs, group, activeId, x, y, z, w, h };
savedPanel = { id, size, tabs, group, activeId, panelLock, x, y, z, w, h };
}
else {
savedPanel = { id, size, tabs, group, activeId };
savedPanel = { id, size, tabs, group, activeId, panelLock };
}
if (afterPanelSaved) {
afterPanelSaved(savedPanel, panelData);
Expand Down Expand Up @@ -102,7 +102,7 @@ function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLoaded) {
return null;
}
function loadPanelData(savedPanel) {
let { id, size, activeId, x, y, z, w, h, group } = savedPanel;
let { id, size, activeId, x, y, z, w, h, group, panelLock } = savedPanel;
let tabs = [];
for (let savedTab of savedPanel.tabs) {
let tabData = loadTabData(savedTab);
Expand All @@ -112,10 +112,10 @@ function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLoaded) {
}
let panelData;
if (w || h || x || y || z) {
panelData = { id, size, activeId, group, x, y, z, w, h, tabs };
panelData = { id, size, activeId, group, x, y, z, w, h, tabs, panelLock };
}
else {
panelData = { id, size, activeId, group, tabs };
panelData = { id, size, activeId, group, tabs, panelLock };
}
if (savedPanel.id === DockData_1.maximePlaceHolderId) {
panelData.panelLock = {};
Expand Down
15 changes: 7 additions & 8 deletions src/DockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export interface PanelBase {
w?: number;
/** float mode only */
h?: number;

/**
* addition information of a panel,
* This prevents the panel from being removed when there is no tab inside
* a locked panel can not be moved to float layer either
*/
panelLock?: PanelLock; // if not null, panel won't disappear even when all children are gone
}

export interface BoxBase {
Expand Down Expand Up @@ -244,14 +251,6 @@ export interface PanelData extends PanelBase, BoxChild {

tabs: TabData[];

/**
* addition information of a panel,
* This prevents the panel from being removed when there is no tab inside
* a locked panel can not be moved to float layer either
*/
panelLock?: PanelLock; // if not null, panel won't disappear even when all children are gone


}

export interface TabPaneCache {
Expand Down
12 changes: 6 additions & 6 deletions src/Serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export function saveLayoutData(
tabs.push(savedTab);
}
}
let {id, size, activeId, group} = panelData;
let {id, size, activeId, group, panelLock} = panelData;
let savedPanel: PanelBase;
if (panelData.parent.mode === 'float' || panelData.parent.mode === 'window') {
let {x, y, z, w, h} = panelData;
savedPanel = {id, size, tabs, group, activeId, x, y, z, w, h};
savedPanel = {id, size, tabs, group, activeId, panelLock, x, y, z, w, h};
} else {
savedPanel = {id, size, tabs, group, activeId};
savedPanel = {id, size, tabs, group, activeId, panelLock};
}
if (afterPanelSaved) {
afterPanelSaved(savedPanel, panelData);
Expand Down Expand Up @@ -124,7 +124,7 @@ export function loadLayoutData(
}

function loadPanelData(savedPanel: PanelBase): PanelData {
let {id, size, activeId, x, y, z, w, h, group} = savedPanel;
let {id, size, activeId, x, y, z, w, h, group, panelLock} = savedPanel;

let tabs: TabData[] = [];
for (let savedTab of savedPanel.tabs) {
Expand All @@ -135,9 +135,9 @@ export function loadLayoutData(
}
let panelData: PanelData;
if (w || h || x || y || z) {
panelData = {id, size, activeId, group, x, y, z, w, h, tabs};
panelData = {id, size, activeId, group, x, y, z, w, h, tabs, panelLock};
} else {
panelData = {id, size, activeId, group, tabs};
panelData = {id, size, activeId, group, tabs, panelLock};
}
if (savedPanel.id === maximePlaceHolderId) {
panelData.panelLock = {};
Expand Down

0 comments on commit 741c1ef

Please sign in to comment.