-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Collections as array; traBy function for ngFor; (#100)
Version 1.1.0 🎆 * Feature: collections has `data` member now. `data` is an array, and the requested information is kept in order. Closes #84. Closes #54. * Feature: trackBy added on collection. Optimize use of ngFor. * Deprecated: callback functions deprecated on get(), all(), detele() and save(). And... * Demo: demo-collection-info component added. Show info about received collection. * tslint: array<> to [] on types * version 1.1.0 bump * Readme updated: sort and trackby added
- Loading branch information
Showing
35 changed files
with
222 additions
and
238 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<p><code>$length={{ collection.$length }}. $is_loading={{ collection.$is_loading }}. $source={{ collection.$source }}.</code></p> |
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,9 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { ICollection } from 'ngx-jsonapi'; | ||
@Component({ | ||
selector: 'demo-collection-info', | ||
templateUrl: './collection-info.component.html' | ||
}) | ||
export class CollectionInfoComponent { | ||
@Input() public collection: ICollection; | ||
} |
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,9 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { CollectionInfoComponent } from './collection-info.component'; | ||
@NgModule({ | ||
imports: [CommonModule], | ||
exports: [CollectionInfoComponent], | ||
declarations: [CollectionInfoComponent] | ||
}) | ||
export class SharedModule {} |
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,13 +1,15 @@ | ||
import { Resource } from '../resource'; | ||
import { IPage } from './page'; | ||
import { IDataResource } from './data-resource'; | ||
import { IDocumentData } from './document'; | ||
|
||
export interface ICollection<R extends Resource = Resource> extends Array<Resource> { | ||
export interface ICollection<R extends Resource = Resource> extends IDocumentData { | ||
$length: number; | ||
$toArray: Array<R>; | ||
$toArray: R[]; | ||
$is_loading: boolean; | ||
$source: 'new' | 'memory' | 'store' | 'server'; | ||
$cache_last_update: number; | ||
data: Array<IDataResource>; // this need disapear is for datacollection | ||
page: IPage; | ||
data: R[]; | ||
trackBy: Function; | ||
} |
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,9 +1,9 @@ | ||
import { IDataResource } from './data-resource'; | ||
import { IDocument } from '../interfaces/document'; | ||
import { IDocument, IDocumentData } from '../interfaces/document'; | ||
import { IPage } from './page'; | ||
|
||
export interface IDataCollection extends IDocument { | ||
data: Array<IDataResource>; | ||
export interface IDataCollection extends IDocumentData { | ||
data: IDataResource[]; | ||
page?: IPage; | ||
_lastupdate_time?: number; // used when come from Store | ||
} |
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,6 +1,6 @@ | ||
import { IDocument } from './document'; | ||
import { IDocument, IDocumentData } from './document'; | ||
import { IDataResource } from './data-resource'; | ||
|
||
export interface IDataObject extends IDocument { | ||
export interface IDataObject extends IDocumentData { | ||
data: IDataResource; | ||
} |
Oops, something went wrong.