Actually change version schema

This commit is contained in:
Misode
2020-11-09 13:03:50 +01:00
parent 8d2bf43764
commit cbf6e7e4cf
2 changed files with 20 additions and 7 deletions

View File

@@ -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()
})
}

View File

@@ -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]> = {
</option>`).join('')}
</select>`
const [prefix, suffix, body] = choice.node.hook(this, pathWithContext, value, mounter)
return [prefix, inject + suffix, body]
},