-
-
Notifications
You must be signed in to change notification settings - Fork 33
Related items module #191
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
Open
timio23
wants to merge
37
commits into
directus-labs:main
Choose a base branch
from
timio23:related-items-module
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Related items module #191
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
37e482d
initial upload
timio23 a935ad3
Merge branch 'directus-labs:main' into related-items-module
timio23 9ad0bff
Update pnpm-lock.yaml
timio23 01bb86f
added API reference to README
timio23 c52adec
Merge branch 'main' into related-items-module
ukmadlz 7383cd1
moved admin check to index
timio23 0389ccc
removed comments
timio23 593d392
added keywords and authors
timio23 7c4f324
updated Directus minimum version
timio23 e1dd62f
hide Label on interface
timio23 8d36e8a
settings field full width
timio23 081f6bf
removed special parameter
timio23 307aaab
datetime improvements on mobile
timio23 d1182ea
graceful errors for hook
timio23 2e08ae8
added support for junction tables
timio23 54fd668
notification on item update and stop self editing
timio23 56498a6
special parameters required
timio23 f1b73db
eslint changes
timio23 1ddabc9
Merge branch 'related-items-module' of https://github.com/timio23/ext…
timio23 1ec0c25
Merge branch 'main' into related-items-module
timio23 0c5d22e
moved author and contributors - linting
timio23 76d0e1f
Merge branch 'related-items-module' of https://github.com/timio23/ext…
timio23 80efe62
another linting error
timio23 8f854e9
try catch on endpoint
timio23 e9e66e3
Improve icon color
timio23 5a0847a
Improve v-chip hover styling
timio23 26457df
nullified related items ID bug fix
timio23 4d2234b
Added label to template
timio23 c182749
Show notice when creating new item
timio23 959293c
Make label persistant
timio23 000bdc6
fixed text alignment
timio23 af449a5
remove duplicate items
timio23 a88c97f
hydrate fields after saving settings
timio23 38aa2c4
added systen-data dependancy
timio23 996afab
linting fixes
timio23 39d324c
Update pnpm-lock.yaml
timio23 33f58f5
Merge branch 'main' into related-items-module
timio23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,80 @@ | ||
# Related Items Bundle | ||
|
||
Find all collections, fields or items related to a collection even if it doesn't include the reverse fields from the supported relationships: Many to One (m2o), One to Many (o2m), Many to Many (m2m) or Many to Any (m2a). | ||
|
||
 | ||
