From 3be11992694dc71d556395d88aabfac21368350d Mon Sep 17 00:00:00 2001
From: "Mark M. Florida" <markflorida@wustl.edu>
Date: Mon, 12 Sep 2016 18:07:47 -0500
Subject: [PATCH] XNAT-4515: newly created PI can now be immediately edited

---
 src/main/webapp/scripts/xnat/app/investigators.js         | 8 ++++++--
 .../screens/xnat_projectData/edit/details.vm              | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main/webapp/scripts/xnat/app/investigators.js b/src/main/webapp/scripts/xnat/app/investigators.js
index dc237a1e..b35ff329 100644
--- a/src/main/webapp/scripts/xnat/app/investigators.js
+++ b/src/main/webapp/scripts/xnat/app/investigators.js
@@ -131,13 +131,13 @@ var XNAT = getObject(XNAT);
     };
 
     // return array of ids of selected investigators
-    Investigators.fn.getSelected = function(){
+    Investigators.fn.getSelected = function(i){
         var self = this;
         this.selected = [];
         this.menu$.find(':selected').each(function(){
             self.selected.push(this.value)
         });
-        return this.selected;
+        return i || i === 0 ? this.selected[i] : this.selected;
     };
 
     // renders the <option> elements
@@ -326,6 +326,10 @@ var XNAT = getObject(XNAT);
                                 }
                                 // update the menu associated with the dialog
                                 self.updateMenu([].concat(self.getSelected(), (!setPrimary ? selected : [])));
+                                // set the PI if editing/creating PI
+                                if (setPrimary) {
+                                    investigators.primary = selected;
+                                }
                                 dialog.close();
                             }
                         });
diff --git a/src/main/webapp/xnat-templates/screens/xnat_projectData/edit/details.vm b/src/main/webapp/xnat-templates/screens/xnat_projectData/edit/details.vm
index ca93b436..3f552ed4 100644
--- a/src/main/webapp/xnat-templates/screens/xnat_projectData/edit/details.vm
+++ b/src/main/webapp/xnat-templates/screens/xnat_projectData/edit/details.vm
@@ -288,6 +288,7 @@
         var editPrimary = spawn('a#edit-primary|href=#!', 'Edit Selected');
 
         editPrimary.onclick = function(){
+//            investigators.primary = primaryMenu.getSelected(0);
             if (investigators.primary !== 'NULL') {
                 primaryMenu.dialog(investigators.primary)
             }
-- 
GitLab