I18n nogo areas errors (#413)
This commit is contained in:
parent
2aa840acda
commit
5e14484302
3 changed files with 45 additions and 19 deletions
|
|
@ -711,7 +711,6 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p id="nogoError" class="invalid-feedback" style="display: none"></p>
|
||||
<form name="loadNogosForm" id="loadNogosForm">
|
||||
<fieldset>
|
||||
<legend data-i18n="loadNogos.source">Source</legend>
|
||||
|
|
@ -795,6 +794,8 @@
|
|||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<p id="nogoError" class="invalid-feedback" style="display: none"></p>
|
||||
|
||||
<button type="button" class="btn btn-secondary" data-i18n="modal.close" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -197,7 +197,9 @@ BR.NogoAreas = L.Control.extend({
|
|||
resolve(reader.result);
|
||||
};
|
||||
reader.onerror = function () {
|
||||
self.displayUploadError('Could not load file: ' + reader.error.message);
|
||||
self.displayUploadError(
|
||||
i18next.t('loadNogos.error.loading-file-error', { err: reader.error.message })
|
||||
);
|
||||
};
|
||||
|
||||
reader.readAsText(nogoFile);
|
||||
|
|
@ -206,25 +208,25 @@ BR.NogoAreas = L.Control.extend({
|
|||
});
|
||||
} else {
|
||||
// FIXME: use form validator instead
|
||||
self.displayUploadError('Missing file or URL.');
|
||||
self.displayUploadError(i18next.t('loadNogos.error.missing-file-url'));
|
||||
return false;
|
||||
}
|
||||
var nogoWeight = parseFloat($('#nogoWeight').val());
|
||||
if (isNaN(nogoWeight)) {
|
||||
// FIXME: use form validator instead
|
||||
self.displayUploadError('Missing default nogo weight.');
|
||||
self.displayUploadError(i18next.t('loadNogos.error.missing-default-nogo-weight'));
|
||||
return false;
|
||||
}
|
||||
var nogoRadius = parseFloat($('#nogoRadius').val());
|
||||
if (isNaN(nogoRadius) || nogoRadius < 0) {
|
||||
// FIXME: use form validator instead
|
||||
self.displayUploadError('Invalid default nogo radius.');
|
||||
self.displayUploadError(i18next.t('loadNogos.error.invalid-default-nogo-radius'));
|
||||
return false;
|
||||
}
|
||||
var nogoBuffer = parseFloat($('#nogoBuffer').val());
|
||||
if (isNaN(nogoBuffer)) {
|
||||
// FIXME: use form validator instead
|
||||
self.displayUploadError('Invalid nogo buffering radius.');
|
||||
self.displayUploadError(i18next.t('loadNogos.error.invalid-nogo-buffering-radius'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +245,7 @@ BR.NogoAreas = L.Control.extend({
|
|||
});
|
||||
|
||||
if (cleanedGeoJSONFeatures.length === 0) {
|
||||
self.displayUploadError('No valid area found in provided input.');
|
||||
self.displayUploadError(i18next.t('loadNogos.error.no-valid-area'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -268,6 +270,7 @@ BR.NogoAreas = L.Control.extend({
|
|||
nogosPoints = nogosPoints.filter(function (e) {
|
||||
return e;
|
||||
});
|
||||
try {
|
||||
self.setOptions({
|
||||
nogos: nogosPoints,
|
||||
polygons: geoJSON.getLayers().filter(function (e) {
|
||||
|
|
@ -280,6 +283,18 @@ BR.NogoAreas = L.Control.extend({
|
|||
self._fireUpdate();
|
||||
self.displayUploadError(undefined);
|
||||
$('#loadNogos').modal('hide');
|
||||
} catch (err) {
|
||||
if (err.name === 'NS_ERROR_MALFORMED_URI') {
|
||||
self.displayUploadError(i18next.t('loadNogos.error.loading-file-too-big'));
|
||||
} else {
|
||||
self.displayUploadError(i18next.t('loadNogos.error.loading-file-unexpected'));
|
||||
}
|
||||
// fire a fake empty nogos before removing layers from map
|
||||
// because it will automatically refresh the URL, and that will
|
||||
// fail if we do not empty nogos first
|
||||
self.fire('update', { options: { nogos: [], polygons: [], polylines: [] } });
|
||||
self._clear();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -84,6 +84,16 @@
|
|||
},
|
||||
"loadNogos": {
|
||||
"defaultProperties": "Default properties",
|
||||
"error": {
|
||||
"invalid-default-nogo-radius": "Invalid default nogo radius.",
|
||||
"invalid-nogo-buffering-radius": "Invalid nogo buffering radius.",
|
||||
"loading-file-error": "Could not load file: {{err}}.",
|
||||
"loading-file-too-big": "Too many nogo areas in this file! Please simplify the geometry and/or reduce the number of zones.",
|
||||
"loading-file-unexpected": "Unexpected error when loading this file.",
|
||||
"missing-default-nogo-weight": "Missing default nogo weight.",
|
||||
"missing-file-url": "Missing file or URL.",
|
||||
"no-valid-area": "No valid area found in provided input."
|
||||
},
|
||||
"file": "File (.geojson)",
|
||||
"load": "Load",
|
||||
"nogoBuffer": "Buffer no-go areas (in meters)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue