cartodb-4.42/lib/assets/javascripts/builder/editor/map-operations/remove-map.js
2024-04-06 05:25:13 +00:00

27 lines
828 B
JavaScript
Executable File

var Notifier = require('builder/components/notifier/notifier');
var errorParser = require('builder/helpers/error-parser');
module.exports = function (opts) {
if (!opts.visDefinitionModel) throw new Error('visDefinitionModel is required');
var visDefinitionModel = opts.visDefinitionModel;
var successCallback = opts.onSuccess;
var errorCallback = opts.onError;
var name = visDefinitionModel.get('name');
visDefinitionModel.destroy({
wait: true,
success: function (mdl, attrs) {
successCallback && successCallback(mdl, attrs);
},
error: function (mdl, e) {
errorCallback && errorCallback(mdl, e);
Notifier.addNotification({
status: 'error',
info: _t('editor.maps.delete.error', {name: name, error: errorParser(e)}),
closable: true
});
}
});
};