-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applying necessary changes to cadastrapp to support MapStore layout changes #156
Changes from 5 commits
143f8f5
f3369ff
f2e85a9
6047129
0cc75e1
789ba0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
} | ||
}, | ||
"dependencies": [ | ||
"BurgerMenu" | ||
"SidebarMenu" | ||
] | ||
} | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import classnames from "classnames"; | ||
|
||
/** | ||
* Wrapper for DockablePanel with main intension to support applying of custom styling to make dock panels have proper | ||
* offset depending on the sidebars presence on the page | ||
* @memberof components.misc.panels | ||
* @name DockContainer | ||
* @param id {string} - id applied to the container | ||
* @param children {JSX.Element} | ||
* @param dockStyle {object} - style object obtained from mapLayoutValuesSelector and used to calculate offsets | ||
* @param className {string} - class name | ||
* @param style - style object to apply to the container. Can be used to overwrite styles applied by dockStyle calculations | ||
* @returns {JSX.Element} | ||
* @constructor | ||
*/ | ||
const DockContainer = ({ id, children, dockStyle, className, style = {}}) => { | ||
const persistentStyle = { | ||
width: `calc(100% - ${(dockStyle?.right ?? 0) + (dockStyle?.left ?? 0)}px)`, | ||
transform: `translateX(-${(dockStyle?.right ?? 0)}px)`, | ||
pointerEvents: 'none' | ||
}; | ||
return ( | ||
<div id={id} className={classnames({ | ||
...(className ? {[className]: true} : {}), | ||
'dock-container': true | ||
})} style={{...persistentStyle, ...style}}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DockContainer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {mapLayoutSelector} from "@mapstore/selectors/maplayout"; | ||
import {memoize} from "lodash"; | ||
|
||
export const boundingSidebarRectSelector = (state) => state.maplayout && state.maplayout.boundingSidebarRect || {}; | ||
|
||
/** | ||
* Retrieve only specific attribute from map layout | ||
* @function | ||
* @memberof selectors.mapLayout | ||
* @param {object} state the state | ||
* @param {object} attributes attributes to retrieve, bool {left: true} | ||
* @param {boolean} isDock flag to use dock paddings instead of toolbar paddings | ||
* @return {object} selected attributes of layout of the map | ||
*/ | ||
export const mapLayoutValuesSelector = memoize((state, attributes = {}, isDock = false) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This basically is the copy of selector from upstream repo. isDock needed to apply offset from the right equal to sidebar width. If it's false - sidebar width + panel width offset is applied instead. |
||
const layout = mapLayoutSelector(state); | ||
const boundingSidebarRect = boundingSidebarRectSelector(state); | ||
return layout && Object.keys(layout).filter(key => | ||
attributes[key]).reduce((a, key) => { | ||
if (isDock) { | ||
return ({...a, [key]: (boundingSidebarRect[key] ?? layout[key])}); | ||
} | ||
return ({...a, [key]: layout[key]}); | ||
}, | ||
{}) || {}; | ||
}, (state, attributes, isDock) => | ||
JSON.stringify(mapLayoutSelector(state)) + | ||
JSON.stringify(boundingSidebarRectSelector(state)) + | ||
JSON.stringify(attributes) + (isDock ? '_isDock' : '')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge these two, and toggle only when cadastrapp it is open, to prevent unnecessary actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, merged and added optional chaining for controlState variable because state branch may not exist in such subset of actions.