var entities = require('./mock/entities.json');
var Vue = require('vue');
var v3webpack = require('v3webpack-cli');
document.body.innerHTML="<div id='app0'></div>";
var widgetObjes=[{"componentCode":"login","windowCode":"login","widgetCode":"JGDiv1","elementId":"app0"}];
var attrs = [];
var data = {};
for(var ds in entities){
  var val = entities[ds];
  var datas = [];
  if(val){
    for(var i=0,l=val.length;i<l;i++){
      var rd = val[i];
      var metadata = {
        isCurrent : i==0,
        isSelected : i==0
      };
      rd._metadata_ = metadata;
      datas.push(rd);
    }
    datas.current= val.length>0 ? val[0]:{};  }
  data[ds] = datas;
  attrs.push(" :");
  attrs.push(ds);
  attrs.push("=\"");
  attrs.push(ds);
  attrs.push("\"");
}
for(var i=0,l=widgetObjes.length;i<l;i++){
  var widget = widgetObjes[i];
  var template = ["<"];
  var tagName = v3webpack.getWindowComponentName(widget.componentCode,widget.windowCode,widget.widgetCode);
  template.push(tagName);
  template = template.concat(attrs);
  template.push(">");
  template.push("</");
  template.push(tagName);
  template.push(">");debugger;
  new Vue({
    el : "#"+widget.elementId,
    template : template.join(""),
    data : data,
    methods : {aa:function(){alert(11);}}
  });
}
