Closed simon-leech closed 3 months ago
I have created a sample plugin here to test this query
mapp.ui.layers.panels.MultipleLocationsDelete = (layer) => {
layer.MultipleLocationsDelete = mapp.utils.html.node`
<button
data-id="delete-locations"
class="flat wide bold primary-colour"
onclick=${deleteLocations}>${layer.MultipleLocationsDelete?.btn_label || mapp.dictionary.confirm_delete}`;
async function deleteLocations() {
// Run the query to delete the locations
const locationDelete = await mapp.utils.xhr(`${mapp.host}/api/query?` +
mapp.utils.paramString({
template: 'locations_delete',
locale: layer.mapview.locale.key,
layer: layer.key,
table: layer.table,
filter: layer.filter?.current
}));
// If error, show the error message
if (locationDelete instanceof Error) {
alert('Error deleting locations')
}
// Reload the layer to show the changes
layer.reload();
// Alert the user that the locations have been deleted
alert('Locations deleted')
}
return layer.MultipleLocationsDelete
}
To test it add this to a layer.
"MultipleLocationsDelete": {
"btn_label": "Delete Multiple Locations"
},
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
This PR addresses issue https://github.com/GEOLYTIX/xyz/issues/1289
It provides a
locations_delete
query. Which is similar tolocation_delete
except it takesfilter
as a parameter to enable multiple locations to be deleted.This must only be able to be called as layer query. Therefore, this query must have
_.layer
as a parameter or it will throw an error.