|
||
You can include system collections such as Users and Files and benefit from seeing all the relations to other collections. For example, when viewing a file in the File Library, you will see what collections and items reference the file and know what will be impacted if it is edited or deleted. | ||
|
||
## Usage | ||
|
||
Once installed and configured, visit an item for an included collection and scroll to the bottom of the page. By default, all related items are returned with pagination over 10 records. Use the collection filters at the top to easily see the related items in that collection. | ||
|
||
Click on an item to open the draw for more information or make changes to that item. However, some system tables are not supported. | ||
|
||
## Requirements | ||
|
||
- Directus 11.1.2+ | ||
- Admin user to initialize module | ||
|
||
## Installation | ||
|
||
Refer to the Official Guide for details on installing the extension from the Marketplace or manually. | ||
|
||
## How to configure this module | ||
|
||
1. Using an Admin user, go to the project settings `/admin/settings/project` and scroll to the bottom | ||
2. Click on the field labelled "Related Items Collections" | ||
3. Tick the collections to include from the dropdown field | ||
4. Save changes | ||
|
||
When opening the project settings for the first time, the module will automatically add the new system field at the bottom of the page. Any selection of the collections will create a new alias field within that collection's Data model. The new interface can be repositioned or customized but any changes to these fields will be lost if you choose to exclude the collection in future. Admin permissions are required during these steps. | ||
|
||
## Permissions | ||
|
||
This extension uses the current user's policy/role permissions and will only show the permitted data. Please refer to your Access Policies to ensure your users have required access. | ||
|
||
## API Reference | ||
|
||
This bundle contains an endpoint extension. The data can be queried using the following endpoint: | ||
|
||
``` | ||
GET /related-items/<collection>/<item_id> | ||
``` | ||
|
||
The response will be an array of related collections and for each one, a secondary array of any related items from that collection. For example: | ||
|
||
``` | ||
{ | ||
"collection": "directus_files", | ||
"fields": [ | ||
"directus_files_id.id", | ||
"directus_files_id.title", | ||
"directus_files_id.type" | ||
], | ||
"relation": "m2m", | ||
"translations": null, | ||
"field": "article_id", | ||
"junction_field": "directus_files_id", | ||
"primary_key": "id", | ||
"template": "{{ title }}", | ||
"items": [ | ||
{ | ||
"directus_files_id": { | ||
"id": "x0x1234x-5xx6-7890-x123-xxx4xx56789x", | ||
"title": "Annual Leave Policy", | ||
"type": "image/jpeg" | ||
} | ||
}, | ||
{ | ||
"directus_files_id": { | ||
"id": "x9x8765x-5xx6-7890-x123-xxx4xx56789x", | ||
"title": "Brand Guidelines", | ||
"type": "image/png" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
_Note: The fields and primary key can be used as context when processing the items or rendering an output._ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,81 @@ | ||
{ | ||
"name": "@directus-labs/related-items-bundle", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"description": "Show all related items across selected collections.", | ||
"author": "Directus Labs", | ||
"contributors": [ | ||
{ | ||
"name": "Tim Butterfield", | ||
"email": "[email protected]", | ||
"url": "https://www.npmjs.com/~timio23" | ||
} | ||
], | ||
"license": "MIT", | ||
"keywords": [ | ||
"directus", | ||
"directus-extension", | ||
"directus-extension-bundle", | ||
"relational", | ||
"m2o", | ||
"m2m", | ||
"o2m", | ||
"m2a" | ||
], | ||
"icon": "extension", | ||
"files": [ | ||
"dist" | ||
], | ||
"directus:extension": { | ||
"type": "bundle", | ||
"path": { | ||
"app": "dist/app.js", | ||
"api": "dist/api.js" | ||
}, | ||
"entries": [ | ||
{ | ||
"type": "module", | ||
"name": "related-items-module", | ||
"source": "src/related-items-module/index.ts" | ||
}, | ||
{ | ||
"type": "endpoint", | ||
"name": "related-items-endpoint", | ||
"source": "src/related-items-endpoint/index.ts" | ||
}, | ||
{ | ||
"type": "interface", | ||
"name": "related-items-interface", | ||
"source": "src/related-items-interface/index.ts" | ||
}, | ||
{ | ||
"type": "hook", | ||
"name": "related-items-hook", | ||
"source": "src/related-items-hook/index.ts" | ||
} | ||
], | ||
"host": "^11.1.2" | ||
timio23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"scripts": { | ||
"build": "directus-extension build", | ||
"dev": "directus-extension build -w --no-minify", | ||
"link": "directus-extension link", | ||
"add": "directus-extension add", | ||
"validate": "directus-extension validate" | ||
}, | ||
"dependencies": { | ||
"@directus/eslint-config": "^0.1.0", | ||
"@directus/format-title": "^12.0.1", | ||
"@directus/system-data": "^3.1.0", | ||
"vue-i18n": "^9.14.0", | ||
"vue-router": "^4.4.5" | ||
}, | ||
"devDependencies": { | ||
"@directus/constants": "^13.0.0", | ||
"@directus/extensions-sdk": "^13.0.1", | ||
"@directus/types": "^13.0.0", | ||
"@directus/utils": "^13.0.0", | ||
"typescript": "^5.6.3", | ||
"vue": "^3.5.13" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.