ContractListEntriesComponent¶
Source | contract-listentries |
---|
Contract paged listentry display. Each DataContract can have several list definitions to store its necessary data in. Each of this lists can grow to an large list of elements. To be able to page this entries easily this component can be used.
Shows simply a button, when the user will be able to page to the next page. Else nothing will be displayed, only the OnUpdate function is called so you can load your list entries like you want.
Inputs¶
contractId
-string
: contract to load the data forlistName
-string
: list name to load the data forcount
-number
: page size to split the loaded bunches inreverse
-boolean
: should the data loaded reverse?dfsStorage
-boolean
(default = true): store values in dfsencryptedHashes
-boolean
(default = true): encrypt hashes from valuesonUpdate
-Function
: is emitted when new data was loadedonError
-Function
: is emitted when an error occures during list entries loading
Example¶
In this exmapled we are saved sub contract ids within a list and load the dbcp definition for the contracts.
- component.ts
import { prottle } from 'bcc';
import {
EvanBCCService,
EvanCoreService
} from 'angular-core';
...
private loadedEntries: Array<string>;
constructor(
private bccService: EvanBCCService,
private core: EvanCoreService
) {}
ngOnInit() {
...
this.contractId = '0x000...';
this.loadedEntries = [ ];
...
}
onUpdate(listEntries = this.listEntryComponent.listEntries) {
if (listEntries.length > 0) {
await prottle(10, listEntries.map(listEntry => async () => {
listEntry = listEntry.substring(0, 42);
if (!this.loadedEntries.find(entry => entry.address === listEntry)) {
this.loadedEntries.push(
await this.bccService.description.getDescriptionFromContract(listEntry, this.core.activeAccount())
);
}
});
}
}
- component.html
<ion-list>
<ion-item *ngFor="entry of loadedEntries">{{ entry }}</ion-item>
</ion-list>
<contract-listentries #listEntryComponent
[contractId]="contractId"
[count]="10"
[dfsStorage]="false"
[encryptedHashes]="false"
[listName]="'biglist'"
[reverse]="true"
[onUpdate]="loadTasks.bind(this)">
</contract-listentries>