@@ -52,7 +52,13 @@ import {
52
52
ErrorsService
53
53
} from './shared/services' ;
54
54
55
- import { JsonEditorConfig , Preview , SchemaValidationErrors , JsonPatch , Shortcut , CustomShortcutKeys } from './shared/interfaces' ;
55
+ import { JsonEditorConfig ,
56
+ Preview ,
57
+ SchemaValidationErrors ,
58
+ JsonPatch ,
59
+ Shortcut ,
60
+ CustomShortcutKeys ,
61
+ JSONSchema } from './shared/interfaces' ;
56
62
57
63
58
64
@Component ( {
@@ -69,6 +75,7 @@ export class JsonEditorComponent extends AbstractTrackerComponent implements OnC
69
75
70
76
@Input ( ) config : JsonEditorConfig ;
71
77
@Input ( ) record : object ;
78
+ // original schema
72
79
@Input ( ) schema : any ;
73
80
@Input ( ) errorMap : SchemaValidationErrors ;
74
81
@Input ( ) jsonPatches : Array < JsonPatch > ;
@@ -84,6 +91,8 @@ export class JsonEditorComponent extends AbstractTrackerComponent implements OnC
84
91
isBottomConsoleOpen = false ;
85
92
bottomConsoleActiveTab = '' ;
86
93
customShortcutKeys : CustomShortcutKeys ;
94
+ // altered schema enchanced with configs
95
+ fixedSchema : JSONSchema ;
87
96
88
97
// used to decide if the [record] is change caused by recordChange.emit or parent component
89
98
private lastEmittedRecord : object ;
@@ -103,7 +112,7 @@ export class JsonEditorComponent extends AbstractTrackerComponent implements OnC
103
112
104
113
ngOnInit ( ) {
105
114
this . appGlobalsService . adminMode$ . subscribe ( adminMode => {
106
- this . keysStoreService . buildKeysMap ( this . _record , this . schema ) ;
115
+ this . keysStoreService . buildKeysMap ( this . _record , this . fixedSchema ) ;
107
116
} ) ;
108
117
109
118
// listen for all changes on json
@@ -146,15 +155,15 @@ export class JsonEditorComponent extends AbstractTrackerComponent implements OnC
146
155
const schemaChanged = changes [ 'schema' ] || changes [ 'config' ] ;
147
156
148
157
if ( schemaChanged ) {
149
- this . schema = this . schemaFixerService . fixSchema ( this . schema , this . config . schemaOptions ) ;
150
- this . jsonSchemaService . setSchema ( this . schema ) ;
158
+ this . fixedSchema = this . schemaFixerService . fixSchema ( this . schema , this . config . schemaOptions ) ;
159
+ this . jsonSchemaService . setSchema ( this . fixedSchema ) ;
151
160
}
152
161
153
162
if ( schemaChanged || recordChanged ) {
154
- this . record = this . recordFixerService . fixRecord ( this . record , this . schema ) ;
163
+ this . record = this . recordFixerService . fixRecord ( this . record , this . fixedSchema ) ;
155
164
this . _record = fromJS ( this . record ) ;
156
165
this . jsonStoreService . setJson ( this . _record ) ;
157
- this . keysStoreService . buildKeysMap ( this . _record , this . schema ) ;
166
+ this . keysStoreService . buildKeysMap ( this . _record , this . fixedSchema ) ;
158
167
}
159
168
160
169
0 commit comments