Commit 41612f99 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Use handlebars template to render invoices.

parent da6a02ed
......@@ -8,8 +8,16 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_slapos_invoice_printout.js"></script>
<script id="download-link-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child ui-btn-icon-center" data-i18n="Download Invoice" target=_blank href={{invoice_url}} > <img src='pdf_icon.png'></img></a></li>
</ul>
</script>
</head>
<body>
<button data-i18n="loading" type="submit" class="responsive ui-btn ui-icon-spinner ui-icon-spin ui-btn-icon-center ui-disabled" style="border:none;">loading</button>
</body>
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.59109.57245.24132</string> </value>
<value> <string>964.60140.15778.40123</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1516299235.36</float>
<float>1516361248.37</float>
<string>UTC</string>
</tuple>
</state>
......
/*globals console, window, rJS, RSVP, loopEventListener, i18n, $*/
/*globals console, window, rJS, RSVP, loopEventListener, i18n, Handlebars $*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, Handlebars) {
"use strict";
var gadget_klass = rJS(window);
var gadget_klass = rJS(window),
download_invoice_source = gadget_klass.__template_element
.getElementById("download-link-template")
.innerHTML,
download_invoice_template = Handlebars.compile(download_invoice_source);
gadget_klass
.declareAcquiredMethod("jio_get", "jio_get")
......@@ -19,10 +23,14 @@
.push(function (element) {
return gadget.getSetting("hateoas_url")
.push(function (hateoas_url) {
var link = "<a href=" + hateoas_url + "/" + options.value.jio_key + "/SaleInvoiceTransaction_viewSlapOSPrintout> <img src='pdf_icon.png'></img> </a>";
element.innerHTML = link;
var link = hateoas_url + "/" +
options.value.jio_key +
"/SaleInvoiceTransaction_viewSlapOSPrintout";
element.innerHTML = download_invoice_template({
invoice_url: link
});
return element;
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.59129.49175.45653</string> </value>
<value> <string>964.60112.26500.11690</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1516300442.85</float>
<float>1516360952.96</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment