Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: download vc button #160

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-git

## Added to documentation?

- [ ] πŸ“– [Mock App docs site](https://uncefact.github.io/tests-untp/docs/mock-apps/)
- [ ] πŸ“œ README.md
- [ ] πŸ“• storybook
- [ ] πŸ™… no documentation needed
Expand Down
120 changes: 105 additions & 15 deletions app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,23 @@
}
}
]
},
{
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_dpps",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_dpps"
}
]
}
]
},
Expand Down Expand Up @@ -1422,6 +1439,23 @@
}
}
]
},
{
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_dpps",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_dpps"
}
]
}
]
},
Expand All @@ -1433,7 +1467,7 @@
"name": "LocalStorageLoader",
"type": "EntryData",
"props": {
"storageKey": "CherriesFarm_dpps",
"storageKey": "orchard_facility_dpps",
"nestedComponents": [
{
"name": "JsonForm",
Expand Down Expand Up @@ -1624,7 +1658,7 @@
}
},
"identifierKeyPath": "/0/id",
"localStorageParams": { "storageKey": "CherriesFarm_dpps", "keyPath": "/0/epcList/index/name" }
"localStorageParams": { "storageKey": "orchard_facility_dpps", "keyPath": "/0/epcList/index/name" }
}
]
},
Expand All @@ -1636,6 +1670,14 @@
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/0/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_transaction_event"
}
]
}
]
},
Expand Down Expand Up @@ -4250,7 +4292,7 @@
"name": "LocalStorageLoader",
"type": "EntryData",
"props": {
"storageKey": "orchard_facility_transaction_event",
"storageKey": "packhouse_facility_transaction_event",
"nestedComponents": [
{
"name": "JsonForm",
Expand Down Expand Up @@ -4892,10 +4934,18 @@
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "CherriesFarm_dpps",
"storageKey": "packhouse_facility_dpps",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "packhouse_facility_dpps"
}
]
}
]
},
Expand All @@ -4907,7 +4957,7 @@
"name": "LocalStorageLoader",
"type": "EntryData",
"props": {
"storageKey": "CherriesFarm_dpps",
"storageKey": "packhouse_facility_dpps",
"nestedComponents": [
{
"name": "JsonForm",
Expand Down Expand Up @@ -5098,18 +5148,26 @@
}
},
"identifierKeyPath": "/0/id",
"localStorageParams": { "storageKey": "CherriesFarm_dpps", "keyPath": "/0/epcList/index/name" }
"localStorageParams": { "storageKey": "packhouse_facility_dpps", "keyPath": "/0/epcList/index/name" }
}
]
},
{
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_transaction_event",
"storageKey": "packhouse_facility_transaction_event",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/0/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "packhouse_facility_transaction_event"
}
]
}
]
}
Expand Down Expand Up @@ -5778,10 +5836,18 @@
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "CherriesFarm_dpps",
"storageKey": "fumigation_and_freight_forwarding_facility_dpps",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "fumigation_and_freight_forwarding_facility_dpps"
}
]
}
]
},
Expand All @@ -5793,7 +5859,7 @@
"name": "LocalStorageLoader",
"type": "EntryData",
"props": {
"storageKey": "CherriesFarm_dpps",
"storageKey": "fumigation_and_freight_forwarding_facility_dpps",
"nestedComponents": [
{
"name": "JsonForm",
Expand Down Expand Up @@ -5984,18 +6050,26 @@
}
},
"identifierKeyPath": "/0/id",
"localStorageParams": { "storageKey": "CherriesFarm_dpps", "keyPath": "/0/epcList/index/name" }
"localStorageParams": { "storageKey": "fumigation_and_freight_forwarding_facility_dpps", "keyPath": "/0/epcList/index/name" }
}
]
},
{
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_transaction_event",
"storageKey": "fumigation_and_freight_forwarding_facility_transaction_event",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/0/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "fumigation_and_freight_forwarding_facility_transaction_event"
}
]
}
]
}
Expand Down Expand Up @@ -6664,10 +6738,18 @@
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "CherriesFarm_dpps",
"storageKey": "airport_terminal_facility_dpps",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "airport_terminal_facility_dpps"
}
]
}
]
},
Expand All @@ -6679,7 +6761,7 @@
"name": "LocalStorageLoader",
"type": "EntryData",
"props": {
"storageKey": "CherriesFarm_dpps",
"storageKey": "airport_terminal_facility_dpps",
"nestedComponents": [
{
"name": "JsonForm",
Expand Down Expand Up @@ -6870,18 +6952,26 @@
}
},
"identifierKeyPath": "/0/id",
"localStorageParams": { "storageKey": "CherriesFarm_dpps", "keyPath": "/0/epcList/index/name" }
"localStorageParams": { "storageKey": "airport_terminal_facility_dpps", "keyPath": "/0/epcList/index/name" }
}
]
},
{
"name": "mergeToLocalStorage",
"parameters": [
{
"storageKey": "orchard_facility_transaction_event",
"storageKey": "airport_terminal_facility_transaction_event",
"objectKeyPath": "/decodedEnvelopedVC/credentialSubject/0/id"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "airport_terminal_facility_transaction_event"
}
]
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion documentation/docs/mock-apps/components/custom-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import Disclaimer from '../../_disclaimer.mdx';

## Description

The CustomButton component renders a button with loading state and optional download functionality. It provides a flexible and reusable button solution for various use cases within the application.
The CustomButton component renders a button with a loading state and optional download functionality, offering a flexible and reusable solution for various use cases within the application.

This component is used to download data returned by the last service in the services array defined in the application configuration (app-config.json). If the last service does not return any data, the button will not be displayed. For details about the types of services (function types), refer to the `Function Type` section in each service’s documentation.

## Example

Expand Down
8 changes: 8 additions & 0 deletions documentation/docs/mock-apps/configuration/service-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ graph TD
"objectKeyPath": "/vc/credentialSubject/product/itemIdentifiers/0/identifierValue"
}
]
},
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "Steel_Mill_1_dpps"
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ flowchart TD

## Definitions

| Property | Required | Description | Type |
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | |
| path | No | The path of the data wants to convert. If the path is undefined, it will convert the whole data. | [IdentifierKeyPath](/docs/mock-apps/common/identifier-key-path) |
| Property | Required | Description | Type |
| -------- | -------- | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
| path | No | The path of the data wants to convert. If the path is undefined, it will convert the whole data. | [IdentifierKeyPath](/docs/mock-apps/common/identifier-key-path) |

## Function type

| Type | Description |
| ---------- | ------------------------------------------------------------------------------------------------------------------------ |
| ReturnData | It processes the input data or generates data independently and returns the processed result after successful execution. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
sidebar_position: 28
huynguyen-hl marked this conversation as resolved.
Show resolved Hide resolved
title: Get Value From Local Storage
---

import Disclaimer from '../../\_disclaimer.mdx';

<Disclaimer />

## Description

The `getValueFromLocalStorage` service retrieves data from the browser's local storage. It takes a specific storage key to locate the data and an optional key to extract a particular value from the stored object. If no key is provided, the entire item is returned. Additionally, the function can update a provided state object with the retrieved data if a `stateKey` is specified.

## Diagram

```mermaid
sequenceDiagram
participant C as Client
participant G as getValueFromLocalStorage
participant L as LocalStorage

C->>G: Call getValueFromLocalStorage(data, params)
G->>L: Get data from LocalStorage (storageKey)
L-->>G: Return stored data
G->>G: Parse data and extract key (if specified)
G->>G: Update state object (if stateKey is specified)
G-->>C: Return retrieved data or updated state
```

## Example

```json
{
"name": "getValueFromLocalStorage",
"parameters": [
{
"storageKey": "topLineSteel_dpps",
"key": "/vc"
}
]
}
```

## Definitions

| Property | Required | Description | Type |
| ---------- | -------- | ------------------------------------------------------------------------------------------------ | ------ |
| storageKey | Yes | The key used to locate the specific data in local storage | String |
| key | No | The key to retrieve a specific value within the stored object. If not provided, returns all data | String |
| stateKey | No | The key used to update the provided state object with the retrieved data | String |

## Function type

| Type | Description |
| ---------- | ------------------------------------------------------------------------------------------------------------------------ |
| ReturnData | It processes the input data or generates data independently and returns the processed result after successful execution. |
10 changes: 8 additions & 2 deletions documentation/docs/mock-apps/services/merge-to-local-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 27
title: Merge To Local Storage
---

import Disclaimer from '../../_disclaimer.mdx';
import Disclaimer from '../../\_disclaimer.mdx';

<Disclaimer />

Expand Down Expand Up @@ -48,4 +48,10 @@ sequenceDiagram
| Property | Required | Description | Type |
|----------|----------|-------------|------|
| storageKey | Yes | The key used to access the specific data in local storage | String |
| objectKeyPath | Yes | JSON path to the unique identifier within the object to be stored | String |
| objectKeyPath | Yes | JSON path to the unique identifier within the object to be stored | String |

## Function type

| Type | Description |
| ---- | ----------------------------------------------------------------- |
| Void | Performs an operation without returning any data after execution. |
Loading
Loading