DocumentProvider

Represents the set of documents that is displayed in the view. This includes the list of filtered documents, as well as the currently displayed one. It uses a DocumentService to retrieve documents from the server. It also emits events when the filtered documents, or the currently displayed document change.

Constructor

new DocumentProvider(service)

Constructs a new documents provider.

Parameters:
NameTypeDescription
serviceDocumentService

The document service.

Classes

DocumentProvider

Members

allDocuments :Array.<Document>

The list of all documents.

Type:

displayedDocumentIndex :number

The currently displayed document.

Type:
  • number

filteredDocuments :Array.<Document>

The list of filtered documents.

Type:

filters :Array.<DocumentFilter>

The list of filters.

Type:

service :DocumentService

The document service.

Methods

addFilter(newFilter)

Adds a filter to the filtering pipeline.

Parameters:
NameTypeDescription
newFilterDocumentFilter

The new filter to add.

getAllDocuments() → {Array.<Document>}

Returns the list of all documents.

Returns:

An array with all documents

Type: 
Array.<Document>

getDisplayedDocument() → {Document|undefined}

Returns the currently displayed document.

Returns:

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).

Returns:

A promise for the document image

Type: 
Promise.<(string|undefined)>

getDisplayedDocumentIndex() → {number|undefined}

Returns the displayed document index.

Returns:

The index of the displayed document

Type: 
number | undefined

getFilteredDocuments() → {Array.<Document>}

Returns the filtered list of documents.

Returns:

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.

Parameters:
NameTypeDescription
docDocument

The document.

setDisplayedDocumentIndex(index)

Change the displayed document index. Sends a DISPLAYED_DOCUMENT_CHANGED event.

Parameters:
NameTypeDescription
indexnumber

The new document index.

shiftDisplayedDocumentIndex(offset)

Shift the displayed document index. The filtered array is treated as cyclical. Sends a DISPLAYED_DOCUMENT_CHANGED event.

Parameters:
NameTypeDescription
offsetnumber

The offset that will be applied to the current index.