diff --git a/src/app/app.ts b/src/app/app.ts index 3ede6d53..e969588f 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -233,14 +233,24 @@ Promise.all([ if (id === version) return const newCollections = versionSchemas[id].getCollections() - RegistryFetcher(COLLECTIONS, id).then(() => { - SCHEMAS = versionSchemas[id].getSchemas(COLLECTIONS) - COLLECTIONS = newCollections + RegistryFetcher(newCollections, id).then(() => { + + const newSchemas = versionSchemas[id].getSchemas(newCollections) + + const fixModel = (model: any) => { + if (model.schema) { + models[model.id].schema = newSchemas.get(model.schema) + models[model.id].validate() + models[model.id].invalidate() + } else if (model.children) { + model.children.forEach(fixModel) + } + } + config.models.forEach(fixModel) treeVersionLabel.textContent = id version = id ga('set', 'dimension3', version); - updateModel() }) } diff --git a/src/app/hooks/renderHtml.ts b/src/app/hooks/renderHtml.ts index 82bca8c1..f9fdc343 100644 --- a/src/app/hooks/renderHtml.ts +++ b/src/app/hooks/renderHtml.ts @@ -35,10 +35,14 @@ export const renderHtml: Hook<[any, Mounter], [string, string, string]> = { choice({ choices, config, switchNode }, path, value, mounter) { const choice = switchNode.activeCase(path, true) - const pathWithContext = (config?.context) ? - new ModelPath(path.getModel(), new Path(path.getArray(), [config.context])) : path + const pathWithContext = (config?.context) ? new ModelPath(path.getModel(), new Path(path.getArray(), [config.context])) : path const pathWithChoiceContext = config?.choiceContext ? new Path([], [config.choiceContext]) : config?.context ? new Path([], [config.context]) : path + const [prefix, suffix, body] = choice.node.hook(this, pathWithContext, value, mounter) + if (choices.length === 1) { + return [prefix, suffix, body] + } + const inputId = mounter.register(el => { (el as HTMLSelectElement).value = choice.type el.addEventListener('change', () => { @@ -52,7 +56,6 @@ export const renderHtml: Hook<[any, Mounter], [string, string, string]> = { `).join('')} ` - const [prefix, suffix, body] = choice.node.hook(this, pathWithContext, value, mounter) return [prefix, inject + suffix, body] },