cartodb-4.42/lib/assets/javascripts/builder/components/modals/creation/modal-creation-view.js

48 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var CoreView = require('backbone/core-view');
var _ = require('underscore');
var renderLoading = require('builder/components/loading/render-loading');
var ErrorView = require('builder/components/error/error-view');
var REQUIRED_OPTS = [
'errorTitle',
'loadingTitle',
'runAction',
'modalModel'
];
/**
* Remove confirmation dialog
*/
module.exports = CoreView.extend({
className: 'Dialog-content',
initialize: function (opts) {
_.each(REQUIRED_OPTS, function (item) {
if (!opts[item]) throw new Error(item + ' is required');
this['_' + item] = opts[item];
}, this);
},
render: function () {
this.clearSubViews();
this.$el.html(
renderLoading({
title: this._loadingTitle
})
);
this._runAction({
error: this._renderErrorView.bind(this)
});
return this;
},
_renderErrorView: function (errorMessage) {
var errorView = new ErrorView({
title: this._errorTitle,
desc: errorMessage
});
this.$el.html(errorView.render().el);
this.addView(errorView);
}
});