-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrender-check_grid.js
64 lines (53 loc) · 1.75 KB
/
render-check_grid.js
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
/*
Writes parsed check grids based on 'Tickbox grid' form elements
to the output document (field-check_grid). Unlike their radio
button counterparts, they are always displayed as the complete
grid with no "LITE" option.
*/
function prepareCheckGridCells(parsedChkGrid, dataObject)
{
var rowIndex = 0;
var currentHeader = "";
var currentTableRow = [];
var currentStatusRow = [];
var columnIndex = 0;
var currentStatusValue = false;
var currentCellText = "";
// Loops checkbox grid object rows.
for (rowIndex = 0; rowIndex < parsedChkGrid.rowList.length; rowIndex = rowIndex + 1)
{
// Reads current row name and initializes grid row.
currentHeader = parsedChkGrid.rowList[rowIndex];
currentTableRow = [currentHeader];
currentStatusRow = [];
columnIndex = 0;
currentStatusValue = false;
currentCellText = "";
// Reads current tick status row.
if (rowIndex >= 0 && rowIndex < parsedChkGrid.boxStatus.length)
{
currentStatusRow = parsedChkGrid.boxStatus[rowIndex];
}
// Loops status cells.
while (columnIndex >= 0 && columnIndex < parsedChkGrid.columnList.length)
{
currentStatusValue = false;
currentCellText = dataObject.unfilledItem;
// If grid column exists, read corresponding tick status for cell.
if (columnIndex >= 0 && columnIndex < currentStatusRow.length)
{
currentStatusValue = currentStatusRow[columnIndex];
}
if (currentStatusValue === true)
{
// Box ticked.
currentCellText = dataObject.filledItem;
}
// Add cell.
currentTableRow.push(currentCellText);
columnIndex = columnIndex + 1;
}
// Adds prepared row to document table.
dataObject.cellGrid.push(currentTableRow);
}
}