webix-hub / webix-jet

Webix Jet micro framework for Webix UI
67 stars 19 forks source link

Init window/popup view class with Webix-Jet doesn't work because of webpack transpiling #18

Closed vunguyen-it closed 6 years ago

vunguyen-it commented 6 years ago

I'm facing the issue that the window/popup and context menu view that defined to extends JetView will not be able to init by this.ui() inside the parent view. Please see the example code below:

class WindowsView extends JetView {
    config(){
        return {
            view:"popup",
            top:200, left:300,
            body:{ template:"Text 2 (fixed position)" }
        };
    }
    showWindow(){
        this.getRoot().show();
    }
}

class TopView extends JetView {
  config(){
    return {
      rows:[{
        template:"Webix Jet Demo", type:"header"
      },{
        view:"button",
        value: "window",
        click: () => {
          this.context.showWindow()
        }
      }]
    }
  }  
  init(){
    this.context = this.ui(WindowsView);
    console.log(this.context)
  }
  destroy(){
    $$("context").destructor();
  }
}

var app = new JetApp({
  start:"/top",
  debug:true,
  views:{
    top: TopView
  }
});

app.render();

As my investigation, webpack build will transpile the class to function form in the end, and then webix will not able to determine the input layout/view, it will return a spacer view (something like that) as default.

So is there any solutions for this, I want to keep the layout and logic of the window/popup extends JetView.

Please advise. Many thanks

mkozhukh commented 6 years ago

Try to update your code to the latest version of Webix Jet Starting from version 1.4, the code uses a more correct test for Webix Jet classes, so above must work ( Work for me locally, with Webix Jet 1.5.3 )