CLOUDSTACK-7766: Field Validations Missing for Ingress and Egress Rules (cherry picked from commit 94b16b3bd5f8b3b7635f07e9304e461cd2dc2275) Signed-off-by: Rohit Yadav <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/227e7613 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/227e7613 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/227e7613 Branch: refs/heads/4.4 Commit: 227e76132d129318cdf1a519f038b02708b9bfd7 Parents: 5cce048 Author: Gabor Apati-Nagy <[email protected]> Authored: Tue Oct 28 19:06:14 2014 +0000 Committer: Rohit Yadav <[email protected]> Committed: Thu Dec 11 20:36:17 2014 +0530 ---------------------------------------------------------------------- ui/scripts/network.js | 34 +++++++++++++++++++++++++++------ ui/scripts/ui/widgets/multiEdit.js | 9 +++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/227e7613/ui/scripts/network.js ---------------------------------------------------------------------- diff --git a/ui/scripts/network.js b/ui/scripts/network.js index f6a8f3d..b69d43b 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -4721,11 +4721,19 @@ }, 'startport': { edit: true, - label: 'label.start.port' + label: 'label.start.port', + validation: { + number: true, + range: [0, 65535] + } }, 'endport': { edit: true, - label: 'label.end.port' + label: 'label.end.port', + validation: { + number: true, + range: [0, 65535] + } }, 'icmptype': { edit: true, @@ -4740,7 +4748,10 @@ 'cidr': { edit: true, label: 'label.cidr', - isHidden: true + isHidden: true, + validation: { + ipv4cidr: true + } }, 'accountname': { edit: true, @@ -4920,11 +4931,19 @@ }, 'startport': { edit: true, - label: 'label.start.port' + label: 'label.start.port', + validation: { + number: true, + range: [0, 65535] + } }, 'endport': { edit: true, - label: 'label.end.port' + label: 'label.end.port', + validation: { + number: true, + range: [0, 65535] + } }, 'icmptype': { edit: true, @@ -4939,7 +4958,10 @@ 'cidr': { edit: true, label: 'label.cidr', - isHidden: true + isHidden: true, + validation: { + ipv4cidr: true + } }, 'accountname': { edit: true, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/227e7613/ui/scripts/ui/widgets/multiEdit.js ---------------------------------------------------------------------- diff --git a/ui/scripts/ui/widgets/multiEdit.js b/ui/scripts/ui/widgets/multiEdit.js index 47e5f43..861dc03 100755 --- a/ui/scripts/ui/widgets/multiEdit.js +++ b/ui/scripts/ui/widgets/multiEdit.js @@ -992,6 +992,10 @@ .attr('disabled', field.isDisabled ? 'disabled' : false) .appendTo($td); + if (field.validation) { + $td.find('input').first().data("validation-settings", field.validation ); + } + if (field.isDisabled) $input.hide(); if (field.defaultValue) { $input.val(field.defaultValue); @@ -1243,6 +1247,11 @@ $multiForm.validate(); + var inputs = $multiForm.find('input'); + $.each(inputs, function() { + if ($(this).data && $(this).data('validation-settings')) + $(this).rules('add', $(this).data('validation-settings')); + }); return this; };
