Browse Source

Fix new layer default inputs

pull/312/head
Artur Arseniev 9 years ago
parent
commit
3f1be03a5b
  1. 9
      src/style_manager/model/PropertyComposite.js
  2. 20
      src/style_manager/view/PropertyStackView.js

9
src/style_manager/model/PropertyComposite.js

@ -24,10 +24,15 @@ module.exports = Property.extend({
this.set('properties', new Properties(properties)); this.set('properties', new Properties(properties));
}, },
getDefaultValue() { /**
* Returns default value
* @param {Boolean} defaultProps Force to get defaults from properties
* @return {string}
*/
getDefaultValue(defaultProps) {
let value = this.get('defaults'); let value = this.get('defaults');
if (value) { if (value && !defaultProps) {
return value; return value;
} }

20
src/style_manager/view/PropertyStackView.js

@ -4,7 +4,7 @@ var Layers = require('./../model/Layers');
var LayersView = require('./LayersView'); var LayersView = require('./LayersView');
module.exports = PropertyCompositeView.extend({ module.exports = PropertyCompositeView.extend({
templateField() { templateField() {
const pfx = this.pfx; const pfx = this.pfx;
const ppfx = this.ppfx; const ppfx = this.ppfx;
@ -162,17 +162,14 @@ module.exports = PropertyCompositeView.extend({
}, },
/** /**
* Add layer * Add new layer
* @param Event
*
* @return Object
* */ * */
addLayer(e) { addLayer() {
if(this.getTarget()){ if (this.getTarget()) {
var layers = this.getLayers(); const layers = this.getLayers();
var layer = layers.add({ name : 'test' }); const layer = layers.add({name: 'New'});
var index = layers.indexOf(layer); const index = layers.indexOf(layer);
layer.set('value', this.getDefaultValue()); layer.set('value', this.model.getDefaultValue(1));
// In detached mode valueUpdated will add new 'layer value' // In detached mode valueUpdated will add new 'layer value'
// to all subprops // to all subprops
@ -180,7 +177,6 @@ module.exports = PropertyCompositeView.extend({
// This will set subprops with a new default values // This will set subprops with a new default values
this.model.set('stackIndex', index); this.model.set('stackIndex', index);
return layer;
} }
}, },

Loading…
Cancel
Save