This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow asynchronous List View Grid headings (#1436)
- Loading branch information
1 parent
76c5998
commit f4d21a6
Showing
16 changed files
with
514 additions
and
313 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
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,24 +1,27 @@ | ||
import { Component } from '@angular/core'; | ||
import { | ||
Component, | ||
OnInit | ||
} from '@angular/core'; | ||
|
||
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | ||
|
||
@Component({ | ||
selector: 'sky-test-cmp', | ||
templateUrl: './grid-async.component.fixture.html' | ||
}) | ||
export class GridAsyncTestComponent { | ||
export class GridAsyncTestComponent implements OnInit { | ||
public items: Array<any> = [ | ||
{ 'id': 1, 'name': 'Windstorm', 'email': '[email protected]' }, | ||
{ 'id': 2, 'name': 'Bombasto', 'email': '[email protected]' }, | ||
{ 'id': 3, 'name': 'Magneta', 'email': '[email protected]' }, | ||
{ 'id': 4, 'name': 'Tornado', 'email': '[email protected]' } | ||
]; | ||
|
||
public asyncHeading = new BehaviorSubject<string>(undefined); | ||
public asyncHeading = new BehaviorSubject<string>(''); | ||
|
||
constructor() { | ||
public ngOnInit() { | ||
setTimeout(() => { | ||
this.asyncHeading.next('updated'); | ||
this.asyncHeading.next('Column1'); | ||
}, 100); | ||
} | ||
} |
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,67 +1,103 @@ | ||
import { | ||
Component, ViewChild, TemplateRef, ContentChildren, QueryList, ViewChildren | ||
Component, | ||
ViewChild, | ||
TemplateRef, | ||
ContentChildren, | ||
QueryList, | ||
ViewChildren | ||
} from '@angular/core'; | ||
|
||
import { SkyGridComponent } from '../grid.component'; | ||
|
||
import { | ||
ListItemModel, | ||
ListSortFieldSelectorModel | ||
} from '../../list/state'; | ||
|
||
let moment = require('moment'); | ||
const moment = require('moment'); | ||
|
||
@Component({ | ||
selector: 'sky-test-cmp', | ||
template: require('./grid.component.fixture.html') | ||
}) | ||
export class GridTestComponent { | ||
public hasToolbar: boolean = false; | ||
@ViewChild(SkyGridComponent) | ||
public grid: SkyGridComponent; | ||
|
||
@ContentChildren(TemplateRef) | ||
public templates: QueryList<TemplateRef<any>>; | ||
|
||
@ViewChildren(TemplateRef) | ||
public viewtemplates: QueryList<TemplateRef<any>>; | ||
|
||
public hasToolbar = false; | ||
public searchedData: any; | ||
public searchText: string; | ||
public activeSortSelector: ListSortFieldSelectorModel; | ||
public sortField: ListSortFieldSelectorModel; | ||
|
||
public selectedColumnIds: Array<string> = [ | ||
public selectedColumnIds: string[] = [ | ||
'column1', | ||
'column2', | ||
'column3', | ||
'column4', | ||
'column5' | ||
]; | ||
public data: any[] = [ | ||
new ListItemModel('1', { column1: '1', column2: 'Apple', | ||
column3: 1, column4: moment().add(1, 'minute') }), | ||
new ListItemModel('2', { column1: '01', column2: 'Banana', | ||
column3: 1, column4: moment().add(6, 'minute'), column5: 'test' }), | ||
new ListItemModel('3', { column1: '11', column2: 'Carrot', | ||
column3: 11, column4: moment().add(4, 'minute') }), | ||
new ListItemModel('4', { column1: '12', column2: 'Daikon', | ||
column3: 12, column4: moment().add(2, 'minute') }), | ||
new ListItemModel('5', { column1: '13', column2: 'Edamame', | ||
column3: 13, column4: moment().add(5, 'minute') }), | ||
new ListItemModel('6', { column1: '20', column2: 'Fig', | ||
column3: 20, column4: moment().add(3, 'minute') }), | ||
new ListItemModel('7', { column1: '21', column2: 'Grape', | ||
column3: 21, column4: moment().add(7, 'minute') }) | ||
]; | ||
|
||
@ViewChild(SkyGridComponent) | ||
public grid: SkyGridComponent; | ||
@ContentChildren(TemplateRef) | ||
public templates: QueryList<TemplateRef<any>>; | ||
@ViewChildren(TemplateRef) | ||
public viewtemplates: QueryList<TemplateRef<any>>; | ||
|
||
public activeSortSelector: ListSortFieldSelectorModel; | ||
public data: any[] = [ | ||
new ListItemModel('1', { | ||
column1: '1', | ||
column2: 'Apple', | ||
column3: 1, | ||
column4: moment().add(1, 'minute') | ||
}), | ||
new ListItemModel('2', { | ||
column1: '01', | ||
column2: 'Banana', | ||
column3: 1, | ||
column4: moment().add(6, 'minute'), | ||
column5: 'test' | ||
}), | ||
new ListItemModel('3', { | ||
column1: '11', | ||
column2: 'Carrot', | ||
column3: 11, | ||
column4: moment().add(4, 'minute') | ||
}), | ||
new ListItemModel('4', { | ||
column1: '12', | ||
column2: 'Daikon', | ||
column3: 12, | ||
column4: moment().add(2, 'minute') | ||
}), | ||
new ListItemModel('5', { | ||
column1: '13', | ||
column2: 'Edamame', | ||
column3: 13, | ||
column4: moment().add(5, 'minute') | ||
}), | ||
new ListItemModel('6', { | ||
column1: '20', | ||
column2: 'Fig', | ||
column3: 20, | ||
column4: moment().add(3, 'minute') | ||
}), | ||
new ListItemModel('7', { | ||
column1: '21', | ||
column2: 'Grape', | ||
column3: 21, | ||
column4: moment().add(7, 'minute') | ||
}) | ||
]; | ||
|
||
public sortField: ListSortFieldSelectorModel; | ||
public searchFunction: (data: any, searchText: string) => boolean = | ||
(data: any, searchText: string) => { | ||
this.searchedData = data; | ||
this.searchText = searchText; | ||
return true; | ||
} | ||
|
||
public onSort(sortSelector: ListSortFieldSelectorModel) { | ||
this.activeSortSelector = sortSelector; | ||
} | ||
|
||
public searchFunction: (data: any, searchText: string) => boolean = | ||
(data: any, searchText: string) => { | ||
this.searchedData = data; | ||
this.searchText = searchText; | ||
return true; | ||
} | ||
} |
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.