MCPcopy Create free account
hub / github.com/codecombat/codecombat / getChildSchema

Method getChildSchema

app/core/treema-ext.js:554–592  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

552 }
553
554 getChildSchema (key) {
555 // construct the child schema here
556
557 let prop
558 const i18nChildSchema = {
559 title: this.findLanguageName(key),
560 type: 'object',
561 properties: {},
562 }
563 if (!this.parent) { return i18nChildSchema }
564 if (this.workingSchema.props == null) {
565 console.warn('i18n props array is empty! Filling with all parent properties by default')
566 this.workingSchema.props = ((() => {
567 const result = []
568 for (prop in this.parent.schema.properties) {
569 const _ = this.parent.schema.properties[prop]
570 if (prop !== 'i18n') {
571 result.push(prop)
572 }
573 }
574 return result
575 })())
576 }
577
578 for (const i18nProperty of Array.from(this.workingSchema.props)) {
579 const parentSchemaProperties = this.parent.schema.properties != null ? this.parent.schema.properties : {}
580 for (const extraSchemas of [this.parent.schema.oneOf, this.parent.schema.anyOf]) {
581 for (const extraSchema of Array.from(extraSchemas != null ? extraSchemas : [])) {
582 const object = (extraSchema != null ? extraSchema.properties : undefined) != null ? (extraSchema != null ? extraSchema.properties : undefined) : {}
583 for (prop in object) {
584 const schema = object[prop]
585 if (parentSchemaProperties[prop] == null) { parentSchemaProperties[prop] = schema }
586 }
587 }
588 }
589 i18nChildSchema.properties[i18nProperty] = parentSchemaProperties[i18nProperty]
590 }
591 return i18nChildSchema
592 }
593 // this must be filled out in order for the i18n node to work
594
595 childPropertiesAvailable () {

Callers

nothing calls this directly

Calls 1

findLanguageNameMethod · 0.95

Tested by

no test coverage detected