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