Skip to content

Commit

Permalink
Merge pull request #202 from jdev-org/issue-197
Browse files Browse the repository at this point in the history
ISSUE-197 - Icon grouping for map selection
  • Loading branch information
pierrejego authored Jan 6, 2025
2 parents e2f87a8 + b83c443 commit ec2bb3d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions js/extension/cadastrapp.css
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,9 @@ input.request-obj-double.form-control{
.cadastrapp-modal .react-grid-Cell, .cadastrapp .react-grid-Grid .react-grid-Cell {
user-select: text;
}

.cadstrap_selectionToolsButton {
display: flex;
justify-content: center;
margin: 10px 0 10px 0;
}
4 changes: 4 additions & 0 deletions js/extension/components/search/PlotSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Identifier from '../forms/Identifier';
import Lot from '../forms/Lot';
import useFormState from '../../hooks/useFormState';
import SearchButtons from './SearchButtons';
import SelectionTools from '@js/extension/plugins/cadastrapp/toolbar/SelectionTools';

export default function PlotsSearch({onSearch = () => {}, loading}) {
const [currentTab, setCurrentTab] = useState('reference');
Expand All @@ -20,6 +21,9 @@ export default function PlotsSearch({onSearch = () => {}, loading}) {
return (
<div className="plots-search">
<h3><Message msgId={'cadastrapp.parcelle.title'}/></h3>
<div className='cadstrap_selectionToolsButton'>
<SelectionTools foncier = {false}/>
</div>
<Tabs
className="not-scrolled-tab"
onSelect={k => setCurrentTab(k)}
Expand Down
2 changes: 1 addition & 1 deletion js/extension/plugins/cadastrapp/MainToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import HelpButton from './toolbar/Help';
export default function MainToolbar(props) {
return (<div className="side-bar pull-left">
<ZoomTo/>
<SelectionTools {...props}/>
<SearchTools/>
<SelectionTools {...props}/>
<RequestLanding />
<Preferences configStyles={props.styles}/>
<HelpButton helpUrl={props?.helpUrl}/>
Expand Down
10 changes: 6 additions & 4 deletions js/extension/plugins/cadastrapp/toolbar/SelectionTools.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { SELECTION_TYPES } from '../../../constants';
import { toggleSelectionTool } from '../../../actions/cadastrapp';
import { currentSelectionToolSelector } from '../../../selectors/cadastrapp';
Expand Down Expand Up @@ -43,19 +43,21 @@ const BUTTONS_SETTINGS = {
* They are mutually exclusive and allow to start a selection on map.
*/
function SelectionTools({ foncier = true, currentTool, onClick = () => {} }) {

useEffect(() => onClick("POINT"), []);
return <>
{
Object.keys(SELECTION_TYPES)
.filter(k => foncier ? true : k !== SELECTION_TYPES.LANDED_PROPERTY) // if foncier: false, do not show landed property button
.filter(k => foncier ? k === SELECTION_TYPES.LANDED_PROPERTY : k !== SELECTION_TYPES.LANDED_PROPERTY) // if foncier: false, do not show landed property button, if true show only landed prop button
.map(k => SELECTION_TYPES[k])
.map(toolName => {
const isActive = toolName === currentTool;
return (<TButton
bsStyle={isActive && "success"}
{...BUTTONS_SETTINGS[toolName]}
// if the current selection button is clicked, it turns off selection
onClick={() => isActive ? onClick() : onClick(toolName)}
onClick={() => {
isActive ? onClick() : onClick(toolName);
}}
/>);
})
}
Expand Down

0 comments on commit ec2bb3d

Please sign in to comment.