Skip to content

Commit

Permalink
feat: adds delete property functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
FritzHoing committed Sep 5, 2023
1 parent 98805d8 commit a30801b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/components/ToolMenu/Draw/Attributions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ const AttributionDrawer: React.FC<AttributionDrawerProps> = ({
return;
}

Object.entries(input.fields).forEach(([key, value]) => {
// @ts-ignore
selectedFeature.set(value.name, value.value);
});
if (Object.keys(currentProperties).length > 0) {
Object.entries(input.fields).forEach(([key, value]) => {
// @ts-ignore
selectedFeature.set(value.name, value.value);
});
} else {
selectedFeature.set('', '');
}

};

const onPropertyAdd = () => {
Expand All @@ -103,13 +108,14 @@ const AttributionDrawer: React.FC<AttributionDrawerProps> = ({
};

const remove = (keyToRemove: string) => {
const existingFields = form.getFieldValue('fields');

delete existingFields[keyToRemove];
const updatedProperties = currentProperties;

form.setFieldsValue({
fields: existingFields
});
delete updatedProperties[keyToRemove];

selectedFeature?.unset(keyToRemove);

setCurrentProperties(updatedProperties);

setRender(!render);
};
Expand Down

0 comments on commit a30801b

Please sign in to comment.