mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-30 23:37:28 +03:00 
			
		
		
		
	Auto expand schema with one element
This commit is contained in:
		
							parent
							
								
									ed2a5b46e1
								
							
						
					
					
						commit
						7618507cda
					
				|  | @ -42,6 +42,7 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit { | |||
|       this.initComponent(compRef.instance); | ||||
|       this._renderer.setElementAttribute(compRef.location.nativeElement, 'class', this.location.element.nativeElement.className); | ||||
|       compRef.changeDetectorRef.detectChanges(); | ||||
|       this.loaded = true; | ||||
|       return compRef; | ||||
|     }).catch(err => { | ||||
|       console.log(err); | ||||
|  | @ -55,7 +56,6 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit { | |||
|     if (this.pointer) { | ||||
|       this._loadAfterSelf(); | ||||
|     } | ||||
|     this.loaded = true; | ||||
|   } | ||||
| 
 | ||||
|   // cache JsonSchema view
 | ||||
|  | @ -73,7 +73,8 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit { | |||
|             return; | ||||
|           } | ||||
|           insertAfter($element.cloneNode(true), this.elementRef.nativeElement); | ||||
|         } ); | ||||
|           this.loaded = true; | ||||
|         }); | ||||
|       }); | ||||
|     } else { | ||||
|       cache[this.pointer] = this._loadAfterSelf(); | ||||
|  |  | |||
|  | @ -62,8 +62,8 @@ | |||
|     </tr> | ||||
|     <tr class="param-schema" [ngClass]="{'param-array': prop._isArray, 'last': last}" [hidden]="!prop._pointer"> | ||||
|       <td colspan="2"> | ||||
|         <zippy #subSchema title="test" [headless]="true" (open)="lazySchema.load()"> | ||||
|           <json-schema-lazy #lazySchema class="nested-schema" [pointer]="prop._pointer" [isArray]='prop._isArray' | ||||
|         <zippy #subSchema title="Expand" [headless]="true" (open)="lazySchema.load()" [visible]="autoExpand"> | ||||
|           <json-schema-lazy #lazySchema [auto]="autoExpand" class="nested-schema" [pointer]="prop._pointer" [isArray]='prop._isArray' | ||||
|           [nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> | ||||
|           </json-schema-lazy> | ||||
|         </zippy> | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ export class JsonSchema extends BaseComponent { | |||
|   @Input() childFor: string; | ||||
|   @Input() isRequestSchema: boolean; | ||||
|   normalizer: SchemaNormalizer; | ||||
|   autoExpand = false; | ||||
| 
 | ||||
|   constructor(specMgr:SpecManager, private _renderer: Renderer, private _elementRef: ElementRef) { | ||||
|     super(specMgr); | ||||
|  | @ -100,6 +101,8 @@ export class JsonSchema extends BaseComponent { | |||
|         } | ||||
|         return (propSchema && propSchema.type === 'object' && propSchema._pointer); | ||||
|       }); | ||||
| 
 | ||||
|     this.autoExpand = this.properties && this.properties.length === 1; | ||||
|   } | ||||
| 
 | ||||
|   trackByIdx(index: number, item: any): number { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user