diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 8ddcbed89e7..e49b94ff52c 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -365,9 +365,26 @@ }); var array2 = []; - array2.push("&ispublic=" + (args.data.ispublic=="on")); - array2.push("&isfeatured=" + (args.data.isfeatured=="on")); - array2.push("&isextractable=" + (args.data.isextractable=="on")); + + //array2.push("&ispublic=" + (args.data.ispublic=="on")); + if(args.data.ispublic == "on") + array2.push("&ispublic=true"); + else if(args.data.ispublic == "off") + array2.push("&ispublic=false"); + //if args.data.ispublic is undefined, do not pass ispublic to API call. + + if(args.data.isfeatured == "on") + array2.push("&isfeatured=true"); + else if(args.data.isfeatured == "off") + array2.push("&isfeatured=false"); + //if args.data.isfeatured is undefined, do not pass isfeatured to API call. + + if(args.data.isextractable == "on") + array2.push("&isextractable=true"); + else if(args.data.isextractable == "off") + array2.push("&isextractable=false"); + //if args.data.isextractable is undefined, do not pass isextractable to API call. + $.ajax({ url: createURL("updateTemplatePermissions&id=" + args.context.templates[0].id + "&zoneid=" + args.context.templates[0].zoneid + array2.join("")), dataType: "json", @@ -585,7 +602,12 @@ isextractable: { label: 'extractable', isBoolean: true, - isEditable: true, + isEditable: function() { + if(isAdmin()) + return true; + else + return false; + }, converter:cloudStack.converters.toBooleanText }, passwordenabled: { @@ -597,13 +619,28 @@ ispublic: { label: 'label.public', isBoolean: true, - isEditable: true, + isEditable: function() { + if(isAdmin()) { + return true; + } + else { + if (g_userPublicTemplateEnabled == "true") + return true; + else + return false; + } + }, converter:cloudStack.converters.toBooleanText }, isfeatured: { label: 'label.featured', isBoolean: true, - isEditable: true, + isEditable: function() { + if(isAdmin()) + return true; + else + return false; + }, converter:cloudStack.converters.toBooleanText }, crossZones: { diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 7968bc7a460..c7cc716ea75 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -185,7 +185,7 @@ $loading.remove(); } ); - + return true; }, error: function(args) { //args here is parsed errortext from API response @@ -310,7 +310,7 @@ )); else if ($input.is('input[type=checkbox]')) { var val = $input.is(':checked'); - + $value.data('detail-view-boolean-value', _s(val)); $value.html(_s(val) ? _l('label.yes') : _l('label.no')); } @@ -347,7 +347,7 @@ var $input = $(this); if ($input.is('[type=checkbox]')) { - data[$input.attr('name')] = $input.is(':checked') ? 'on' : null; + data[$input.attr('name')] = $input.is(':checked') ? 'on' : 'off'; } else { data[$input.attr('name')] = $input.val(); } @@ -702,8 +702,11 @@ $name.html(_l(value.label)); $value.html(_s(content)); - // Set up editable metadata - $value.data('detail-view-is-editable', value.isEditable); + // Set up editable metadata + if(typeof(value.isEditable) == 'function') + $value.data('detail-view-is-editable', value.isEditable()); + else //typeof(value.isEditable) == 'boolean' or 'undefined' + $value.data('detail-view-is-editable', value.isEditable); if (value.select) { value.selected = $value.html();