You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2012/06/21 22:43:37 UTC
git commit: CS-14854: cloudstack 3.0 UI - (1) extend detailView
widget to take in dynamic isEditable value. (2) template page - edit template
action - for regular user and domain admin: make Extractable field and
Featured field non-editable. Do NOT send
Updated Branches:
refs/heads/master 79410f90b -> aac1ac555
CS-14854: cloudstack 3.0 UI - (1) extend detailView widget to take in dynamic isEditable value. (2) template page - edit template action - for regular user and domain admin: make Extractable field and Featured field non-editable. Do NOT send “isfeatured”, “isextractable” to updateTemplatePermission API when they are non-editable.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/aac1ac55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/aac1ac55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/aac1ac55
Branch: refs/heads/master
Commit: aac1ac555d8fa3d4a4c3626af0d09b572034de1a
Parents: 79410f9
Author: Jessica Wang <je...@citrix.com>
Authored: Thu Jun 21 13:43:04 2012 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Thu Jun 21 13:43:04 2012 -0700
----------------------------------------------------------------------
ui/scripts/templates.js | 49 ++++++++++++++++++++++++++----
ui/scripts/ui/widgets/detailView.js | 13 +++++---
2 files changed, 51 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/aac1ac55/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index 8ddcbed..e49b94f 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: {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/aac1ac55/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index 7968bc7..c7cc716 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();