forked from pagopa/io-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MyPortal): [#174883732] Adds MD documentation on webview injecte…
…d script and original JS file (pagopa#2220) * [#174883732] Adds documentation from webview scripts definition * Rename JS file and updates documentation * Rename JS file and updates documentation * Rename JS file and updates documentation * updates documentation * updates documentation * updates documentation * updates documentation * Fixes conflict error * Minor improvements
- Loading branch information
1 parent
6eef55f
commit a32cf71
Showing
4 changed files
with
731 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
## Functions | ||
|
||
<dl> | ||
<dt><a href="#closeModal">closeModal()</a></dt> | ||
<dd><p>This function sends to IO App the input to stop the webview communication and close the current screen.</p> | ||
</dd> | ||
<dt><a href="#showLoader">showLoader()</a></dt> | ||
<dd><p>This function sends to IO App the input to show the activity indicator loader.</p> | ||
</dd> | ||
<dt><a href="#hideLoader">hideLoader()</a></dt> | ||
<dd><p>This function sends to IO App the input to hide the activity indicator loader.</p> | ||
</dd> | ||
<dt><a href="#showSuccess">showSuccess(payload)</a></dt> | ||
<dd><p>A function to show the success component on the IO App side.</p> | ||
</dd> | ||
<dt><a href="#showErrorMessage">showErrorMessage(payload)</a></dt> | ||
<dd><p>A function to send an error message to IO App component</p> | ||
</dd> | ||
<dt><a href="#showAlertBox">showAlertBox(payload)</a></dt> | ||
<dd><p>A function to show an AlertBox in the IO App component.</p> | ||
</dd> | ||
<dt><a href="#checkInjectionCompleted">checkInjectionCompleted()</a></dt> | ||
<dd><p>This is a utility function to check if the injection is yet completed. | ||
This calls onInjectionCompleted function which is implemented by the client and not injected by IO App.</p> | ||
</dd> | ||
</dl> | ||
|
||
## Typedefs | ||
|
||
<dl> | ||
<dt><a href="#AlertContents">AlertContents</a> : <code>Object</code></dt> | ||
<dd><p>An Object to define the values of Title and description of an alert box.</p> | ||
</dd> | ||
<dt><a href="#MessagePayloadS">MessagePayloadS</a> : <code>Object</code></dt> | ||
<dd><p>An object defined for internationalization purpose. | ||
The key is the language key and the value is the message text</p> | ||
<p>Accepted keys:</p> | ||
<ul> | ||
<li>it</li> | ||
<li>en</li> | ||
</ul> | ||
</dd> | ||
<dt><a href="#MessagePayloadL">MessagePayloadL</a> : <code>Object</code></dt> | ||
<dd><p>An object defined for internationalization purpose. | ||
The key is the language key and the value is the payload for alert box</p> | ||
</dd> | ||
</dl> | ||
|
||
<a name="closeModal"></a> | ||
|
||
## closeModal() | ||
This function sends to IO App the input to stop the webview communication and close the current screen. | ||
|
||
**Kind**: global function | ||
<a name="showLoader"></a> | ||
|
||
## showLoader() | ||
This function sends to IO App the input to show the activity indicator loader. | ||
|
||
**Kind**: global function | ||
<a name="hideLoader"></a> | ||
|
||
## hideLoader() | ||
This function sends to IO App the input to hide the activity indicator loader. | ||
|
||
**Kind**: global function | ||
<a name="showSuccess"></a> | ||
|
||
## showSuccess(payload) | ||
A function to show the success component on the IO App side. | ||
|
||
**Kind**: global function | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| payload | [<code>MessagePayloadS</code>](#MessagePayloadS) | Will be the message showed in the success screen, otherwise a common text will be displayed | | ||
|
||
<a name="showErrorMessage"></a> | ||
|
||
## showErrorMessage(payload) | ||
A function to send an error message to IO App component | ||
|
||
**Kind**: global function | ||
|
||
| Param | Type | | ||
| --- | --- | | ||
| payload | [<code>MessagePayloadS</code>](#MessagePayloadS) | | ||
|
||
<a name="showAlertBox"></a> | ||
|
||
## showAlertBox(payload) | ||
A function to show an AlertBox in the IO App component. | ||
|
||
**Kind**: global function | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| payload | [<code>MessagePayloadL</code>](#MessagePayloadL) | the value to display in the alert box. | | ||
|
||
<a name="checkInjectionCompleted"></a> | ||
|
||
## checkInjectionCompleted() | ||
This is a utility function to check if the injection is yet completed. | ||
This calls onInjectionCompleted function which is implemented by the client and not injected by IO App. | ||
|
||
**Kind**: global function | ||
<a name="AlertContents"></a> | ||
|
||
## AlertContents : <code>Object</code> | ||
An Object to define the values of Title and description of an alert box. | ||
|
||
**Kind**: global typedef | ||
**Properties** | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| title | <code>string</code> | The title of the alert box. | | ||
| description | <code>string</code> | The main message of the alert box. | | ||
|
||
<a name="MessagePayloadS"></a> | ||
|
||
## MessagePayloadS : <code>Object</code> | ||
An object defined for internationalization purpose. | ||
The key is the language key and the value is the message text | ||
|
||
Accepted keys: | ||
- it | ||
- en | ||
|
||
**Kind**: global typedef | ||
**Properties** | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| it | <code>string</code> | The message defined in Italian. | | ||
| en | <code>string</code> | The message defined in English. | | ||
|
||
<a name="MessagePayloadL"></a> | ||
|
||
## MessagePayloadL : <code>Object</code> | ||
An object defined for internationalization purpose. | ||
The key is the language key and the value is the payload for alert box | ||
|
||
**Kind**: global typedef | ||
**Properties** | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| it | <code>AlertContent</code> | The values of the alert box in Italian language | | ||
| en | <code>AlertContent</code> | The values of the alert box in English language | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable no-undef */ | ||
|
||
/** | ||
* An Object to define the values of Title and description of an alert box. | ||
* | ||
* @typedef {Object} AlertContents | ||
* @property {string} title - The title of the alert box. | ||
* @property {string} description - The main message of the alert box. | ||
*/ | ||
|
||
/** | ||
* An object defined for internationalization purpose. | ||
* The key is the language key and the value is the message text | ||
* | ||
* Accepted keys: | ||
* - it | ||
* - en | ||
* @typedef {Object} MessagePayloadS | ||
* @property {string} it - The message defined in Italian. | ||
* @property {string} en - The message defined in English. | ||
*/ | ||
|
||
/** | ||
* An object defined for internationalization purpose. | ||
* The key is the language key and the value is the payload for alert box | ||
* | ||
* @typedef {Object} MessagePayloadL | ||
* @property {AlertContent} it - The values of the alert box in Italian language | ||
* @property {AlertContent} en - The values of the alert box in English language | ||
*/ | ||
|
||
// /** | ||
// * The object that defines the data exchange between IO App and webpage layers. | ||
// * | ||
// * @typedef {Object} Message | ||
// * @property {string} type - The values of the alert box in Italian language | ||
// * @property {(...MessagePayloadL|...MessagePayloadS)} - (Optional) The values of the alert box in English language | ||
// */ | ||
|
||
// /** | ||
// * This function sends messages to IO app layer. | ||
// * | ||
// * @param {Message} message | ||
// */ | ||
function sendMessagesToRN(message) { | ||
if (message) { | ||
if (window.ReactNativeWebView) { | ||
window.ReactNativeWebView.postMessage(JSON.stringify(message)); | ||
} | ||
return; | ||
} | ||
console.error("Specify a message to send"); | ||
} | ||
|
||
/** | ||
* This function sends to IO App the input to stop the webview communication and close the current screen. | ||
*/ | ||
function closeModal() { | ||
const message = { | ||
type: "CLOSE_MODAL" | ||
}; | ||
sendMessagesToRN(message); | ||
} | ||
|
||
/** | ||
* This function sends to IO App the input to show the activity indicator loader. | ||
*/ | ||
function showLoader() { | ||
const message = { | ||
type: "START_LOAD" | ||
}; | ||
sendMessagesToRN(message); | ||
} | ||
|
||
/** | ||
* This function sends to IO App the input to hide the activity indicator loader. | ||
*/ | ||
function hideLoader() { | ||
const message = { | ||
type: "END_LOAD" | ||
}; | ||
sendMessagesToRN(message); | ||
} | ||
|
||
/** | ||
* A function to show the success component on the IO App side. | ||
* | ||
* @param {MessagePayloadS} payload - Will be the message showed in the success screen, otherwise a common text will be displayed | ||
*/ | ||
function showSuccess(payload) { | ||
const message = { | ||
type: "SHOW_SUCCESS", | ||
...payload | ||
}; | ||
sendMessagesToRN(message); | ||
} | ||
|
||
/** | ||
* A function to send an error message to IO App component | ||
* | ||
* @param {MessagePayloadS} payload | ||
*/ | ||
function showErrorMessage(payload) { | ||
const message = { | ||
type: "SHOW_ERROR", | ||
...payload | ||
}; | ||
sendMessagesToRN(message); | ||
} | ||
|
||
/** | ||
* A function to show an AlertBox in the IO App component. | ||
* | ||
* @param {MessagePayloadL} payload - the value to display in the alert box. | ||
*/ | ||
function showAlertBox(payload) { | ||
const message = { | ||
type: "SHOW_ALERT", | ||
...payload | ||
}; | ||
sendMessagesToRN(message); | ||
} | ||
|
||
/** | ||
* This is a utility function to check if the injection is yet completed. | ||
* This calls onInjectionCompleted function which is implemented by the client and not injected by IO App. | ||
*/ | ||
function checkInjectionCompleted() { | ||
if (typeof onInjectionCompleted === "function") { | ||
onInjectionCompleted(); | ||
} | ||
} | ||
|
||
checkInjectionCompleted(); |
Oops, something went wrong.