0
1
Fork 0
hedera-web-mindshore/js/hedera/report.js

82 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-10-21 23:34:35 +00:00
2022-05-24 21:11:12 +00:00
module.exports = new Class({
2015-10-21 23:34:35 +00:00
Extends: Vn.Object
2022-05-24 21:11:12 +00:00
,initialize: function(moduleInfo, gui) {
this.info = moduleInfo;
this.gui = gui;
this.conn = gui.conn;
2022-05-24 21:11:12 +00:00
this.parent(null);
}
2022-05-30 01:30:33 +00:00
,open: function(lot) {
this.lot = lot;
2022-05-24 21:11:12 +00:00
this.createWindow();
}
2015-10-21 23:34:35 +00:00
2022-05-24 21:11:12 +00:00
,print: function() {
this.window.print();
2015-10-21 23:34:35 +00:00
}
2022-05-24 21:11:12 +00:00
,includeCss: function(path) {
2015-10-21 23:34:35 +00:00
var basePath = location.protocol +'//'+ location.host;
basePath += location.port ? ':'+ location.port : '';
2022-05-24 21:11:12 +00:00
basePath += location.pathname.substring(0,
location.pathname.lastIndexOf('/'));
2015-10-21 23:34:35 +00:00
2022-05-24 21:11:12 +00:00
var link = this.doc.createElement('link');
2015-10-21 23:34:35 +00:00
link.rel = 'stylesheet';
link.type = 'text/css';
2022-05-24 21:11:12 +00:00
link.href = basePath +'/'+ path + Vn.getVersion();
2015-10-21 23:34:35 +00:00
2022-05-24 21:11:12 +00:00
var head = this.doc.getElementsByTagName('head')[0];
head.appendChild(link);
2015-10-21 23:34:35 +00:00
}
2022-05-24 21:11:12 +00:00
,createWindow: function() {
var reportWindow = window.open(
2015-11-19 13:57:23 +00:00
'js/hedera/report.html', '_blank',
'height=650, width=950, resizable=yes, fullscreen=no,'+
2015-11-19 13:57:23 +00:00
'titlebar=no, menubar=no, toolbar=no, location=no, scrollbars=yes'
);
2015-10-21 23:34:35 +00:00
2022-05-24 21:11:12 +00:00
if (!reportWindow) {
Htk.Toast.showError(
_('Please unlock popups and try again'));
2015-11-19 13:57:23 +00:00
return false;
2015-10-21 23:42:52 +00:00
}
2022-05-24 21:11:12 +00:00
reportWindow.addEventListener('load',
this._onWindowLoad.bind(this));
2015-10-21 23:42:52 +00:00
this.window = reportWindow;
2015-11-19 13:57:23 +00:00
return true;
}
2022-05-24 21:11:12 +00:00
,_onWindowLoad: function() {
2015-11-19 13:57:23 +00:00
this.doc = this.window.document
2022-05-24 21:11:12 +00:00
this.includeCss('reports/'+ this.info.path +'/style.css');
2015-11-19 13:57:23 +00:00
2022-05-24 21:11:12 +00:00
var printButton = this.doc.getElementById('print');
printButton.addEventListener('click', this.print.bind(this));
Vn.Node.setText(printButton, _('Print'));
2015-11-19 13:57:23 +00:00
2022-05-24 21:11:12 +00:00
this.onWindowCreate();
2015-11-19 13:57:23 +00:00
}
2022-05-24 21:11:12 +00:00
,onWindowCreate: function() {
var builder = new Vn.Builder();
builder.compileFile('reports/'+ this.info.path +'/ui.xml');
2015-11-19 13:57:23 +00:00
2022-05-24 21:11:12 +00:00
var scope = this.scope = builder.load(this.doc, this);
2022-05-26 06:08:31 +00:00
scope.link(null, {
2022-05-30 01:30:33 +00:00
lot: this.lot,
2022-05-24 21:11:12 +00:00
conn: this.conn
});
2022-05-28 01:18:06 +00:00
this.$ = scope.$;
2015-11-19 13:57:23 +00:00
2022-05-28 01:18:06 +00:00
this.doc.body.appendChild(scope.$.report);
2015-10-21 23:34:35 +00:00
}
});