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

add documentation

apply code guidelines
change previewField to readonly
parent b9df76c1
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@
<title>Vorschau</title>
<fieldName>PREVIEW</fieldName>
<contentType>IMAGE</contentType>
<state>READONLY</state>
</entityField>
<entityIncomingField>
<name>OrgDocument_dfi</name>
......
......@@ -2,25 +2,26 @@ import("system.vars");
import("system.result");
import("system.db");
// Check if assignment parameters are present
if(vars.exists("$param.AssignmentTable_param") &&
vars.exists("$param.AssignmentName_param") &&
vars.exists("$param.AssignmentRowId_param"))
{
vars.exists("$param.AssignmentRowId_param")) {
var assignmentTable = vars.get("$param.AssignmentTable_param");
var assignmentName = vars.get("$param.AssignmentName_param");
var assignmentRowId = vars.get("$param.AssignmentRowId_param");
var alias = db.getCurrentAlias();
var documents = [];
// Check for Selection
// Check if multiple Documents are selected
if(vars.exists("$local.idvalues") && vars.get("$local.idvalues") != '')
metadata = db.getBinaryMetadataForIds(vars.get("$local.idvalues"), true, alias)
else
metadata = db.getBinaryMetadata(assignmentTable, assignmentName, assignmentRowId, false, alias);
for( var i = 0; i < metadata.length; i++)
{
documents.push( [metadata[i].id, metadata[i].filename, metadata[i].size, metadata[i].edit, metadata[i].preview, metadata[i].mimetype]);
// Iterate through found binaray data and populate result array
for( var i = 0; i < metadata.length; i++) {
documents.push( [metadata[i].id, metadata[i].filename, metadata[i].size,
metadata[i].edit, metadata[i].preview, metadata[i].mimetype]);
}
result.object(documents);
......
......@@ -2,7 +2,7 @@
<preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.1">
<name>_____PREFERENCES_PROJECT</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<projectName>xRM-Basic-5-1</projectName>
<projectName>xRM-Basic5</projectName>
<jditoMaxContentSize v="57671680" />
<calendarCategoriesEvent>
<entry>
......
......@@ -3,29 +3,39 @@ import("system.db");
import("system.vars");
import("system.neon");
/**
* Provides static methods for managing documents.
* Do not create an instance of this
*
* @static
* @class
*/
function DocumentUtil(){
}
DocumentUtil.downloadSelectedDocuments = function(){
/**
* Utility function to download all selected or open documents.
* Selected documents will be checked with $local.uids.
* Open documents will be checked with $field.id.
* Documents will be downloaded with neon.doanload
*/
DocumentUtil.downloadSelectedDocuments = function() {
var alias = db.getCurrentAlias();
// Multiple Files (=not oppened)
if(vars.exists("$local.uids"))
{
// Download selected files (=not oppened)
if(vars.exists("$local.uids")) {
var rows = JSON.parse(vars.get("$local.rows"));
var uids = JSON.parse(vars.get("$local.uids"));
var binaryContents = db.getBinaryContents(uids, alias);
for(var i = 0; i < binaryContents.length; i++)
{
for(var i = 0; i < binaryContents.length; i++) {
var base64data = binaryContents[i];
var filename = rows[i]["NAME"];
neon.download(base64data, filename);
}
}
// Single File (=already opened)
else if(vars.exists("$field.ID"))
{
// Download open file
else if(vars.exists("$field.ID")) {
var id = vars.get("$field.ID");
var name = vars.get("$field.NAME");
var binaryContent = db.getBinaryContent(id, alias);
......@@ -33,9 +43,11 @@ DocumentUtil.downloadSelectedDocuments = function(){
}
}
DocumentUtil.deleteCurrentDocument = function(){
if(vars.exists("$local.uid"))
{
/**
* Utility function to delete the current/opened Document.
*/
DocumentUtil.deleteCurrentDocument = function() {
if(vars.exists("$local.uid")) {
var uid = vars.get("$local.uid");
var alias = db.getCurrentAlias();
db.deleteBinary(uid, alias);
......
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