cartodb-4.42/lib/assets/javascripts/builder/components/modals/map-metadata/footer/footer-view.js
2024-04-06 05:25:13 +00:00

46 lines
1.0 KiB
JavaScript
Executable File

var CoreView = require('backbone/core-view');
var template = require('./footer.tpl');
module.exports = CoreView.extend({
tagName: 'ul',
className: 'Modal-listActions u-flex u-alignCenter ',
events: {
'click .js-save': '_save',
'click .js-close': '_close'
},
initialize: function (opts) {
if (!opts.visMetadataModel) throw new Error('visMetadataModel is required');
if (!opts.onSaveAction) throw new Error('onSaveAction is required');
this._visMetadataModel = opts.visMetadataModel;
this._onSaveAction = opts.onSaveAction;
this._onCloseAction = opts.onCloseAction;
this._initBinds();
},
_initBinds: function () {
this._visMetadataModel.on('change', this.render, this);
},
render: function () {
this.$el.html(
template({
canFinish: this._visMetadataModel.isValid()
})
);
return this;
},
_save: function () {
this._visMetadataModel.isValid() && this._onSaveAction();
},
_close: function () {
this._onCloseAction && this._onCloseAction();
}
});