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

feat: UILD-409: Write installation documentation for ui-linked-data module #44

Merged
merged 3 commits into from
Dec 2, 2024
Merged
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
57 changes: 37 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# @folio/linked-data

s3fs marked this conversation as resolved.
Show resolved Hide resolved
This project is a new MARVA editor.
© 2024 EBSCO Information Services.

This software is distributed under the terms of the Apache License, Version 2.0. See the file "[LICENSE](LICENSE)" for more information.

## Introduction
UI application designed for performing operations on a library's linked data graph. This application can run standalone outside of the FOLIO platform. The [ui-ld-folio-wrapper](https://github.com/folio-org/ui-ld-folio-wrapper) module integrates this application for use within FOLIO.

## Table of Contents

Expand All @@ -24,39 +29,45 @@ or Yarn:
yarn install
```

### 2. Provide API config:

#### a) For an external API:
### 2. Configure the application:

Create a JSON object with required data, then use it in such cases:
s3fs marked this conversation as resolved.
Show resolved Hide resolved

- For development or using MARVA as a standalone application, in a browser's localstorage create a record with a key `okapi_config` and stringified JSON value (see "JSON config example");
- For development or using Linked data as a standalone application, in a browser's localstorage create a record with a key `okapi_config` and stringified JSON value (see "JSON config example");

- For an embedded application:
Use JSON in the `config` attribute, see [Usage](#usage) section.

###### JSON config example:
###### Configuration options:
* `basePath`: Backend URI to which requests from the frontend are going to be directed.
* `tenant`: Okapi tenant.
* `token`: Okapi token.
* `customEvents`: A dictionary with custom event names. The keys of this dictionary have to be specific while the values can be arbitrary but unique. Events are used to communicate between this application and its container when running in embedded mode.
* `TRIGGER_MODAL`: Root application can dispatch this event to open a prompt in Linked data application which will inform a user about unsaved changes before leaving an Edit or Create page.
* `PROCEED_NAVIGATION`: Linked data application dispatches this event when a user clicks in the prompt "Save and continue" button or closes the prompt.
* `BLOCK_NAVIGATION`: Linked data application dispatches this event when user makes changes in a work form ("Create" or "Edit" page).
* `UNBLOCK_NAVIGATION`: Root application can dispatch this event to allow Linked data to proceed its navigation after it's been blocked.
* `NAVIGATE_TO_ORIGIN`: Linked data application dispatches this event when there is a need to navigate to the entrypoint from where the navigation to the Linked data application happened.
* `DROP_NAVIGATE_TO_ORIGIN`: Linked data application dispatches this event when there is no longer a need to navigate to the entrypoint from where the navigation to the Linked data application happened. Subsequent `NAVIGATE_TO_ORIGIN` calls have no effect unless a new navigation origin is set within the root application.

###### Configuration example:

```json
{
"basePath": "YOUR_API_URI",
"tenant": "YOUR_TENANT",
"token": "YOUR_TOKEN",
// For embedded application only. Events also should be dispatched or listened in the root application.
"customEvents": {
"TRIGGER_MODAL": "triggermodal", // Root application can dispatch this event to open a prompt in MARVA which will inform a user about unsaved changes before leaving an Edit or Create page.
"PROCEED_NAVIGATION": "proceednavigation", // MARVA dispatches this event when a user clicks in the prompt "Save and continue" button or closes the prompt.
"BLOCK_NAVIGATION": "blocknavigation" // MARVA dispatches this event when user makes changes in a work form ("Create" or "Edit" page).
"TRIGGER_MODAL": "TRIGGER_MODAL",
"PROCEED_NAVIGATION": "PROCEED_NAVIGATION",
"BLOCK_NAVIGATION": "BLOCK_NAVIGATION",
"UNBLOCK_NAVIGATION": "UNBLOCK_NAVIGATION",
"NAVIGATE_TO_ORIGIN": "NAVIGATE_TO_ORIGIN",
"DROP_NAVIGATE_TO_ORIGIN": "DROP_NAVIGATE_TO_ORIGIN"
}
}
```
s3fs marked this conversation as resolved.
Show resolved Hide resolved

#### b) For an opened API (e.g. locally started. Can be used for development purposes):

1. Rename `.env` file to `.env.local`.

2. In that file change `EDITOR_API_BASE_PATH` variable's value.

## Scripts

The following scripts are available:
Expand Down Expand Up @@ -85,13 +96,19 @@ The following scripts are available:
1. Build the code as an embedded application using `npm run build:lib` command. The built code will be placed in `./dist` folder.
2. Add the script on a page:

```html
<script src="[PATH_TO_SCRIPT]/linked-data.es.js"></script>
```
1. As a package in the files where you plan to use the application if it was added to your project via package management tools:
```js
import '@folio/linked-data';
```
2. Or as a script:
```html
<script src="[PATH_TO_SCRIPT]/linked-data.es.js"></script>
```


3. Add a web component in the required HTML container on the page.

Use a config with a required API config for passing it in the MARVA application through the web component (see JSON config example in [Installation](#installation) section):
Use a config with a required API config for passing it in the Linked data application through the web component (see JSON config example in [Installation](#installation) section):

```html
<div id="linked-data-container">
Expand Down
Loading