-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.gs
109 lines (82 loc) · 2.54 KB
/
Main.gs
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
99
100
101
102
103
104
105
106
107
108
109
function onOpen() {
FirebaseConnector.setToken("");
//create Amis menu
Utility.createAmisMenu();
//alert for amis menu
if (!Config.devMode) {
Browser.msgBox('To Open AMIS click on "AMIS" in the menu');
}
//read all the named ranges and put in cache
AmisNamedRanges.getAllNamedRanges();
//cache all cols with in each template.
ProtectionMaker.getTmplColsWidth();
}
function openSidebar(){
//create sidebar
Utility.openSidebar();
}
/**
* function called on the onEdit event
* @param {object} e the event
* @return {void}
*/
function onEdit(e){
var activeRangeA1, template, sheet;
//IF user is NOT editing a Template Sheet. Do normal logic.
if( !Utility.isTemplate() && !Utility.isMaster() ) {
sheet=SpreadSheetCache.getActiveSheet();
template=Utility.getTemplateBySheetObj(sheet);
activeRangeA1=e.range.getA1Notation();
if (!ProtectionMaker.validateColumnNumber(sheet, template)) {
return;
}
if (!ProtectionMaker.protectWrongForecast(activeRangeA1)) {
return;
}
//forecast methodologies on edit
ForecastingMethodologies.onEdit(e);
//set the last date on edit event
LastDateUpdater.onEditSetLastUpdateDate(e, activeRangeA1);
//sets the B4 cell
SyncMasterSheet.setLastUpdate();
}
}
/**
* onLogin event
*/
function onLogin(){
if (Utility.isMaster()) {
return;
}
//ForecastingMethodologies.getConfig(true);
}
/**
* protect sheet event
* @deprecated not used
*/
function protectSheet(userToken){
userToken = userToken ? userToken : FirebaseConnector.getToken();
if(userToken){
//Need for LASTDATE UPDATER -- it set range to be protected from update date and other info
LastDateUpdater.protectCell(userToken);
//ProtectRanges.protectCell(userToken);
//store the ranges where not apply rebuild style, formulas , conditional formatting
//ProtectFormulas.protectCell(userToken);
//store the last row update label position
// LastDateUpdater.protectCell(userToken);
//
//ProtectionMaker.protectCell(userToken);
//store the rules for new formulas
//ForecastUtility.protectCell(userToken);
}
}
/**
* setter for the firebase token
* @param {string} token
*/
function setSecretariatCountry (chosenCountry ) {
PropertiesService.getUserProperties().setProperty("secretariatCountry", chosenCountry);
};
function getSecretariatCountry( ) {
return PropertiesService.getUserProperties().getProperty("secretariatCountry");
};