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

Undo Feature Implemented for Units #150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-i18next": "^13.5.0",
"react-icons": "^5.3.0",
"react-id-generator": "^3.0.2",
"react-json-view": "^1.21.3",
"react-router-dom": "^6.20.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getFeatureLabel } from '../utils';
import { getFeatureLabel, getFillStyles, getLineStyles, getTextStyle } from '../utils';
import { layer } from 'azure-maps-control';

// Sets polygon, line, and symbol layers to invisible
function drawingModeChanged(allLayers) {
Expand Down Expand Up @@ -52,7 +53,7 @@ function grabToPointer(layerName, hoverLayer, map) {
});
}

// Changes cursor between grabbing and grabbing when map is clicked and dragged
// Changes cursor between grab and grabbing when map is clicked and dragged
function grabAndGrabbing(map) {
map.events.add('mousedown', () => {
map.getCanvas().style.cursor = 'grabbing';
Expand All @@ -63,6 +64,7 @@ function grabAndGrabbing(map) {
});
}

// Changes color of clicked feature, changes color of previously clicked feature back to original color
function updateSelectedColor(map, unitSelected) {
if(unitSelected) {
const lineLayer = map.layers.getLayerById('lineClickLayer');
Expand Down Expand Up @@ -101,6 +103,7 @@ function updateLevels(levels, selectedLevel, newValue) {
return levels;
}

// Set GeoJSON fields for a new feature
function setFields(feature, selectedLevel) {
if (!feature.data.properties.name) {
feature.data.properties.name = {};
Expand Down Expand Up @@ -136,10 +139,47 @@ function setFields(feature, selectedLevel) {
}
}

// Deletes all units on level that is currently being changed, so only most recent changes are displayed
function deleteUnitPrevEdits(units, selectedLevel) {
units.features = units.features.filter(item => item.properties.level_id !== selectedLevel.id);
}

// Sets features to be clicked on
function setFeatures(map, e, selectedLayerId) {
var features;
if(selectedLayerId === 'unitButton')
features = map.layers.getRenderedShapes(e.position, 'unitClick');
else if(selectedLayerId === 'levelButton')
features = map.layers.getRenderedShapes(e.position, 'levelFill');
else if(selectedLayerId === 'footprintButton')
features = map.layers.getRenderedShapes(e.position, 'footprintClick');
else
features = map.layers.getRenderedShapes(e.position, ['unitClick', 'levelClick']);

return features;
}

// Creates layers for units
function unitLayers(dataSource, category) {
var unitLayer = new layer.PolygonLayer(dataSource, 'unitClick', getFillStyles('unit', category));
var unitLines = new layer.LineLayer(dataSource, null, getLineStyles('unit', category));
var polygonHoverLayer = new layer.PolygonLayer(dataSource, null, {
fillColor: 'rgba(135, 206, 250, 0.8)',
filter: ['==', ['get', 'id'], ''],
cursor: 'pointer !important',
});

var polygonClickLayer = new layer.PolygonLayer(dataSource, 'unitClickChange', {
fillColor: 'rgba(75, 146, 210, 0.8)',
filter: ['==', ['get', 'id'], ''] ,
cursor: 'pointer !important',
});

var unitSymbols = new layer.SymbolLayer(dataSource, null, getTextStyle(category));

return [unitLayer, unitLines, polygonHoverLayer, polygonClickLayer, unitSymbols];
}

export {
currentEditData,
groupAndSort,
Expand All @@ -149,5 +189,7 @@ export {
setFields,
deleteUnitPrevEdits,
grabAndGrabbing,
updateSelectedColor
updateSelectedColor,
setFeatures,
unitLayers
};
41 changes: 41 additions & 0 deletions src/pages/conversion/places-preview-map/indes.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,44 @@ export const toolbar = css `
pointerEvents: none
`;

export const buttonStyle = css `
color: #323130;
fill: #323130;
background-color: #fff;
box-shadow: rgba(0, 0, 0, 0.16) 0 0 4px;
background-size: 12px 12px;
position: relative;
user-select: none;
margin: 0;
padding: 0;
border: none;
border-collapse: collapse;
min-width: 32px;
height: 32px;
padding: 0 10px;
text-align: center;
cursor: pointer;
line-height: 32px;
background-position: center center;
background-repeat: no-repeat;
overflow: hidden;

&:hover {
color: #31acce;
}

&:disabled,
buttonStyle[disabled]{
background-color: #e5e5e5;
color: #6c757d;
cursor: not-allowed;
}
`;

export const undoStyle = css `
position: absolute;
right: 1%;
bottom: 20%;
z-index: 2;
`;

Loading
Loading