Skip to content

Commit 19e34d0

Browse files
committed
Order property of schema is not taken into account #175
1 parent 178782e commit 19e34d0

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
<div
1+
<div *ngIf="!state.schema.order"
22
[ngStyle]="{display:'flex', 'flex-wrap': 'wrap', 'flex-direction': this.state.schema.layout === 'vertical' ? 'column':'row'}">
33
<div *ngFor="let s of states; let i = index">
44
<app-wrapper *ngIf="show(i)" [state]="s"></app-wrapper>
55
&nbsp;
66
</div>
7+
</div>
8+
<div *ngIf="state.schema.order"
9+
[ngStyle]="{display:'flex', 'flex-wrap': 'wrap', 'flex-direction': this.state.schema.layout === 'vertical' ? 'column':'row'}">
10+
<div *ngFor="let o of this.state.schema.order">
11+
<app-wrapper *ngIf="getState(o)" [state]="getState(o)!"></app-wrapper>
12+
<div
13+
[ngStyle]="{display:'flex', 'flex-wrap': 'wrap', 'flex-direction': this.state.schema.layout === 'vertical' ? 'row':'column'}">
14+
<div *ngFor="let oo of getArray(o)">
15+
<app-wrapper [state]="getState(oo)!"></app-wrapper>
16+
&nbsp;
17+
</div>
18+
</div>
19+
&nbsp;
20+
</div>
721
</div>

projects/dashjoin/json-schema-form/src/lib/object/object.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { FormGroup } from '@angular/forms';
32
import { BaseComponent } from '../base/base.component';
43
import { State } from '../state';
54

@@ -48,4 +47,17 @@ export class ObjectComponent extends BaseComponent implements OnInit {
4847
}
4948
return true
5049
}
50+
51+
getState(o: string | string[]): State | undefined {
52+
for (const state of this.states)
53+
if (state.name === o)
54+
return state
55+
return undefined
56+
}
57+
58+
getArray(o: string | string[]): string[] | undefined {
59+
if (Array.isArray(o))
60+
return o
61+
return undefined
62+
}
5163
}

src/app/app.component.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@
138138
Layout:
139139
</td>
140140
<td>
141-
<!--
142141
<button (click)="select('order')">order</button>
143-
-->
144142
<button (click)="select('tab')">tab</button>
145143
<button (click)="select('table')">table</button>
146144
<button (click)="select('vertical')">vertical</button>

0 commit comments

Comments
 (0)