You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2012/07/30 23:32:37 UTC

[1/2] git commit: CS-15726: Use custom validation for tagger widget

Updated Branches:
  refs/heads/master 36fc2bd9b -> 1fbf5952c


CS-15726: Use custom validation for tagger widget

Show a generic dialog box for tagger validation, instead of using
jQuery validate

--it conflicted with the detail view's edit fields and prevented
submission unless the key and value fields were filled out.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/6b47907f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/6b47907f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/6b47907f

Branch: refs/heads/master
Commit: 6b47907f3980efa899f606035245cde535454e1d
Parents: 36fc2bd
Author: Brian Federle <br...@citrix.com>
Authored: Mon Jul 30 14:29:47 2012 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Mon Jul 30 14:32:32 2012 -0700

----------------------------------------------------------------------
 ui/scripts/ui/widgets/tagger.js |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6b47907f/ui/scripts/ui/widgets/tagger.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/tagger.js b/ui/scripts/ui/widgets/tagger.js
index f671342..c616945 100644
--- a/ui/scripts/ui/widgets/tagger.js
+++ b/ui/scripts/ui/widgets/tagger.js
@@ -1,13 +1,26 @@
 (function($, cloudStack) {
+  var isFormValid = function($form) {
+    var key = $form.find('input[name=key]').val();
+    var value = $form.find('input[name=value]').val();
+
+    if (!key || !value) {
+      cloudStack.dialog.notice({ message: 'Please specify a tag key and value' });
+      
+      return false;
+    }
+
+    return true;
+  };
+  
   var elems = {
     inputArea: function(args) {
       var $form = $('<form>').addClass('tag-input');
       var $keyField = $('<div>').addClass('field key');
       var $keyLabel = $('<label>').attr('for', 'key').html('Key:');
-      var $key = $('<input>').addClass('key required').attr('name', 'key');
+      var $key = $('<input>').addClass('key').attr('name', 'key');
       var $valueField = $('<div>').addClass('field value');
       var $valueLabel = $('<label>').attr('for', 'value').html('Value:');
-      var $value = $('<input>').addClass('value required').attr('name', 'value');
+      var $value = $('<input>').addClass('value').attr('name', 'value');
       var $submit = $('<input>').attr('type', 'submit').val('Add');
 
       $keyField.append($keyLabel, $key);
@@ -22,7 +35,7 @@
       $form.submit(
         args.onSubmit ?
           function() {
-            if (!$form.valid()) return false;
+            if (!isFormValid($form)) return false;
             
             args.onSubmit({
               data: cloudStack.serializeForm($form),