From 16561769711253e813f21de645aa04d18b1eabe1 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 18 Jun 2012 13:25:23 -0700 Subject: [PATCH] =?UTF-8?q?CS-14854:=20cloudstack=203.0=20UI=20-=20(1)=20e?= =?UTF-8?q?xtend=20detailView=20widget=20to=20take=20in=20dynamic=20isEdit?= =?UTF-8?q?able=20value.=20(2)=20template=20page=20-=20edit=20template=20a?= =?UTF-8?q?ction=20-=20for=20regular=20user=20and=20domain=20admin:=20make?= =?UTF-8?q?=20Extractable=20field=20and=20Featured=20field=20non-editable.?= =?UTF-8?q?=20Do=20NOT=20send=20=E2=80=9Cisfeatured=E2=80=9D,=20=E2=80=9Ci?= =?UTF-8?q?sextractable=E2=80=9D=20to=20updateTemplatePermission=20API=20w?= =?UTF-8?q?hen=20they=20are=20non-editable.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/scripts/templates.js | 29 +++++++++++++++++++++++++---- ui/scripts/ui/widgets/detailView.js | 9 ++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 8ddcbed89e7..4c765538934 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -366,8 +366,19 @@ var array2 = []; array2.push("&ispublic=" + (args.data.ispublic=="on")); - array2.push("&isfeatured=" + (args.data.isfeatured=="on")); - array2.push("&isextractable=" + (args.data.isextractable=="on")); + + 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 +596,12 @@ isextractable: { label: 'extractable', isBoolean: true, - isEditable: true, + isEditable: function() { + if(isAdmin()) + return true; + else + return false; + }, converter:cloudStack.converters.toBooleanText }, passwordenabled: { @@ -603,7 +619,12 @@ 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 219a9369273..68520e08a23 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -345,7 +345,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(); } @@ -700,8 +700,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();