diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js new file mode 100644 index 00000000..992b8d91 --- /dev/null +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -0,0 +1,29 @@ +'use strict'; + +import {Component, View, EventEmitter, ElementRef} from 'angular2/core'; +import {CORE_DIRECTIVES} from 'angular2/common'; +import JsonSchema from './json-schema'; +import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; + +@Component({ + selector: 'json-schema-lazy', + inputs: ['pointer'] +}) +@View({ + template: '', + directives: [CORE_DIRECTIVES] +}) +export default class JsonSchemaLazy { + + constructor(elementRef, dcl) { + this.elementRef = elementRef; + this.dcl = dcl; + } + + load() { + this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { + compRef.instance.pointer = this.pointer; + }); + } +} +JsonSchemaLazy.parameters = [[ElementRef], [DynamicComponentLoader]]; diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html index aa9df574..f6ea37d9 100644 --- a/lib/components/ResponsesList/responses-list.html +++ b/lib/components/ResponsesList/responses-list.html @@ -1,6 +1,6 @@

Responses

+ [type]="response.type" [empty]="!response.schema" (open)="lazy.load()">
Headers @@ -14,6 +14,8 @@
Response schema
- - + + + diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.js index 31007576..5be00969 100644 --- a/lib/components/ResponsesList/responses-list.js +++ b/lib/components/ResponsesList/responses-list.js @@ -3,6 +3,7 @@ import {RedocComponent, BaseComponent} from '../base'; import JsonPointer from '../../utils/JsonPointer'; import JsonSchema from '../JsonSchema/json-schema'; +import JsonSchemaLazy from '../JsonSchema/json-schema-lazy'; import Zippy from '../../common/components/Zippy/zippy'; import {statusCodeType} from '../../utils/helpers'; @@ -14,7 +15,7 @@ function isNumeric(n) { selector: 'responses-list', templateUrl: './lib/components/ResponsesList/responses-list.html', styleUrls: ['./lib/components/ResponsesList/responses-list.css'], - directives: [JsonSchema, Zippy] + directives: [JsonSchema, Zippy, JsonSchemaLazy] }) export default class ResponsesList extends BaseComponent { constructor(schemaMgr) {