@@ -411,7 +411,7 @@ let Importer = {
411
411
}
412
412
} ) ;
413
413
} ,
414
- formatImportTypeSelectorDialog : function ( file , mixedMappingConfig ) {
414
+ formatImportTypeSelectorDialog : ( file , mixedMappingConfig ) => {
415
415
416
416
let importType = $ ( 'input[name=import-type]:checked' ) . val ( ) ;
417
417
@@ -434,7 +434,9 @@ let Importer = {
434
434
435
435
let targetTypeSelector = $ ( '#target-type-select' ) ;
436
436
437
- Importer . updateSchemaTypeCache ( targetTypeSelector ) ;
437
+ Importer . updateSchemaTypeCache ( ) . then ( ignore => {
438
+ Importer . updateSchemaTypeSelector ( targetTypeSelector ) ;
439
+ } ) ;
438
440
439
441
targetTypeSelector . off ( 'change' ) . on ( 'change' , function ( e , data ) { Importer . updateMapping ( file , data ) ; } ) ;
440
442
$ ( ".import-option" ) . off ( 'change' ) . on ( 'change' , function ( e , data ) { Importer . updateMapping ( file , data ) ; } ) ;
@@ -458,35 +460,42 @@ let Importer = {
458
460
Importer . updateSchemaTypeSelector ( targetTypeSelector ) ;
459
461
460
462
} ,
461
- updateSchemaTypeCache : ( targetTypeSelector ) => {
463
+ updateSchemaTypeCache : async ( ) => {
462
464
463
- if ( ! Importer . schemaTypeCachePopulated ) {
465
+ return new Promise ( ( resolve ) => {
464
466
465
- _Helpers . getSchemaInformationPromise ( ) . then ( schemaData => {
467
+ if ( ! Importer . schemaTypeCachePopulated ) {
466
468
467
- Importer . clearSchemaTypeCache ( ) ;
469
+ _Helpers . getSchemaInformationPromise ( ) . then ( schemaData => {
468
470
469
- for ( let res of schemaData ) {
471
+ Importer . clearSchemaTypeCache ( ) ;
470
472
471
- if ( res . isServiceClass === false ) {
473
+ for ( let res of schemaData ) {
472
474
473
- if ( res . isRel ) {
475
+ if ( res . isServiceClass === false ) {
474
476
475
- Importer . schemaTypeCache [ 'relTypes' ] . push ( res ) ;
477
+ if ( res . isRel ) {
476
478
477
- } else {
479
+ Importer . schemaTypeCache [ 'relTypes' ] . push ( res ) ;
480
+
481
+ } else {
478
482
479
- Importer . schemaTypeCache [ 'graphTypes' ] . push ( res ) ;
480
- Importer . schemaTypeCache [ 'nodeTypes' ] . push ( res ) ;
483
+ Importer . schemaTypeCache [ 'graphTypes' ] . push ( res ) ;
484
+ Importer . schemaTypeCache [ 'nodeTypes' ] . push ( res ) ;
485
+ }
481
486
}
482
487
}
483
- }
484
488
485
- Importer . updateSchemaTypeSelector ( targetTypeSelector ) ;
489
+ Importer . schemaTypeCachePopulated = true ;
486
490
487
- Importer . schemaTypeCachePopulated = true ;
488
- } ) ;
489
- }
491
+ resolve ( 'success' ) ;
492
+ } ) ;
493
+
494
+ } else {
495
+
496
+ resolve ( 'success_from_cache' ) ;
497
+ }
498
+ } ) ;
490
499
} ,
491
500
updateSchemaTypeSelector : ( typeSelect ) => {
492
501
@@ -1031,19 +1040,6 @@ let Importer = {
1031
1040
let propertySelector = $ ( '#property-select' ) ;
1032
1041
let typeConfig = configuration [ path ] ;
1033
1042
1034
- fetch ( Structr . rootUrl + 'SchemaNode?' + Structr . getRequestParameterName ( 'sort' ) + '=name' ) . then ( response => response . json ( ) ) . then ( data => {
1035
-
1036
- if ( data && data . result ) {
1037
-
1038
- typeSelector . append ( data . result . map ( r => `<option value="${ r . name } ">${ r . name } </option>` ) . join ( '' ) ) ;
1039
-
1040
- // trigger select event when an element is already configured
1041
- if ( typeConfig && typeConfig . type ) {
1042
- typeSelector . val ( typeConfig . type ) . trigger ( 'change' ) ;
1043
- }
1044
- }
1045
- } ) ;
1046
-
1047
1043
typeSelector . on ( 'change' , function ( e ) {
1048
1044
1049
1045
let type = $ ( this ) . val ( ) ;
@@ -1190,6 +1186,16 @@ let Importer = {
1190
1186
} ) ;
1191
1187
1192
1188
} ) ;
1189
+
1190
+ Importer . updateSchemaTypeCache ( ) . then ( ignore => {
1191
+
1192
+ typeSelector . append ( Importer . schemaTypeCache . nodeTypes . map ( n => `<option value="${ n . name } ">${ n . name } </option>` ) . sort ( ) . join ( '' ) ) ;
1193
+
1194
+ // trigger select event when an element is already configured
1195
+ if ( typeConfig && typeConfig . type ) {
1196
+ typeSelector . val ( typeConfig . type ) . trigger ( 'change' ) ;
1197
+ }
1198
+ } ) ;
1193
1199
} ,
1194
1200
showSetPropertyOptions : ( el , key , path , structure , configuration , attributes ) => {
1195
1201
@@ -1324,7 +1330,9 @@ let Importer = {
1324
1330
customOnlyCheckbox . prop ( 'checked' , true ) ;
1325
1331
}
1326
1332
1327
- Importer . updateSchemaTypeCache ( targetTypeSelector ) ;
1333
+ Importer . updateSchemaTypeCache ( ) . then ( ignore => {
1334
+ Importer . updateSchemaTypeSelector ( targetTypeSelector ) ;
1335
+ } ) ;
1328
1336
1329
1337
$ ( '#types-container' ) . empty ( ) ;
1330
1338
$ ( '#start-import' ) . off ( 'click' ) ;
0 commit comments