Browse Source

Update layers view when component prop changes. Closes #2433

pull/2475/head
Artur Arseniev 7 years ago
parent
commit
5c5e4fee48
  1. 9
      src/navigator/view/ItemView.js
  2. 4
      src/navigator/view/ItemsView.js

9
src/navigator/view/ItemView.js

@ -66,6 +66,7 @@ export default Backbone.View.extend({
this.ppfx = this.em.get('Config').stylePrefix; this.ppfx = this.em.get('Config').stylePrefix;
this.sorter = o.sorter || ''; this.sorter = o.sorter || '';
this.pfx = this.config.stylePrefix; this.pfx = this.config.stylePrefix;
this.parentView = o.parentView;
const pfx = this.pfx; const pfx = this.pfx;
const ppfx = this.ppfx; const ppfx = this.ppfx;
const model = this.model; const model = this.model;
@ -75,6 +76,7 @@ export default Backbone.View.extend({
this.listenTo(components, 'remove add reset', this.checkChildren); this.listenTo(components, 'remove add reset', this.checkChildren);
this.listenTo(model, 'change:status', this.updateStatus); this.listenTo(model, 'change:status', this.updateStatus);
this.listenTo(model, 'change:open', this.updateOpening); this.listenTo(model, 'change:open', this.updateOpening);
this.listenTo(model, 'change:layerable', this.updateLayerable);
this.listenTo(model, 'change:style:display', this.updateVisibility); this.listenTo(model, 'change:style:display', this.updateVisibility);
this.className = `${pfx}layer ${pfx}layer__t-${type} no-select ${ppfx}two-color`; this.className = `${pfx}layer ${pfx}layer__t-${type} no-select ${ppfx}two-color`;
this.inputNameCls = `${ppfx}layer-name`; this.inputNameCls = `${ppfx}layer-name`;
@ -350,6 +352,12 @@ export default Backbone.View.extend({
this.render(); this.render();
}, },
updateLayerable() {
const { parentView } = this;
const toRerender = parentView || this;
toRerender.render();
},
render() { render() {
const { model, config, pfx, ppfx, opt } = this; const { model, config, pfx, ppfx, opt } = this;
const { isCountable } = opt; const { isCountable } = opt;
@ -367,6 +375,7 @@ export default Backbone.View.extend({
config: this.config, config: this.config,
sorter: this.sorter, sorter: this.sorter,
opened: this.opt.opened, opened: this.opt.opened,
parentView: this,
parent: model, parent: model,
level level
}).render().$el; }).render().$el;

4
src/navigator/view/ItemsView.js

@ -11,6 +11,7 @@ export default Backbone.View.extend({
this.ppfx = config.pStylePrefix || ''; this.ppfx = config.pStylePrefix || '';
this.pfx = config.stylePrefix || ''; this.pfx = config.stylePrefix || '';
this.parent = o.parent; this.parent = o.parent;
this.parentView = o.parentView;
const pfx = this.pfx; const pfx = this.pfx;
const ppfx = this.ppfx; const ppfx = this.ppfx;
const parent = this.parent; const parent = this.parent;
@ -72,13 +73,14 @@ export default Backbone.View.extend({
* @return Object Object created * @return Object Object created
* */ * */
addToCollection(model, fragmentEl, index) { addToCollection(model, fragmentEl, index) {
const level = this.level; const { level, parentView } = this;
var fragment = fragmentEl || null; var fragment = fragmentEl || null;
var viewObject = ItemView; var viewObject = ItemView;
var view = new viewObject({ var view = new viewObject({
level, level,
model, model,
parentView,
config: this.config, config: this.config,
sorter: this.sorter, sorter: this.sorter,
isCountable: this.isCountable, isCountable: this.isCountable,

Loading…
Cancel
Save