Multiplicom / axiom

3 stars 0 forks source link

Enable adding query parameters to documentation page request #91

Closed basvandenberg closed 3 years ago

basvandenberg commented 3 years ago

Currently it is only possible to define a docId for showing a documentation page, in which case the page {docRoot}/{docId}.html is loaded and displayed.

let docId = 'my_doc_id';
DocViewer.create(docId);
// loads and displays: /your/root/my_doc_id.html

Sending along (optional) query parameters would enable displaying different variants of the same help content (for example for different view contexts).

let docId = 'my_doc_id';
let queryParams = {
    paramA: 'test1',
    paramB: 'test2'
}
DocViewer.create(docId, queryParams);
// loads and displays:  /your/root/my_doc_id.html?paramA=test1&paramB=test2

The queryParams should be optional, so if not defined/provided, it should be ignored.

basvandenberg commented 3 years ago

Instead of adding queryParams as parameter of the DocViewer.create() function, I enabled setting a function that will be used for fetching the query parameters.

// set root url of the help documents
DocViewer.setDocRoot('my/doc/root');
// set function for fetching query parameters
DocViewer.setQueryParamsFunc(myQueryParamsFunc);

If this function is set, it will be used to fetch query parameters, and (if there are any) they will be send to the server as part of the help document request.