Constructor
new DocumentProvider(service)
Constructs a new documents provider.
Name | Type | Description |
---|---|---|
service | DocumentService | The document service. |
Classes
Members
allDocuments :Array.<Document>
The list of all documents.
- Array.<Document>
displayedDocumentIndex :number
The currently displayed document.
- number
filteredDocuments :Array.<Document>
The list of filtered documents.
- Array.<Document>
filters :Array.<DocumentFilter>
The list of filters.
- Array.<DocumentFilter>
service :DocumentService
The document service.
Methods
addFilter(newFilter)
Adds a filter to the filtering pipeline.
Name | Type | Description |
---|---|---|
newFilter | DocumentFilter | The new filter to add. |
getAllDocuments() → {Array.<Document>}
Returns the list of all documents.
An array with all documents
- Type:
- Array.<Document>
getDisplayedDocument() → {Document|undefined}
Returns the currently displayed document.
The displayed document
- Type:
- Document |
undefined
(async) getDisplayedDocumentImage() → {Promise.<(string|undefined)>}
Returns the image corresponding to the displayed document. It is a string that can be put into the src
attribute of an img
tag (so either an URL or a base64 encoded file).
A promise for the document image
- Type:
- Promise.<(string|undefined)>
getDisplayedDocumentIndex() → {number|undefined}
Returns the displayed document index.
The index of the displayed document
- Type:
- number |
undefined
getFilteredDocuments() → {Array.<Document>}
Returns the filtered list of documents.
An array with filtered documents
- Type:
- Array.<Document>
(async) refreshDocumentList()
Updates the filtered documents list by fetching them from the DocumentService
and applying the successive filters. Triggers the DOCUMENT_LIST_UPDATED
and then the DISPLAYED_DOCUMENT_CHANGED
events.
setDisplayedDocument(doc)
Sets the given document as the displayed one.
Name | Type | Description |
---|---|---|
doc | Document | The document. |
setDisplayedDocumentIndex(index)
Change the displayed document index. Sends a DISPLAYED_DOCUMENT_CHANGED
event.
Name | Type | Description |
---|---|---|
index | number | The new document index. |
shiftDisplayedDocumentIndex(offset)
Shift the displayed document index. The filtered array is treated as cyclical. Sends a DISPLAYED_DOCUMENT_CHANGED
event.
Name | Type | Description |
---|---|---|
offset | number | The offset that will be applied to the current index. |