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, $) {
|
(function(cloudStack, $) {
|
||||||
|
|
||||||
|
var requiredNetworkOfferingExists = false;
|
||||||
|
|
||||||
cloudStack.sections.configuration = {
|
cloudStack.sections.configuration = {
|
||||||
title: 'Configuration',
|
title: 'Configuration',
|
||||||
id: 'configuration',
|
id: 'configuration',
|
||||||
@ -1011,6 +1014,14 @@
|
|||||||
async: true,
|
async: true,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listnetworkofferingsresponse.networkoffering;
|
var items = json.listnetworkofferingsresponse.networkoffering;
|
||||||
|
|
||||||
|
$(items).each(function(){
|
||||||
|
if(this.availability == "Required") {
|
||||||
|
requiredNetworkOfferingExists = true;
|
||||||
|
return false; //break each loop
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
args.response.success({
|
args.response.success({
|
||||||
actionFilter: networkOfferingActionfilter,
|
actionFilter: networkOfferingActionfilter,
|
||||||
data:items
|
data:items
|
||||||
@ -1115,15 +1126,23 @@
|
|||||||
inputData['serviceProviderList[' + serviceProviderIndex + '].provider'] = value;
|
inputData['serviceProviderList[' + serviceProviderIndex + '].provider'] = value;
|
||||||
serviceProviderIndex++;
|
serviceProviderIndex++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(args.$form.find('.form-item[rel=availability]').css("display") == "none")
|
||||||
|
inputData['availability'] = 'Optional';
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL('createNetworkOffering'),
|
url: createURL('createNetworkOffering'),
|
||||||
data: inputData,
|
data: inputData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: true,
|
async: true,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
var item = data.createnetworkofferingresponse.networkoffering;
|
||||||
|
|
||||||
|
if(inputData['availability'] == "Required")
|
||||||
|
requiredNetworkOfferingExists = true;
|
||||||
|
|
||||||
args.response.success({
|
args.response.success({
|
||||||
data: data.createnetworkofferingresponse.networkoffering,
|
data: item,
|
||||||
actionFilter: networkOfferingActionfilter
|
actionFilter: networkOfferingActionfilter
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1133,10 +1152,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
createForm: {
|
createForm: {
|
||||||
title: 'Add network offering',
|
title: 'Add network offering',
|
||||||
desc: 'Please specify the 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: {
|
fields: {
|
||||||
name: { label: 'Name', validation: { required: true } },
|
name: { label: 'Name', validation: { required: true } },
|
||||||
|
|
||||||
@ -1183,8 +1208,7 @@
|
|||||||
args.response.success({
|
args.response.success({
|
||||||
data: [
|
data: [
|
||||||
{ id: 'Optional', description: 'Optional' },
|
{ id: 'Optional', description: 'Optional' },
|
||||||
{ id: 'Required', description: 'Required' },
|
{ id: 'Required', description: 'Required' }
|
||||||
{ id: 'Unavailable', description: 'Unavailable' }
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1428,7 +1452,10 @@
|
|||||||
data: {
|
data: {
|
||||||
id: args.context.networkOfferings[0].id
|
id: args.context.networkOfferings[0].id
|
||||||
},
|
},
|
||||||
success: function(json) {
|
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();
|
args.response.success();
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
@ -1530,7 +1557,10 @@
|
|||||||
data: {
|
data: {
|
||||||
id: args.context.networkOfferings[0].id
|
id: args.context.networkOfferings[0].id
|
||||||
},
|
},
|
||||||
success: function(json) {
|
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();
|
args.response.success();
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user