cartodb/lib/assets/javascripts/builder/editor/map-operations/remove-map.js

27 lines
828 B
JavaScript
Raw Normal View History

2020-06-15 10:58:47 +08:00
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
});
}
});
};