-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitValueSetSheet.js
49 lines (39 loc) · 2.46 KB
/
InitValueSetSheet.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
function initvalueSetSheet(sheetName) {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const valueSetSheet = ss.insertSheet(sheetName, ss.getActiveSheet().getIndex());
// Setup the table size
const initialColumnSize = 7;
const initialRowSize = 16;
valueSetSheet.deleteColumns(initialColumnSize+1, 26-initialColumnSize);
valueSetSheet.deleteRows(initialRowSize+2, 1000-(initialRowSize+1));
valueSetSheet.setFrozenRows(1);
valueSetSheet.setFrozenColumns(4);
// Set the header labels
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_MAPPED_TO_ONTOLOGY_ACRONYM, "", 80);
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_MAPPED_TO_TERM_ID, "Mapped To", 150);
valueSetSheet.getRange(1, 1, 1, 2).mergeAcross();
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_CATEGORY, "Category", 150);
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_VALUE_LABEL, "Preferred Label", 150);
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_VALUE_DESCRIPTION, "Description", 520);
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_FORMAL_LABEL, "Canonical Label", 150);
setHeader(valueSetSheet, 1, VALUESET_GLOSSARY_IS_DEPRECATED, "Is Deprecated?", 150);
// Give color to selected columns
const headerRange = valueSetSheet.getRange(1, VALUESET_GLOSSARY_MAPPED_TO_ONTOLOGY_ACRONYM, 1, 4);
setRangeColor(headerRange, "#ead1dc"); // light red
const acronymRange = valueSetSheet.getRange(2, VALUESET_GLOSSARY_MAPPED_TO_ONTOLOGY_ACRONYM, initialRowSize, 1);
setRangeColor(acronymRange, "#ead1dc"); // light red
const mappedToRange = valueSetSheet.getRange(2, VALUESET_GLOSSARY_MAPPED_TO_TERM_ID, initialRowSize, 1);
setRangeColor(mappedToRange, "#ead1dc"); // light red
const categoryRange = valueSetSheet.getRange(2, VALUESET_GLOSSARY_CATEGORY, initialRowSize, 1);
setRangeColor(categoryRange, "#ead1dc"); // light red
const valueLabelRange = valueSetSheet.getRange(2, VALUESET_GLOSSARY_VALUE_LABEL, initialRowSize, 1);
setRangeColor(valueLabelRange, "#ead1dc"); // light red
const valueSetSheetRange = valueSetSheet.getRange(2, VALUESET_GLOSSARY_MAPPED_TO_TERM_ID, initialRowSize, initialColumnSize);
valueSetSheetRange.setHorizontalAlignment("left").setVerticalAlignment("top");
// The sheet is protected only to the owner by default
const protection = valueSetSheet.protect().setDescription('Protected ' + sheetName + ' sheet');
const owner = ss.getOwner().getEmail();
protection.removeEditors(protection.getEditors());
protection.addEditors([owner]);
return valueSetSheet;
}