Skip to content

Commit

Permalink
Fix new layer default inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Sep 14, 2017
1 parent f230b83 commit 3f1be03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 7 additions & 2 deletions src/style_manager/model/PropertyComposite.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ module.exports = Property.extend({
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');

if (value) {
if (value && !defaultProps) {
return value;
}

Expand Down
20 changes: 8 additions & 12 deletions src/style_manager/view/PropertyStackView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Layers = require('./../model/Layers');
var LayersView = require('./LayersView');

module.exports = PropertyCompositeView.extend({

templateField() {
const pfx = this.pfx;
const ppfx = this.ppfx;
Expand Down Expand Up @@ -162,25 +162,21 @@ module.exports = PropertyCompositeView.extend({
},

/**
* Add layer
* @param Event
*
* @return Object
* Add new layer
* */
addLayer(e) {
if(this.getTarget()){
var layers = this.getLayers();
var layer = layers.add({ name : 'test' });
var index = layers.indexOf(layer);
layer.set('value', this.getDefaultValue());
addLayer() {
if (this.getTarget()) {
const layers = this.getLayers();
const layer = layers.add({name: 'New'});
const index = layers.indexOf(layer);
layer.set('value', this.model.getDefaultValue(1));

// In detached mode valueUpdated will add new 'layer value'
// to all subprops
this.valueUpdated();

// This will set subprops with a new default values
this.model.set('stackIndex', index);
return layer;
}
},

Expand Down

0 comments on commit 3f1be03

Please sign in to comment.