Skip to content
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

Merged
merged 6 commits into from
May 10, 2022

Conversation

alexander-fedorenko
Copy link
Collaborator

@alexander-fedorenko alexander-fedorenko commented May 6, 2022

Description

This PR applies several changes and improvements to the cadastrapp to make it compatible with the updated MapStore layout (geosolutions-it/MapStore2#8086)

  1. Extension will properly update map layout when cadastrapp panel is open. It will apply additional offset to the panel if sidebar exists.
  2. Annotations and cadastrapp tools can be open at the same time, but only one of them can perform drawing operations at a time. When cadastrapp selection tool is toggled on - geometry edit session in annotations will be cancelled, unsaved geometry will disappear. If annotations starts drawing geometry while cadastrapp has selection tool active - it will be automatically toggled off.
  3. Cadastrapp panel will close when feature editor panel at the bottom is open.
  4. Cadastrapp will reset drawing on close only if it's the owner of drawing.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?
#150

What is the new behavior?
As per PR description

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

- Making menu item toggleable;
- Alternative set of actions for cadastrapp when tool should be toggled without affecting drawing status
- Close feature editor when cadastrapp is open.
- Reset annotation editing session when cadastrapp selection tool is activated.
- Toggle cadastrapp tool off when annotation triggers drawing.
@alexander-fedorenko alexander-fedorenko self-assigned this May 6, 2022
@tdipisa tdipisa requested review from offtherailz and removed request for tdipisa May 10, 2022 08:47
Copy link
Collaborator

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the code looks good to me. Not tested yet.
Only a change and a question

Comment on lines 139 to 184
action$.ofType(SET_CONTROL_PROPERTIES)
action$.ofType(SET_CONTROL_PROPERTIES, SET_CONTROL_PROPERTY, TOGGLE_CONTROL)
.filter(() => isCadastrappOpen(store))
.filter(({ control, properties }) => control === "metadataexplorer" && properties?.enabled) // open the catalog from TOC
.map( () => setControlProperty(CONTROL_NAME, "enabled", false));
.filter(({control, property, properties = [], type}) => {
const state = store.getState();
const controlState = state.controls[control].enabled;
switch (type) {
case SET_CONTROL_PROPERTY:
case TOGGLE_CONTROL:
return (property === 'enabled' || !property) && controlState && shutdownList.includes(control);
default:
return findIndex(keys(properties), prop => prop === 'enabled') > -1 && controlState && shutdownList.includes(control);
}
})
.map( () => {
return setControlProperty(CONTROL_NAME, "enabled", false);
});

export const closeCadastrappOnFeatureGridOpen = (action$) =>
action$.ofType(OPEN_FEATURE_GRID)
.switchMap( () => {
let actions = [
setControlProperty('cadastrapp', 'enabled', false)
];
return Rx.Observable.from(actions);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

* @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) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

@tdipisa tdipisa merged commit c0e3237 into georchestra:master May 10, 2022
@MaelREBOUX
Copy link
Member

Good job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants