Skip to content

Commit

Permalink
Merge branch 'fix/CDCRM-1235-1237-conflits-cadastrapp' into 'open/dev…
Browse files Browse the repository at this point in the history
…elop'

fix/CDCRM-1235-1237-conflits-cadastrapp

Closes CDCRM-1235

See merge request rennes-metropole/signalement/signalement-backend!197
  • Loading branch information
FNI18300 committed Mar 19, 2024
2 parents 5e9f35b + 04ecced commit 421a676
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"login": "Vous êtes",
"organization": "Collectivité",
"email": "Votre adresse mail",
"description": "Objet",
"description": "Objet",
"description.count":"nombre de caracteres restants:",
"instructions": "Afin d'effectuer un signalement sur une thématique, merci de renseigner le formulaire ci-dessous ainsi que de localiser sur la carte l'objet du signalement.",
"reporting.thema": "Signalement sur la thématique",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
updateDockPanelsList,
} from "@mapstore/actions/maplayout";
import {TOGGLE_CONTROL, toggleControl} from "@mapstore/actions/controls";
import {signalementSidebarControlSelector} from "@js/extension/selectors/signalement-selector";
import {isOpen} from "@js/extension/selectors/signalement-selector";

let backendURLPrefix = "/signalement";
let currentLayout;
Expand All @@ -53,65 +53,76 @@ export const initSignalementEpic = (action$) =>
return Rx.Observable.of(initSignalementDone()).delay(0);
});

export const openSignalementPanelEpic = (action$, store) =>
action$.ofType(TOGGLE_CONTROL, actions.SIGNALEMENT_LAYER_OPEN_PANEL)
.filter(action => action.type === actions.SIGNALEMENT_LAYER_OPEN_PANEL || (action.control === "signalement" && !!store.getState() && !!signalementSidebarControlSelector(store.getState())))
/**
* On opening signalement panel from layer
* @param action$
* @param store
* @returns {*}
*/
export const openSignalementLayerPanelEpic = (action$, store) =>
action$.ofType(actions.SIGNALEMENT_LAYER_OPEN_PANEL)
.switchMap((action) => {
let layout = store.getState().maplayout;
layout = {
transform: layout.layout.transform,
height: layout.layout.height,
rightPanel: true,
leftPanel: layout.layout.leftPanel,
...layout.boundingMapRect,
right: SIGNALEMENT_PANEL_WIDTH + RIGHT_SIDEBAR_MARGIN_LEFT,
boundingMapRect: {
...layout.boundingMapRect,
right: SIGNALEMENT_PANEL_WIDTH + RIGHT_SIDEBAR_MARGIN_LEFT
},
boundingSidebarRect: layout.boundingSidebarRect
};
currentLayout = layout;
window.signalement.debug("sig panel signalement added to right dockpanels list");
return Rx.Observable.from([updateDockPanelsList('signalement', 'add', 'right'), signalementUpdateMapLayout(layout), initDrawingSupport(), openPanel(action?.currentLayer)]);
return Rx.Observable.from([initDrawingSupport(), toggleControl('signalement', 'enabled'), openPanel(action?.currentLayer)]);
});


export const closeSignalementPanelEpic = (action$, store) =>
action$.ofType(TOGGLE_CONTROL, actions.SIGNALEMENT_DRAFT_CANCELED)
.filter(action => action.type === actions.SIGNALEMENT_DRAFT_CANCELED || (action.control === "signalement" && !!store.getState() && !signalementSidebarControlSelector(store.getState())))
/**
* On opening/closing signalement panel by toggle control
* @param action$
* @param store
* @returns {*}
*/
export const openSignalementPanelEpic = (action$, store) =>
action$.ofType(TOGGLE_CONTROL)
.filter(action =>action.control === "signalement")
.switchMap((action) => {
const actionsList = [updateDockPanelsList('signalement', 'remove', 'right')]
if (action.type === actions.SIGNALEMENT_DRAFT_CANCELED) {
actionsList.push(toggleControl('signalement'))
let actionsList = []
if (isOpen(store.getState())) {
actionsList.push(updateDockPanelsList('signalement', 'add', 'right'),
initDrawingSupport(), openPanel());
window.signalement.debug("sig panel signalement to open");
} else {
actionsList.push(closePanel())
actionsList.push(updateDockPanelsList('signalement', 'remove', 'right'),
stopDrawingSupport(), closePanel());
window.signalement.debug("sig panel signalement to close");
}
let layout = store.getState().maplayout;
layout = {transform: layout.layout.transform, height: layout.layout.height, rightPanel: true, leftPanel: false, ...layout.boundingMapRect, right: layout.boundingSidebarRect.right, boundingMapRect: {...layout.boundingMapRect, right: layout.boundingSidebarRect.right}, boundingSidebarRect: layout.boundingSidebarRect}
window.signalement.debug("sig panel signalement removed from right dockpanels list");
currentLayout = layout;
return Rx.Observable.from(actionsList).concat(Rx.Observable.from([signalementUpdateMapLayout(layout), stopDrawingSupport()]));
return Rx.Observable.from(actionsList);
});


export const closeSignalementPanelEpic = (action$, store) =>
action$.ofType(actions.SIGNALEMENT_DRAFT_CANCELED, actions.SIGNALEMENT_CLOSE_PANEL)
.filter(() => !!store.getState() && isOpen(store.getState()))
.switchMap(() => {
window.signalement.debug("sig panel signalement closing");
return Rx.Observable.from([stopDrawingSupport(), updateDockPanelsList('signalement', 'remove', 'right'),
toggleControl('signalement', 'enabled')]);
});

/**
* On clicking on another panel from the right sidebar
* @param action$
* @param store
* @returns {*}
*/
export const onOpeningAnotherRightPanelSignalement = (action$, store) =>
action$.ofType(TOGGLE_CONTROL)
.filter((action) => store && store.getState() &&
action.control !== 'signalement' &&
store.getState().maplayout.dockPanels.right.includes("signalement") &&
store.getState().maplayout.dockPanels.right.includes(action.control))
!!isOpen(store.getState()) &&
store.getState().maplayout.dockPanels.right.includes(action.control)
)
.switchMap((action) => {
return Rx.Observable.of(updateDockPanelsList("signalement", "remove", "right"))
.concat(Rx.Observable.of(closePanel()));
return Rx.Observable.of(closePanel());
});


export function onUpdatingLayoutWhenSignalementPanelOpened(action$, store) {
return action$.ofType(UPDATE_MAP_LAYOUT, FORCE_UPDATE_MAP_LAYOUT)
.filter((action) => store && store.getState() &&
!!signalementSidebarControlSelector(store.getState()) &&
(action.source === "signalement" || action.source === undefined) &&
currentLayout?.right !== action?.layout?.right)
!!isOpen(store.getState()) &&
!action.source)
.switchMap((action) => {
let layout = store.getState().maplayout;
layout = {
Expand Down Expand Up @@ -248,7 +259,8 @@ export const createTaskSignalementEpic = (action$) =>
position: "tr",
autoDismiss: 5
}),
taskCreated(response.data)
taskCreated(response.data),
closePanel()
]))
.catch(() => Rx.Observable.from([
error({
Expand Down Expand Up @@ -389,7 +401,7 @@ export const stopDrawingSignalementEpic = (action$, store) =>
};
//let actualFeatures = changedGeometriesSelector(state);
//work around to avoid import of draw.js - see issues with geosolutions
let actualFeatures = state && state.draw && state.draw.tempFeatures;
let actualFeatures = state && state.draw && state.draw.tempFeatures;
if (!actualFeatures || actualFeatures.length === 0) {
actualFeatures = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getSignalementState = createSelector(
(selector) => selector
);

export const isOpen = (state) => get(state, "signalement.open");
export const isOpen = (state) => get(state, "controls.signalement.enabled");

export const signalementAttachmentConfigurationSelector = (state) => get(state, "signalement.attachmentConfiguration");

Expand All @@ -17,5 +17,3 @@ export const signalementLayersSelector = (state) => get(state, "signalement.cont
export const signalementThemasSelector = (state) => get(state, "signalement.contextThemas");

export const signalementMeSelector = (state) => get(state, "signalement.user");

export const signalementSidebarControlSelector = (state) => get(state, "controls.signalement.enabled")

0 comments on commit 421a676

Please sign in to comment.