bug 13765

Properly sync returned sticky fields from the API with the UI form, by
dynamically generating createForm fields based on Lb sticky
capabilities object; this will keep the required and conditional
fields properly up to date with the API requirements.
This commit is contained in:
Brian Federle 2012-02-21 15:13:52 -08:00
parent ad8e13cf03
commit c36808d5d2
3 changed files with 41 additions and 15 deletions

View File

@ -1,7 +1,18 @@
#new labels (begin) **********************************************************************************************
label.sticky.tablesize=Table size
label.sticky.expire=Expires
label.sticky.cookie-name=Cookie name
label.sticky.mode=Mode
label.sticky.length=Length
label.sticky.holdtime=Hold time
label.sticky.request-learn=Request learn
label.sticky.prefix=Prefix
label.sticky.nocache=No cache
label.sticky.indirect=Indirect
label.sticky.postonly=Post only
label.sticky.domain=Domain
state.Allocating=Allocating
state.Migrating=Migrating
#new labels (end) ************************************************************************************************

View File

@ -1614,6 +1614,18 @@
<script language="javascript">
dictionary = {
'label.sticky.domain': '<fmt:message key="label.sticky.domain"/>',
'label.sticky.postonly': '<fmt:message key="label.sticky.postonly"/>',
'label.sticky.indirect': '<fmt:message key="label.sticky.indirect"/>',
'label.sticky.nocache': '<fmt:message key="label.sticky.nocache"/>',
'label.sticky.prefix': '<fmt:message key="label.sticky.prefix"/>',
'label.sticky.request-learn': '<fmt:message key="label.sticky.request-learn"/>',
'label.sticky.holdtime': '<fmt:message key="label.sticky.holdtime"/>',
'label.sticky.length': '<fmt:message key="label.sticky.length"/>',
'label.sticky.mode': '<fmt:message key="label.sticky.mode"/>',
'label.sticky.cookie-name': '<fmt:message key="label.sticky.cookie-name"/>',
'label.sticky.expire': '<fmt:message key="label.sticky.expire"/>',
'label.sticky.tablesize': '<fmt:message key="label.sticky.tablesize"/>',
'state.Migrating': '<fmt:message key="state.Migrating"/>',
'state.Allocating': '<fmt:message key="state.Allocating"/>',
'label.total.of.ip': '<fmt:message key="label.total.of.ip"/>',

View File

@ -19,21 +19,24 @@
)[0].value);
var baseFields = {
stickyName: { label: 'Sticky Name', validation: { required: true } },
name: { label: 'Name', validation: { required: true }, isHidden: true },
mode: { label: 'Mode', isHidden: true },
length: { label: 'Length', validation: { required: true }, isHidden: true },
holdtime: { label: 'Hold Time', validation: { required: true }, isHidden: true },
tablesize: { label: 'Table size', isHidden: true },
expire: { label: 'Expire', isHidden: true },
requestlearn: { label: 'Request-Learn', isBoolean: true, isHidden: true },
prefix: { label: 'Prefix', isBoolean: true, isHidden: true },
nocache: { label: 'No cache', isBoolean: true, isHidden: true },
indirect: { label: 'Indirect', isBoolean: true, isHidden: true },
postonly: { label: 'Is post-only', isBoolean: true, isHidden: true },
domain: { label: 'Domain', isBoolean: true, isHidden: true }
stickyName: { label: 'Sticky Name', validation: { required: true } }
};
$.map(
$.map(
stickinessCapabilities,
function(c) { return c.paramlist; }
),
function(p) {
baseFields[p.paramname] = {
label: _l('label.sticky.' + p.paramname),
isHidden: true,
isBoolean: p.isflag,
validation: { required: p.required }
};
}
);
var conditionalFields = {
methodname: {
label: 'Stickiness method',
@ -123,7 +126,7 @@
},
after: function(args) {
// Remove fields not applicable to sticky method
args.$form.find('.form-item:hidden').remove()
args.$form.find('.form-item:hidden').remove();
var data = cloudStack.serializeForm(args.$form);