-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTAHitlistUtils.js
More file actions
78 lines (68 loc) · 2.93 KB
/
TAHitlistUtils.js
File metadata and controls
78 lines (68 loc) · 2.93 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
/**
* @class TAHitlistUtils
* @classdesc Class to work with the hitlist
*
* @constructs TAHitlistUtils
* @param {Object} globals - object of global report variables {pageContext: this.pageContext, report: report, user: user, state: state, confirmit: confirmit, log: log}
* @param {TAFolder} folder
* @param {Hitlist} hitlist
*/
class TAHitlistUtils{
private var _globals;
private var _folder: TAFolder;
private var _hitlist: HitList;
function TAHitlistUtils(globals, folder, hitlist){
_globals = globals;
_folder = folder;
_hitlist = hitlist;
}
/**
* @memberof TAHitlistUtils
* @instance
* @function AddTAColumn
* @description function to add a text analytics variable to the hitlist
* @param {String} columnName - type of the question "overallsentiment" or "os", "categories" or "c", "positivementions" or "positive" or "pm", "negativementions" or "negative" or "nm", "categorysentiment" or "cs"
* @param {Boolean} sortable
* @param {String} postfix - id of the selected category
*/
function AddTAColumn(columnName, sortable, postfix){
var hitlistColumn: HitListColumn = new HitListColumn();
var dsId = _folder.GetDatasourceId();
var project: Project = _globals.report.DataSource.GetProject(dsId);
var columnId = _folder.GetQuestionId(columnName);
hitlistColumn.QuestionnaireElement = columnName == "categorysentiment" ? project.CreateQuestionnaireElement(columnId, postfix) : project.CreateQuestionnaireElement(columnId);
sortable ? (hitlistColumn.IsSortable = true) : null;
_hitlist.Columns.Add(hitlistColumn);
}
/**
* @memberof TAHitlistUtils
* @instance
* @function AddColumn
* @description function to add a not text analytics variable to the hitlist
* @param {String} columnName - variable qId
* @param {Boolean} sortable
*/
function AddColumn(columnName, sortable){
var hitlistColumn: HitListColumn = new HitListColumn();
var project : Project = _globals.report.DataSource.GetProject(_folder.GetDatasourceId());
hitlistColumn.QuestionnaireElement = project.CreateQuestionnaireElement(columnName);
sortable ? (hitlistColumn.IsSortable = true) : null;
_hitlist.Columns.Add(hitlistColumn);
}
/**
* @memberof TAHitlistUtils
* @instance
* @function AddConfiguredColumns
* @description function to add columns from config
*/
function AddConfiguredColumns(){
var hitlistColumn: HitListColumn;
var project : Project = _globals.report.DataSource.GetProject(_folder.GetDatasourceId());
var columns = _folder.GetHitlistColumns();
for( var i = 0; i < columns.length; i++){
hitlistColumn = new HitListColumn();
hitlistColumn.QuestionnaireElement = project.CreateQuestionnaireElement(columns[i]);
_hitlist.Columns.Add(hitlistColumn);
}
}
}