-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
50 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
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
101 changes: 101 additions & 0 deletions
101
packages/client/src/app/shared/json-schema/widgets/tabs/tabs.widget.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,101 @@ | ||
import { Component, OnInit, ChangeDetectorRef, Inject } from '@angular/core'; | ||
import { ControlWidget, SFSchemaEnum, SFSchema, SFUISchemaItem, SFComponent, SFSchemaEnumType, SFGridSchema, ObjectLayoutWidget, FormProperty } from '@delon/form'; | ||
import { getData } from './../../util'; | ||
// tslint:disable-next-line:import-blacklist | ||
import { of, Observable } from 'rxjs'; | ||
import { delay } from 'rxjs/operators'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
@Component({ | ||
selector: 'sf-tabs', | ||
template: | ||
` | ||
<nz-tabset (nzSelectChange)="queryChange([$event])"> | ||
<nz-tab *ngFor="let tab of tabs" [nzTitle]="titleTemplate"> | ||
<ng-template #titleTemplate> | ||
{{tab.title}} | ||
</ng-template> | ||
</nz-tab> | ||
</nz-tabset> | ||
<div> | ||
<div nz-row [nzGutter]="16"> | ||
<ng-container *ngIf="grid; else noGrid"> | ||
<nz-row [nzGutter]="grid.gutter"> | ||
<ng-container *ngFor="let i of props[currentIndex]"> | ||
<ng-container *ngIf="i.property.visible"> | ||
<nz-col | ||
[nzSpan]="i.grid.span" [nzOffset]="i.grid.offset" | ||
[nzXs]="i.grid.xs" [nzSm]="i.grid.sm" [nzMd]="i.grid.md" | ||
[nzLg]="i.grid.lg" [nzXl]="i.grid.xl" [nzXXl]="i.grid.xxl"> | ||
<sf-item [formProperty]="i.property" [fixed-label]="i.spanLabelFixed"></sf-item> | ||
</nz-col> | ||
</ng-container> | ||
</ng-container> | ||
</nz-row> | ||
</ng-container> | ||
<ng-template #noGrid> | ||
<ng-container *ngFor="let i of props[currentIndex]"> | ||
<ng-container *ngIf="i.property.visible"> | ||
<sf-item [formProperty]="i.property" [fixed-label]="i.spanLabelFixed"></sf-item> | ||
</ng-container> | ||
</ng-container> | ||
</ng-template> | ||
</div> | ||
</div> | ||
`, | ||
preserveWhitespaces: false, | ||
|
||
}) | ||
export class TabsWidgetComponent extends ObjectLayoutWidget implements OnInit { | ||
|
||
grid: SFGridSchema; | ||
tabs: any = []; | ||
static readonly KEY = 'tabs'; | ||
currentIndex = 0; | ||
props: any = {}; | ||
|
||
constructor( | ||
@Inject(ChangeDetectorRef) public readonly cd: ChangeDetectorRef, | ||
@Inject(SFComponent) public readonly sfComp: SFComponent, | ||
public client: HttpClient, | ||
) { | ||
super(cd, sfComp); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.grid = this.ui.grid; | ||
this.tabs = this.ui.tabs || []; | ||
this.tabs.forEach((tab, index) => { | ||
this.props[index] = this.props[index] || []; | ||
if (Array.isArray(tab.fields)) { | ||
tab.fields.forEach(element => { | ||
const item = this.getFormProperty(element); | ||
this.props[index].push(item); | ||
}); | ||
} | ||
}); | ||
|
||
} | ||
|
||
getFormProperty(key) { | ||
const property = this.formProperty.properties[key] as FormProperty; | ||
property.ui = property.ui || {}; | ||
|
||
// to fixed ui widget default set by parent. | ||
if (property.ui.widget === this.ui.widget) { | ||
property.ui.widget = property.type; | ||
} | ||
|
||
const item = { | ||
property: property, | ||
grid: property.ui.grid || this.grid || {}, | ||
spanLabelFixed: property.ui.spanLabelFixed, | ||
}; | ||
return item; | ||
} | ||
|
||
|
||
queryChange(list: any) { | ||
this.currentIndex = list[0].index; | ||
} | ||
} |
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