Commit b9301b7b authored by Sven Franck's avatar Sven Franck

hack link to fetch invoice PDF file, hack field displays

parent 1a67168a
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
{"field": "total_price", "show": true, "persist": true, "sort":false}, {"field": "total_price", "show": true, "persist": true, "sort":false},
{"field": "price_currency", "show": "true", "priority": 4, "merge": "total_price"}, {"field": "price_currency", "show": "true", "priority": 4, "merge": "total_price"},
{"field": "translated_simulation_state_title", "show":"true", "priority": 5}, {"field": "translated_simulation_state_title", "show":"true", "priority": 5},
{"custom": true, "show": true, "persist": true, "sort": false, "action_list": [{"setters": ["data-method", "href"], "setValues":[["_actions", "destroy", "method"], ["_actions", "destroy", "href"]], "class_list": "action translate", "action": "download", "icon":"file-alt", "text": "Download", "text_i18n":"portable_type_dict.invoice_dict.download"}]} {"custom": true, "show": true, "persist": true, "sort": false, "action_list": [{"class_list": "action translate", "action": "download", "icon":"file-alt", "text": "Download", "text_i18n":"portable_type_dict.invoice_dict.download"}]}
] ]
} }
], ],
......
...@@ -1084,6 +1084,29 @@ ...@@ -1084,6 +1084,29 @@
.fail(util.error); .fail(util.error);
}, },
/**
* Download a document as pdf
* @method download
* @param {string} type
* @param {string} portal type
* @param {string} identifier
**/
"download": function (obj) {
console.log(obj)
util.loader("", "status_dict.downloading");
storage["items"].get({"_id": obj.element.href.split("/").pop()},{"_view": "web_view"})
.then(function(response) {
util.loader("", "status_dict.rendering");
window.location.href = util.parse(response).data._links.slapos_jump.href;
})
.fail(function (error){
util.error(error);
util.loader("", "status_dict.failed", "ban-circle");
});
},
/** /**
* Look up single value from dict * Look up single value from dict
* @method translateLookup * @method translateLookup
...@@ -1456,18 +1479,6 @@ ...@@ -1456,18 +1479,6 @@
factory.util.setPopupPointer(obj, "export"); factory.util.setPopupPointer(obj, "export");
}, },
/**
* Download a document as pdf
* @method download
* @param {string} type
* @param {string} portal type
* @param {string} identifier
**/
"download": function (obj) {
console.log(obj)
util.error("Download: Not implemented.");
},
/** /**
* Generic pagination method changing number of records displayed * Generic pagination method changing number of records displayed
* @method limit * @method limit
...@@ -1636,8 +1647,8 @@ ...@@ -1636,8 +1647,8 @@
// TODO: action menu handling...? // TODO: action menu handling...?
// TODO: should we set properties.config here or ? // TODO: should we set properties.config here or ?
"mapTableRows": function (items, spec, field_dict, url_pointer, update) { "mapTableRows": function (items, spec, field_dict, url_pointer, update) {
var arr, obj, cell, row, i, j, k, m, n, section, label, props, core, var arr, obj, cell, row, i, j, k, m, n, o, section, label, props, core,
item, level, scheme, segment; item, level, scheme, segment, p;
if (spec.scheme === undefined) { if (spec.scheme === undefined) {
util.error("mapTableRows: Missing scheme"); util.error("mapTableRows: Missing scheme");
...@@ -1716,6 +1727,13 @@ ...@@ -1716,6 +1727,13 @@
// action menu // action menu
if (props.action_menu && cell.action_list) { if (props.action_menu && cell.action_list) {
// HACK to add correct HREF and reference
if (item._relative_url) {
for (o = 0; o < cell.action_list.length; o += 1) {
cell.action_list[o].reference = spec.set_id;
cell.action_list[o].href = window.encodeURIComponent(item._relative_url);
}
}
cell.action_list = cell.action_list || []; cell.action_list = cell.action_list || [];
} }
...@@ -1724,11 +1742,21 @@ ...@@ -1724,11 +1742,21 @@
cell.image = item[cell.field]; cell.image = item[cell.field];
} else { } else {
// custom cells have text/text_i18n defined // custom cells have text/text_i18n defined
// more HACK:
if (cell.custom === undefined) { if (cell.custom === undefined) {
if (cell.field === "price_currency") {
cell.text = item[cell.field].split("/").pop();
cell.text_i18n = null;
} else {
if (!isNaN(parseFloat(item[cell.field])) && isFinite(item[cell.field])) {
cell.text = Math.round(item[cell.field]).toFixed(2);
} else {
cell.text = item[cell.field]; cell.text = item[cell.field];
}
cell.text_i18n = item[cell.field + "_i18n"] || null cell.text_i18n = item[cell.field + "_i18n"] || null
} }
} }
}
// add cell to row // add cell to row
row.push(cell); row.push(cell);
} }
...@@ -2786,6 +2814,7 @@ ...@@ -2786,6 +2814,7 @@
} }
} }
dict["data-action"] = button.action; dict["data-action"] = button.action;
dict["data-reference"] = button.reference;
config.children.push({ config.children.push({
"type": "a", "type": "a",
...@@ -7538,7 +7567,6 @@ ...@@ -7538,7 +7567,6 @@
convert = "values"; convert = "values";
} }
console.log(parcel.query)
return storage[parcel.storage][method || "allDocs"](parcel.query, hacked_view) return storage[parcel.storage][method || "allDocs"](parcel.query, hacked_view)
.then(function (response) { .then(function (response) {
// TODO: best way? // TODO: best way?
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
"uploading": "Uploading", "uploading": "Uploading",
"fetching": "Fetching Data", "fetching": "Fetching Data",
"storing": "Storing Data", "storing": "Storing Data",
"downloading": "Downloading",
"rendering": "Rendering",
"saving": "Saving", "saving": "Saving",
"saved": "Saved", "saved": "Saved",
"failed": "Failed", "failed": "Failed",
......
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