Browse Source

HUE-281 beeswax: table creation doesn't give error feedback

Improved error notification
Enrico Berti 13 years ago
parent
commit
f6db666785
1 changed files with 18 additions and 9 deletions
  1. 18 9
      apps/beeswax/src/beeswax/templates/create_table_manually.mako

+ 18 - 9
apps/beeswax/src/beeswax/templates/create_table_manually.mako

@@ -125,7 +125,7 @@ ${layout.menubar(section='tables')}
 	                ${comps.bootstrapLabel(table_form["field_terminator"])}
 	                ${comps.bootstrapLabel(table_form["field_terminator"])}
 	                <div class="controls">
 	                <div class="controls">
 	                    ${comps.field(table_form["field_terminator"], render_default=True)}
 	                    ${comps.field(table_form["field_terminator"], render_default=True)}
-	                    <span  class="help-inline error-inline hide">${_('This field is required. Spaces are not allowed.')}</span>
+	                    <span  class="help-inline error-inline hide">${_('This field is required. Spaces are not allowed. Terminator must be exactly one character.')}</span>
 	                    <span class="help-block">
 	                    <span class="help-block">
 	                        ${_('Enter the column delimiter.  Must be a single character.  Use syntax like "\001" or "\t" for special characters.')}
 	                        ${_('Enter the column delimiter.  Must be a single character.  Use syntax like "\001" or "\t" for special characters.')}
 	                    </span>
 	                    </span>
@@ -135,7 +135,7 @@ ${layout.menubar(section='tables')}
 	                ${comps.bootstrapLabel(table_form["collection_terminator"])}
 	                ${comps.bootstrapLabel(table_form["collection_terminator"])}
 	                <div class="controls">
 	                <div class="controls">
 	                    ${comps.field(table_form["collection_terminator"], render_default=True)}
 	                    ${comps.field(table_form["collection_terminator"], render_default=True)}
-	                    <span  class="help-inline error-inline hide">${_('This field is required. Spaces are not allowed.')}</span>
+	                    <span  class="help-inline error-inline hide">${_('This field is required. Spaces are not allowed. Terminator must be exactly one character.')}</span>
 	                    <span class="help-block">
 	                    <span class="help-block">
 	                        ${_('Use for array types.')}
 	                        ${_('Use for array types.')}
 	                    </span>
 	                    </span>
@@ -145,7 +145,7 @@ ${layout.menubar(section='tables')}
 	                ${comps.bootstrapLabel(table_form["map_key_terminator"])}
 	                ${comps.bootstrapLabel(table_form["map_key_terminator"])}
 	                <div class="controls">
 	                <div class="controls">
 	                    ${comps.field(table_form["map_key_terminator"], render_default=True)}
 	                    ${comps.field(table_form["map_key_terminator"], render_default=True)}
-	                    <span  class="help-inline error-inline hide">${_('This field is required. Spaces are not allowed.')}</span>
+	                    <span  class="help-inline error-inline hide">${_('This field is required. Spaces are not allowed. Terminator must be exactly one character.')}</span>
 	                    <span class="help-block">
 	                    <span class="help-block">
 	                        ${_('Use for map types.')}
 	                        ${_('Use for map types.')}
 	                    </span>
 	                    </span>
@@ -191,7 +191,7 @@ ${layout.menubar(section='tables')}
 	            ${_('Use')} <strong>InputFormat</strong> ${_('to choose a custom implementation.')}
 	            ${_('Use')} <strong>InputFormat</strong> ${_('to choose a custom implementation.')}
 	            <br/>
 	            <br/>
 	        </div>
 	        </div>
-	
+
 	        <div class="control-group">
 	        <div class="control-group">
 	            <label id="fileFormatRadio" class="control-label">${_('File format')}</label>
 	            <label id="fileFormatRadio" class="control-label">${_('File format')}</label>
 	            <div class="controls">
 	            <div class="controls">
@@ -251,7 +251,7 @@ ${layout.menubar(section='tables')}
 	                </span>
 	                </span>
 	            </div>
 	            </div>
 	        </div>
 	        </div>
