Skip to content
Snippets Groups Projects
Commit 0bee6d51 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

added comments to Keyword_lib

[Projekt: Entwicklung - Neon][TicketNr.: 1022526][Bereitstellung erste Version 5.1 Customizing für Gremium]
parent f2bae3e7
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("system.translate");
/**
* provides methods for interactions with keywords
*/
function KeywordUtils(){
/**
* returns the default case for keyword-arrays (id and translated name)
* @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY"
* @return {Array} a 2D array in form of [["id1", "name1"], ["idN", "nameN"]]
* @example
* var kwdUtils, items;
*
* kwdUtils = new KeywordUtils();
* items = kwdUtils.getStandardArray("ADDRESS.TYPE");
* result.object(items);
*/
this.getStandardArray = function(keywordType){
return this.createKeyword(keywordType).toArray();
return this.createKeyword(keywordType).toArray(["id", "name"]);
}
/**
* returns a specific name (translated) - this is normally the view-value - of a given keyword;
* <br/>if the key could not be found an empty string "" is returned
* @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY"
* @param {String} key id value of the keyword where the view-value shall be searched
* @return {String} representation of the translated name of the keyword-key
* @example
* var kwdUtils, histMedium;
* histMedium = vars.get("$field.MEDIUM");
* if (histMedium){
* kwdUtils = new KeywordUtils();
* result.string(vars.get("$field.SUBJECT") + " (" + kwdUtils.getViewValue("HISTORY.MEDIUM", histMedium) + ")");
* }
*/
this.getViewValue = function(keywordType, key){
var k = this.createKeyword(keywordType);
return k.getPropForKey(key, "name") || "";
}
/**
* creates an object with methods for interacting with an specific keyword
* @param {String} keywordType specifies the type of the keyword and therefore the list elements; e.g. "COUNTRY"
* @return {Object} object with the following methods:
* <br/>- toArray
* <br/>- getPropForKey
* <br/>- getPropsForKey
*/
this.createKeyword = function(keywordType){
var valueContainer, _toArrayFn, _getPropForKeyFn, _getPropsForKeyFn;
......@@ -99,7 +135,7 @@ function KeywordUtils(){
if (keyObject == undefined)
return undefined;
return keyObject[field];
}
};
_getPropsForKeyFn = function(key, fields) {
var keyObject, i, l, currentRow, currentField;
......@@ -119,7 +155,7 @@ function KeywordUtils(){
currentRow.push("");
}
return currentRow;
}
};
_toArrayFn = function(fields){
var res, id, currentRow;
......@@ -133,17 +169,17 @@ function KeywordUtils(){
res.push(currentRow);
}
return res;
}
};
return {
/*
*test
**/
"toArray": _toArrayFn
,"getPropForKey": _getPropForKeyFn
,"getPropsForKey": _getPropsForKeyFn
}
}
/**
* toArray
*/
toArray: _toArrayFn
,getPropForKey: _getPropForKeyFn
,getPropsForKey: _getPropsForKeyFn
};
};
function createKeywordEntry(id, name, description){
......@@ -161,7 +197,7 @@ function KeywordUtils(){
id: id
,name: name
,description: description || ""
}
};
}
function createKeywordEntriesContainer(keywordEntries){
......
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