MCPcopy Index your code
hub / github.com/codecombat/codecombat / formatDocument

Method formatDocument

app/core/treema-ext.js:685–706  ·  view source on GitHub ↗
(docOrModel)

Source from the content-addressed store, hash-verified

683 modelToString (model) { return model.get('name') }
684
685 formatDocument (docOrModel) {
686 if (docOrModel instanceof CocoModel) { return this.modelToString(docOrModel) }
687 if (this.settings.supermodel == null) { return 'Unknown' }
688 let m = this.getReferencedModel(this.getData(), this.workingSchema)
689 const data = this.getData()
690 if (_.isString(data)) { // LatestVersionOriginalReferenceNode just uses original
691 if (m.schema().properties.version) {
692 m = this.settings.supermodel.getModelByOriginal(m.constructor, data)
693 } else {
694 // get by id
695 m = this.settings.supermodel.getModel(m.constructor, data)
696 }
697 } else {
698 m = this.settings.supermodel.getModelByOriginalAndMajorVersion(m.constructor, data.original, data.majorVersion)
699 }
700 if (this.instance && !m) {
701 m = this.instance
702 this.settings.supermodel.registerModel(m)
703 }
704 if (!m) { return 'Unknown - ' + (data.original != null ? data.original : data) }
705 return this.modelToString(m)
706 }
707
708 getReferencedModel (data, schema) {
709 if (schema.links == null) { return null }

Callers 3

buildValueForDisplayMethod · 0.95
buildValueForEditingMethod · 0.95
searchCallbackMethod · 0.95

Calls 3

modelToStringMethod · 0.95
getReferencedModelMethod · 0.95
schemaMethod · 0.80

Tested by

no test coverage detected