[Import/Export] Adds Import and Export functionality
Added context actions for importing and exporting JSON representations of domain objects. Added FileInputService for triggering file picker and retrieving uploaded data. Also added a File Input form control for integration with MCTForms.
This commit is contained in:
@@ -65,6 +65,20 @@ define(['csv'], function (CSV) {
|
||||
this.saveAs(blob, filename);
|
||||
};
|
||||
|
||||
/**
|
||||
* Export an object as a JSON file. Triggers a download using the function
|
||||
* provided when the ExportService was instantiated.
|
||||
*
|
||||
* @param {Object} obj an object to be exported as JSON
|
||||
* @param {ExportOptions} [options] additional parameters for the file
|
||||
* export
|
||||
*/
|
||||
ExportService.prototype.exportJSON = function (obj, options) {
|
||||
var filename = (options && options.filename) || "test-export.json";
|
||||
var jsonText = JSON.stringify(obj);
|
||||
var blob = new Blob([jsonText], {type: "application/json"});
|
||||
this.saveAs(blob, filename);
|
||||
};
|
||||
/**
|
||||
* Additional parameters for file export.
|
||||
* @typedef ExportOptions
|
||||
|
||||
Reference in New Issue
Block a user