mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #1253: Modify row click behaviour in Sunstone
When clicking on a row with CTRL it will be checked/unchecked. When >= 1 rows are already selected, subsequent clicks on rows will (un)select them instead of triggering the info dialog. (cherry picked from commit 6cf2c019ff0fec234beb668fcf20e9d3611837c3)
This commit is contained in:
parent
a467bbc30e
commit
a344dbdd57
@ -517,4 +517,5 @@ $(document).ready(function(){
|
||||
tableCheckboxesListener(dataTable_acls);
|
||||
//shortenedInfoFields('#datatable_acls');
|
||||
|
||||
infoListener(dataTable_acls);
|
||||
})
|
||||
|
@ -864,5 +864,5 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_clusters);
|
||||
tableCheckboxesListener(dataTable_clusters);
|
||||
// clusterInfoListener();
|
||||
infoListener(dataTable_clusters);
|
||||
});
|
||||
|
@ -356,21 +356,6 @@ function datastoreElementArray(element_json){
|
||||
];
|
||||
}
|
||||
|
||||
function datastoreInfoListener(){
|
||||
|
||||
$('#tbodydatastores tr',dataTable_datastores).live("click", function(e){
|
||||
if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
|
||||
|
||||
var aData = dataTable_datastores.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Datastore.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
function updateDatastoreSelect(){
|
||||
datastores_select = makeSelectOptions(dataTable_datastores,
|
||||
1,
|
||||
@ -703,7 +688,7 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_datastores);
|
||||
tableCheckboxesListener(dataTable_datastores);
|
||||
datastoreInfoListener();
|
||||
infoListener(dataTable_datastores,'Datastore.showinfo');
|
||||
|
||||
$('div#menu li#li_datastores_tab').live('click',function(){
|
||||
dataTable_datastores.fnFilter('',5);
|
||||
|
@ -179,17 +179,6 @@ function groupElementArray(group_json){
|
||||
users_str ];
|
||||
}
|
||||
|
||||
// function groupInfoListener(){
|
||||
// $('#groups_tab #tbodygroups tr',main_tabs_context).live("click",function(e){
|
||||
// //do nothing if we are clicking a checkbox!
|
||||
// if ($(e.target).is('input')) {return true;}
|
||||
// var aData = dataTable_groups.fnGetData(this);
|
||||
// var id = $(aData[0]).val();
|
||||
// Sunstone.runAction("Group.showinfo",id);
|
||||
// return false;
|
||||
// });
|
||||
// }
|
||||
|
||||
function updateGroupSelect(){
|
||||
groups_select = makeSelectOptions(dataTable_groups,
|
||||
1,//id_col
|
||||
@ -302,4 +291,5 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_groups);
|
||||
tableCheckboxesListener(dataTable_groups);
|
||||
infoListener(dataTable_groups);
|
||||
})
|
||||
|
@ -425,22 +425,6 @@ function hostElementArray(host_json){
|
||||
];
|
||||
}
|
||||
|
||||
//Listen to clicks on the tds of the tables and shows the info dialogs.
|
||||
function hostInfoListener(){
|
||||
$('#tbodyhosts tr',dataTable_hosts).live("click",function(e){
|
||||
//do nothing if we are clicking a checkbox!
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
|
||||
var aData = dataTable_hosts.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Host.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//updates the host select by refreshing the options in it
|
||||
function updateHostSelect(){
|
||||
hosts_select = makeSelectOptions(dataTable_hosts,
|
||||
@ -743,7 +727,7 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_hosts);
|
||||
tableCheckboxesListener(dataTable_hosts);
|
||||
hostInfoListener();
|
||||
infoListener(dataTable_hosts, "Host.showinfo");
|
||||
|
||||
$('div#menu li#li_hosts_tab').live('click',function(){
|
||||
dataTable_hosts.fnFilter('',3);
|
||||
|
@ -555,24 +555,6 @@ function imageElementArray(image_json){
|
||||
];
|
||||
}
|
||||
|
||||
// Set up the listener on the table TDs to show the info panel
|
||||
function imageInfoListener(){
|
||||
$('#tbodyimages tr',dataTable_images).live("click",function(e){
|
||||
var target = $(e.target);
|
||||
|
||||
if (target.is('input') || target.is('select') || target.is('option'))
|
||||
return true;
|
||||
|
||||
var aData = dataTable_images.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Image.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Callback to update an element in the dataTable
|
||||
function updateImageElement(request, image_json){
|
||||
var id = image_json.IMAGE.ID;
|
||||
@ -1180,5 +1162,5 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_images);
|
||||
tableCheckboxesListener(dataTable_images);
|
||||
imageInfoListener();
|
||||
infoListener(dataTable_images,'Image.showinfo');
|
||||
});
|
||||
|
@ -857,21 +857,6 @@ function templateElementArray(template_json){
|
||||
];
|
||||
}
|
||||
|
||||
// Set up the listener on the table TDs to show the info panel
|
||||
function templateInfoListener(){
|
||||
$('#tbodytemplates tr',dataTable_templates).live("click",function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
|
||||
var aData = dataTable_templates.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Template.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//Updates the select input field with an option for each template
|
||||
function updateTemplateSelect(){
|
||||
var templates_select =
|
||||
@ -2178,5 +2163,5 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_templates);
|
||||
tableCheckboxesListener(dataTable_templates);
|
||||
templateInfoListener();
|
||||
infoListener(dataTable_templates,'Template.showinfo');
|
||||
});
|
||||
|
@ -342,20 +342,6 @@ function userElementArray(user_json){
|
||||
]
|
||||
};
|
||||
|
||||
function userInfoListener(){
|
||||
$('#tbodyusers tr',dataTable_users).live("click",function(e){
|
||||
//do nothing if we are clicking a checkbox!
|
||||
if ($(e.target).is('input')) return true;
|
||||
var aData = dataTable_users.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("User.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
function updateUserSelect(){
|
||||
users_select = makeSelectOptions(dataTable_users,
|
||||
1,//id_col
|
||||
@ -571,5 +557,5 @@ $(document).ready(function(){
|
||||
initCheckAllBoxes(dataTable_users);
|
||||
tableCheckboxesListener(dataTable_users);
|
||||
//shortenedInfoFields('#datatable_users');
|
||||
userInfoListener();
|
||||
infoListener(dataTable_users,'User.showinfo');
|
||||
});
|
||||
|
@ -683,22 +683,6 @@ function vMachineElementArray(vm_json){
|
||||
};
|
||||
|
||||
|
||||
//Creates a listener for the TDs of the VM table
|
||||
function vMachineInfoListener(){
|
||||
|
||||
$('#tbodyvmachines tr',dataTable_vMachines).live("click", function(e){
|
||||
if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
|
||||
|
||||
var aData = dataTable_vMachines.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("VM.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Callback to refresh a single element from the list
|
||||
function updateVMachineElement(request, vm_json){
|
||||
var id = vm_json.VM.ID;
|
||||
@ -1410,5 +1394,5 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_vMachines);
|
||||
tableCheckboxesListener(dataTable_vMachines);
|
||||
vMachineInfoListener();
|
||||
infoListener(dataTable_vMachines,'VM.showinfo');
|
||||
})
|
@ -496,23 +496,6 @@ function vNetworkElementArray(vn_json){
|
||||
network.TOTAL_LEASES ];
|
||||
}
|
||||
|
||||
|
||||
//Adds a listener to show the extended info when clicking on a row
|
||||
function vNetworkInfoListener(){
|
||||
|
||||
$('#tbodyvnetworks tr',dataTable_vNetworks).live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
|
||||
var aData = dataTable_vNetworks.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Network.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//Callback to update a vnet element after an action on it
|
||||
function updateVNetworkElement(request, vn_json){
|
||||
id = vn_json.VNET.ID;
|
||||
@ -1209,7 +1192,7 @@ $(document).ready(function(){
|
||||
|
||||
initCheckAllBoxes(dataTable_vNetworks);
|
||||
tableCheckboxesListener(dataTable_vNetworks);
|
||||
vNetworkInfoListener();
|
||||
infoListener(dataTable_vNetworks,'Network.showinfo');
|
||||
|
||||
$('div#menu li#li_vnets_tab').live('click',function(){
|
||||
dataTable_vNetworks.fnFilter('',5);
|
||||
|
@ -787,6 +787,33 @@ function popUpTemplateUpdateDialog(elem_str,select_items,sel_elems){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Shows run a custom action when clicking on rows.
|
||||
function infoListener(dataTable, info_action){
|
||||
$('tbody tr',dataTable).live("click",function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
|
||||
var aData = dataTable.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
var count = $('tbody .check_item:checked', dataTable).length;
|
||||
|
||||
if (info_action){
|
||||
if (e.ctrlKey || count >= 1)
|
||||
$('.check_item',this).trigger('click');
|
||||
else {
|
||||
popDialogLoading();
|
||||
Sunstone.runAction(info_action,id)
|
||||
};
|
||||
} else {
|
||||
$('.check_item',this).trigger('click');
|
||||
};
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function mustBeAdmin(){
|
||||
return gid == 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user