mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-29 00:54:09 +03:00
Use dropdown instead of buttons for discriminator switch
This commit is contained in:
parent
4c450e56b5
commit
4f2e1a29e6
|
@ -29,10 +29,10 @@
|
|||
<div class="param-description" innerHtml="{{prop.description | marked}}"></div>
|
||||
<div class="discriminator-info" *ngIf="prop.isDiscriminator">
|
||||
<span>This field value determines the exact schema:</span>
|
||||
<ul>
|
||||
<li *ngFor="#derived of schema.derived"
|
||||
(click)="selectDerived(derived)" [ngClass]="{active: derived.active}"> {{derived.name}} </li>
|
||||
</ul>
|
||||
<dropdown (change)="selectDerived($event)">
|
||||
<option *ngFor="#derived of schema.derived; #i=index"
|
||||
[value]="i">{{derived.name}}</option>
|
||||
</dropdown>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
import {ElementRef} from 'angular2/core';
|
||||
|
||||
import {RedocComponent, BaseComponent, SchemaManager} from '../base';
|
||||
import {Tabs, Tab} from '../../common/components/Tabs/tabs';
|
||||
import {DropDown} from '../../common/components/DropDown/dropdown';
|
||||
import JsonPointer from '../../utils/JsonPointer';
|
||||
|
||||
@RedocComponent({
|
||||
selector: 'json-schema',
|
||||
templateUrl: './lib/components/JsonSchema/json-schema.html',
|
||||
styleUrls: ['./lib/components/JsonSchema/json-schema.css'],
|
||||
directives: [JsonSchema, Tabs, Tab],
|
||||
directives: [JsonSchema, DropDown],
|
||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor']
|
||||
})
|
||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
|
||||
|
@ -21,8 +21,9 @@ export default class JsonSchema extends BaseComponent {
|
|||
this.final = false;
|
||||
}
|
||||
|
||||
selectDerived(subClass) {
|
||||
if (subClass.active) return;
|
||||
selectDerived(subClassIdx) {
|
||||
let subClass = this.schema.derived[subClassIdx];
|
||||
if (!subClass || subClass.active) return;
|
||||
this.schema.derived.forEach((subSchema) => {
|
||||
subSchema.active = false;
|
||||
});
|
||||
|
@ -62,7 +63,7 @@ export default class JsonSchema extends BaseComponent {
|
|||
}
|
||||
|
||||
this.schema = schema;
|
||||
if (schema.derived.length) this.selectDerived(schema.derived[0]);
|
||||
this.selectDerived(0);
|
||||
}
|
||||
|
||||
prepareObjectPropertiesData(schema) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user