sliceuser: normal user can add users to slice now
[unfold.git] / portal / templates / slice-tab-users-view.html
index eef4161..18007ab 100644 (file)
                     console.log(slice_users);
                 }
             });
-       }); // post rest/user
-    }
+       }); // post rest/use
+
+               $('button#addusers').click(function() {
+               $.post("/update/slice/",{'filters':{'slice_hrn':'{{slice}}'},'params':{'users':slice_users}}, function(data) {
+                       if(data.success){
+                       // TODO: highlight row after success
+                       //$('tr[id="'+record_id+'"]').highlight();
+                       mysliceAlert('Success: slice updated','success', true);
+                       }else{
+                       mysliceAlert('Rest Error for: '+data.error,'warning', true);
+                       }
+               }); // post update slice
+               // TODO: refresh table
+               //window.location="/portal/institution#slices";
+               }); // button#addusers click
+
+    } // get_users_in_slice
 
     $(document).ready(function() {
             // TODO: Add a filter based on the list of authorities
                                $( "#auth_list" ).autocomplete({
                                source: list_authorities,
                                minLength: 0,
-                               change: function (event, ui) {
-                                               get_users_in_slice(this.value); 
-                                       if(!ui.item){
-                               //http://api.jqueryui.com/autocomplete/#event-change -
-                               //The item selected from the menu, if any. Otherwise the property is null
-                               //so clear the item for force selection
-                                       jQuery("#auth_list").val("");
-                                                       alert("Please select an authority from the given list.")
-                                       }
+                               select: function (event, ui) {
+                                               get_users_in_slice(ui.item.value);
                                }
                                //select: function( event, ui ) {console.log(jQuery(this))}
                        });
 
             get_users_in_slice("{{user_details.parent_authority}}");
 
-               $('button#addusers').click(function() {
-                $.post("/update/slice/",{'filters':{'slice_hrn':'{{slice}}'},'params':{'users':slice_users}}, function(data) {
-                       if(data.success){
-                       // TODO: highlight row after success
-                       //$('tr[id="'+record_id+'"]').highlight();
-                       mysliceAlert('Success: slice updated','success', true);
-                       }else{
-                       mysliceAlert('Rest Error for: '+data.error,'warning', true);
-                       }
-                }); // post update slice
-            
-               // TODO: refresh table
-               //window.location="/portal/institution#slices";
-
-            }); // button#addusers click
        $('[title!=""]').qtip();
     }); // document ready
 </script>
 
                 <!-- XXX TODO: for the moment only PIs have access to Update but users that have slice credentials should also have access to that -->
 
-                               {% if 'is_pi'  in pi %}
                                <button id="addusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Update users</button>
-                               {%endif%}
                </div>