@@ -43,20 +43,22 @@ seamsApp.controller('navController', ['$scope', '$route', '$routeParams',
43
43
var html = $scope . $root . renderSchema ( $scope . $root . schema ) ;
44
44
$ ( '#schemacontent' ) . html ( html ) ;
45
45
var checked = 0 ;
46
- $ ( '.facet_checkbox' , '#schemacontent' ) . each ( function ( ) {
47
- $ ( this ) . change ( function ( ) {
48
- if ( $ ( this ) . is ( ":checked" ) ) {
49
- checked ++ ;
50
- }
51
- else {
52
- checked -- ;
53
- }
54
- $ ( '#importbutton' ) . attr ( 'disabled' , checked == 0 ) ;
55
- $ ( '#facetstatus' ) . css ( 'visibility' , checked == 0 ? 'visible' : 'hidden' ) ;
46
+ if ( ! $scope . $root . schemaError ) {
47
+ $ ( '.facet_checkbox' , '#schemacontent' ) . each ( function ( ) {
48
+ $ ( this ) . change ( function ( ) {
49
+ if ( $ ( this ) . is ( ":checked" ) ) {
50
+ checked ++ ;
51
+ }
52
+ else {
53
+ checked -- ;
54
+ }
55
+ $ ( '#importbutton' ) . attr ( 'disabled' , checked == 0 ) ;
56
+ $ ( '#facetstatus' ) . css ( 'visibility' , checked == 0 ? 'visible' : 'hidden' ) ;
57
+ } ) ;
56
58
} ) ;
57
- } ) ;
58
- $ ( '#importbutton' ) . attr ( 'disabled' , checked == 0 ) ;
59
- $ ( '#facetstatus' ) . css ( 'visibility' , checked == 0 ? 'visible' : 'hidden' ) ;
59
+ }
60
+ $ ( '#importbutton' ) . attr ( 'disabled' , checked == 0 || $scope . $root . schemaError ) ;
61
+ $ ( '#facetstatus' ) . css ( 'visibility' , ( checked == 0 || $scope . $root . schemaError ) ? 'visible' : 'hidden' ) ;
60
62
}
61
63
break ;
62
64
case 'search' :
@@ -291,15 +293,24 @@ seamsApp.controller('seamsController', ['$scope', '$route', '$routeParams', '$lo
291
293
// and whether its faceted or not, together with an example value from the
292
294
// uploaded file (x.data)
293
295
$scope . $root . renderSchema = function ( x ) {
296
+ $scope . $root . schemaError = false ;
294
297
var html = '<table class="table_basic">\n' ;
295
298
html += '<input type="hidden" name="upload_id" id="upload_id" value="' + x . upload_id + '"/>\n' ;
296
299
html += "<thead>\n" ;
297
300
html += " <th>name</th><th>type</th><th>facet</th><th>e.g</th>\n" ;
298
301
html += "</thead>\n"
299
302
for ( var i in x . fields ) {
300
- html += "<tr>" ;
301
303
var f = x . fields [ i ] ;
302
- html += "<td>" + f . name + "</td>\n" ;
304
+ if ( ! f . name ) {
305
+ f . hasError = true ;
306
+ $scope . $root . schemaError = true ;
307
+ html += "<tr class='error'>" ;
308
+ }
309
+ else {
310
+ html += "<tr>" ;
311
+ }
312
+ html += '<td class="' + ( f . name ? '' : 'error' ) + '">' ;
313
+ html += ( f . name || '✗ Missing field name' ) + '</td>\n' ;
303
314
html += "<td>" + $scope . $root . typeWidget ( f ) + "</td>\n" ;
304
315
html += "<td>" + $scope . $root . facetWidget ( f ) + "</td>\n" ;
305
316
for ( var j in x . data ) {
@@ -330,7 +341,8 @@ seamsApp.controller('seamsController', ['$scope', '$route', '$routeParams', '$lo
330
341
$scope . $root . typeWidget = function ( f ) {
331
342
var n = f . safename ;
332
343
var t = f . type ;
333
- var html = '<select name="' + n + '" class="input_select" onchange="datatypechange(\'' + n + '\')" data-original-name="' + f . name + '">\n' ;
344
+ var html = '<select name="' + n + '" class="input_select" onchange="datatypechange(\'' + n + '\')" data-original-name="' + f . name ;
345
+ html += ( f . hasError ) ? '" disabled="disabled">\n' : '">\n' ;
334
346
var opts = { "string" :"String" , "number" :"Number" , "boolean" :"Boolean" , "arrayofstrings" :"Array of Strings" } ;
335
347
for ( var i in opts ) {
336
348
html += '<option value="' + i + '"' ;
@@ -350,7 +362,7 @@ seamsApp.controller('seamsController', ['$scope', '$route', '$routeParams', '$lo
350
362
var t = f . type ;
351
363
var v = f . facet . toString ( ) ;
352
364
var html = '<input class="input_checkbox facet_checkbox" type="checkbox" value="true" name="' + n + '" id="' + n + '"' ;
353
- if ( t == "number" || t == "boolean" ) {
365
+ if ( t == "number" || t == "boolean" || f . hasError ) {
354
366
html += ' disabled="disabled"' ;
355
367
}
356
368
if ( v == "true" ) {
@@ -784,9 +796,13 @@ seamsApp.directive('previewSearchHtml', function(){
784
796
var datatypechange = function ( e ) {
785
797
var d = $ ( 'select[name=' + e + ']' ) ;
786
798
var v = d . val ( ) ;
787
- if ( v == "string" || v == "arrayofstrings" ) {
788
- $ ( 'input#' + e ) . prop ( "disabled" , false ) ;
799
+ var i = $ ( 'input#' + e ) ;
800
+ if ( v == "string" || v == "arrayofstrings" ) {
801
+ i . prop ( "disabled" , false ) ;
789
802
} else {
790
- $ ( 'input#' + e ) . prop ( "disabled" , true ) ;
803
+ if ( i . is ( ':checked' ) ) {
804
+ i . prop ( "checked" , false ) . trigger ( 'change' ) ;
805
+ }
806
+ i . prop ( "disabled" , true ) ;
791
807
}
792
808
}
0 commit comments