mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
fixed page actions: sorting pages
This commit is contained in:
parent
3ba9b0d2f4
commit
97c8d9bf9a
2 changed files with 28 additions and 4 deletions
|
|
@ -86,6 +86,7 @@ const defaultDefinition = (darkMode) => {
|
|||
components: {},
|
||||
handle: 'home',
|
||||
name: 'Home',
|
||||
index: 0,
|
||||
},
|
||||
},
|
||||
globalSettings: {
|
||||
|
|
@ -1098,6 +1099,7 @@ const EditorComponent = (props) => {
|
|||
name,
|
||||
handle: newHandle,
|
||||
components: {},
|
||||
index: Object.keys(copyOfAppDefinition.pages).length,
|
||||
};
|
||||
|
||||
setCurrentPageId(newPageId);
|
||||
|
|
@ -1347,6 +1349,25 @@ const EditorComponent = (props) => {
|
|||
});
|
||||
};
|
||||
|
||||
const updateOnSortingPages = (newSortedPages) => {
|
||||
const copyOfAppDefinition = JSON.parse(JSON.stringify(appDefinition));
|
||||
const pagesObj = newSortedPages.reduce((acc, page, index) => {
|
||||
acc[page.id] = {
|
||||
...page,
|
||||
index: index,
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const newAppDefinition = _.cloneDeep(copyOfAppDefinition);
|
||||
|
||||
newAppDefinition.pages = pagesObj;
|
||||
|
||||
appDefinitionChanged(newAppDefinition, {
|
||||
pageDefinitionChanged: true,
|
||||
});
|
||||
};
|
||||
|
||||
// !-------
|
||||
|
||||
const currentState = props?.currentState;
|
||||
|
|
@ -1383,7 +1404,7 @@ const EditorComponent = (props) => {
|
|||
<EditorHeader
|
||||
darkMode={props.darkMode}
|
||||
globalSettingsChanged={globalSettingsChanged}
|
||||
appDefinition={appDefinition}
|
||||
appDefinition={_.cloneDeep(appDefinition)}
|
||||
toggleAppMaintenance={toggleAppMaintenance}
|
||||
editingVersion={editingVersion}
|
||||
app={app}
|
||||
|
|
@ -1437,7 +1458,7 @@ const EditorComponent = (props) => {
|
|||
updatePageHandle={updatePageHandle}
|
||||
// updateOnPageLoadEvents={updateOnPageLoadEvents}
|
||||
// showHideViewerNavigationControls={showHideViewerNavigation}
|
||||
// updateOnSortingPages={updateOnSortingPages}
|
||||
updateOnSortingPages={updateOnSortingPages}
|
||||
setEditorMarginLeft={handleEditorMarginLeftChange}
|
||||
/>
|
||||
{!props.showComments && (
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ export const LeftSidebar = forwardRef((props, ref) => {
|
|||
dataSourcesChanged,
|
||||
globalDataSourcesChanged,
|
||||
dataQueriesChanged,
|
||||
|
||||
appDefinition,
|
||||
setSelectedComponent,
|
||||
removeComponent,
|
||||
|
|
@ -145,7 +144,11 @@ export const LeftSidebar = forwardRef((props, ref) => {
|
|||
updateHomePage={updateHomePage}
|
||||
updatePageHandle={updatePageHandle}
|
||||
clonePage={clonePage}
|
||||
pages={Object.entries(appDefinition.pages).map(([id, page]) => ({ id, ...page })) || []}
|
||||
pages={
|
||||
Object.entries(_.cloneDeep(appDefinition).pages)
|
||||
.map(([id, page]) => ({ id, ...page }))
|
||||
.sort((a, b) => a.index - b.index) || []
|
||||
}
|
||||
homePageId={appDefinition.homePageId}
|
||||
showHideViewerNavigationControls={showHideViewerNavigationControls}
|
||||
updateOnSortingPages={updateOnSortingPages}
|
||||
|
|
|
|||
Loading…
Reference in a new issue