Skip to content

Commit 7e0f1cf

Browse files
author
Jessica Wang
committed
CLOUDSTACK-8040: UI: register template dialog, register ISO dialog - fix a bug that hidden fields fail to be generated before cloudStack.preFilter.createTemplate() is called. Thus, cloudStack.preFilter.createTemplate() is unable to change hidden fields's css display property from none to inline-block for admin users.
1 parent 7d7df02 commit 7e0f1cf

1 file changed

Lines changed: 81 additions & 85 deletions

File tree

ui/scripts/templates.js

Lines changed: 81 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,18 @@
408408
osTypeId: {
409409
label: 'label.os.type',
410410
docID: 'helpRegisterTemplateOSType',
411-
select: function(args) {
412-
if (ostypeObjs == undefined) {
413-
$.ajax({
414-
url: createURL("listOsTypes"),
415-
dataType: "json",
416-
async: false,
417-
success: function(json) {
418-
ostypeObjs = json.listostypesresponse.ostype;
419-
}
420-
});
421-
}
422-
args.response.success({
423-
data: ostypeObjs
424-
});
411+
select: function(args) {
412+
$.ajax({
413+
url: createURL("listOsTypes"),
414+
dataType: "json",
415+
async: true,
416+
success: function(json) {
417+
var ostypeObjs = json.listostypesresponse.ostype;
418+
args.response.success({
419+
data: ostypeObjs
420+
});
421+
}
422+
});
425423
}
426424
},
427425

@@ -849,16 +847,16 @@
849847
}
850848

851849
if ('templates' in args.context && args.context.templates[0].ostypeid != undefined) {
852-
if (ostypeObjs == undefined) {
853-
$.ajax({
854-
url: createURL("listOsTypes"),
855-
dataType: "json",
856-
async: false,
857-
success: function(json) {
858-
ostypeObjs = json.listostypesresponse.ostype;
859-
}
860-
});
861-
}
850+
var ostypeObjs;
851+
$.ajax({
852+
url: createURL("listOsTypes"),
853+
dataType: "json",
854+
async: false,
855+
success: function(json) {
856+
var ostypeObjs = json.listostypesresponse.ostype;
857+
}
858+
});
859+
862860
if (ostypeObjs != undefined) {
863861
var ostypeName;
864862
for (var i = 0; i < ostypeObjs.length; i++) {
@@ -963,16 +961,16 @@
963961
label: 'label.os.type',
964962
isEditable: true,
965963
select: function(args) {
966-
if (ostypeObjs == undefined) {
967-
$.ajax({
968-
url: createURL("listOsTypes"),
969-
dataType: "json",
970-
async: false,
971-
success: function(json) {
972-
ostypeObjs = json.listostypesresponse.ostype;
973-
}
974-
});
975-
}
964+
var ostypeObjs;
965+
$.ajax({
966+
url: createURL("listOsTypes"),
967+
dataType: "json",
968+
async: false,
969+
success: function(json) {
970+
ostypeObjs = json.listostypesresponse.ostype;
971+
}
972+
});
973+
976974
var items = [];
977975
$(ostypeObjs).each(function() {
978976
items.push({
@@ -1231,16 +1229,16 @@
12311229
}
12321230

12331231
if ('templates' in args.context && args.context.templates[0].ostypeid != undefined) {
1234-
if (ostypeObjs == undefined) {
1235-
$.ajax({
1236-
url: createURL("listOsTypes"),
1237-
dataType: "json",
1238-
async: false,
1239-
success: function(json) {
1240-
ostypeObjs = json.listostypesresponse.ostype;
1241-
}
1242-
});
1243-
}
1232+
var ostypeObjs;
1233+
$.ajax({
1234+
url: createURL("listOsTypes"),
1235+
dataType: "json",
1236+
async: false,
1237+
success: function(json) {
1238+
ostypeObjs = json.listostypesresponse.ostype;
1239+
}
1240+
});
1241+
12441242
if (ostypeObjs != undefined) {
12451243
var ostypeName;
12461244
for (var i = 0; i < ostypeObjs.length; i++) {
@@ -1362,16 +1360,16 @@
13621360
label: 'label.os.type',
13631361
isEditable: true,
13641362
select: function(args) {
1365-
if (ostypeObjs == undefined) {
1366-
$.ajax({
1367-
url: createURL("listOsTypes"),
1368-
dataType: "json",
1369-
async: false,
1370-
success: function(json) {
1371-
ostypeObjs = json.listostypesresponse.ostype;
1372-
}
1373-
});
1374-
}
1363+
var ostypeObjs;
1364+
$.ajax({
1365+
url: createURL("listOsTypes"),
1366+
dataType: "json",
1367+
async: false,
1368+
success: function(json) {
1369+
ostypeObjs = json.listostypesresponse.ostype;
1370+
}
1371+
});
1372+
13751373
var items = [];
13761374
$(ostypeObjs).each(function() {
13771375
items.push({
@@ -1565,27 +1563,25 @@
15651563
required: true
15661564
},
15671565
select: function(args) {
1568-
if (ostypeObjs == undefined) {
1569-
$.ajax({
1570-
url: createURL("listOsTypes"),
1571-
dataType: "json",
1572-
async: false,
1573-
success: function(json) {
1574-
ostypeObjs = json.listostypesresponse.ostype;
1575-
}
1576-
});
1577-
}
1578-
var items = [];
1579-
//items.push({id: "", description: "None"}); //shouldn't have None option when bootable is checked
1580-
$(ostypeObjs).each(function() {
1581-
items.push({
1582-
id: this.id,
1583-
description: this.description
1584-
});
1585-
});
1586-
args.response.success({
1587-
data: items
1588-
});
1566+
$.ajax({
1567+
url: createURL("listOsTypes"),
1568+
dataType: "json",
1569+
async: true,
1570+
success: function(json) {
1571+
var ostypeObjs = json.listostypesresponse.ostype;
1572+
var items = [];
1573+
//items.push({id: "", description: "None"}); //shouldn't have None option when bootable is checked
1574+
$(ostypeObjs).each(function() {
1575+
items.push({
1576+
id: this.id,
1577+
description: this.description
1578+
});
1579+
});
1580+
args.response.success({
1581+
data: items
1582+
});
1583+
}
1584+
});
15891585
}
15901586
},
15911587

@@ -2286,16 +2282,16 @@
22862282
label: 'label.os.type',
22872283
isEditable: true,
22882284
select: function(args) {
2289-
if (ostypeObjs == undefined) {
2290-
$.ajax({
2291-
url: createURL("listOsTypes"),
2292-
dataType: "json",
2293-
async: false,
2294-
success: function(json) {
2295-
ostypeObjs = json.listostypesresponse.ostype;
2296-
}
2297-
});
2298-
}
2285+
var ostypeObjs;
2286+
$.ajax({
2287+
url: createURL("listOsTypes"),
2288+
dataType: "json",
2289+
async: false,
2290+
success: function(json) {
2291+
ostypeObjs = json.listostypesresponse.ostype;
2292+
}
2293+
});
2294+
22992295
var items = [];
23002296
$(ostypeObjs).each(function() {
23012297
items.push({

0 commit comments

Comments
 (0)