-
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-1267 Implemented configuration component
- Loading branch information
Showing
41 changed files
with
1,001 additions
and
988 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
51 changes: 51 additions & 0 deletions
51
ui/src/app/metadata/configuration/component/array-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,51 @@ | ||
<div> | ||
<ng-container *ngIf="property.items.type === 'object'"> | ||
<div class="p-2" role="term" [translate]="property.name">{{ property.name }}</div> | ||
<div class="p-2" *ngIf="property.value && property.value.length"> | ||
<div *ngFor="let value of property.value; let i = index;" class="mb-2 bg-lighter"> | ||
<div *ngFor="let prop of getKeys(property.items); let n = index;" | ||
class="d-flex p-2"> | ||
<div class="w-50"> | ||
<span [class.invisible]="n">{{ i + 1 }}. </span> | ||
<span [translate]="property.items.properties[prop].title">{{ property.items.properties[prop].title }}</span> | ||
</div> | ||
<div class="w-50" [ngbPopover]="value[prop]" triggers="mouseenter:mouseleave" container="body" placement="left"> | ||
{{ value[prop] }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</ng-container> | ||
<ng-container *ngIf="property.items.type === 'string'" [ngSwitch]="getItemType(property.items)"> | ||
<ng-container *ngSwitchCase="'datalist'"> | ||
<ng-template [ngTemplateOutlet]="listref"></ng-template> | ||
</ng-container> | ||
<ng-container *ngSwitchCase="'select'"> | ||
<ng-template [ngTemplateOutlet]="listref"></ng-template> | ||
</ng-container> | ||
<ng-container *ngSwitchDefault> | ||
<div *ngFor="let attr of attributeList$ | async" class="d-flex justify-content-between border-bottom border-light"> | ||
<span class="w-50 p-2" role="term" [translate]="attr.label">{{ attr.label }}</span> | ||
<div class="w-50 p-2"> | ||
<span *ngIf="property.value && property.value.indexOf(attr.key) > -1" translate="value.true"> | ||
true | ||
</span> | ||
<span *ngIf="!property.value || !(property.value.indexOf(attr.key) > -1)" translate="value.false"> | ||
false | ||
</span> | ||
</div> | ||
</div> | ||
</ng-container> | ||
</ng-container> | ||
</div> | ||
<ng-template #listref> | ||
<div class="d-flex border-bottom border-light"> | ||
<span class="w-50 p-2" role="term" [translate]="property.name">{{ property.name }}</span> | ||
<p class="text-secondary w-50 p-2" *ngIf="!property.value || !property.value.length">—</p> | ||
<ul class="list-unstyled w-50 py-2" *ngIf="property.value && property.value.length"> | ||
<li *ngFor="let item of property.value"> | ||
{{ item }} | ||
</li> | ||
</ul> | ||
</div> | ||
</ng-template> |
36 changes: 36 additions & 0 deletions
36
ui/src/app/metadata/configuration/component/array-property.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,36 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { Property } from '../../domain/model/property'; | ||
import { Observable, of } from 'rxjs'; | ||
import { AttributesService } from '../../domain/service/attributes.service'; | ||
import { ConfigurationPropertyComponent } from './configuration-property.component'; | ||
|
||
@Component({ | ||
selector: 'array-property', | ||
templateUrl: './array-property.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class ArrayPropertyComponent extends ConfigurationPropertyComponent { | ||
@Input() property: Property; | ||
|
||
constructor( | ||
private attrService: AttributesService | ||
) { | ||
super(); | ||
} | ||
|
||
getKeys(schema): string[] { | ||
return Object.keys(schema.properties); | ||
} | ||
|
||
get attributeList$(): Observable<{ key: string, label: string }[]> { | ||
if (this.property.widget && this.property.widget.hasOwnProperty('data')) { | ||
return of(this.property.widget.data); | ||
} | ||
if (this.property.widget && this.property.widget.hasOwnProperty('dataUrl')) { | ||
return this.attrService.query(this.property.widget.dataUrl); | ||
} | ||
return of([]); | ||
} | ||
} | ||
|
Empty file.
19 changes: 19 additions & 0 deletions
19
ui/src/app/metadata/configuration/component/configuration-property.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,19 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { Property } from '../../domain/model/property'; | ||
|
||
@Component({ | ||
selector: 'configuration-property', | ||
templateUrl: './configuration-property.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class ConfigurationPropertyComponent { | ||
@Input() property: Property; | ||
|
||
constructor() { } | ||
|
||
getItemType(items: Property): string { | ||
return items.widget ? items.widget.id : 'default'; | ||
} | ||
} | ||
|
33 changes: 23 additions & 10 deletions
33
ui/src/app/metadata/configuration/component/metadata-configuration.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 |
---|---|---|
@@ -1,10 +1,23 @@ | ||
<div class="row" *ngIf="configuration && configuration.columns"> | ||
<div class="col-xl-6 col-xs-12" *ngFor="let sections of configuration.columns"> | ||
<section class="px-3" *ngFor="let section of sections; let i = index;"> | ||
{{ i + 1 }}: {{ section.label }} | ||
<ng-container *ngFor="let prop of section.properties"> | ||
{{ prop | json }} | ||
</ng-container> | ||
</section> | ||
</div> | ||
</div> | ||
<div *ngIf="configuration" class="container"> | ||
<section class="px-3 mb-3" *ngFor="let section of configuration.sections; let i = index;"> | ||
<div class="config-group"> | ||
<div class="numbered-header d-flex justify-content-start bg-light align-items-center"> | ||
<h2 class="title h4 m-0 flex-grow-1"> | ||
<span class="d-inline-block px-2 py-1 mr-2 mb-0 h4 number border border-secondary bg-white rounded-lg"><span *ngIf="i + 1 < 10">0</span>{{ i + 1 }}</span> | ||
<span class="text">{{ section.label | translate }}</span> | ||
</h2> | ||
<div class="actions px-2"> | ||
<a class="edit-link change-view" [routerLink]="['../', 'edit', section.id]"> | ||
<i class="fa fa-edit"></i> | ||
Edit | ||
</a> | ||
</div> | ||
</div> | ||
<div class="d-flex border-bottom border-light border-2 p-2"> | ||
<strong class="w-50">Option</strong> | ||
<strong class="w-50">Value</strong> | ||
</div> | ||
<object-property class="d-block" *ngIf="section" [property]="section"></object-property> | ||
</div> | ||
</section> | ||
</div> |
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
7 changes: 7 additions & 0 deletions
7
ui/src/app/metadata/configuration/component/object-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,7 @@ | ||
<ng-container *ngFor="let prop of property.properties"> | ||
<ng-container [ngSwitch]="prop.type"> | ||
<primitive-property *ngSwitchDefault [property]="prop"></primitive-property> | ||
<array-property *ngSwitchCase="'array'" [property]="prop"></array-property> | ||
<object-property *ngSwitchCase="'object'" [property]="prop"></object-property> | ||
</ng-container> | ||
</ng-container> |
26 changes: 26 additions & 0 deletions
26
ui/src/app/metadata/configuration/component/object-property.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,26 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { Property } from '../../domain/model/property'; | ||
import { ConfigurationPropertyComponent } from './configuration-property.component'; | ||
|
||
@Component({ | ||
selector: 'object-property', | ||
templateUrl: './object-property.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class ObjectPropertyComponent extends ConfigurationPropertyComponent { | ||
@Input() property: Property; | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
getKeys(schema): string[] { | ||
return Object.keys(schema.properties); | ||
} | ||
|
||
getItemType(items: Property): string { | ||
return items.widget ? items.widget.id : 'default'; | ||
} | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
ui/src/app/metadata/configuration/component/primitive-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,5 @@ | ||
<div *ngIf="property.name" class="d-flex border-bottom border-light p-2"> | ||
<span class="w-50 d-block" role="term" [translate]="property.name">{{ property.name }}</span> | ||
<span class="w-50 d-block" | ||
role="definition">{{ property.value || property.value === false ? property.value : '-' }}</span> | ||
</div> |
15 changes: 15 additions & 0 deletions
15
ui/src/app/metadata/configuration/component/primitive-property.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,15 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { ConfigurationPropertyComponent } from './configuration-property.component'; | ||
|
||
@Component({ | ||
selector: 'primitive-property', | ||
templateUrl: './primitive-property.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class PrimitivePropertyComponent extends ConfigurationPropertyComponent { | ||
constructor() { | ||
super(); | ||
} | ||
} | ||
|
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
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.