-Fix args.context for zone host details panel

-Fix list view edit action
-Support range input for create form
This commit is contained in:
Brian Federle 2011-11-21 14:22:35 -08:00
parent c9b2031fa9
commit cfcda326e5
5 changed files with 92 additions and 33 deletions

View File

@ -2681,6 +2681,30 @@ Dialogs*/
float: left;
}
.ui-dialog div.form-container div.value .range-edit {
width: 249px;
height: 33px;
margin: 2px 0 0;
}
.ui-dialog div.form-container div.value .range-edit .range-item {
width: 124px;
height: 32px;
position: relative;
float: left;
}
.ui-dialog div.form-container div.value .range-edit input {
width: 105px;
margin: 0 9px 0 0;
}
.ui-dialog div.form-container div.value .range-edit label.error {
position: absolute;
left: 3px;
top: 25px;
}
.ui-dialog div.form-container div.value select {
width: 100%;
float: right;

View File

@ -138,7 +138,11 @@
edit: {
label: 'Edit instance name',
action: function(args) {
args.response.success(args.data[0]);
if ((args.data.name) == '') {
args.response.error({ message: 'Instance name cannot be blank.' });
} else {
args.response.success();
}
}
},
@ -369,7 +373,7 @@
}
},
resetPassword: {
label: 'Reset password',
label: 'Reset password',
action: function(args) {
args.response.success({});
},
@ -384,7 +388,7 @@
return 'VM password reset. New password is: ' + args.password;
}
},
notification: {
notification: {
poll: testData.notifications.customPoll({
password: '1284018jaj#'
})

View File

@ -186,12 +186,9 @@
label: 'Netmask',
validation: { required: true }
},
startip: {
label: 'Start IP',
validation: { required: true }
},
endip: {
label: 'Start IP',
ipRange: {
label: 'IP Range',
range: ['startip', 'endip'],
validation: { required: true }
}
}

View File

@ -193,13 +193,34 @@
}
});
} else {
$input = $('<input>').attr({
name: key,
type: this.password || this.isPassword ? 'password' : 'text'
}).appendTo($value);
// Text field
if (this.range) {
$input = $.merge(
// Range start
$('<input>').attr({
type: 'text',
name: this.range[0]
}),
if (this.defaultValue) {
$input.val(this.defaultValue);
// Range end
$('<input>').attr({
type: 'text',
name: this.range[1]
})
).appendTo(
$('<div>').addClass('range-edit').appendTo($value)
);
$input.wrap($('<div>').addClass('range-item'));
} else {
$input = $('<input>').attr({
name: key,
type: this.password || this.isPassword ? 'password' : 'text'
}).appendTo($value);
if (this.defaultValue) {
$input.val(this.defaultValue);
}
}
}

View File

@ -312,9 +312,11 @@
};
// Hide edit field, validate and save changes
var showLabel = function(val) {
var showLabel = function(val, options) {
if (!options) options = {};
var oldVal = $label.html();
if (val) $label.html(val);
$label.html(val);
var data = {
id: $instanceRow.data('list-view-item-id'),
@ -336,6 +338,8 @@
$edit.hide();
$label.fadeIn();
$instanceRow.closest('div.data-table').dataTable('refresh');
if (options.success) options.success(args);
},
error: function(args) {
if (args.message) {
@ -343,6 +347,8 @@
$edit.hide(),
$label.html(oldVal).fadeIn();
$instanceRow.closest('div.data-table').dataTable('refresh');
if (options.error) options.error(args);
}
}
}
@ -354,24 +360,28 @@
return false;
}
if ($label.is(':visible')) {
if (!$editInput.is(':visible')) {
showEditField();
} else if ($editInput.val() != $label.html()) {
$edit.animate({ opacity: 0.5 });
var originalName = $label.html();
var newName = $editInput.val();
addNotification(
{
section: $instanceRow.closest('div.view').data('view-args').id,
desc: 'Renamed ' + originalName + ' to ' + newName
},
function(data) {
showLabel(newName);
},
[{ name: newName }]
);
showLabel(newName, {
success: function() {
addNotification(
{
section: $instanceRow.closest('div.view').data('view-args').id,
desc: newName ? 'Set value of ' + $instanceRow.find('td.name span').html() + ' to ' + newName :
'Unset value for ' + $instanceRow.find('td.name span').html()
},
function(args) {
},
[{ name: newName }]
);
}
});
} else {
showLabel();
}
@ -1017,10 +1027,8 @@
};
// Populate context object w/ instance data
detailViewArgs.context[
$listView.data('view-args').activeSection
] = [jsonObj];
var listViewActiveSection = $listView.data('view-args').activeSection;
// Create custom-generated detail view
if (listViewData.detailView.pageGenerator) {
detailViewArgs.pageGenerator = listViewData.detailView.pageGenerator;
@ -1032,6 +1040,11 @@
else
detailViewArgs.section = listViewArgs.activeSection ? listViewArgs.activeSection : listViewArgs.id;
detailViewArgs.context[
listViewActiveSection != '_zone' ?
listViewActiveSection : detailViewArgs.section
] = [jsonObj];
createDetailView(detailViewArgs, function($detailView) {
$detailView.data('list-view', $listView);
});