cmv-app icon indicating copy to clipboard operation
cmv-app copied to clipboard

_LayoutMixin mutates the prototype object panes

Open green3g opened this issue 7 years ago • 6 comments

How often can you reproduce it?

  • [ ] Always
  • [x] Sometimes
  • [ ] Rarely
  • [ ] Unable
  • [ ] I didn’t try

Description:

The initPanes function is adding properties to the this.panes object. This results in a object that is quite different from the default if more than one instance of cmv is created.

For instance:

            this.panes.outer = new BorderContainer({
                id: 'borderContainerOuter',
                design: 'sidebar',
                gutters: false
            }).placeAt(container);

This should be avoided because when cmv initializes subsequent times after this object is modified, it fails because lang.clone is unable to handle complex objects like BorderContainer.

Steps to reproduce:

  1. Startup cmv, then try to create a new instance of an app.

Expected results:

CMV should be able to initialize more than once. Why? I am working on an interface that uses cmv in a single page app, and there are situations where cmv is added and removed from the page. This shouldn't be a problem.

Actual results:

CMV fails to initialize a second time.

Environment:

Software Version
CMV Version 2.0.0beta
Browser Chrome
Operating system Windows 7 x64

green3g avatar Mar 08 '17 19:03 green3g

The original panes are preserved in this.defaultPanes so they can be restored before initPanes method is called a second time. Clearly, you'll want to iterate through this.panes to destroy all the existing panes before initializing them again.

tmcgee avatar Mar 08 '17 20:03 tmcgee

Have you messed with destroyRecursive or destroy at all? Should one of those perhaps be implemented?

green3g avatar Mar 08 '17 20:03 green3g

In theory, if I use dijit/registry and do something like:

registry.toArray().forEach(function(item){
    item.destroyRecursive();
});

It should resolve the issues.

But as you might expect each widget may utilize this at different levels and I can tell already, it is going to be a big problem I think throughout cmv. I think a lot of widgets don't clean up after themselves properly when destroy is called on them, so when they are reinitialized they have issues.

green3g avatar Mar 08 '17 20:03 green3g

The original panes are preserved in this.defaultPanes so they can be restored before initPanes method is called a second time

Why would initPanes be called a second time unless the app.startup method is called again?

green3g avatar Mar 08 '17 21:03 green3g

Hard to know your intent when you say CMV should be able to initialize more than once. I interpret this to mean starting an app from startup method.

tmcgee avatar Mar 08 '17 22:03 tmcgee

Oh, I misunderstood. So basically what I'm suggesting is this. We have a single page application where cmv is initialized based on the current state of the page. But CMV is not always loaded on the page.

For example:

  1. CMV is started on a dom node with a particular config.
  2. Some other part of the app changes, and cmv is removed (destroyed) from the dom
  3. A new dom node is created and CMV is initialized again, on that new dom node

Basically, on that new dom node, cmv needs to be able to re-initialize itself from scratch, but if there are panes left over from the previous startup these issues will arise.

green3g avatar Mar 08 '17 23:03 green3g