Initial commit
This commit is contained in:
26
lib/assets/javascripts/dashboard/data/map-model.js
Normal file
26
lib/assets/javascripts/dashboard/data/map-model.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const Backbone = require('backbone');
|
||||
const LayersCollection = require('dashboard/data/layers-collection');
|
||||
const checkAndBuildOpts = require('builder/helpers/required-opts');
|
||||
|
||||
const REQUIRED_OPTS = [
|
||||
'configModel'
|
||||
];
|
||||
|
||||
const MapModel = Backbone.Model.extend({
|
||||
urlRoot: '/api/v1/maps',
|
||||
|
||||
initialize: function (options) {
|
||||
checkAndBuildOpts(options, REQUIRED_OPTS, this);
|
||||
this.bind('change:id', this._fetchLayers, this);
|
||||
|
||||
this.layers = new LayersCollection(null, { configModel: this._configModel });
|
||||
this.layers.map = this;
|
||||
},
|
||||
|
||||
// fetch related layers
|
||||
_fetchLayers: function () {
|
||||
this.layers.fetch();
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = MapModel;
|
||||
Reference in New Issue
Block a user