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

remove defaultAction

add filename from uploaded file
add utility methods to retrieve filename/filedata
parent 4bd6acc5
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@
<name>NAME</name>
<title>Dateiname</title>
<fieldName>FILENAME</fieldName>
<mandatory v="true" />
<state>AUTO</state>
</entityField>
<entityField>
......@@ -44,6 +45,7 @@
<title>Datum</title>
<fieldName>EDIT_DATE</fieldName>
<contentType>DATE</contentType>
<outputFormat>yyyy-MM-dd HH:mm:ss</outputFormat>
<state>READONLY</state>
</entityField>
<entityField>
......@@ -69,7 +71,7 @@
<name>BINDATA_UPLOAD</name>
<title>Datei</title>
<contentType>FILE</contentType>
<defaultAction>%aditoprj%/entity/Document_entity/entityfields/bindata_upload/defaultAction.js</defaultAction>
<onValueChange>%aditoprj%/entity/Document_entity/entityfields/bindata_upload/onValueChange.js</onValueChange>
</entityField>
<entityActionGroup>
<name>Document_actions</name>
......
import("system.logging");
logging.log("document default action");
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
import("Util_lib");
import("Document_lib");
var uploadValue = ProcessHandlingUtil.getOnValidationValue(vars.get("$field.BINDATA_UPLOAD"));
neon.setFieldValue("$field.NAME", DocumentUtil.getFilenameFromUpload(uploadValue));
import("system.logging");
import("system.db");
import("system.vars");
import("Document_lib");
var assignmentTable = vars.get("$param.AssignmentTable_param");
var assignmentName = vars.get("$param.AssignmentName_param");
var assignmentRowId = vars.get("$param.AssignmentRowId_param");
var bindata = vars.get("$field.BINDATA_UPLOAD");
var bindata = DocumentUtil.getBindataFromUpload(vars.get("$field.BINDATA_UPLOAD"));
var filename = vars.get("$field.NAME");
var description = vars.get("$field.DESCRIPTION");
var alias = db.getCurrentAlias();
......
import("system.vars");
import("system.db");
import("system.logging");
import("Document_lib");
var id = vars.get("$field.ID");
var parentId = "";
......@@ -8,10 +9,15 @@ var fileName = vars.get("$field.NAME");
var description = vars.get("$field.DESCRIPTION");
var keyword = "";
var alias = db.getCurrentAlias();
var base64data = vars.get("$field.BINDATA_UPLOAD");
var bindata = DocumentUtil.getBindataFromUpload(vars.get("$field.BINDATA_UPLOAD"));
if (bindata == ''){
bindata = vars.get("$field.BINDATA_UPLOAD")
}
// Check if bindata is present and execute the corresponding update method
if(base64data != '')
db.updateBinary(id, parentId, base64data, fileName, description, keyword, alias);
if(bindata != '')
db.updateBinary(id, parentId, bindata, fileName, description, keyword, alias);
else
db.updateBinaryMetadata(id, parentId, fileName, description, keyword, alias);
\ No newline at end of file
......@@ -10,6 +10,25 @@
<alias>Data_alias</alias>
<fromClauseProcess>%aditoprj%/entity/Pers_entity/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/Pers_entity/conditionProcess.js</conditionProcess>
<linkInformation>
<linkInformation>
<name>9ce0dfd2-192d-4446-8b2d-a4c053abc44a</name>
<tableName>PERS</tableName>
<primaryKey>PERSID</primaryKey>
</linkInformation>
<linkInformation>
<name>348312a8-6392-4adb-af69-75cbcfc5b65b</name>
<tableName>RELATION</tableName>
<primaryKey>RELATIONID</primaryKey>
<isUIDTable v="true" />
</linkInformation>
<linkInformation>
<name>edf5e4f3-993d-4097-b59d-a100d5222cad</name>
<tableName>ORG</tableName>
<primaryKey>ORGID</primaryKey>
<readonly v="true" />
</linkInformation>
</linkInformation>
<entityFields>
<entityField>
<name>DATEOFBIRTH</name>
......@@ -449,23 +468,4 @@
<description>PARAMETER</description>
</entityParameter>
</entityFields>
<linkInformation>
<linkInformation>
<name>9ce0dfd2-192d-4446-8b2d-a4c053abc44a</name>
<tableName>PERS</tableName>
<primaryKey>PERSID</primaryKey>
</linkInformation>
<linkInformation>
<name>348312a8-6392-4adb-af69-75cbcfc5b65b</name>
<tableName>RELATION</tableName>
<primaryKey>RELATIONID</primaryKey>
<isUIDTable v="true" />
</linkInformation>
<linkInformation>
<name>edf5e4f3-993d-4097-b59d-a100d5222cad</name>
<tableName>ORG</tableName>
<primaryKey>ORGID</primaryKey>
<readonly v="true" />
</linkInformation>
</linkInformation>
</entity>
......@@ -53,3 +53,35 @@ DocumentUtil.deleteCurrentDocument = function() {
db.deleteBinary(uid, alias);
}
}
/**
* Utility function to retrieve the filename from an uploadcomponent value.
* The value of an uploadcomponent contains filename + filedata separated by
* a semicolon e.g. "file1.jpg;base64data"
*
* @param {String} pUploadValue the value of the uploadcomponent (filename + filedata)
* @return {String} the filename or empty String
*/
DocumentUtil.getFilenameFromUpload = function(pUploadValue) {
var result = pUploadValue.split(";");
if(result.length > 0)
return result[0];
else
return '';
}
/**
* Utility function to retrieve the filedata from an uploadcomponent value.
* The value of an uploadcomponent contains filename + filedata separated by
* a semicolon e.g. "file1.jpg;base64data"
*
* @param {String} pUploadValue the value of the uploadcomponent (filename + filedata)
* @return {String} the filedata or empty String
*/
DocumentUtil.getBindataFromUpload = function(pUploadValue) {
var result = pUploadValue.split(";");
if(result.length > 1)
return result[1];
else
return '';
}
\ No newline at end of file
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