Constructor
new ViewNavigator(setupopt, parentView)
Creates an instance of ViewNavigator.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setup |
Object |
<optional> |
The configuration for the view navigator instance. Properties
|
||||||||||||||||||||||||||||||
parentView |
ViewCLI | The parent view associated with this navigator. |
- Source:
Extends
Members
StringBuilder :StringTemplateBuilder
The StringTemplateBuilder instance used for constructing string templates.
Type:
- Overrides:
- Source:
navErrorCallback :function
Callback function on navigation error.
Type:
- function
- Source:
navSuccessCallback :function
Callback function on successful navigation.
Type:
- function
- Source:
options :Array
Array of navigation options.
Type:
- Array
- Source:
parentView
Retrieves the parent view associated with this navigator.
- Source:
question :Object
Question configuration for prompting user input.
Type:
- Object
- Source:
type :string
The type of navigation ('nav' or 'doc-list').
Type:
- string
- Source:
Methods
_parentView()
The parent view associated with this navigator.
- Source:
addOption(data) → {ViewNavigator}
Adds a new navigation option to the navigator.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Data for the new navigation option. |
- Source:
Returns:
The current ViewNavigator instance.
- Type
- ViewNavigator
boolAnswer(a, strictopt) → {boolean}
Converts a user input to a boolean value, considering 'y' or 'n' as affirmative and negative answers, respectively.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
a |
string | The user input to be converted to a boolean value ('y' or 'n'). |
||
strict |
boolean |
<optional> |
false | If set to true, strict mode requires 'y' or 'n' input only. |
- Overrides:
- Source:
Throws:
-
When strict mode is enabled and the input is not 'y' or 'n'.
- Type
- Error.Log
Returns:
The boolean value based on the user input.
- Type
- boolean
(async) fire(paramsopt) → {Promise}
Prompts user input based on the provided question text and navigates to the chosen option.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
Object |
<optional> |
Additional parameters for rendering and navigation. |
- Source:
Throws:
-
When an error occurs during navigation.
- Type
- Error.Log
Returns:
A promise resolving to the result of navigation.
- Type
- Promise
getOption(index) → {NavigatorOption}
Retrieves a navigation option by its index.
Parameters:
| Name | Type | Description |
|---|---|---|
index |
string | The index of the navigation option to retrieve. |
- Source:
Returns:
The navigation option instance.
- Type
- NavigatorOption
(async) navTo(index, paramsopt)
Navigates to a specific navigation option by its index.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
index |
string | The index of the navigation option to navigate to. |
|
params |
Object |
<optional> |
Additional parameters to be passed to the view. |
- Source:
Throws:
-
When an error occurs during navigation.
- Type
- Error.Log
print(txt, addHeaderopt)
Prints a message to the console with optional header and project name.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
txt |
string | The text to be printed. |
|
addHeader |
string |
<optional> |
The optional header to be added to the message. |
- Overrides:
- Source:
printError(err)
Prints an error message to the console, including error name, message, and stack trace.
Parameters:
| Name | Type | Description |
|---|---|---|
err |
Error | The error object to be printed. |
- Overrides:
- Source:
printTable(data, optionsopt)
Prints tabular data to the console as a table.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Object | The data to be displayed in the table. |
|
options |
Object |
<optional> |
Additional options for printing the table, including headers. |
- Overrides:
- Source:
printTemplate(stringContent)
Prints a string template content to the console.
Parameters:
| Name | Type | Description |
|---|---|---|
stringContent |
string | The string template content to be printed. |
- Overrides:
- Source:
render(paramsopt) → {string}
Renders the navigation options and displays them to the user.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
Object |
<optional> |
Additional parameters for rendering. |
- Source:
Throws:
-
When an error occurs during rendering.
- Type
- Error.Log
Returns:
The rendered string output of the navigation options.
- Type
- string
setOption(index, data, overrideopt)
Sets or updates an existing navigation option by its index.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
index |
string | The index of the navigation option to set or update. |
||
data |
Object | Data for the navigation option. |
||
override |
boolean |
<optional> |
false | Indicates whether to override the existing option or merge the data. |
- Source: