Module: nagvis Branch: master Commit: 9f7d27709dc4f4f2683f5b917a065ef9258c36c7 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=9f7d27709dc4f4f2683f5b917a065ef9258c36c7
Author: Roman Kyrylych <[email protected]> Date: Tue Aug 25 11:53:42 2009 +0300 gmap: Added basic client-side validation for link/location adding/editing Signed-off-by: Roman Kyrylych <[email protected]> --- uifx/src/modules/gmap/view/DialogLink.mxml | 18 +++++++++++++++--- uifx/src/modules/gmap/view/DialogLocation.mxml | 22 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/uifx/src/modules/gmap/view/DialogLink.mxml b/uifx/src/modules/gmap/view/DialogLink.mxml index 4a2e596..ecec9f8 100644 --- a/uifx/src/modules/gmap/view/DialogLink.mxml +++ b/uifx/src/modules/gmap/view/DialogLink.mxml @@ -49,7 +49,7 @@ public var hostgroups : ArrayCollection; public var services : ArrayCollection; public var servicegroups : ArrayCollection; - + [Bindable] public var locations : ArrayCollection; private var _link : Link; @@ -200,14 +200,26 @@ lnkLocation2.selectedItem = location; } + private function validate() : Boolean + { + if (lnkLocation1.selectedItem == lnkLocation2.selectedItem) + { + Alert.show("You cannot create a link between the same location"); + return false; + } + + return true; + } + private function onAddClicked() : void { - dispatchEvent(new LinkEvent(LinkEvent.ADD, getUpdatedLink())); + if (validate()) + dispatchEvent(new LinkEvent(LinkEvent.ADD, getUpdatedLink())); } private function onSaveClicked() : void { - if (_link && _link.id && _link.id.length > 0) + if (_link && _link.id && _link.id.length > 0 && validate()) { dispatchEvent(new LinkEvent(LinkEvent.SAVE, getUpdatedLink())); } diff --git a/uifx/src/modules/gmap/view/DialogLocation.mxml b/uifx/src/modules/gmap/view/DialogLocation.mxml index 29b8b55..39464fc 100644 --- a/uifx/src/modules/gmap/view/DialogLocation.mxml +++ b/uifx/src/modules/gmap/view/DialogLocation.mxml @@ -188,14 +188,32 @@ return ul; } + private function validate() : Boolean + { + if (locName.text == "") + { + Alert.show("Please enter a label for the location"); + return false; + } + + if (locLat.text == "" || locLng.text == "") + { + Alert.show("Please specify coordinates for the location"); + return false; + } + + return true; + } + private function onAddClicked() : void { - dispatchEvent(new LocationEvent(LocationEvent.ADD, getUpdatedLocation())); + if (validate()) + dispatchEvent(new LocationEvent(LocationEvent.ADD, getUpdatedLocation())); } private function onSaveClicked():void { - if (_location && _location.id && _location.id.length > 0) + if (_location && _location.id && _location.id.length > 0 && validate()) { dispatchEvent(new LocationEvent(LocationEvent.SAVE, getUpdatedLocation())); } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
