Commit 30d26f93 authored by Jérome Perrin's avatar Jérome Perrin

Turn Output_viewDownloadExcelSpreadsheet in a generic Output_viewDownloadFile gadget

The action must have in its configuration an output_id, which must
correspond to an object under the key output_id.
This object has the following properties:
  name: the name of the file to download
  mime_type: the mime type of this file
  data: the data, encoded in base64
parent f21637f4
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script> <script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Output_viewDownloadExcelSpreadsheet.js" type="text/javascript"></script> <script src="Output_viewDownloadFile.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<a class="download_link ui-btn ui-btn-inline ui-icon-action ui-btn-icon-right">Download</a> <a class="download_link ui-btn ui-btn-inline ui-icon-action ui-btn-icon-right">Download</a>
......
...@@ -24,13 +24,14 @@ ...@@ -24,13 +24,14 @@
"_attachment": "body.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
var result = JSON.parse(simulation_json)[0].result, var result = JSON.parse(simulation_json).result.result_list[options.result],
output = result[options.action_definition.configuration.output_id],
download_link = gadget.props.element.querySelector( download_link = gadget.props.element.querySelector(
".download_link" ".download_link"
); );
download_link.download = "demandPlannerOutput.xls"; /* XXX this does not work with Internet Explorer */
download_link.href = "data:application/excel;base64," download_link.download = output.name;
+ result['demandPlannerOutput.xls']; download_link.href = "data:" + output.mime_type+ ";base64," + output.data;
}); });
}) })
......
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