-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHIBUI-914 Fixed issues with summary page, fixed issues with bindings
- Loading branch information
Showing
34 changed files
with
434 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
ui/src/app/metadata/domain/component/summary-property.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<div class="mb-3" *ngIf="property"> | ||
<ng-container [ngSwitch]="property.type"> | ||
<ng-container *ngSwitchDefault> | ||
<ng-container *ngIf="property.name"> | ||
<strong class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</strong> | ||
<span class="d-block" role="definition">{{ property.value || property.value === false ? property.value : '-' }}</span> | ||
</ng-container> | ||
</ng-container> | ||
<ng-container *ngSwitchCase="'array'"> | ||
<ng-container *ngIf="property.name"> | ||
<strong class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</strong> | ||
</ng-container> | ||
<ng-container *ngIf="property.items.type === 'object'"> | ||
<p class="text-secondary" *ngIf="!property.value || !property.value.length">—</p> | ||
<table class="table table-sm table-bordered table-striped" *ngIf="property.value && property.value.length"> | ||
<thead> | ||
<tr class="table-secondary"> | ||
<th *ngFor="let prop of getKeys(property.items)"> | ||
<translate-i18n [key]="property.items.properties[prop].title"></translate-i18n> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let value of property.value"> | ||
<td *ngFor="let prop of getKeys(property.items)" | ||
[ngbPopover]="value[prop]" | ||
triggers="mouseenter:mouseleave" | ||
container="body" | ||
placement="top"> | ||
{{ value[prop] }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</ng-container> | ||
<ng-container *ngIf="property.items.type === 'string'"> | ||
<p class="text-secondary" *ngIf="!property.value || !property.value.length">—</p> | ||
<ul class="list-unstyled" *ngIf="property.value && property.value.length"> | ||
<li *ngFor="let item of property.value"> | ||
{{ item }} | ||
</li> | ||
</ul> | ||
</ng-container> | ||
</ng-container> | ||
<ng-container *ngSwitchCase="'object'"> | ||
<ng-container *ngIf="property.name"> | ||
<span class="text-primary d-block" role="term" [translate]="property.name">{{ property.name }}</span> | ||
</ng-container> | ||
<ng-container *ngIf="property.properties"> | ||
<summary-property *ngFor="let prop of property.properties" [property]="prop"></summary-property> | ||
</ng-container> | ||
</ng-container> | ||
</ng-container> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
113 changes: 113 additions & 0 deletions
113
ui/src/app/metadata/domain/component/wizard-summary.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { Component, Input, SimpleChanges, OnChanges, Output, EventEmitter } from '@angular/core'; | ||
|
||
import { Wizard, WizardStep } from '../../../wizard/model'; | ||
import { MetadataProvider, MetadataResolver } from '../../domain/model'; | ||
import { Property } from '../model/property'; | ||
import { getSplitSchema } from '../../../wizard/reducer'; | ||
|
||
interface Section { | ||
id: string; | ||
index: number; | ||
label: string; | ||
properties: Property[]; | ||
} | ||
|
||
export function getDefinition(path: string, definitions): any { | ||
let def = path.split('/').pop(); | ||
return definitions[def]; | ||
} | ||
|
||
export function getPropertyItemSchema(items: any, definitions: any): any { | ||
if (!items) { return null; } | ||
return items.$ref ? getDefinition(items.$ref, definitions) : items; | ||
} | ||
|
||
export function getStepProperty(property, model, definitions): Property { | ||
property = property.$ref ? getDefinition(property.$ref, definitions) : property; | ||
return { | ||
name: property.title, | ||
value: model, | ||
type: property.type, | ||
items: getPropertyItemSchema(property.items, definitions), | ||
properties: getStepProperties( | ||
property, | ||
model, | ||
definitions | ||
) | ||
}; | ||
} | ||
|
||
|
||
export function getStepProperties(schema: any, model: any, definitions: any = {}): Property[] { | ||
if (!schema || !schema.properties) { return []; } | ||
return Object | ||
.keys(schema.properties) | ||
.map(property => { | ||
return getStepProperty( | ||
schema.properties[property], | ||
model[property], | ||
definitions | ||
); | ||
}); | ||
} | ||
|
||
@Component({ | ||
selector: 'wizard-summary', | ||
templateUrl: './wizard-summary.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class WizardSummaryComponent implements OnChanges { | ||
@Input() summary: { definition: Wizard<MetadataProvider | MetadataResolver>, schema: { [id: string]: any }, model: any }; | ||
|
||
@Output() onPageSelect: EventEmitter<string> = new EventEmitter(); | ||
|
||
sections: Section[]; | ||
columns: Array<Section>[]; | ||
steps: WizardStep[]; | ||
|
||
constructor() {} | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
if (changes.summary && this.summary) { | ||
const schemas = this.summary.schema; | ||
const model = this.summary.model; | ||
const def = this.summary.definition; | ||
const steps = def.steps; | ||
|
||
this.sections = steps | ||
.filter(step => step.id !== 'summary') | ||
.map( | ||
(step: WizardStep) => { | ||
return ({ | ||
id: step.id, | ||
index: step.index, | ||
label: step.label, | ||
properties: getStepProperties( | ||
schemas[step.id] || getSplitSchema(schemas['summary'], step), | ||
def.formatter(model), | ||
schemas.definitions || schemas.hasOwnProperty('summary') ? schemas['summary'].definitions : {} | ||
) | ||
}); | ||
} | ||
); | ||
|
||
this.columns = this.sections.reduce((resultArray, item, index) => { | ||
const chunkIndex = Math.floor(index / Math.round(this.sections.length / 2)); | ||
|
||
if (!resultArray[chunkIndex]) { | ||
resultArray[chunkIndex] = []; | ||
} | ||
|
||
resultArray[chunkIndex].push(item); | ||
|
||
return resultArray; | ||
}, []); | ||
} | ||
} | ||
|
||
gotoPage(page: string = ''): void { | ||
this.onPageSelect.emit(page); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.