-
Notifications
You must be signed in to change notification settings - Fork 0
/
ManageEditsForm.js
141 lines (118 loc) · 4.62 KB
/
ManageEditsForm.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//the setTrigger functions activite a trigger that calls in whenever someone submits
//a new entry in the meeting form. I have one for production and one for testing (in theory)
function setTriggerDev() {
var form = FormApp.openById('1J1ziKGmfP9oPEL26_cIoOvpheWd_O6MPUpSE11lVH3c');
ScriptApp.newTrigger('parseFormInfoDev')
.forForm(form)
.onFormSubmit()
.create();
}
function setTriggerProd() {
var form = FormApp.openById('1I8UJCjdycdO0ZBGoPDJtqUczUsy7JuoI4DpnvaC1PII');
ScriptApp.newTrigger('parseFormInfoProd')
.forForm(form)
.onFormSubmit()
.create();
}
//these functions are called whenever the forms are filled
//the only difference between prod/dev is the summary page used to
//look up the current ORP list
function parseFormInfoDev(e) {
orpSummaryPage='1EupTnQ4Lh5m6Z0rYJ8Nwizl0Nb1pnvOCRwBVWKCc_D8'
parseFormInfoAll(orpSummaryPage,e)
}
function parseFormInfoProd(e) {
orpSummaryPage='1rQTgHL0CLkERCq7zd-OCwQu9JChr7SvEFcHDlpN8cbE'
parseFormInfoAll(orpSummaryPage,e)
}
//parseFormInfo* calls this function
//Depending on the request, items are added to the right part of the general page
function parseFormInfoAll(orpSummaryPage,e){
var lastORPInfo = getORPInfo(orpSummaryPage) //gets info from most recent ORP (sheet, date)
var ssheet=lastORPInfo[0]
var sprSheet=SpreadsheetApp.open(DriveApp.getFileById(ssheet)) // Open the most recent ORP
var sheet = sprSheet.getSheetByName("General") //general sheet of the most recent ORP
Logger.log('Look, a new request')
Logger.log(e)
var answers = e.response.getItemResponses();
var release=null
var request=null
var category=null
for ( var i in answers) {
var t=answers[i].getItem().getTitle()
var r=answers[i].getResponse()
//These are magic strings from the questions in the google form
//They need to be kept in sync if the form is updated
if ( t.slice(0,12) == 'What kind of' ) {
if ( r.slice(0,8)=='External') { category='External' }
if ( r.slice(0,3)=='AOB') { category='AOB' }
if ( r.slice(0,7)=='General') { category='General' }
if ( r.slice(0,5)=='CMSSW') { category='CMSSW' }
}
if ( t.slice(0,11) == 'Which CMSSW' ) {
release=r
}
if ( t.slice(0,7) == 'What is' ) {
request=r
}
}
Logger.log(category+' '+release)
Logger.log(request)
var glock = LockService.getScriptLock();
if( !glock.tryLock(10000) ) {
throwError('Spreadsheet is locked by another script for 10000 seconds. There is a problem.')
return;
}
if ( category == 'External' ) {
var relList=releaseList()
var releaseNum=relList.indexOf(release)
addExternalRequestForm(sheet,releaseNum,request)
}
if ( category == 'CMSSW' ) {
var relList=releaseList()
var releaseNum=relList.indexOf(release)
addCMSSWRequestForm(sheet,releaseNum,request)
}
if ( category == 'General' ) {
addGeneralRequestForm(sheet,request)
}
if ( category == 'AOB' ) {
addAOBRequestForm(sheet,request)
}
glock.releaseLock();
}
function addCMSSWRequestForm(sheet,release,message) {
var issueInfo=getGenInfo(sheet)
var insLoc=issueInfo[0]['nom'][release] //magic to know where to add a line - can be done better
handleRequestFromSidebar(sheet,insLoc,message)
updateCountingInfo(sheet,insLoc,issueInfo[0],issueInfo[1])
Logger.log("Adding CMSSW Request")
}
function addExternalRequestForm(sheet,release,message) {
var issueInfo=getGenInfo(sheet)
var insLoc=issueInfo[0]['dis'][release]//magic to know where to add a line - can be done better
handleRequestFromSidebar(sheet,insLoc,message)
updateCountingInfo(sheet,insLoc,issueInfo[0],issueInfo[1])
Logger.log("Adding external Request")
}
function addGeneralRequestForm(sheet,message) {
var issueInfo=getGenInfo(sheet)
var insLoc=issueInfo[0]['gen'][0]//magic to know where to add a line - can be done better
handleRequestFromSidebar(sheet,insLoc,message)
updateCountingInfo(sheet,insLoc,issueInfo[0],issueInfo[1])
Logger.log("Adding general Request")
}
function addAOBRequestForm(sheet,message) {
var issueInfo=getGenInfo(sheet)
var insLoc=issueInfo[0]['aob']//magic to know where to add a line - can be done better
handleRequestFromSidebar(sheet,insLoc,message)
updateCountingInfo(sheet,insLoc,issueInfo[0],issueInfo[1])
Logger.log("Adding AOB Request")
}
function addPendingRequestForm(sheet,release,message) {
var issueInfo=getGenInfo(sheet)
var insLoc=issueInfo[0]['ext'][release]//magic to know where to add a line - can be done better
handleRequestFromSidebar(sheet,insLoc,message)
updateCountingInfo(sheet,insLoc,issueInfo[0],issueInfo[1])
Logger.log("Adding external Request")
}