Institution: delete slice bug fix
[myslice.git] / portal / static / js / institution.js
1 $(document).ready(function() {
2     $('a.home-tab').click(function() {
3         $('ul.nav-tabs li').removeClass('active');
4         $(this).parent().addClass('active');
5         $('div.home-panel').hide();
6         $('div#'+$(this).data('panel')).show();
7     });
8     var url = window.location;
9     if(url.hash) {
10         // Fragment exists 
11         tab = url.href.split("#")[1];
12         tab_exists = $('div#'+tab).length;
13         if (tab_exists) {
14            $('ul.nav-tabs li').removeClass('active');
15            $('li#'+tab+'-tab').addClass('active');
16            $('div.home-panel').hide();            
17            $('div#'+tab).show();
18         }
19     }
20
21     /* TODO: factorize into functions */
22     $('button#deleteusers').click(function() {
23         $('input:checkbox.user').each(function (index) {
24             if(this.checked){
25                 var record_id = this.id;
26                 $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) {
27                     if(data.success){
28                         $('tr[id="'+record_id+'"]').fadeOut("slow");
29                         $('tr[id="'+record_id+'"]').remove();
30                     }else{
31                         alert("Rest Error for "+record_id+": "+data.error);
32                     }
33                 });
34                 
35             }
36         });
37     });
38     $('button#deleteslices').click(function() {
39         $('input:checkbox.slice').each(function (index) {
40             if(this.checked){
41                 var record_id = this.id;
42                 $.post("/delete/slice/",{'filters':{'slice_hrn':this.id}}, function(data) {
43                     if(data.success){
44                         $('tr[id="'+record_id+'"]').fadeOut("slow");
45                         $('tr[id="'+record_id+'"]').remove();
46                     }else{
47                         alert("Rest Error for "+record_id+": "+data.error);
48                     }
49                 });
50                 
51             }
52         });
53     });
54
55     $('button#createslice').click(function() {
56         window.location="/portal/slice_request/";
57     });
58     $('button#slicerequestbtn').click(function() {
59         /*
60         window.location="/portal/slice_request/";
61         */
62     });
63 });