-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added dbx-content-pit feat: dbx-table (#23) * checkpoint: outlined @dbx-web/table * checkpoint: dbx-table * checkpoint: dbx-table * checkpoint: dbx-table * checkpoint: dbx-table * checkpoint: dbx-table refactor: updated accumulatorFlattenPageListLoadingState() - fixed issue where accumulatorFlattenPageListLoadingState() would return an empty loading state instead of all the current values fix: fixed enableMultiTabIndexedDbPersistence usage - fixed issue where trying to use both enableMultiTabIndexedDbPersistence and enableMultiTabIndexedDbPersistence at the same time - enableMultiTabIndexedDbPersistence is now the default, with enableIndexedDbPersistence being used if enableMultiTabIndexedDbPersistence is false
- Loading branch information
ci
committed
Jan 31, 2023
1 parent
b3a0be8
commit ea6c063
Showing
133 changed files
with
1,886 additions
and
63 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
17 changes: 17 additions & 0 deletions
17
...mo/src/app/modules/doc/modules/extension/component/table.item.action.example.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,17 @@ | ||
import { filterMaybe } from '@dereekb/rxjs'; | ||
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy, Input } from '@angular/core'; | ||
import { AbstractDbxInjectionDirective } from '@dereekb/dbx-core'; | ||
import { map, distinctUntilChanged, BehaviorSubject, switchMap } from 'rxjs'; | ||
import { Maybe } from '@dereekb/util'; | ||
|
||
@Component({ | ||
template: ` | ||
<div class="doc-example-table-action-cell"> | ||
<button mat-icon-button><mat-icon>thumb_up</mat-icon></button> | ||
<dbx-button-spacer></dbx-button-spacer> | ||
<button mat-icon-button><mat-icon>thumb_down</mat-icon></button> | ||
</div> | ||
`, | ||
styleUrls: ['./table.item.action.example.scss'] | ||
}) | ||
export class DocExtensionTableItemActionExampleComponent {} |
7 changes: 7 additions & 0 deletions
7
apps/demo/src/app/modules/doc/modules/extension/component/table.item.action.example.scss
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 @@ | ||
.doc-example-table-action-cell { | ||
min-width: 110px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 4px; | ||
} |
28 changes: 28 additions & 0 deletions
28
...demo/src/app/modules/doc/modules/extension/component/table.item.cell.example.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,28 @@ | ||
import { filterMaybe } from '@dereekb/rxjs'; | ||
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy, Input } from '@angular/core'; | ||
import { AbstractDbxInjectionDirective } from '@dereekb/dbx-core'; | ||
import { map, distinctUntilChanged, BehaviorSubject, switchMap } from 'rxjs'; | ||
import { Maybe } from '@dereekb/util'; | ||
import { DbxTableColumn } from '@dereekb/dbx-web/table'; | ||
import { ExampleTableData } from './table.item'; | ||
|
||
@Component({ | ||
template: ` | ||
<div style="text-align: center"> | ||
<div class="dbx-small">{{ name }}</div> | ||
<div class="dbx-small dbx-hint">{{ columnName }}</div> | ||
</div> | ||
` | ||
}) | ||
export class DocExtensionTableItemCellExampleComponent { | ||
item!: ExampleTableData; | ||
column!: DbxTableColumn<Date>; | ||
|
||
get name() { | ||
return this.item.name; | ||
} | ||
|
||
get columnName() { | ||
return this.column.columnName; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...mo/src/app/modules/doc/modules/extension/component/table.item.header.example.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 { filterMaybe } from '@dereekb/rxjs'; | ||
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy, Input } from '@angular/core'; | ||
import { AbstractDbxInjectionDirective } from '@dereekb/dbx-core'; | ||
import { map, distinctUntilChanged, BehaviorSubject, switchMap } from 'rxjs'; | ||
import { Maybe } from '@dereekb/util'; | ||
import { ExampleTableData } from './table.item'; | ||
|
||
@Component({ | ||
template: ` | ||
<div>{{ name }}</div> | ||
` | ||
}) | ||
export class DocExtensionTableItemHeaderExampleComponent { | ||
item!: ExampleTableData; | ||
|
||
get name() { | ||
return this.item.name; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/demo/src/app/modules/doc/modules/extension/component/table.item.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,5 @@ | ||
import { ModelKeyRef } from '@dereekb/util'; | ||
|
||
export interface ExampleTableData extends ModelKeyRef { | ||
name: string; | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/demo/src/app/modules/doc/modules/extension/container/table.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,16 @@ | ||
<dbx-content-container> | ||
<doc-feature-layout header="Table Extension" hint=""> | ||
<!-- Examples --> | ||
<doc-feature-example header="dbx-table-view" hint="The base-level component that renders the state of a dbxTableStore."> | ||
<dbx-table-view dbxTable [dbxTableInput]="exampleInput" [dbxTableViewDelegate]="exampleViewDelegate" [dbxTableDataDelegate]="exampleDataDelegate"></dbx-table-view> | ||
<h3>Context Loading</h3> | ||
<p class="dbx-hint">While the context is loading the table shows a spinning loader.</p> | ||
<dbx-table-view dbxTable [dbxTableInput]="exampleInput" [dbxTableViewDelegate]="exampleViewDelegate" [dbxTableDataDelegate]="exampleLoadingContextDelegate"></dbx-table-view> | ||
<h3>Data Loading</h3> | ||
<p class="dbx-hint">This example shows how loading the data is handled. The delegate also provides a loadMore() functionality, allowing more items to load as the table is scrolled.</p> | ||
<button *ngIf="isLoading$ | async" mat-raised-button (click)="loadMoreItems()">Finish Loading Items</button> | ||
<p></p> | ||
<dbx-table-view dbxTable [dbxTableInput]="exampleInput" [dbxTableViewDelegate]="exampleViewDelegate" [dbxTableDataDelegate]="exampleLoadingDataDelegate"></dbx-table-view> | ||
</doc-feature-example> | ||
</doc-feature-layout> | ||
</dbx-content-container> |
117 changes: 117 additions & 0 deletions
117
apps/demo/src/app/modules/doc/modules/extension/container/table.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,117 @@ | ||
import { DocExtensionTableItemCellExampleComponent } from './../component/table.item.cell.example.component'; | ||
import { startOfDay } from 'date-fns/esm'; | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { DateRangeDayDistanceInput, expandDaysForDateRange, dateRange, formatToISO8601DayString, DateRangeType } from '@dereekb/date'; | ||
import { DbxInjectionComponentConfig } from '@dereekb/dbx-core'; | ||
import { DbxWidgetDataPair } from '@dereekb/dbx-web'; | ||
import { DbxTableColumn, DbxTableContextData, DbxTableContextDataDelegate, dbxTableDateHeaderInjectionFactory, dbxTableDateRangeDayDistanceInputCellInput, DbxTableViewDelegate } from '@dereekb/dbx-web/table'; | ||
import { beginLoading, beginLoadingPage, ListLoadingState, PageListLoadingState, successPageResult, successResult } from '@dereekb/rxjs'; | ||
import { Maybe, ModelKeyRef, range } from '@dereekb/util'; | ||
import { delay, map, Observable, of, startWith, BehaviorSubject, skip, shareReplay, distinctUntilChanged, switchMap } from 'rxjs'; | ||
import { DocExtensionTableItemActionExampleComponent } from '../component/table.item.action.example.component'; | ||
import { DocExtensionTableItemHeaderExampleComponent } from '../component/table.item.header.example.component'; | ||
import { ExampleTableData } from '../component/table.item'; | ||
|
||
@Component({ | ||
templateUrl: './table.component.html' | ||
}) | ||
export class DocExtensionTableComponent implements OnDestroy { | ||
readonly exampleInput: DateRangeDayDistanceInput = { | ||
date: startOfDay(new Date()), | ||
distance: 6 | ||
}; | ||
|
||
readonly exampleTableData: ExampleTableData[] = range(0, 15).map((x) => ({ name: `Example ${x}`, key: String(x) })); | ||
readonly exampleTableDataItems = new BehaviorSubject<ExampleTableData[]>(this.exampleTableData); | ||
|
||
readonly isLoading$ = this.exampleTableDataItems.pipe( | ||
skip(1), | ||
map((x) => false), | ||
startWith(true), | ||
distinctUntilChanged(), | ||
shareReplay(1) | ||
); | ||
|
||
readonly exampleViewDelegate: DbxTableViewDelegate<DateRangeDayDistanceInput, Date, ExampleTableData> = { | ||
inputHeader: dbxTableDateRangeDayDistanceInputCellInput(), | ||
columnHeader: dbxTableDateHeaderInjectionFactory(), | ||
itemHeader: function (item: ExampleTableData) { | ||
return { | ||
componentClass: DocExtensionTableItemHeaderExampleComponent, | ||
init: (x) => { | ||
x.item = item; | ||
} | ||
}; | ||
}, | ||
itemCell: function (column: DbxTableColumn<Date>, item: ExampleTableData) { | ||
return { | ||
componentClass: DocExtensionTableItemCellExampleComponent, | ||
init: (x) => { | ||
x.item = item; | ||
x.column = column; | ||
} | ||
}; | ||
}, | ||
itemAction: function (item: ExampleTableData) { | ||
return { | ||
componentClass: DocExtensionTableItemActionExampleComponent | ||
}; | ||
} | ||
}; | ||
|
||
readonly exampleDataDelegate: DbxTableContextDataDelegate<DateRangeDayDistanceInput, Date, ExampleTableData> = { | ||
loadData: (input) => { | ||
const allDays = expandDaysForDateRange(dateRange({ ...input })); | ||
const columns: DbxTableColumn<Date>[] = allDays.map((x) => ({ columnName: formatToISO8601DayString(x), meta: x })); | ||
const items: ExampleTableData[] = [...this.exampleTableData]; | ||
const items$: Observable<PageListLoadingState<ExampleTableData>> = of(successPageResult(0, items)); | ||
|
||
const result: DbxTableContextData<DateRangeDayDistanceInput, Date, ExampleTableData> = { | ||
input, | ||
columns, | ||
items$ | ||
}; | ||
|
||
return of(successResult(result)); // .pipe(delay(1000), startWith(beginLoadingPage<typeof result>(0))); | ||
} | ||
}; | ||
|
||
readonly exampleLoadingContextDelegate: DbxTableContextDataDelegate<DateRangeDayDistanceInput, Date, ExampleTableData> = { | ||
loadData: (input) => { | ||
return of(beginLoadingPage<DbxTableContextData<DateRangeDayDistanceInput, Date, ExampleTableData>>(0)); | ||
} | ||
}; | ||
|
||
readonly exampleLoadingDataDelegate: DbxTableContextDataDelegate<DateRangeDayDistanceInput, Date, ExampleTableData> = { | ||
loadData: (input) => { | ||
const allDays = expandDaysForDateRange(dateRange({ ...input })); | ||
const columns: DbxTableColumn<Date>[] = allDays.map((x) => ({ columnName: formatToISO8601DayString(x), meta: x })); | ||
const items$: Observable<PageListLoadingState<ExampleTableData>> = this.exampleTableDataItems | ||
.pipe( | ||
skip(1), | ||
switchMap((x) => of(successPageResult(0, x)).pipe(delay(1000), startWith(beginLoadingPage<ExampleTableData[]>(0)))) | ||
) | ||
.pipe(startWith(beginLoadingPage<ExampleTableData[]>(0))); | ||
|
||
const result: DbxTableContextData<DateRangeDayDistanceInput, Date, ExampleTableData> = { | ||
input, | ||
columns, | ||
items$, | ||
loadMore: () => this.loadMoreItems() | ||
}; | ||
|
||
return of(successResult(result)); | ||
} | ||
}; | ||
|
||
loadMoreItems() { | ||
const currentItems = this.exampleTableDataItems.value; | ||
const itemsCount = currentItems.length; | ||
const newItems = range(itemsCount + 1, itemsCount + 15).map((x) => ({ name: `Example ${x}`, key: String(x) })); | ||
this.exampleTableDataItems.next([...currentItems, ...newItems]); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.exampleTableDataItems.complete(); | ||
} | ||
} |
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.