Skip to content
Snippets Groups Projects
Commit e2d7b0bd authored by Markus Escher's avatar Markus Escher
Browse files

change Document_lib download to selectionRows

parent bf1e7549
No related branches found
No related tags found
No related merge requests found
import("Document_lib");
DocumentUtil.downloadSingleDocument();
DocumentUtil.downloadSelectedDocuments();
......@@ -15,17 +15,27 @@ function DocumentUtil(){
/**
* Utility function to download all selected documents.
* Selected documents will be checked with $local.uids.
* Selected documents will be checked with $sys.selectionRows
* Documents will be downloaded with neon.download
*/
DocumentUtil.downloadSelectedDocuments = function() {
var alias = db.getCurrentAlias();
// Download selected files (=not opened)
if(vars.exists("$local.uids") && vars.exists("$local.rows")
&& vars.get("$local.rows") && JSON.parse(vars.get("$local.rows")).length > 0) {
var rows = JSON.parse(vars.get("$local.rows"));
var uids = JSON.parse(vars.get("$local.uids"));
if(vars.exists("$sys.selectionRows") && vars.get("$sys.selectionRows")) {
var rows;
try {
rows = JSON.parse(vars.get("$sys.selectionRows"));
} catch (e) {
rows = JSON.parse(JSON.stringify(vars.get("$sys.selectionRows")));
}
var uids;
try {
uids = JSON.parse(vars.get("$sys.selection"));
} catch (e) {
uids = JSON.parse(JSON.stringify(vars.get("$sys.selection")));
}
var binaryContents = db.getBinaryContents(uids, alias);
// check if multiplie Files are selected.
......@@ -39,29 +49,6 @@ DocumentUtil.downloadSelectedDocuments = function() {
}
}
/**
* Utility function dow download a single Document.
*/
DocumentUtil.downloadSingleDocument = function() {
var alias = db.getCurrentAlias();
var id;
var name;
if(vars.exists("$local.uid")) {
// Download single file (=not opened)
id = JSON.parse(vars.get("$local.uid"));
name = vars.get("$local.value");
} else {
// Download open file
id = vars.get("$field.UID");
name = vars.get("$field.NAME");
}
var binaryContent = db.getBinaryContent(id, alias);
if(binaryContent != null && binaryContent != '')
neon.download(binaryContent, name);
}
/**
* Utility function to delete the current/opened Document.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment