mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 12451: add network offering - hide availability dropdown when a Required network offering has existed. Only optional network offerings are allowed to create.
This commit is contained in:
parent
8b55d8b1b0
commit
4aaf15a353
@ -1,4 +1,7 @@
|
||||
(function(cloudStack, $) {
|
||||
|
||||
var requiredNetworkOfferingExists = false;
|
||||
|
||||
cloudStack.sections.configuration = {
|
||||
title: 'Configuration',
|
||||
id: 'configuration',
|
||||
@ -1011,6 +1014,14 @@
|
||||
async: true,
|
||||
success: function(json) {
|
||||
var items = json.listnetworkofferingsresponse.networkoffering;
|
||||
|
||||
$(items).each(function(){
|
||||
if(this.availability == "Required") {
|
||||
requiredNetworkOfferingExists = true;
|
||||
return false; //break each loop
|
||||
}
|
||||
});
|
||||
|
||||
args.response.success({
|
||||
actionFilter: networkOfferingActionfilter,
|
||||
data:items
|
||||
@ -1116,14 +1127,22 @@
|
||||
serviceProviderIndex++;
|
||||
});
|
||||
|
||||
if(args.$form.find('.form-item[rel=availability]').css("display") == "none")
|
||||
inputData['availability'] = 'Optional';
|
||||
|
||||
$.ajax({
|
||||
url: createURL('createNetworkOffering'),
|
||||
data: inputData,
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
success: function(data) {
|
||||
var item = data.createnetworkofferingresponse.networkoffering;
|
||||
|
||||
if(inputData['availability'] == "Required")
|
||||
requiredNetworkOfferingExists = true;
|
||||
|
||||
args.response.success({
|
||||
data: data.createnetworkofferingresponse.networkoffering,
|
||||
data: item,
|
||||
actionFilter: networkOfferingActionfilter
|
||||
});
|
||||
},
|
||||
@ -1137,6 +1156,12 @@
|
||||
createForm: {
|
||||
title: 'Add network offering',
|
||||
desc: 'Please specify the network offering',
|
||||
preFilter: function(args) {
|
||||
if(requiredNetworkOfferingExists == true)
|
||||
args.$form.find('.form-item[rel=availability]').hide();
|
||||
else
|
||||
args.$form.find('.form-item[rel=availability]').css('display', 'inline-block');
|
||||
},
|
||||
fields: {
|
||||
name: { label: 'Name', validation: { required: true } },
|
||||
|
||||
@ -1183,8 +1208,7 @@
|
||||
args.response.success({
|
||||
data: [
|
||||
{ id: 'Optional', description: 'Optional' },
|
||||
{ id: 'Required', description: 'Required' },
|
||||
{ id: 'Unavailable', description: 'Unavailable' }
|
||||
{ id: 'Required', description: 'Required' }
|
||||
]
|
||||
});
|
||||
}
|
||||
@ -1429,6 +1453,9 @@
|
||||
id: args.context.networkOfferings[0].id
|
||||
},
|
||||
success: function(json) {
|
||||
if(args.context.networkOfferings[0].availability == "Required")
|
||||
requiredNetworkOfferingExists = false; //since only one or zero Required network offering can exist
|
||||
|
||||
args.response.success();
|
||||
},
|
||||
error: function(data) {
|
||||
@ -1531,6 +1558,9 @@
|
||||
id: args.context.networkOfferings[0].id
|
||||
},
|
||||
success: function(json) {
|
||||
if(args.context.networkOfferings[0].availability == "Required")
|
||||
requiredNetworkOfferingExists = false; //since only one or zero Required network offering can exist
|
||||
|
||||
args.response.success();
|
||||
},
|
||||
error: function(data) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user