From d6faa50c278e6370c571908c53222271e5905c10 Mon Sep 17 00:00:00 2001 From: artf Date: Fri, 14 Dec 2018 18:45:05 +0100 Subject: [PATCH] Avoid clear button on nested properties --- src/style_manager/model/Layer.js | 1 + src/style_manager/view/PropertyView.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/style_manager/model/Layer.js b/src/style_manager/model/Layer.js index 15ed5809b..7b35ad3cb 100644 --- a/src/style_manager/model/Layer.js +++ b/src/style_manager/model/Layer.js @@ -18,6 +18,7 @@ module.exports = Backbone.Model.extend({ 'properties', properties instanceof Properties ? properties : new Properties(properties) ); + this.get('properties').forEach(item => item.parent = this.collection.property); // If there is no value I'll try to get it from values // I need value setted to make preview working diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 80c3ee6d6..b214c5440 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -21,11 +21,13 @@ module.exports = Backbone.View.extend({ const pfx = this.pfx; const icon = model.get('icon'); const info = model.get('info'); + const parent = model.parent; + return ` ${model.get('name')} - ⨯ + ${ !parent ? `⨯` : '' } `; }, @@ -89,20 +91,23 @@ module.exports = Backbone.View.extend({ * @private */ updateStatus() { - const status = this.model.get('status'); + const { model } = this; + const status = model.get('status'); + const parent = model.parent; const pfx = this.pfx; const ppfx = this.ppfx; const config = this.config; const updatedCls = `${ppfx}four-color`; const computedCls = `${ppfx}color-warn`; const labelEl = this.$el.children(`.${pfx}label`); - const clearStyle = this.getClearEl().style; + const clearStyleEl = this.getClearEl(); + const clearStyle = clearStyleEl ? clearStyleEl.style : {}; labelEl.removeClass(`${updatedCls} ${computedCls}`); clearStyle.display = 'none'; switch (status) { case 'updated': - labelEl.addClass(updatedCls); + !parent && labelEl.addClass(updatedCls); if (config.clearProperties) { clearStyle.display = 'inline';