-	
+
 	        <div id="location" class="control-group hide">
 	        <div id="location" class="control-group hide">
 	            ${comps.bootstrapLabel(table_form["external_location"])}
 	            ${comps.bootstrapLabel(table_form["external_location"])}
 	            <div class="controls">
 	            <div class="controls">
@@ -261,7 +261,6 @@ ${layout.menubar(section='tables')}
 	                file_chooser=True,
 	                file_chooser=True,
 	                show_errors=False
 	                show_errors=False
 	                )}
 	                )}
-	                <span class="help-inline"><a id="pathChooser" href="#" class="btn" data-filechooser-destination="table-external_location">${_('Choose File')}</a></span>
 	                <span class="help-block">
 	                <span class="help-block">
 	                ${_("Enter the path (on HDFS) to your table's data location")}
 	                ${_("Enter the path (on HDFS) to your table's data location")}
 	                </span>
 	                </span>
@@ -526,6 +525,16 @@ ${layout.menubar(section='tables')}
             }
             }
         });
         });
 
 
+        // fire the event on page load
+        $("#id_table-field_terminator_0").change();
+        $("#id_table-collection_terminator_0").change();
+        $("#id_table-map_key_terminator_0").change();
+
+        // show the first validation error if any
+        if ($(".errorlist").length > 0){
+            $(".step[href='#"+$(".errorlist").eq(0).closest(".stepDetails").attr("id")+"']").click();
+        }
+
         $("input[name='table-row_format']").change(function(){
         $("input[name='table-row_format']").change(function(){
             $(".stepDetailsInner").hide();
             $(".stepDetailsInner").hide();
             $("#step3"+$(this).val()).show();
             $("#step3"+$(this).val()).show();
@@ -600,7 +609,7 @@ ${layout.menubar(section='tables')}
             // step 3
             // step 3
             var step3Valid = true;
             var step3Valid = true;
             var fieldTerminatorFld = $("#id_table-field_terminator_1");
             var fieldTerminatorFld = $("#id_table-field_terminator_1");
-            if ($("#id_table-field_terminator_0").val() == "__other__" && !isValid($.trim(fieldTerminatorFld.val()))) {
+            if ($("#id_table-field_terminator_0").val() == "__other__" && (!isValid($.trim(fieldTerminatorFld.val())) || $.trim(fieldTerminatorFld.val()).length != 1)) {
                 showFieldError(fieldTerminatorFld);
                 showFieldError(fieldTerminatorFld);
                 step3Valid = false;
                 step3Valid = false;
             }
             }
@@ -609,7 +618,7 @@ ${layout.menubar(section='tables')}
             }
             }
 
 
             var collectionTerminatorFld = $("#id_table-collection_terminator_1");
             var collectionTerminatorFld = $("#id_table-collection_terminator_1");
-            if ($("#id_table-collection_terminator_0").val() == "__other__" && !isValid($.trim(collectionTerminatorFld.val()))) {
+            if ($("#id_table-collection_terminator_0").val() == "__other__" && (!isValid($.trim(collectionTerminatorFld.val())) || $.trim(collectionTerminatorFld.val()).length != 1)) {
                 showFieldError(collectionTerminatorFld);
                 showFieldError(collectionTerminatorFld);
                 step3Valid = false;
                 step3Valid = false;
             }
             }
@@ -618,7 +627,7 @@ ${layout.menubar(section='tables')}
             }
             }
 
 
             var mapKeyTerminatorFld = $("#id_table-map_key_terminator_1");
             var mapKeyTerminatorFld = $("#id_table-map_key_terminator_1");
-            if ($("#id_table-map_key_terminator_0").val() == "__other__" && !isValid($.trim(mapKeyTerminatorFld.val()))) {
+            if ($("#id_table-map_key_terminator_0").val() == "__other__" && (!isValid($.trim(mapKeyTerminatorFld.val())) || $.trim(mapKeyTerminatorFld.val()).length != 1)) {
                 showFieldError(mapKeyTerminatorFld);
                 showFieldError(mapKeyTerminatorFld);
                 step3Valid = false;
                 step3Valid = false;
             }
             }