Produced by Araxis Merge on 6/22/2017 10:29:10 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | RAMS_CIF.zip\RAMS_CIF\RAMS_CIF\js | dynamicMembers.js | Thu Jun 22 12:35:48 2017 UTC |
2 | RAMS_CIF.zip\RAMS_CIF\RAMS_CIF\js | dynamicMembers.js | Thu Jun 22 13:36:18 2017 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 3056 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | ||
2 | var curren tAttachmen tID; | |
3 | var userOb ject = {}; | |
4 | var localS iteAppObje ct = {}; | |
5 | ||
6 | function r efreshDisp lay(refres hType){ | |
7 | var ro w, contain er, pageHe ader, side Well, page Footer, he aderArea; | |
8 | ||
9 | $('#re fresh-sect ion').remo ve(); | |
10 | // $(' div#insert ').attr("c lass", "co ntainer"); | |
11 | row = document.c reateEleme nt("div"); | |
12 | row.se tAttribute ("class", "row"); | |
13 | row.se tAttribute ("id", "re fresh-sect ion"); | |
14 | $('div #insert'). append(row ); | |
15 | ||
16 | contai ner = docu ment.creat eElement(" div"); | |
17 | contai ner.setAtt ribute("cl ass", "col -xs-9"); | |
18 | row.ap pendChild( container) ; | |
19 | ||
20 | pageHe ader = doc ument.crea teElement( "div"); | |
21 | pageHe ader.setAt tribute("c lass", "pa ge-header" ); | |
22 | pageHe ader.setAt tribute("t abindex", "0"); | |
23 | contai ner.append Child(page Header); | |
24 | ||
25 | he aderArea = $('div.pa ge-header' ); | |
26 | he aderArea.e mpty(); | |
27 | ||
28 | if(ref reshType = = "Facilit y"){ | |
29 | he aderBuilde r("Sites", headerAre a); | |
30 | sendREST ("GET", si teUrl.conc at("_api/W eb/Lists/g etByTitle( 'facility' )/Items"), null, fun ction(grou pJSON){ | |
31 | var cu rrentGroup s = groupJ SON.d.resu lts; | |
32 | var fa cility, us erGroupID, localSite LiaisonID; | |
33 | ||
34 | //loop through S harePoint facility g roups | |
35 | for( var i=0; i <currentGr oups.lengt h; i++){ | |
36 | facili ty = curre ntGroups[i ].Facility Name; | |
37 | userGr oupID = cu rrentGroup s[i].Users Id; | |
38 | localS iteLiaison ID = curre ntGroups[i ].Facility LiaisonId; | |
39 | ||
40 | userOb ject[facil ity] = {}; | |
41 | userOb ject[facil ity]["user GroupID"] = userGrou pID; | |
42 | userOb ject[facil ity]["grou pID"] = cu rrentGroup s[i].Id; | |
43 | userOb ject[facil ity]["loca lSiteLiais onID"] = l ocalSiteLi aisonID; | |
44 | ||
45 | //use AJAX calls to add us er and lia ison data for each f acility to global ob ject | |
46 | getUsers (userGroup ID, facili ty); | |
47 | getLiais on(localSi teLiaisonI D, facilit y); | |
48 | } | |
49 | ||
50 | grab LocalSiteA pplication s(assigned ID); //s ave local site app d ata to glo bal object | |
51 | contai ner.append Child(faci lityDispla y()); //bu ild local site appli cations pa ge | |
52 | ||
53 | pageFooter = documen t.createEl ement("div "); | |
54 | pageFooter .setAttrib ute("class ", "progre ss-contain er"); | |
55 | container. appendChil d(pageFoot er); | |
56 | pageFooter = documen t.createEl ement("div "); | |
57 | pageFooter .setAttrib ute("class ", "button -container "); | |
58 | container. appendChil d(pageFoot er); | |
59 | ||
60 | progressBu ilder(); | |
61 | }); | |
62 | }else if(refresh Type == "P ersonnel") { | |
63 | va r AOMember = AOMembe rCheck(); | |
64 | if(AOMem ber == tru e) | |
65 | { | |
66 | readOn lyState = false; | |
67 | } | |
68 | ||
69 | he aderBuilde r("Personn el", heade rArea); | |
70 | se ndREST("GE T", siteUr l.concat(" _api/Web/C urrentUser /Groups"), null, fun ction(grou pJSON){ | |
71 | var cu rrentGroup s = groupJ SON.d.resu lts; | |
72 | var si teUsersGro upID = -1; | |
73 | ||
74 | for( var i=0; i <currentGr oups.lengt h; i++){ / /find the site users ' group fo r the user 's site | |
75 | if(current Groups[i]. Title.inde xOf("Users ") > -1){ | |
76 | siteUs ersGroupID = current Groups[i]. Id; | |
77 | } | |
78 | } | |
79 | ||
80 | //pe rform REST calls if we found s ite users group | |
81 | if(s iteUsersGr oupID > 0) { //assumi ng user be longs to o nly one si te | |
82 | sendREST ("GET", si teUrl.conc at("_api/W eb/SiteGro ups("+site UsersGroup ID+")/User s"), null, function( siteUsers) { | |
83 | se ndREST("GE T", restPa th.concat( "study/"+a ssignedID+ "/members" ), null, f unction(st udyMembers ){ | |
84 | container. appendChil d(personne lDisplay(s tudyMember s, siteUse rs)); | |
85 | //containe r.appendCh ild(editPe rsonnelDis play()); | |
86 | ||
87 | pageFooter = documen t.createEl ement("div "); | |
88 | pageFooter .setAttrib ute("class ", "progre ss-contain er"); | |
89 | container. appendChil d(pageFoot er); | |
90 | pageFooter = documen t.createEl ement("div "); | |
91 | pageFooter .setAttrib ute("class ", "button -container "); | |
92 | container. appendChil d(pageFoot er); | |
93 | ||
94 | progressBu ilder(); | |
95 | $("[value= 'Save Prog ress']").a ttr("oncli ck", "inse rtPerson() "); | |
96 | //$("[valu e='Save Pr ogress']") .attr("onk eypress", "insertPer son()"); | |
97 | }) ; | |
98 | }); | |
99 | } | |
100 | }); | |
101 | ||
102 | }else if(refresh Type == "F iles"){ | |
103 | he aderBuilde r("Attachm ents", hea derArea); | |
104 | ||
105 | se ndREST("GE T", siteUr l.concat(" _api/web/G etFolderBy ServerRela tiveUrl('S hared%20Do cuments/"+ assignedID +"/Study%2 0Team')/Fi les?$expan d=ListItem AllFields" ), null, f unction(re turnedFile s){ | |
106 | //attach ments = fi lterCheckl ists(retur nedFiles.d .results, "-RAMS-"); | |
107 | attach ments = re turnedFile s.d.result s; | |
108 | containe r.appendCh ild(attach mentsDispl ay(attachm ents)); | |
109 | ||
110 | pageFoot er = docum ent.create Element("d iv"); | |
111 | pageFoot er.setAttr ibute("cla ss", "prog ress-conta iner"); | |
112 | containe r.appendCh ild(pageFo oter); | |
113 | pageFoot er = docum ent.create Element("d iv"); | |
114 | pageFoot er.setAttr ibute("cla ss", "butt on-contain er"); | |
115 | containe r.appendCh ild(pageFo oter); | |
116 | ||
117 | progress Builder(); | |
118 | }) ; | |
119 | } | |
120 | ||
121 | sideWe ll = docum ent.create Element("d iv"); | |
122 | sideWe ll.setAttr ibute("cla ss", "col- xs-3 toolb ar"); | |
123 | row.ap pendChild( sideWell); | |
124 | ||
125 | sideCo lumnBuilde r(null); | |
126 | }; | |
127 | ||
128 | /* add the users fou nd to the global obj ect userOb ject */ | |
129 | function a ddUserArra y(data, fa cility){ | |
130 | va r userArra y = []; | |
131 | va r user = d ata.d.resu lts; | |
132 | ||
133 | fo r(var i=0; i<user.le ngth; i++) { | |
134 | us erArray.pu sh(user[i] .Title); | |
135 | us erObject[f acility][u ser[i].Tit le] = {}; | |
136 | us erObject[f acility][u ser[i].Tit le]["id"] = user[i]. Id; | |
137 | } | |
138 | us erObject[f acility][" users"] = userArray; | |
139 | } | |
140 | ||
141 | /* return the JSON o f the user s belongin g to a sit e group */ | |
142 | function g etUsers(gr oupID, fac ility){ // replace co mmittee wi th facilit y | |
143 | re turn $.aja x({ | |
144 | asyn c: false, | |
145 | type : 'GET', | |
146 | url: siteUrl.c oncat("_ap i/Web/site groups("+g roupID+")/ users"), | |
147 | head ers: {"acc ept": "app lication/j son;odata= verbose"}, | |
148 | data Type: 'jso n', | |
149 | succ ess: funct ion(json){ | |
150 | addUse rArray(jso n, facilit y); | |
151 | } | |
152 | }) ; | |
153 | } | |
154 | ||
155 | /* add the local sit e liaison found to t he global object use rObject */ | |
156 | function a ddLiaison( data, faci lity){ | |
157 | va r user = d ata.d.resu lts; | |
158 | us erObject[f acility][" localSiteL iaison"] = user[0].T itle; | |
159 | ||
160 | } | |
161 | ||
162 | /* return the JSON o f the loca l site lia ison belon ging to a site group */ | |
163 | function g etLiaison( localSiteL iaisonID, facility){ | |
164 | re turn $.aja x({ | |
165 | asyn c: false, | |
166 | type : 'GET', | |
167 | url: siteUrl.c oncat("_ap i/Web/site groups("+l ocalSiteLi aisonID+") /users"), | |
168 | head ers: {"acc ept": "app lication/j son;odata= verbose"}, | |
169 | data Type: 'jso n', | |
170 | succ ess: funct ion(json){ | |
171 | addLia ison(json, facility) ; | |
172 | } | |
173 | }) ; | |
174 | } | |
175 | ||
176 | ||
177 | function p ersonnelDi splay(stud yMembers, siteUsers) { | |
178 | var co ntainer, t able, tabl eDiv, tbod y, trow, s kipFlag, c ell, butto nID; | |
179 | ||
180 | // va r selectUs ers = []; | |
181 | // var tempList = ramsUser s.values() ; | |
182 | //**** ********** ********** ******** N EED THIS T O WORK OFF OF A SP U SER GROUP | |
183 | ||
184 | // //n ot includi ng users w ho are alr eady in th e table an d are acti ve | |
185 | // for (var i=0; i<tableUse rs.length; i++){ | |
186 | // skipFlag = false; | |
187 | // for(var j =0; j<retu rnedMember s.length; j++){ | |
188 | // if((t ableUsers[ i].display Name == re turnedMemb ers[j].use r.displayN ame) && (r eturnedMem bers[j].me mberRole ! = "RAMS Re viewer")/* &&(returne dMembers[j ].activeMe mber)*/){ | |
189 | // s kipFlag = true; | |
190 | // } | |
191 | // } | |
192 | // if(!skipF lag) | |
193 | // selec tUsers.pus h(tableUse rs[i].disp layName); | |
194 | // } | |
195 | ||
196 | contai ner = docu ment.creat eElement(" div"); | |
197 | contai ner.setAtt ribute("cl ass", "for m-content" ); | |
198 | ||
199 | /*Head er Table*/ | |
200 | table = tableHea derHelper( "Personnel ", [/*"VA" ,*/ "Name" , "Study T eam?", "Ro le", "COI Required?" , "Edit St udy?", "Pu rpose", "N otify?", " Update"]); | |
201 | contai ner.append Child(tabl e); | |
202 | ||
203 | /*Scro llable Bod y Table*/ | |
204 | tableD iv = docum ent.create Element("d iv"); | |
205 | tableD iv.setAttr ibute("cla ss", "div- table-cont ent-big"); | |
206 | ||
207 | table = document .createEle ment("tabl e"); | |
208 | table. setAttribu te("class" , "table t able-strip ed table-h over"); | |
209 | ||
210 | /*Tabl e Body*/ | |
211 | tbody = document .createEle ment("tbod y"); | |
212 | ||
213 | /*firs t row*/ | |
214 | // tro w = docume nt.createE lement("tr "); | |
215 | // //n ot va | |
216 | // tro w.appendCh ild(checkb oxCellHelp er("initVA ", "Is Per son not in VA", "swa pForNonVA( 'initVA', 'initPerso n')")); | |
217 | // //b lank space | |
218 | // tro w.appendCh ild(textCe llHelper(" td", "")); | |
219 | // //t row.append Child(sele ctCellHelp er("initPe rson", "Se lect Perso n to Add", ["Please Select a U ser"].conc at(selectU sers), nul l)); | |
220 | // //s tudy team | |
221 | // tro w.appendCh ild(checkb oxCellHelp er("initSt udyTeam", "Is Person on Study Team", nul l)); | |
222 | // //b lank space //role | |
223 | // tro w.appendCh ild(textCe llHelper(" td", "")); | |
224 | // //t row.append Child(sele ctCellHelp er("initPe rsonRole", "Person's Role", [" Principal Investigat or", "Clin ical Coord inator", " Contractor "], null)) ; | |
225 | // //C OI require d | |
226 | // tro w.appendCh ild(checkb oxCellHelp er("initCO IReq", "Do es Person Require CO I", null)) ; | |
227 | // //w rite permi ssions | |
228 | // tro w.appendCh ild(checkb oxCellHelp er("initWr itePerm", "Does Pers on have Wr ite Permis sions", nu ll)); | |
229 | // //e xplination | |
230 | // tro w.appendCh ild(textCe llHelper(" td", "")); | |
231 | // //t row.append Child(text areaCellHe lper("td", "initExpl anation", "Explinati on of Pers on")); | |
232 | // //n otificatio ns | |
233 | // tro w.appendCh ild(checkb oxCellHelp er("initNo tify", "Do es Person want notif ications", null)); | |
234 | // //a dd/remove | |
235 | // //t row.append Child(butt onCellHelp er("Add", "insertPer son()")); | |
236 | // tro w.appendCh ild(textCe llHelper(" td", "")); | |
237 | ||
238 | // tbo dy.appendC hild(trow) ; | |
239 | ||
240 | // /*S econd row* / | |
241 | // tro w = docume nt.createE lement("tr "); | |
242 | ||
243 | // //b lank | |
244 | // tro w.appendCh ild(textCe llHelper(" td", "")); | |
245 | ||
246 | // //n ame | |
247 | // cel l = select CellHelper ("initPers on", "Sele ct Person to Add", [ "Please Se lect a Use r"].concat (selectUse rs), null) ; | |
248 | // cel l.setAttri bute("cols pan", "2") ; | |
249 | // tro w.appendCh ild(cell); | |
250 | ||
251 | // //r ole | |
252 | // cel l = select CellHelper ("initPers onRole", " Person's R ole", ["Pl ease Selec t a Role", "Clinical Coordinat or", "Cont ractor", " Scientist" ], null) | |
253 | // cel l.setAttri bute("cols pan", "2") ; | |
254 | // tro w.appendCh ild(cell); | |
255 | ||
256 | // //p urpose | |
257 | // cel l = textar eaCellHelp er("td", " initExplan ation", "E xplination of Person "); | |
258 | // cel l.setAttri bute("cols pan", "3") ; | |
259 | // tro w.appendCh ild(cell); | |
260 | ||
261 | // //a dd person | |
262 | // tro w.appendCh ild(button CellHelper ("Add", "i nsertPerso n()")); | |
263 | ||
264 | // tbo dy.appendC hild(trow) ; | |
265 | ||
266 | for(var i=0; i<st udyMembers .length; i ++){ | |
267 | buttonID = "update "+i; | |
268 | bu ttonID_Rem ove = "rem ove" + i; | |
269 | ||
270 | trow = d ocument.cr eateElemen t("tr"); | |
271 | tr ow.setAttr ibute("tab index", "0 "); | |
272 | ||
273 | // non VA | |
274 | // trow.appen dChild(ret urnChecked (returnedM embers[i]. vaUser)); | |
275 | // name | |
276 | tr ow.appendC hild(textC ellHelper( "td", stud yMembers[i ].user.dis playName)) ; | |
277 | // study team | |
278 | tr ow.appendC hild(retur nChecked(s tudyMember s[i].teamM ember)); | |
279 | // role | |
280 | tr ow.appendC hild(textC ellHelper( "td", stud yMembers[i ].memberRo le)); | |
281 | // coi requir ed | |
282 | tr ow.appendC hild(retur nChecked(s tudyMember s[i].coiRe quired)); | |
283 | // write perm issions | |
284 | tr ow.appendC hild(retur nChecked(s tudyMember s[i].write Permission s)); | |
285 | // explinatio n | |
286 | tr ow.appendC hild(textC ellHelper( "td", stud yMembers[i ].explaina tion)); | |
287 | // notificati ons | |
288 | tr ow.appendC hild(retur nChecked(s tudyMember s[i].notif ications)) ; | |
289 | // remove | |
290 | // if(return edMembers[ i].activeM ember == t rue){ | |
291 | // trow. appendChil d(buttonCe llHelper(" Deactivate ", "deacti vateUser(' "+returned Members[i] .user.user sID+"')")) ; | |
292 | // }else{ | |
293 | // trow. appendChil d(buttonCe llHelper(" Activate", "activate User('"+re turnedMemb ers[i].use r.usersID+ "')")); | |
294 | // } | |
295 | // console.lo g("member: "+ return edMembers[ i].user.di splayName + " with r ole: " + r eturnedMem bers[i].me mberRole); | |
296 | if(( studyMembe rs[i].memb erRole == "Principal Investiga tor") || ( studyMembe rs[i].memb erRole == "Co-Princi pal Invest igator")){ | |
297 | trow .appendChi ld(buttonC ellHelper( "Update", "updatePer son('"+stu dyMembers[ i].user.di splayName+ "')", butt onID, true )); //disa ble update button fo r PI and C oPI | |
298 | trow.a ppendChild (buttonCel lHelper("R emove", "r emovePerso n('"+study Members[i] .user.user sID+"')", buttonID_R emove, tru e)); //dis able remov e button f or PI and CoPI | |
299 | }els e{ | |
300 | trow .appendChi ld(buttonC ellHelper( "Update", "updatePer son('"+stu dyMembers[ i].user.di splayName+ "')", butt onID)); // leave upda te button enabled | |
301 | trow .appendChi ld(buttonC ellHelper( "Remove", "removePer son('"+stu dyMembers[ i].user.us ersID+"')" , buttonID _Remove)); //leave r emove butt on enabled | |
302 | } | |
303 | tb ody.append Child(trow ); | |
304 | } | |
305 | ||
306 | table. appendChil d(tbody); | |
307 | tableD iv.appendC hild(table ); | |
308 | //addi ng in the edit quest ions for t he rows in the table | |
309 | //tabl eDiv.appen dChild(edi tPersonnel Display(re turnedMemb ers, table Users)); | |
310 | contai ner.append Child(tabl eDiv); | |
311 | contai ner.append Child(edit PersonnelD isplay(stu dyMembers, siteUsers )); | |
312 | return container ; | |
313 | } | |
314 | ||
315 | function b uildUserna meList(JSO N){ | |
316 | va r tempList = []; | |
317 | fo r(var i=0; i<JSON.d. results.le ngth; i++) { | |
318 | temp List.push( JSON.d.res ults[i].Ti tle); | |
319 | } | |
320 | re turn tempL ist; | |
321 | } | |
322 | ||
323 | function e ditPersonn elDisplay( studyMembe rs, siteUs ers){ | |
324 | var co ntainer; | |
325 | var se lectUsers = []; //co ntains fin al list of site user s for drop down | |
326 | var sk ipPerson; | |
327 | ||
328 | contai ner = docu ment.creat eElement(" div"); | |
329 | contai ner.setAtt ribute("cl ass", "for m-content" ); | |
330 | ||
331 | var na meIndex, s kipPerson; | |
332 | var st udyMemberN ames = []; | |
333 | var si teUserName s = buildU sernameLis t(siteUser s); //crea te array f rom siteUs ers JSON d ata | |
334 | ||
335 | /*add all study member dis play names to list*/ | |
336 | fo r(var i=0; i<studyMe mbers.leng th; i++){ | |
337 | stud yMemberNam es.push(st udyMembers [i].user.d isplayName ); | |
338 | } | |
339 | /* add site u sers to se lectUsers array (bas ed on role )*/ | |
340 | fo r(var j=0; j<siteUse rNames.len gth; j++){ | |
341 | name Index = st udyMemberN ames.index Of(siteUse rNames[j]) ; //check if site us er is on t he study m ember list | |
342 | if(n ameIndex > -1){ //us er is on t he study m ember list | |
343 | skipPe rson = fal se; | |
344 | if((st udyMembers [nameIndex ].memberRo le == "RAM S Reviewer ") || (stu dyMembers[ nameIndex] .memberRol e == "Prin cipal Inve stigator") || (study Members[na meIndex].m emberRole == "Co-Pri ncipal Inv estigator" )){ | |
345 | skipPers on = true; | |
346 | } | |
347 | if(!sk ipPerson){ //if stud y member i s not a re viewer, PI or Co-PI | |
348 | selectUs ers.push(s iteUserNam es[j]); | |
349 | } | |
350 | }els e{ //user is not on the study member lis t | |
351 | select Users.push (siteUserN ames[j]); | |
352 | } | |
353 | } | |
354 | ||
355 | //need to captur e how many pixels ea ch row tak es up, the n we want to change the height of div-ta ble-conten t-big | |
356 | //to r eflect how much room the table actually | |
357 | ||
358 | //cont ainer.appe ndChild(ra dioFieldHe lper("init VA", "Is t he person you are ad ding in th e VA?", [" Yes", "No" ])); | |
359 | contai ner.append Child(sele ctFieldHel per("initP erson", "S elect a us er to add or update: ", ["Pleas e Select a User"].co ncat(selec tUsers), " updatePers on()")); | |
360 | contai ner.append Child(radi oFieldHelp er("initSt udyTeam", "Is this u ser on you r study te am?", ["Ye s", "No"]) ); | |
361 | contai ner.append Child(sele ctFieldHel per("initP ersonRole" , "What ro le will th is user pl ay?", ["In vestigator ","Co-Inve stigator", "Sub-Inves tigator"," Biostatist ician","Cl inical Coo rdinator", "Collabora tor","CSP Program Ma nager","Da ta Manager ","Lab Man ager","Lab Technicia n","Nation al Study C oordinator ","Nurse A ssessor"," Pharmacist ","Pharmac y Technici an","Regul atory Coor dinator"," Research A ssistant", "Research Nurse","St atistician ","Study C oordinator "])); | |
362 | contai ner.append Child(radi oFieldHelp er("initCO IReq", "Do es this us er have a Conflict o f Interest ?", ["Yes" , "No"])); | |
363 | contai ner.append Child(radi oFieldHelp er("initWr itePerm", "Do you wa nt this us er to be a ble to edi t your app lication?" , ["Yes", "No"])); | |
364 | contai ner.append Child(text FieldHelpe r("initExp lanation", "If neede d, please elaborate on the use r being ad ded.")); | |
365 | contai ner.append Child(radi oFieldHelp er("initNo tify", "Do you want this user to recieve notificat ions perta ining to t his study? ", ["Yes", "No"])); | |
366 | contai ner.append Child(radi oFieldHelp er("initAc tivate", " Do you wan t to give this user access to your appli cation?", ["Yes", "N o"])); | |
367 | ||
368 | return container ; | |
369 | }; | |
370 | ||
371 | function a ttachments Display(re turnedFile s){ | |
372 | var co ntainer, l ink, parag raph, text ; | |
373 | var ta ble, table Div, tbody , trow, da teAdded, c ell; | |
374 | ||
375 | contai ner = docu ment.creat eElement(" div"); | |
376 | contai ner.setAtt ribute("cl ass", "for m-content" ); | |
377 | ||
378 | /*Head er Table*/ | |
379 | // if(r eadOnlySta te == fals e){ | |
380 | // table = ta bleHeaderH elper("Cur rent Attac hments", [ "Attachmen t", "Date Added", "V ersion", " Status", " Date Appro ved", "Doc ument Type ", "Remove "]); | |
381 | // }els e{ | |
382 | // table = ta bleHeaderH elper("Cur rent Attac hments", [ "Attachmen t", "Date Added", "V ersion", " Status", " Date Appro ved", "Doc ument Type "]); | |
383 | // } | |
384 | /*Add link to te mplate*/ | |
385 | paragr aph = docu ment.creat eElement(" P"); | |
386 | text = document. createText Node("Clic k the link to downlo ad the "); | |
387 | ||
388 | link = document. createElem ent("A"); | |
389 | link.href = "https:/ /vaww.sqa. ram.msp. DNS /sites/IRB Applicatio ns/FormTem plates/VHA %20form%20 10-0493_Au thorizatio n%20for%20 Use%20%20R elease%20o f%20IIHI%2 0for%20VHA %20Researc h%20(9-201 5).pdf"; | |
390 | link.t arget = "_ blank"; // open docum ent in new window or tab | |
391 | link.i nnerHTML = "HIPAA Te mplate"; | |
392 | ||
393 | paragr aph.append Child(text ); | |
394 | paragr aph.append Child(link ); | |
395 | contai ner.append Child(para graph); | |
396 | ||
397 | table = tableHea derHelper( "Current A ttachments ", ["Attac hment", "D ate Added" , "Version ", "Status ", "Date A pproved", "Document Type", "Re move", "Up date"]); | |
398 | ||
399 | contai ner.append Child(tabl e); | |
400 | ||
401 | /*Scro llable Bod y Table*/ | |
402 | tableD iv = docum ent.create Element("d iv"); | |
403 | tableD iv.setAttr ibute("cla ss", "div- table-cont ent-big"); | |
404 | ||
405 | table = document .createEle ment("tabl e"); | |
406 | table. setAttribu te("class" , "table t able-strip ed table-h over"); | |
407 | table. setAttribu te("tabind ex", "0"); | |
408 | ||
409 | /*Tabl e Body*/ | |
410 | tbody = document .createEle ment("tbod y"); | |
411 | ||
412 | for(va r i=0; i<r eturnedFil es.length; i++){ | |
413 | tr ow = docum ent.create Element("t r"); | |
414 | tr ow.setAttr ibute("tab index", "0 ") | |
415 | ||
416 | tr ow.appendC hild(linkC ellHelper( "td", (ret urnedFiles [i].Name), "Study%20 Team", ret urnedFiles [i].Name)) ; | |
417 | da teAdded = returnedFi les[i].Tim eCreated.s plit("T")[ 1].replace ("Z", "") + " on " + returnedF iles[i].Ti meCreated. split("T") [0]; | |
418 | tr ow.appendC hild(textC ellHelper( "td", date Added)); | |
419 | tr ow.appendC hild(textC ellHelper( "td", retu rnedFiles[ i].UIVersi on)); //ve rsion //re turnedFile s[i].UIVer sion | |
420 | tr ow.appendC hild(textC ellHelper( "td", retu rnedFiles[ i].ListIte mAllFields .Status)); //status | |
421 | tr ow.appendC hild(textC ellHelper( "td", retu rnedFiles[ i].ListIte mAllFields .DateAppro ved)); //d ate approv ed | |
422 | tr ow.appendC hild(textC ellHelper( "td", retu rnedFiles[ i].ListIte mAllFields .DocumentT ype)); //d ocument ty pe | |
423 | // if(readOnl yState == false){ | |
424 | // trow.a ppendChild (buttonCel lHelper("R emove", "r emoveAttac hment('"+r eturnedFil es[i].Name +"', 'Stud y%20Team') ")); | |
425 | // } | |
426 | ||
427 | tr ow.appendC hild(butto nCellHelpe r("Remove" , "removeA ttachment( '"+returne dFiles[i]. Name+"', ' Study%20Te am')")); | |
428 | tr ow.appendC hild(butto nCellHelpe r("Update" , "updateC urrentAtta chment('"+ returnedFi les[i].Lis tItemAllFi elds.ID+"' )")); | |
429 | ||
430 | tb ody.append Child(trow ); | |
431 | } | |
432 | ||
433 | table. appendChil d(tbody); | |
434 | tableD iv.appendC hild(table ); | |
435 | contai ner.append Child(tabl eDiv); | |
436 | return container ; | |
437 | } | |
438 | ||
439 | function t riggerUpda teModal(){ | |
440 | va r modal, m odalDialog , modalCon tent, moda lHeader; | |
441 | va r header, heading1, lineBreak, updateBut ton, close Button, te xt, modalT itle, moda lBody, mod alFooter; | |
442 | va r containe r, tableHe ader, tabl e, tableDi v, tbody, trow, trow 2, dateAdd ed, cell; | |
443 | va r statusTy pes = ["Ap proved", " Changes Re quested", "Submitted ", "Under Review"]; | |
444 | ||
445 | mo dal = docu ment.creat eElement(" div"); | |
446 | mo dal.setAtt ribute("id ", "update Modal"); | |
447 | mo dal.setAtt ribute("cl ass", "mod al"); | |
448 | ||
449 | mo dalDialog = document .createEle ment("div" ); | |
450 | mo dalDialog. setAttribu te("role", "document "); | |
451 | ||
452 | mo dalContent = documen t.createEl ement("div "); | |
453 | mo dalContent .setAttrib ute("class ", "modal- content"); | |
454 | mo dalHeader = document .createEle ment("div" ); | |
455 | mo dalHeader. setAttribu te("class" , "modal-h eader"); | |
456 | mo dalHeader. setAttribu te("tabind ex", "0"); //start tabbing on modal fro m header | |
457 | ||
458 | he ader = doc ument.crea teElement( "header"); | |
459 | he ader.setAt tribute("c lass", "mo dal-title" ); | |
460 | he ader.setAt tribute("i d", "modal Title2"); | |
461 | ||
462 | he ading1 = d ocument.cr eateElemen t("H2"); | |
463 | he ading1.set Attribute( "class", " modal-titl e"); | |
464 | te xt = docum ent.create TextNode(" Update Doc ument"); | |
465 | he ading1.app endChild(t ext); | |
466 | he ader.appen dChild(hea ding1); | |
467 | mo dalHeader. appendChil d(header); | |
468 | ||
469 | li neBreak = document.c reateEleme nt("br"); | |
470 | te xt = docum ent.create TextNode(" Please upd ate the st atus of th is documen t - "+curr entAttachm entID+" - by selecti ng an opti on below." ); | |
471 | ||
472 | mo dalFooter = document .createEle ment("div" ); | |
473 | mo dalFooter. setAttribu te("class" , "modal-f ooter"); | |
474 | ||
475 | mo dalContent .appendChi ld(modalHe ader); | |
476 | mo dalContent .appendChi ld(lineBre ak); | |
477 | mo dalContent .appendChi ld(text); | |
478 | mo dalContent .appendChi ld(lineBre ak); | |
479 | mo dalContent .appendChi ld(buildSe lecterHelp er("status ", "Status ", statusT ypes, 12)) ; | |
480 | mo dalContent .appendChi ld(lineBre ak); | |
481 | ||
482 | ||
483 | /* Add Save D ocument Bu tton*/ | |
484 | up dateButton = documen t.createEl ement("but ton"); | |
485 | up dateButton .setAttrib ute("class ", "btn bt n-sm modal -button"); //took ou t btn-info | |
486 | up dateButton .setAttrib ute("data- dismiss", "updateMod al") | |
487 | up dateButton .setAttrib ute("aria- label", "U pdate"); | |
488 | ||
489 | up dateButton .setAttrib ute("title ", "Update your docu ment"); // hover tip | |
490 | up dateButton .setAttrib ute("type" , "button" ); | |
491 | up dateButton .setAttrib ute("role" , "button" ); | |
492 | up dateButton .setAttrib ute("id", "updateMod al"); | |
493 | ||
494 | update Button.set Attribute( "onclick", "updateAt tachment() "); | |
495 | te xt = docum ent.create TextNode(" Update Doc ument"); | |
496 | up dateButton .appendChi ld(text); | |
497 | ||
498 | /* Add Close Window But ton*/ | |
499 | cl oseButton = document .createEle ment("butt on"); | |
500 | cl oseButton. setAttribu te("class" , "btn btn -sm modal- button mod al-button- right"); | |
501 | cl oseButton. setAttribu te("data-d ismiss", " modal"); | |
502 | cl oseButton. setAttribu te("aria-l abel", "Cl ose"); | |
503 | ||
504 | cl oseButton. setAttribu te("title" , "Close t his window and retur n to the a pplication "); //hove r tip | |
505 | cl oseButton. setAttribu te("type", "button") ; | |
506 | cl oseButton. setAttribu te("role", "button") ; | |
507 | cl oseButton. setAttribu te("id", " closeModal 2"); | |
508 | ||
509 | cl oseButton. setAttribu te("onclic k", "close Attachment Update()") ; | |
510 | te xt = docum ent.create TextNode(" Close this window"); | |
511 | cl oseButton. appendChil d(text); | |
512 | ||
513 | /* Combine Mo dal Elemen ts*/ | |
514 | mo dalFooter. appendChil d(updateBu tton); | |
515 | mo dalFooter. appendChil d(closeBut ton); | |
516 | mo dalContent .appendChi ld(modalFo oter); | |
517 | mo dalDialog. appendChil d(modalCon tent); | |
518 | mo dal.append Child(moda lDialog); | |
519 | $( 'body').ap pend(modal ); | |
520 | $( '#updateMo dal').popu p('show'); | |
521 | } | |
522 | ||
523 | function u pdateCurre ntAttachme nt(current ID){ | |
524 | cu rrentAttac hmentID = currentID; | |
525 | tr iggerUpdat eModal(); | |
526 | } | |
527 | function c loseAttach mentUpdate (){ | |
528 | $( '#updateMo dal').popu p('hide'); | |
529 | re freshDispl ay('Files' ); | |
530 | } | |
531 | ||
532 | /* enable local site investiga tor dropdo wn with us ers from t he local s ite */ | |
533 | function e nableInves tigatorDro pdown(){ | |
534 | va r facility = $("#add LocalSite" ).find(':s elected'). val(); | |
535 | va r users = []; | |
536 | va r liaison, option, t ext; | |
537 | ||
538 | if (facility !== "Pleas e Select a Facility" ){ | |
539 | user s = userOb ject[facil ity]["user s"]; | |
540 | ||
541 | //ad d availabl e LSIs and enable dr opdown | |
542 | $("# addLSI").c hildren(). remove(); //remove o ld options | |
543 | for( var i=0; i <(users.le ngth); i++ ){ //add n ew options | |
544 | option = documen t.createEl ement("opt ion"); | |
545 | option .setAttrib ute("value ", users[i ]); | |
546 | ||
547 | text = document. createText Node(users [i]); | |
548 | option .appendChi ld(text); | |
549 | $("#ad dLSI").app end(option ); | |
550 | } | |
551 | $("# addLSI").r emoveAttr( "disabled" ); | |
552 | } | |
553 | }; | |
554 | ||
555 | //Add loca l site lia ison to Re viewers gr oup on app lication's list item | |
556 | function a ddToReview ersGroup(j son, local SiteLiaiso nID){ | |
557 | va r applicat ion = json .d.results ; | |
558 | va r listItem ID = appli cation[0]. Id; | |
559 | va r reviewer s = applic ation[0].R eviewersId ; | |
560 | va r newData; | |
561 | ||
562 | if ((reviewer s) == null ){ //no us ers in rev iewers gro up | |
563 | newD ata = { | |
564 | "__metad ata": {"ty pe": "SP.D ata.Applic ationListI tem"}, | |
565 | "Reviewe rsId": {'r esults': [ localSiteL iaisonID]} | |
566 | }; | |
567 | }e lse{ //at least one user in us ers group | |
568 | var reviewersA rray = []; | |
569 | for (var i=0; i<reviewer s.results. length; i+ +){ | |
570 | review ersArray.p ush(review ers.result s[i]); | |
571 | } | |
572 | revi ewersArray .push(loca lSiteLiais onID); | |
573 | ||
574 | newD ata = { | |
575 | "__metad ata": {"ty pe": "SP.D ata.Applic ationListI tem"}, | |
576 | "Reviewe rsId": {'r esults': r eviewersAr ray} | |
577 | }; | |
578 | } | |
579 | ||
580 | // U pdate Appl ication li st item | |
581 | $. ajax({ | |
582 | url: sit eUrl.conca t("_api/We b/Lists/Ge tByTitle(' Applicatio n')/Items( " +listIte mID+ ")"), //post ch ange to ap plication list | |
583 | type: "P OST", | |
584 | data: JS ON.stringi fy(newData ), | |
585 | headers: { | |
586 | "X-R equestDige st": reque stDigest, | |
587 | "Con tent-Type" : "applica tion/json; odata=verb ose", | |
588 | "IF- MATCH": "* ", | |
589 | "X-H TTP-Method ": "MERGE" | |
590 | } | |
591 | }) ; | |
592 | } | |
593 | ||
594 | /* After t he user co nfirms the new local site, | |
595 | * add a r ow in Shar ePoint for the empty local sit e applicat ion. | |
596 | * Add the local sit e liaison for each s ite to the main | |
597 | * applica tion list item (to g rant permi ssions) */ | |
598 | function a ssignMulti SiteStudy( ){ | |
599 | va r localSit e = $("#ad dLocalSite ").find(': selected') .val(); | |
600 | va r localSit eInvestiga tor = $("# addLSI").f ind(':sele cted').val (); | |
601 | va r localSit eInvestiga torID = us erObject[l ocalSite][ localSiteI nvestigato r]["id"]; | |
602 | va r localSit eLiaisonID = userObj ect[localS ite]["loca lSiteLiais onID"]; | |
603 | ||
604 | va r restUrl = siteUrl. concat("_a pi/web/lis ts/getbyti tle('Appli cation')/i tems"); | |
605 | va r principa lInvestiga torID = sp AppData[RA MS.Environ ment.Share Point.List .Applicati on.Princip alInvestig atorId]; | |
606 | va r coPrinci palInvesti gatorID = spAppData[ RAMS.Envir onment.Sha rePoint.Li st.Applica tion.CoPri ncipalInve stigatorId ]; | |
607 | ||
608 | va r userGrou pID = user Object[loc alSite]["u serGroupID "]; | |
609 | va r groupID = userObje ct[localSi te]["group ID"]; | |
610 | va r sendData , data; | |
611 | ||
612 | co nsole.log( "Local Sit e Selected : "+localS ite+"\nLoc al Site In vestigator Selected: "+localSi teInvestig ator+"\nLo cal Site I nvestigato r ID: "+lo calSiteInv estigatorI D+"\nUser Group ID: "+userGrou pID+"\nLoc al Site ID : "+groupI D+"\nLocal Site Liai son ID: "+ localSiteL iaisonID); | |
613 | ||
614 | se ndData = c onfirm("Yo u have sel ected the following site and i nvestigato r:\n\nLoca l Site Sel ected: "+l ocalSite+" \nLocal Si te Investi gator Sele cted: "+lo calSiteInv estigator+ "\n\nPress [OK] to c onfirm you r choices. "); | |
615 | if (sendData ) { | |
616 | //1) Add list item for l ocal site applicatio n (61) to Applicatio n list | |
617 | data = { | |
618 | "__met adata": {" type": "SP .Data.Appl icationLis tItem"}, | |
619 | "Par entStudyID ": assigne dID, //che ck | |
620 | "Par ticipating SiteId": g roupID, | |
621 | "Par ticipating SiteInvest igatorId": localSite Investigat orID, | |
622 | "Par ticipating SiteLiaiso nId": loca lSiteLiais onID, | |
623 | "Par ticipating SiteApplic ationStat" : "Not Sta rted", | |
624 | "Pri ncipalInve stigatorId ": princip alInvestig atorID, | |
625 | "CoP IId": coPr incipalInv estigatorI D | |
626 | } | |
627 | ||
628 | $.aj ax({ | |
629 | type: 'POST', | |
630 | data: JSON.strin gify(data) , | |
631 | url: r estUrl, | |
632 | header s: { | |
633 | "X-R equestDige st": reque stDigest, | |
634 | "con tent-type" : "applica tion/json; odata=verb ose" | |
635 | ||
636 | } | |
637 | }); | |
638 | ||
639 | //2) Add local sit e liaison to reviewe rs group o n main app lication ( 60) list i tem | |
640 | $.aj ax({ | |
641 | type: "GET ", | |
642 | url: siteU rl.concat( "_api/Web/ Lists/GetB yTitle('Ap plication' )/Items" + "?$filter =Study_ID eq '" + as signedID + "'"), | |
643 | headers: { "accept": "applicati on/json; o data=verbo se"}, | |
644 | dataType: 'json', | |
645 | success: function( json){ | |
646 | addToRevie wersGroup( json, loca lSiteLiais onID); | |
647 | } | |
648 | }); | |
649 | } | |
650 | } | |
651 | ||
652 | /* close w indow for adding loc al sites | |
653 | * and ref resh the p age | |
654 | */ | |
655 | function c loseAddSit eModal(){ | |
656 | $( '#addSiteM odal').pop up('toggle '); //or c an use .po pup('hide' ); | |
657 | re freshDispl ay('Facili ty'); | |
658 | } | |
659 | ||
660 | /* | |
661 | * open wi ndow that allows use r to add | |
662 | * local s ite (w/ lo cal site i nvestigato r) | |
663 | * to thei r study | |
664 | */ | |
665 | function t riggerAddS iteModal() { | |
666 | va r modal, m odalDialog , modalCon tent, moda lHeader; | |
667 | va r header, heading1, lineBreak, saveButto n, closeBu tton; | |
668 | va r paragrap h, text, l ist, listI tem1, list Item2, lis tItem3, mo dalTitle, modalBody, modalFoot er; | |
669 | va r containe r, textDiv , table, t ableDiv, t body, trow , trow2, d ateAdded, cell; | |
670 | ||
671 | va r selectFa cilities = []; | |
672 | va r localSit es = []; | |
673 | ||
674 | // create lis t of selec ted local sites | |
675 | fo r(var site in localS iteAppObje ct){ | |
676 | if(! localSiteA ppObject.h asOwnPrope rty(site)) continue; | |
677 | loca lSites.pus h(localSit eAppObject [site]["si teName"]); | |
678 | } | |
679 | ||
680 | // create lis t of avail able facil ities | |
681 | fo r(var key in userObj ect){ | |
682 | if(! userObject .hasOwnPro perty(key) ) continue ; | |
683 | if(loc alSites.in dexOf(key) < 0){ | |
684 | selectFa cilities.p ush(key); | |
685 | } | |
686 | } | |
687 | ||
688 | mo dal = docu ment.creat eElement(" div"); | |
689 | mo dal.setAtt ribute("cl ass", "mod al"); | |
690 | mo dal.setAtt ribute("id ", "addSit eModal"); | |
691 | mo dal.setAtt ribute("ta bindex", " -1"); | |
692 | mo dal.setAtt ribute("ro le", "dial og"); | |
693 | mo dal.setAtt ribute("ar ia-labelle dby", "add SiteModal" ); | |
694 | ||
695 | mo dalDialog = document .createEle ment("div" ); | |
696 | mo dalDialog. setAttribu te("role", "document "); | |
697 | ||
698 | mo dalContent = documen t.createEl ement("div "); | |
699 | mo dalContent .setAttrib ute("class ", "modal- content"); | |
700 | mo dalHeader = document .createEle ment("div" ); | |
701 | mo dalHeader. setAttribu te("class" , "modal-h eader"); | |
702 | mo dalHeader. setAttribu te("tabind ex", "0"); //start t abbing on modal from header | |
703 | ||
704 | he ader = doc ument.crea teElement( "header"); | |
705 | he ader.setAt tribute("c lass", "mo dal-title" ); | |
706 | he ader.setAt tribute("i d", "modal Title"); | |
707 | ||
708 | he ading1 = d ocument.cr eateElemen t("H2"); | |
709 | he ading1.set Attribute( "class", " modal-titl e"); | |
710 | te xt = docum ent.create TextNode(" Add Local Site"); | |
711 | he ading1.app endChild(t ext); | |
712 | he ader.appen dChild(hea ding1); | |
713 | mo dalHeader. appendChil d(header); | |
714 | ||
715 | te xtDiv = do cument.cre ateElement ("div"); | |
716 | te xtDiv.setA ttribute(" class", "c ol-xs-12") ; | |
717 | pa ragraph = document.c reateEleme nt("p"); | |
718 | li neBreak = document.c reateEleme nt("br"); | |
719 | te xt = docum ent.create TextNode(" To success fully add a particip ating site to your a pplication , select t he facilit y and the site inves tigator fr om the res pective dr opdown lis ts. Then c lick the [ Save Data] button to record yo ur changes . Click th e [Close T his Window ] button t o return t o the tabl e."); | |
720 | ||
721 | pa ragraph.ap pendChild( lineBreak) ; | |
722 | pa ragraph.ap pendChild( text); | |
723 | te xtDiv.appe ndChild(pa ragraph); | |
724 | mo dalContent .appendChi ld(textDiv ); | |
725 | ||
726 | mo dalContent .appendChi ld(modalHe ader); | |
727 | mo dalContent .appendChi ld(lineBre ak); | |
728 | mo dalContent .appendChi ld(text); | |
729 | mo dalContent .appendChi ld(lineBre ak); | |
730 | ||
731 | /* Setup for Adding Loc al Site*/ | |
732 | contai ner = docu ment.creat eElement(" div"); | |
733 | contai ner.setAtt ribute("cl ass", "for m-content" ); | |
734 | ||
735 | /*Tabl e Division */ | |
736 | tableD iv = docum ent.create Element("d iv"); | |
737 | tableD iv.setAttr ibute("cla ss", "div- table-cont ent-big"); //div-tab le-content -big shoul d be small ? | |
738 | ||
739 | /*Tabl e Style*/ | |
740 | table = document .createEle ment("tabl e"); | |
741 | table. setAttribu te("class" , "table t able-hover "); | |
742 | table. setAttribu te("tabind ex", "0"); | |
743 | ||
744 | /*Tabl e Body & R ows*/ | |
745 | tbody = document .createEle ment("tbod y"); | |
746 | trow = document. createElem ent("tr"); | |
747 | trow.s etAttribut e("tabinde x", "0"); | |
748 | trow2 = document .createEle ment("tr") ; | |
749 | ||
750 | // trow .appendChi ld(selectC ellHelper( "addLocalS ite", "Sel ect Facili ty to add" , ["Please Select a Facility"] .concat(se lectFacili ties), "en ableInvest igatorDrop down()")); | |
751 | // trow 2.appendCh ild(select CellHelper ("addLSI", "Select I nvestigato r", ["Plea se Select an Investi gator"], n ull, true) ); | |
752 | ||
753 | trow.a ppendChild (buildSele cterHelper ("addLocal Site", "Se lected Fac ility: ", ["Please S elect a Fa cility"].c oncat(sele ctFaciliti es), 12, " enableInve stigatorDr opdown()") ); | |
754 | trow2. appendChil d(buildSel ecterHelpe r("addLSI" , "Selecte d Local Si te Investi gator: ", ["Please S elect an I nvestigato r"], 12)); | |
755 | ||
756 | /*Add Table Elem ents Toget her*/ | |
757 | tbody. appendChil d(trow); | |
758 | tbody. appendChil d(trow2); | |
759 | ta ble.append Child(tbod y); | |
760 | ta bleDiv.app endChild(t able); | |
761 | ||
762 | co ntainer.ap pendChild( lineBreak) ; | |
763 | co ntainer.ap pendChild( tableDiv); | |
764 | ||
765 | mo dalFooter = document .createEle ment("div" ); | |
766 | mo dalFooter. setAttribu te("class" , "modal-f ooter"); | |
767 | ||
768 | /* Add Save B utton*/ | |
769 | sa veButton = document. createElem ent("butto n"); | |
770 | sa veButton.s etAttribut e("class", "btn btn- sm modal-b utton"); | |
771 | sa veButton.s etAttribut e("aria-la bel", "Sav e Data"); | |
772 | ||
773 | sa veButton.s etAttribut e("title", "Save you r site and investiga tor select ions"); // hover tip | |
774 | sa veButton.s etAttribut e("type", "button"); | |
775 | sa veButton.s etAttribut e("role", "button"); | |
776 | sa veButton.s etAttribut e("id", "s aveLocalSi te"); | |
777 | ||
778 | sa veButton.s etAttribut e("onclick ", "assign MultiSiteS tudy()"); | |
779 | te xt = docum ent.create TextNode(" Save Data" ); | |
780 | sa veButton.a ppendChild (text); | |
781 | ||
782 | /* Add Close Window But ton*/ | |
783 | cl oseButton = document .createEle ment("butt on"); | |
784 | cl oseButton. setAttribu te("class" , "btn btn -sm modal- button mod al-button- right"); | |
785 | cl oseButton. setAttribu te("data-d ismiss", " modal"); | |
786 | cl oseButton. setAttribu te("aria-l abel", "Cl ose"); | |
787 | ||
788 | cl oseButton. setAttribu te("title" , "Close t his window and retur n to the t able"); // hover tip | |
789 | cl oseButton. setAttribu te("type", "button") ; | |
790 | cl oseButton. setAttribu te("role", "button") ; | |
791 | cl oseButton. setAttribu te("id", " closeModal "); | |
792 | ||
793 | ||
794 | cl oseButton. setAttribu te("onclic k", "close AddSiteMod al()"); | |
795 | te xt = docum ent.create TextNode(" Close This Window"); | |
796 | cl oseButton. appendChil d(text); | |
797 | ||
798 | /* Combine Mo dal Elemen ts*/ | |
799 | mo dalContent .appendChi ld(contain er); | |
800 | mo dalFooter. appendChil d(saveButt on); | |
801 | mo dalFooter. appendChil d(closeBut ton); | |
802 | mo dalContent .appendChi ld(modalFo oter); | |
803 | mo dalDialog. appendChil d(modalCon tent); | |
804 | mo dal.append Child(moda lDialog); | |
805 | $( 'body').ap pend(modal ); | |
806 | $( '#addSiteM odal').pop up('show') ; | |
807 | } | |
808 | ||
809 | /* add the user titl e to the g lobal obje ct localSi teAppObjec t */ | |
810 | function a ddUser(dat a, siteID, property) { | |
811 | va r title = data.d.Tit le; | |
812 | lo calSiteApp Object[sit eID][prope rty] = tit le; | |
813 | } | |
814 | ||
815 | /* return the JSON o f the user */ | |
816 | function g etUserById (userID, s iteID, pro perty){ | |
817 | re turn $.aja x({ | |
818 | asyn c: false, | |
819 | type : 'GET', | |
820 | url: siteUrl.c oncat("_ap i/Web/GetU serById("+ userID+")/ "), | |
821 | head ers: {"acc ept": "app lication/j son;odata= verbose"}, | |
822 | data Type: 'jso n', | |
823 | succ ess: funct ion(json){ | |
824 | addUse r(json, si teID, prop erty); | |
825 | } | |
826 | }) ; | |
827 | } | |
828 | ||
829 | /* add the facility title to t he global object loc alSiteAppO bject */ | |
830 | function a ddFacility Name(data, siteID, p roperty){ | |
831 | va r title = data.d.Fac ilityName; | |
832 | lo calSiteApp Object[sit eID][prope rty] = tit le; | |
833 | } | |
834 | ||
835 | /* return the JSON o f the faci lity item */ | |
836 | function g etFacility Name(siteI D, propert y){ | |
837 | re turn $.aja x({ | |
838 | asyn c: false, | |
839 | type : 'GET', | |
840 | url: siteUrl.c oncat("_ap i/Web/List s/GetByTit le('Facili ty')/GetIt emById("+s iteID+")/" ), | |
841 | head ers: {"acc ept": "app lication/j son;odata= verbose"}, | |
842 | data Type: 'jso n', | |
843 | succ ess: funct ion(json){ | |
844 | addFac ilityName( json, site ID, proper ty); | |
845 | } | |
846 | }) ; | |
847 | } | |
848 | ||
849 | /* Loop th rough loca l site Sha rePoint ap plications | |
850 | * and add the data to the loc alSiteAppO bject for | |
851 | * later r eference * / | |
852 | function b uildLocalS iteObject( json){ | |
853 | va r applicat ions = jso n.d.result s; | |
854 | va r parentSt udyID, app Status, si teID, inve stigatorID , liaisonI D, hyperli nk, studyI D, studyTi tle; | |
855 | ||
856 | fo r(var i=0; i<applica tions.leng th; i++){ | |
857 | pare ntStudyID = applicat ions[i].Pa rentStudyI D; | |
858 | appS tatus = ap plications [i].Partic ipatingSit eApplicati onStat; | |
859 | site ID = appli cations[i] .Participa tingSiteId ; | |
860 | inve stigatorID = applica tions[i].P articipati ngSiteInve stigatorId ; | |
861 | ||
862 | liai sonID = ap plications [i].Partic ipatingSit eLiaisonId ; | |
863 | hype rlink = ap plications [i].LinkTo Applicatio n; | |
864 | stud yID = appl ications[i ].Study_ID ; | |
865 | stud yTitle = a pplication s[i].Study Title; | |
866 | ||
867 | loca lSiteAppOb ject[siteI D] = {}; | |
868 | loca lSiteAppOb ject[siteI D]["appSta tus"] = ap pStatus; | |
869 | loca lSiteAppOb ject[siteI D]["siteID "] = siteI D; | |
870 | loca lSiteAppOb ject[siteI D]["invest igatorID"] = investi gatorID; | |
871 | ||
872 | loca lSiteAppOb ject[siteI D]["liaiso nID"] = li aisonID; | |
873 | loca lSiteAppOb ject[siteI D]["linkTo Applicatio n"] = hype rlink; | |
874 | loca lSiteAppOb ject[siteI D]["studyI D"] = stud yID; | |
875 | loca lSiteAppOb ject[siteI D]["studyT itle"] = s tudyTitle; | |
876 | ||
877 | cons ole.log("P arent Stud y ID: "+pa rentStudyI D+"\nLocal Site Appl ication St atus: "+ap pStatus+"\ nLocal Sit e ID: "+si teID+"\nLo cal Site I nvestigato r ID: "+in vestigator ID+"\nLoca l Site Lia ison ID: " +liaisonID ); | |
878 | getU serById(in vestigator ID, siteID , "investi gator"); | |
879 | getU serById(li aisonID, s iteID, "li aison"); | |
880 | getF acilityNam e(siteID, "siteName" ); | |
881 | } | |
882 | } | |
883 | ||
884 | /* Grab al l local si te SharePo int applic ations | |
885 | * and ret urn the js on data fo r each lis t item | |
886 | */ | |
887 | function g rabLocalSi teApplicat ions(assig nedID){ | |
888 | var ap plicationU rl = siteU rl.concat( "_api/web/ lists/getb ytitle('Ap plication' )/items?$f ilter=Pare ntStudyID eq '"+assi gnedID+"'" ); | |
889 | re turn $.aja x({ | |
890 | asyn c: false, | |
891 | type : 'GET', | |
892 | url: applicati onUrl, | |
893 | head ers: {"acc ept": "app lication/j son;odata= verbose"}, | |
894 | data Type: 'jso n', | |
895 | succ ess: funct ion(json){ | |
896 | buildL ocalSiteOb ject(json) ; | |
897 | }, | |
898 | erro r: functio n(error){a lert("Erro r: "+JSON. stringify( error));} | |
899 | }) ; | |
900 | } | |
901 | ||
902 | /* invoke function c all to cre ate child study/loca l site app lication * / | |
903 | //Passing in Local S ite Invest igator to be inserte d as study member fo r edit per mission | |
904 | function i nvokeChild Study(site ID, invest igatorID){ | |
905 | ge nerateAssi gnedId("Lo cal", site ID, invest igatorID); | |
906 | } | |
907 | ||
908 | /* | |
909 | * generat e local si te applica tion page: | |
910 | * page al lows user to start a new local site stud y | |
911 | * and des ignate bot h local si te investi gator (LSI ) | |
912 | * and loc al site li aison (LSL ) | |
913 | */ | |
914 | function f acilityDis play(){ | |
915 | var co ntainer, t able, tabl eDiv, tbod y, trow, c ounter, bu ttonID; | |
916 | var se lectFacili ties = []; | |
917 | ||
918 | // create lis t of facil ities | |
919 | fo r(var key in userObj ect){ | |
920 | if(! userObject .hasOwnPro perty(key) ) continue ; | |
921 | sele ctFaciliti es.push(ke y); | |
922 | } | |
923 | ||
924 | contai ner = docu ment.creat eElement(" div"); | |
925 | contai ner.setAtt ribute("cl ass", "for m-content" ); | |
926 | ||
927 | /*Head er Table*/ | |
928 | table = tableHea derHelper( "Local Sit e Applicat ions", ["A dd Site", "Site Name ", "Local Site Inves tigator", "Local Sit e Liaison" , "Applica tion Name" , "Applica tion Link" ]); | |
929 | contai ner.append Child(tabl e); | |
930 | ||
931 | /*Scro llable Bod y Table*/ | |
932 | tableD iv = docum ent.create Element("d iv"); | |
933 | tableD iv.setAttr ibute("cla ss", "div- table-cont ent-big"); | |
934 | ||
935 | table = document .createEle ment("tabl e"); | |
936 | table. setAttribu te("class" , "table t able-strip ed table-h over"); | |
937 | table. setAttribu te("tabind ex", "0"); | |
938 | ||
939 | /*Tabl e Body*/ | |
940 | tbody = document .createEle ment("tbod y"); | |
941 | ||
942 | // add row fo r each loc al site ap plication | |
943 | counte r = 0; | |
944 | fo r (var sit e in local SiteAppObj ect){ | |
945 | if(! localSiteA ppObject.h asOwnPrope rty(site)) continue; | |
946 | trow = documen t.createEl ement("tr" ); //creat e clean ro w | |
947 | trow.a ppendChild (textCellH elper("td" , "Site Ad ded")); | |
948 | trow.appen dChild(tex tCellHelpe r("td", (l ocalSiteAp pObject[si te]["siteN ame"]))); //use ID t o get faci lity | |
949 | trow.appen dChild(tex tCellHelpe r("td", (l ocalSiteAp pObject[si te]["inves tigator"]) )); | |
950 | trow.appen dChild(tex tCellHelpe r("td", (l ocalSiteAp pObject[si te]["liais on"]))); | |
951 | ||
952 | /* Allow access to created lo cal site s tudy 61 if already i nitiated. | |
953 | Allow ability to create lo cal site s tudy 61 ba sed on sta tus of mai n study 60 . */ | |
954 | if((lo calSiteApp Object[sit e]["appSta tus"] == " Draft") && (localSit eAppObject [site]["li nkToApplic ation"])){ //st udy initia ted, show study titl e and link | |
955 | tr ow.appendC hild(textC ellHelper( "td", loca lSiteAppOb ject[site] ["studyTit le"])); | |
956 | trow.app endChild(l inkCellHel per("td", localSiteA ppObject[s ite]["stud yID"], nul l, localSi teAppObjec t[site]["l inkToAppli cation"][" Url"], "_b lank")); | |
957 | }else if(( spAppData. Applicatio nStatus == "Approved ") || (spA ppData.App licationSt atus == "A pproved wi th Major M odificatio ns") || (s pAppData.A pplication Status == "Approved with Minor Modificat ions")){ / /main stud y approved , enable s tart appli cation but ton | |
958 | trow.a ppendChild (textCellH elper("td" , "No Appl ication Na me Availab le")); | |
959 | button ID = "star tapplicati on"+localS iteAppObje ct[site][" siteID"]; | |
960 | trow.a ppendChild (buttonCel lHelper("S tart Appli cation", ( 'invokeChi ldStudy('+ localSiteA ppObject[s ite]["site ID"]+','+l ocalSiteAp pObject[si te]["inves tigatorID" ]+')'),but tonID)); | |
961 | }else{ //m ain study not approv ed, disabl e start ap plication button | |
962 | tr ow.appendC hild(textC ellHelper( "td", "No Applicatio n Name Ava ilable")); | |
963 | button ID = "star tapplicati on"+localS iteAppObje ct[site][" siteID"]; | |
964 | trow.a ppendChild (buttonCel lHelper("S tart Appli cation", ( 'invokeChi ldStudy('+ localSiteA ppObject[s ite]["site ID"]+','+l ocalSiteAp pObject[si te]["inves tigatorID" ]+')'),but tonID, tru e)); | |
965 | } | |
966 | ||
967 | tbody.appe ndChild(tr ow); | |
968 | counter++; | |
969 | } | |
970 | ||
971 | // create row for addin g local si tes | |
972 | trow = document. createElem ent("tr"); | |
973 | trow.a ppendChild (buttonCel lHelper("A dd", "trig gerAddSite Modal()")) ; | |
974 | trow.a ppendChild (textCellH elper("td" , "No Faci lity Selec ted")); | |
975 | trow.a ppendChild (textCellH elper("td" , "No Inve stigator S elected")) ; | |
976 | trow.a ppendChild (textCellH elper("td" , "No Liai son Select ed")); | |
977 | trow.a ppendChild (textCellH elper("td" , "No Appl ication Na me Availab le")); | |
978 | trow.a ppendChild (textCellH elper("td" , "No Appl ication Li nk Availab le")); | |
979 | tbody. appendChil d(trow); | |
980 | ||
981 | table. appendChil d(tbody); | |
982 | tableD iv.appendC hild(table ); | |
983 | contai ner.append Child(tabl eDiv); | |
984 | return container ; | |
985 | }; | |
986 | ||
987 | function g enerateLoc alApp(faci lityID){ | |
988 | //cons ole.log("g enerating local appl ication"); | |
989 | genera teAssigned Id("Local" , facility ID); | |
990 | }; | |
991 | ||
992 | function s wapForNonV A(checkbox ID, swapID ){ | |
993 | var te mpList; | |
994 | var se lectUsers = []; | |
995 | ||
996 | //remo ve drop do wn | |
997 | // $(' #'+swapID) .parent(). children() .remove(); | |
998 | ||
999 | if($(' #'+checkbo xID).is(': checked')) { | |
1000 | $( '#'+swapID ).parent() .replaceWi th(textare aCellHelpe r("td", sw apID, "Typ e in Non V A Person") ); | |
1001 | }else{ | |
1002 | te mpList = r amsUsers.v alues() | |
1003 | ||
1004 | fo r(var i=0; i<tempLis t.length; i++){ | |
1005 | selectUs ers.push(t empList[i] .Title); | |
1006 | } | |
1007 | ||
1008 | $( '#'+swapID ).parent() .replaceWi th(selectC ellHelper( swapID, "S elect Pers on to Add" , selectUs ers, null) ); | |
1009 | } | |
1010 | } | |
1011 | ||
1012 | function i nsertFacil ity(id){ | |
1013 | var fa cility = $ ('#'+id).v al(); | |
1014 | //var facilities = spAppDa ta.Coordin atingSites Id.results ; | |
1015 | //var liaisons; | |
1016 | var da ta, liaiso ns, facili ties; | |
1017 | ||
1018 | if(fac ility != " Please Sel ect a Faci lity"){ | |
1019 | se ndREST("GE T", siteUr l.concat(" _api/web/l ists/getby title('Fac ility')/it ems"), nul l, functio n(json){ | |
1020 | var retu rnedFacili ties = jso n.d.result s; | |
1021 | ||
1022 | if(spApp Data.Coord inatingSit esLiaisonI d == null) { | |
1023 | liai sons = []; | |
1024 | }else{ | |
1025 | liai sons = spA ppData.Coo rdinatingS itesLiaiso nId.result s; | |
1026 | } | |
1027 | ||
1028 | if(spApp Data.Coord inatingSit esId.resul ts.length == 0){ | |
1029 | faci lities = [ ]; | |
1030 | }else{ | |
1031 | //co nsole.log( "not null " + JSON.s tringify(s pAppData.C oordinatin gSitesId)) ; | |
1032 | faci lities = s pAppData.C oordinatin gSitesId.r esults; | |
1033 | } | |
1034 | ||
1035 | for(var i=0; i<ret urnedFacil ities.leng th; i++){ | |
1036 | if(r eturnedFac ilities[i] .FacilityN ame == fac ility){ | |
1037 | facilities .push(retu rnedFacili ties[i].Id ); | |
1038 | liaisons.p ush(return edFaciliti es[i].Faci lityLiaiso nId); | |
1039 | ||
1040 | //console. log("we ar e sending: " + liais ons + " an d " + faci lities); | |
1041 | ||
1042 | data = { | |
1043 | "__met adata": sp AppData.__ metadata, | |
1044 | "Coord inatingSit esId": { | |
1045 | "_ _metadata" : { "type" : "Collect ion(Edm.In t32)"}, | |
1046 | "r esults": f acilities | |
1047 | }, | |
1048 | "Coord inatingSit esLiaisonI d":{ | |
1049 | "_ _metadata" : {"type": "Collecti on(Edm.Int 32)"}, | |
1050 | "r esults": l iaisons | |
1051 | } | |
1052 | } | |
1053 | ||
1054 | spAppData. Coordinati ngSitesId. results = facilities ; | |
1055 | spAppData. Coordinati ngSitesLia isonId = { "results" : liaisons }; | |
1056 | ||
1057 | sendREST(" POST", spA ppData.__m etadata.ur i, data, f unction(){ | |
1058 | if(sps ubsiteAppD ata != nul l){ | |
1059 | se ndREST("PO ST", spsub siteAppDat a.__metada ta.uri, da ta, functi on(){ | |
1060 | refreshD isplay("Fa cility"); | |
1061 | }, "Merge"); | |
1062 | }else{ | |
1063 | re freshDispl ay("Facili ty"); | |
1064 | } | |
1065 | }, "Merge" ); | |
1066 | } | |
1067 | } | |
1068 | }) ; | |
1069 | } | |
1070 | } | |
1071 | ||
1072 | function r emoveFacil ity(facili tyID, liai sonID){ | |
1073 | var fa cilities = []; | |
1074 | var li aisons = [ ]; | |
1075 | var da ta; | |
1076 | //cons ole.log("w e recieved " + facil ityID + " and " + li aisonID); | |
1077 | ||
1078 | //grab facilitie s from app Data, iden tify which one you d on't need and resend merge | |
1079 | // sen dREST("GET ", siteUrl .concat("R AMSIRBSC/_ api/web/li sts/getbyt itle('Faci lity')/ite ms"), null , function (json){ | |
1080 | // var retur nedFacilit ies = json .d.results ; | |
1081 | // for(v ar i=0; i< returnedFa cilities.l ength; i++ ){ | |
1082 | // i f(returned Facilities [i].Id == id){ | |
1083 | for(var j= 0; j<spApp Data.Coord inatingSit esId.resul ts.length; j++){ | |
1084 | if(spA ppData.Coo rdinatingS itesId.res ults[j] != facilityI D) | |
1085 | fa cilities.p ush(spAppD ata.Coordi natingSite sId.result s[j]); | |
1086 | } | |
1087 | for(var j= 0; j<spApp Data.Coord inatingSit esLiaisonI d.results. length; j+ +){ | |
1088 | //cons ole.log("c hecking " + spAppDat a.Coordina tingSitesL iaisonId.r esults[j] + " vs " + liaisonID ); | |
1089 | if(spA ppData.Coo rdinatingS itesLiaiso nId.result s[j] != li aisonID){ | |
1090 | // console.lo g("we want to keep: " + spAppD ata.Coordi natingSite sLiaisonId .results[j ]); | |
1091 | li aisons.pus h(spAppDat a.Coordina tingSitesL iaisonId.r esults[j]) ; | |
1092 | } | |
1093 | } | |
1094 | ||
1095 | if(liaison s.length > = 1){ | |
1096 | data = { | |
1097 | "_ _metadata" : spAppDat a.__metada ta, | |
1098 | "C oordinatin gSitesId": { | |
1099 | "__metad ata": { "t ype": "Col lection(Ed m.Int32)"} , | |
1100 | "results ": facilit ies | |
1101 | }, | |
1102 | "C oordinatin gSitesLiai sonId":{ | |
1103 | "__metad ata": {"ty pe": "Coll ection(Edm .Int32)"}, | |
1104 | "results ": liaison s | |
1105 | } | |
1106 | } | |
1107 | ||
1108 | spAppD ata.Coordi natingSite sLiaisonId = {"resul ts" : liai sons}; | |
1109 | }else{ | |
1110 | //cons ole.log("p ackaging e mpty data" ); | |
1111 | data = { | |
1112 | "_ _metadata" : spAppDat a.__metada ta, | |
1113 | "C oordinatin gSitesId": { | |
1114 | "__metad ata": { "t ype": "Col lection(Ed m.Int32)"} , | |
1115 | "results ": facilit ies | |
1116 | }, | |
1117 | "C oordinatin gSitesLiai sonId":{ | |
1118 | "__metad ata": {"ty pe": "Coll ection(Edm .Int32)"}, | |
1119 | "results ": liaison s | |
1120 | } | |
1121 | } | |
1122 | spAppD ata.Coordi natingSite sLiaisonId = {"resul ts" : liai sons}; | |
1123 | } | |
1124 | ||
1125 | ||
1126 | spAppData. Coordinati ngSitesId. results = facilities ; | |
1127 | ||
1128 | ||
1129 | //console. log("we ar e sending liaisons: " + liaiso ns + ", fa cilities: " + facili ties); | |
1130 | ||
1131 | sendREST(" POST", spA ppData.__m etadata.ur i, data, f unction(){ | |
1132 | if(sps ubsiteAppD ata != nul l){ | |
1133 | se ndREST("PO ST", spsub siteAppDat a.__metada ta.uri, da ta, functi on(){ | |
1134 | refreshD isplay("Fa cility"); | |
1135 | }, "Merge"); | |
1136 | }else{ | |
1137 | re freshDispl ay("Facili ty"); | |
1138 | } | |
1139 | }, "Merge" ); | |
1140 | // } | |
1141 | // } | |
1142 | // }); | |
1143 | } | |
1144 | ||
1145 | function i nsertPerso n(){ | |
1146 | //This sh ould be ve rified on deployment to other environmen ts. The fi rst parame ter could vary. | |
1147 | StartW orkflow("D 9C79A8E-CD 98-4176-9D 11-9C8E91D 62CFF", nu ll); | |
1148 | var in Table, cap turedUser; | |
1149 | ||
1150 | if($(' #initPerso n').val() != "Please Select a User"){ | |
1151 | // check to s ee if pers on is in t he sql tab le | |
1152 | // if($('#in itVA').is( ':checked' )){ | |
1153 | // //per son isn't in VA, nee ds to be a dded | |
1154 | // }else{ | |
1155 | se ndREST("GE T", restPa th.concat( "study/"+a ssignedID+ "/members" ), null, f unction(re turnedMemb ers){ | |
1156 | var foun dUser = nu ll; | |
1157 | ||
1158 | for(var j=0; j<ret urnedMembe rs.length; j++){ | |
1159 | if(r eturnedMem bers[j].us er.display Name == $( '#initPers on').val() ){ | |
1160 | foundUser = returned Members[j] ; | |
1161 | } | |
1162 | } | |
1163 | ||
1164 | if(found User == nu ll){ | |
1165 | send REST("GET" , restPath .concat("u ser"), nul l, functio n(returned Users){ | |
1166 | for(var i= 0; i<retur nedUsers.l ength; i++ ){ | |
1167 | //cons ole.log("c omparing: " + return edUsers[i] .displayNa me + " to " + $('#in itPerson') .val()); | |
1168 | if(ret urnedUsers [i].displa yName == $ ('#initPer son').val( )){ | |
1169 | se ndPersonne lTable(ret urnedUsers [i]); | |
1170 | } | |
1171 | } | |
1172 | }); | |
1173 | }else{ | |
1174 | send PersonnelT able(found User.user, foundUser .study_Mem bersID); | |
1175 | } | |
1176 | }) ; | |
1177 | ||
1178 | // } | |
1179 | }else{ | |
1180 | in sertWarnin g("You mus t first se lect a Use r before y ou can pro ceed.", "a lert-warni ng"); | |
1181 | } | |
1182 | }; | |
1183 | ||
1184 | function s endPersonn elTable(fo undUser, m emberID){ | |
1185 | var da ta = { | |
1186 | "s tudy_Membe rsID": mem berID, | |
1187 | "u ser": foun dUser, | |
1188 | "v aUser": $( '#initVA_0 ').is(':ch ecked'), | |
1189 | "t eamMember" : $('#init StudyTeam_ 0').is(':c hecked'), | |
1190 | "m emberRole" : $('#init PersonRole ').val(), | |
1191 | "c oiRequired ": $('#ini tCOIReq_0' ).is(':che cked'), | |
1192 | "w ritePermis sions": $( '#initWrit ePerm_0'). is(':check ed'), | |
1193 | "e xplainatio n": $('#in itExplanat ion').val( ), | |
1194 | "n otificatio ns": $('#i nitNotify_ 0').is(':c hecked'), | |
1195 | "a ctiveMembe r": $('#in itActivate _0').is(': checked') | |
1196 | } | |
1197 | //cons ole.log("t rying to s end: " + J SON.string ify(data)) ; | |
1198 | //cons ole.log("w e are tryi ng to add " + JSON.s tringify(f oundUser) + " with " + JSON.st ringify(da ta)); | |
1199 | //send REST("POST ", restPat h.concat(" study/"+as signedID+" /members/" +foundUser .usersID), data, fun ction(){ | |
1200 | var AO Member = A OMemberChe ck(); | |
1201 | if (AOMember == true) | |
1202 | { | |
1203 | sendREST( "POST", re stPath.con cat("study /"+assigne dID+"/aome mbers/"), data, func tion(){ | |
1204 | ref reshDispla y('Personn el'); | |
1205 | }) ; | |
1206 | ||
1207 | } | |
1208 | el se | |
1209 | { | |
1210 | se ndREST("PO ST", restP ath.concat ("study/"+ assignedID +"/members /"), data, function( ){ | |
1211 | refr eshDisplay ('Personne l'); | |
1212 | }) ; | |
1213 | } | |
1214 | } | |
1215 | ||
1216 | function r emovePerso n(removeUs erID){ | |
1217 | se ndREST("GE T", restPa th.concat( "study/"+a ssignedID+ "/members" ), null, f unction(re turnedMemb ers){ | |
1218 | var foundDelU ser = null ; | |
1219 | ||
1220 | fo r(var j=0; j<returne dMembers.l ength; j++ ){ | |
1221 | if(r eturnedMem bers[j].us er.usersID == remove UserID){ | |
1222 | foun dDelUser = returnedM embers[j]; | |
1223 | } | |
1224 | } | |
1225 | ||
1226 | va r data = { | |
1227 | "study_Mem bersID": f oundDelUse r.study_Me mbersID, | |
1228 | "user": fo undDelUser .user, | |
1229 | "teamMembe r": foundD elUser.tea mMember, | |
1230 | "memberRol e": foundD elUser.mem berRole, | |
1231 | "coiRequir ed": found DelUser.co iRequired, | |
1232 | "writePerm issions": foundDelUs er.writePe rmissions, | |
1233 | "explainat ion": foun dDelUser.e xplainatio n, | |
1234 | "notificat ions": fou ndDelUser. notificati ons, | |
1235 | "activeMem ber": foun dDelUser.a ctiveMembe r | |
1236 | ||
1237 | } | |
1238 | ||
1239 | se ndREST("PO ST", restP ath.concat ("study/"+ assignedID +"/removem embers/"), data, fun ction(){ | |
1240 | refr eshDisplay ('Personne l'); | |
1241 | }) ; | |
1242 | }) ; | |
1243 | } | |
1244 | ||
1245 | function u pdatePerso n(updateUs er){ | |
1246 | if(upd ateUser == null){ | |
1247 | up dateUser = $('#initP erson').va l(); | |
1248 | } | |
1249 | ||
1250 | sendRE ST("GET", restPath.c oncat("stu dy/"+assig nedID+"/me mbers"), n ull, funct ion(return edMembers) { | |
1251 | fo r(var i=0; i<returne dMembers.l ength; i++ ){ | |
1252 | if(retur nedMembers [i].user.d isplayName == update User){ | |
1253 | //co nsole.log( "found our user: " + returnedM embers[i]. user.displ ayName); | |
1254 | ||
1255 | //na me | |
1256 | $('# initPerson ').val(ret urnedMembe rs[i].user .displayNa me); | |
1257 | ||
1258 | //on study tea m | |
1259 | if(r eturnedMem bers[i].te amMember){ | |
1260 | $('#initSt udyTeam_0' ).attr('ch ecked', 'c hecked'); | |
1261 | }els e{ | |
1262 | $('#initSt udyTeam_1' ).attr('ch ecked', 'c hecked'); | |
1263 | } | |
1264 | ||
1265 | //ro le | |
1266 | $('# initPerson Role').val (returnedM embers[i]. memberRole ); | |
1267 | ||
1268 | //CO I | |
1269 | if(r eturnedMem bers[i].co iRequired) { | |
1270 | $('#initCO IReq_0').a ttr('check ed', 'chec ked'); | |
1271 | }els e{ | |
1272 | $('#initCO IReq_1').a ttr('check ed', 'chec ked'); | |
1273 | } | |
1274 | ||
1275 | //re ad/write | |
1276 | if(r eturnedMem bers[i].wr itePermiss ions){ | |
1277 | $('#initWr itePerm_0' ).attr('ch ecked', 'c hecked'); | |
1278 | }els e{ | |
1279 | $('#initWr itePerm_1' ).attr('ch ecked', 'c hecked'); | |
1280 | } | |
1281 | ||
1282 | //us er explina tion | |
1283 | $('# initExplan ation').va l(returned Members[i] .explainat ion); | |
1284 | ||
1285 | //no tification s | |
1286 | if(r eturnedMem bers[i].no tification s){ | |
1287 | $('#initNo tify_0').a ttr('check ed', 'chec ked'); | |
1288 | }els e{ | |
1289 | $('#initNo tify_1').a ttr('check ed', 'chec ked'); | |
1290 | } | |
1291 | ||
1292 | //ac tivate | |
1293 | if(r eturnedMem bers[i].ac tiveMember ){ | |
1294 | $('#initAc tivate_0') .attr('che cked', 'ch ecked'); | |
1295 | }els e{ | |
1296 | $('#initAc tivate_1') .attr('che cked', 'ch ecked'); | |
1297 | } | |
1298 | } | |
1299 | } | |
1300 | }) | |
1301 | //This should be verified on deploym ent to oth er environ ments. The first par ameter cou ld vary. | |
1302 | StartW orkflow("D 9C79A8E-CD 98-4176-9D 11-9C8E91D 62CFF", nu ll); | |
1303 | }; | |
1304 | ||
1305 | function r eturnCheck ed(boolean ){ | |
1306 | if(boo lean){ | |
1307 | re turn textC ellHelper( "td", "x") ; | |
1308 | } | |
1309 | ||
1310 | return textCellH elper("td" , ""); | |
1311 | } | |
1312 | ||
1313 | function d eactivateU ser(usersI D){ | |
1314 | sendRE ST("POST", restPath. concat("st udy/"+assi gnedID+"/m embers/"+u sersID+"/d eactivate" ), null, f unction(){ | |
1315 | re freshDispl ay("Person nel"); | |
1316 | }); | |
1317 | } | |
1318 | ||
1319 | function a ctivateUse r(usersID) { | |
1320 | sendRE ST("POST", restPath. concat("st udy/"+assi gnedID+"/m embers/"+u sersID+"/a ctivate"), null, fun ction(){ | |
1321 | re freshDispl ay("Person nel"); | |
1322 | }); | |
1323 | } | |
1324 | ||
1325 | function A OMemberChe ck(){ | |
1326 | va r user; | |
1327 | va r AOMember = false; | |
1328 | $ .ajax({ | |
1329 | asyn c: false, | |
1330 | type : 'GET', | |
1331 | url: siteUrl.c oncat("_ap i/Web/Curr entUser/Gr oups"), | |
1332 | head ers: {"acc ept": "app lication/j son;odata= verbose"}, | |
1333 | data Type: 'jso n', | |
1334 | succ ess: funct ion(json){ | |
1335 | user = json.d.re sults; | |
1336 | for(va r i=0; i<u ser.length ; i++){ | |
1337 | if(user[ i].Title.i ndexOf("AO ") > -1){ | |
1338 | AOMember = true; | |
1339 | } | |
1340 | } | |
1341 | } | |
1342 | }) ; | |
1343 | re turn AOMem ber; | |
1344 | } | |
1345 | ||
1346 | function r emoveAttac hment(file , teamFold er){ | |
1347 | var da ta = []; | |
1348 | var re sponse = { }; | |
1349 | ||
1350 | //cons ole.log("l ooking to remove: " + file.spl it("-RAMS- ")[0]); | |
1351 | ||
1352 | respon se = { | |
1353 | "q uestionsID ": file.sp lit("-RAMS -")[0] | |
1354 | }; | |
1355 | ||
1356 | data.p ush(respon se); | |
1357 | ||
1358 | sendRE ST("POST", restPath. concat("st udy/"+assi gnedID+"/r esponses/" +targetSta ge), data, function( ){ | |
1359 | se ndREST("PO ST", siteU rl.concat( "/_api/Web /GetFileBy ServerRela tiveUrl('/ sites/IRBA pplication s/Shared%2 0Documents /"+assigne dID+"/"+te amFolder+" /"+file+"' )"), null, function( ){ | |
1360 | refreshD isplay("Fi les"); | |
1361 | }, "Delete") ; | |
1362 | }); | |
1363 | } | |
1364 | ||
1365 | function getAttachm entItem(it emID) { | |
1366 | ||
1367 | // Send the request an d return t he respons e. | |
1368 | re turn jQuer y.ajax({ | |
1369 | url: sit eUrl.conca t("/_api/W eb/Lists/g etByTitle( 'Shared Do cuments')/ Items(" + itemID + " )"), | |
1370 | type: "G ET", | |
1371 | headers: { "accept ": "applic ation/json ;odata=ver bose" } | |
1372 | }) ; | |
1373 | } | |
1374 | ||
1375 | function u pdateAttac hmentStatu s(itemMeta data, docS tatus) { | |
1376 | ||
1377 | // Define th e list ite m changes. Use the F ileLeafRef property to change the displa y name. | |
1378 | // For simpl icity, als o use the name as th e title. | |
1379 | // The examp le gets th e list ite m type fro m the item 's metadat a, but you can also get it fro m the | |
1380 | // ListItemE ntityTypeF ullName pr operty of the list. | |
1381 | var item; | |
1382 | var approvedDa te = new D ate(); | |
1383 | if (docStatu s == "Appr oved"){ | |
1384 | item = { | |
1385 | "__met adata": {" type": ite mMetadata. type}, | |
1386 | "Statu s": docSta tus, | |
1387 | "DateA pproved" : approvedD ate | |
1388 | }; | |
1389 | } | |
1390 | else { | |
1391 | ||
1392 | item = { | |
1393 | "__met adata": {" type": ite mMetadata. type}, | |
1394 | "Statu s": docSta tus | |
1395 | }; | |
1396 | } | |
1397 | ||
1398 | // Send the request an d return t he promise . | |
1399 | // This call does not return res ponse cont ent from t he server. | |
1400 | re turn jQuer y.ajax({ | |
1401 | url: ite mMetadata. uri, | |
1402 | type: "P OST", | |
1403 | data: JS ON.stringi fy(item), | |
1404 | headers: { | |
1405 | "X-R equestDige st": reque stDigest, | |
1406 | "con tent-type" : "applica tion/json; odata=verb ose", | |
1407 | "IF- MATCH": it emMetadata .etag, | |
1408 | "X-H TTP-Method ": "MERGE" | |
1409 | } | |
1410 | }) ; | |
1411 | } | |
1412 | function u pdateAttac hment() { | |
1413 | va r docStatu s = $('#s tatus').fi nd(':selec ted').val( ); | |
1414 | var no w = new Da te(); | |
1415 | va r attachme ntItem = g etAttachme ntItem(cur rentAttach mentID); | |
1416 | at tachmentIt em.done(fu nction (li stItem, st atus, xhr) { | |
1417 | ||
1418 | // Cha nge the di splay name and title of the li st item. | |
1419 | var ch angeItem = updateAtt achmentSta tus(listIt em.d.__met adata, doc Status); | |
1420 | change Item.done( function ( data, stat us, xhr) { | |
1421 | alert('A ttachment status upd ated'); | |
1422 | }); | |
1423 | change Item.fail( function ( data, stat us, xhr) { | |
1424 | alert('f ile upload ed failed: ' + status ); | |
1425 | }); | |
1426 | }) ; | |
1427 | at tachmentIt em.fail(fu nction (da ta, status , xhr) { | |
1428 | alert('g et attachm ent item f ailed' + s tatus); | |
1429 | }) ; | |
1430 | ||
1431 | ||
1432 | ||
1433 | ||
1434 | } | |
1435 | ||
1436 | function r erouteApp( childId){ | |
1437 | window .location. href("irb- applicatio ns-general .html?" + childId); | |
1438 | } | |
1439 | ||
1440 | /* | |
1441 | //Subscrip tion id - Workflow s ubscriptio n id | |
1442 | //list ite m id for w hich to st art workfl ow. If sit e workflow , then sen d null for itemId | |
1443 | function S tartWorkfl ow(subscri ptionId, i temId) { | |
1444 | var ctx = SP.Client Context.ge t_current( ); | |
1445 | var wfMan ager = SP. WorkflowSe rvices.Wor kflowServi cesManager .newObject (ctx, ctx. get_web()) ; | |
1446 | var subsc ription = wfManager. getWorkflo wSubscript ionService ().getSubs cription(s ubscriptio nId); | |
1447 | ctx.load( subscripti on, 'Prope rtyDefinit ions'); | |
1448 | ctx.execu teQueryAsy nc( | |
1449 | funct ion (sende r, args) { | |
1450 | v ar params= new Objec t(); | |
1451 | / /Find init iation dat a to be pa ssed to wo rkflow. | |
1452 | v ar formDat a = subscr iption.get _propertyD efinitions ()["FormDa ta"]; | |
1453 | i f (formDat a != null && formDat a != 'unde fined' && formData ! = "") { | |
1454 | var ass ocParams = formData. split(";#" ); | |
1455 | for (va r i = 0; i < assocPa rams.lengt h; i++) { | |
1456 | par ams[assocP arams[i]] = subscrip tion.get_p ropertyDef initions() [assocPara ms[i]]; | |
1457 | } | |
1458 | } | |
1459 | i f (itemId) { | |
1460 | wfManag er.getWork flowInstan ceService( ).startWor kflowOnLis tItem(subs cription, itemId, pa rams); | |
1461 | } | |
1462 | e lse { | |
1463 | par ams = { | |
1464 | Study_I D: assigne dID, | |
1465 | Subject : "Personn el Has Cha nged", | |
1466 | To: "CI RB Committ ee Cordina tors", | |
1467 | Body: " The Person nel Has Ch anged." | |
1468 | ||
1469 | }; | |
1470 | wfMana ger.getWor kflowInsta nceService ().startWo rkflow(sub scription, params); | |
1471 | } | |
1472 | c tx.execute QueryAsync ( | |
1473 | functio n (sender, args) { | |
1474 | }, | |
1475 | functio n (sender, args) { | |
1476 | ale rt('Failed to run wo rkflow'); | |
1477 | } | |
1478 | ) ; | |
1479 | }, | |
1480 | funct ion (sende r, args) { | |
1481 | a lert('Fail ed to run workflow') ; | |
1482 | } | |
1483 | ); | |
1484 | */ | |
1485 | ||
1486 | //Subscri ption id - Workflow subscripti on id | |
1487 | //list ite m id for w hich to st art workfl ow. If sit e workflow , then sen d null for itemId | |
1488 | function S tartWorkfl ow(subscri ptionId, i temId) { | |
1489 | var ctx = SP.Clie ntContext. get_curren t(); | |
1490 | var wfM anager = S P.Workflow Services.W orkflowSer vicesManag er.newObje ct(ctx, ct x.get_web( )); | |
1491 | var sub scription = wfManage r.getWorkf lowSubscri ptionServi ce().getSu bscription (subscript ionId); | |
1492 | ctx.loa d(subscrip tion, 'Pro pertyDefin itions'); | |
1493 | ctx.exe cuteQueryA sync( | |
1494 | fun ction (sen der, args) { | |
1495 | var param s= new Obj ect(); | |
1496 | //Find in itiation d ata to be passed to workflow. | |
1497 | var formD ata = subs cription.g et_propert yDefinitio ns()["Form Data"]; | |
1498 | if (formD ata != nul l && formD ata != 'un defined' & & formData != "") { | |
1499 | var a ssocParams = formDat a.split("; #"); | |
1500 | for ( var i = 0; i < assoc Params.len gth; i++) { | |
1501 | p arams[asso cParams[i] ] = subscr iption.get _propertyD efinitions ()[assocPa rams[i]]; | |
1502 | } | |
1503 | } | |
1504 | if (itemI d) { | |
1505 | wfMan ager.getWo rkflowInst anceServic e().startW orkflowOnL istItem(su bscription , itemId, params); | |
1506 | } | |
1507 | else { | |
1508 | params = { | |
1509 | Study_ ID: assign edID, | |
1510 | To: "C IRB Commit tee Cordin ators", | |
1511 | Subjec t: "Person nel Has Ch anged", | |
1512 | Body: "The Perso nnel Has C hanged." | |
1513 | ||
1514 | }; | |
1515 | wfMana ger.getWor kflowInsta nceService ().startWo rkflow(sub scription, params); | |
1516 | } | |
1517 | ctx.execu teQueryAsy nc( | |
1518 | funct ion (sende r, args) { | |
1519 | }, | |
1520 | funct ion (sende r, args) { | |
1521 | a lert('Fail ed to run workflow') ; | |
1522 | } | |
1523 | ); | |
1524 | }, | |
1525 | fun ction (sen der, args) { | |
1526 | alert('Fa iled to ru n workflow '); | |
1527 | } | |
1528 | ); | |
1529 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.