-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTALibrary.js
More file actions
98 lines (91 loc) · 2.64 KB
/
TALibrary.js
File metadata and controls
98 lines (91 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* @class TALibrary
* @classdesc Class to work with different TAFolders
*
* @constructs TALibrary
* @param {Object} globals - object of global report variables {pageContext: this.pageContext, report: report, user: user, state: state, confirmit: confirmit, log: log}
* @param {Object[]} folders - Config.TAQuestions
*/
class TALibrary{
private var _globals;
private var _folders = [];
private var _currentFolder: TAFolder;
private var _filterQuestions;
function TALibrary(globals,config){
_globals = globals;
var filterQuestions = TAHelper.GetTagsFromSurvey(globals, config.DS_Main, ["ta_filter"]);
_filterQuestions = TAHelper.GetConfiguredVariables(globals, null, config.FilterQuestions, filterQuestions, []);
var folder: TAFolder;
for(var i = 0 ; i < config.TAQuestions.length; i++){
folder = new TAFolder(_globals,i, config);
_folders.push(folder);
}
_currentFolder = _folders[0];
}
/**
* @memberof TALibrary
* @instance
* @function GetFolders
* @returns {TAFolder[]}
*/
function GetFolders(){
return _folders;
}
/**
* @memberof TALibrary
* @instance
* @function GetFolderById
* @param {String} id
* @returns {TAFolder}
*/
function GetFolderById(id){
var result;
if(id){
for(var i=0; i<_folders.length; i++){
if(_folders[i].GetId() == id){
result = _folders[i];
break;
}
}
if(!result) {
throw new Error(201, "incorrect question Id");
}
return result
}else{
return _folders[0];
}
}
/**
* @memberof TALibrary
* @instance
* @function GetFilterQuestions
* @returns {String[]}
*/
function GetFilterQuestions(){
return _filterQuestions;
}
/**
* @memberof TALibrary
* @instance
* @function SetCurrentFolder
* @param {String} id
*/
function SetCurrentFolder(id){
for(var i=0; i<_folders.length; i++){
if(_folders[i].id == id){
_currentFolder = _folders[i];
break;
}
}
}
static function GetTAFoldersParameterValue(context) {
var selectedFolder = null;
try {
selectedFolder = !context.state.Parameters.IsNull("TA_FOLDERS") ? context.state.Parameters.GetString("TA_FOLDERS") : null;
} catch(e) {
selectedFolder = null;
} finally {
return selectedFolder;
}
}
}