-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
450b5ea
commit 2e37e54
Showing
8 changed files
with
167 additions
and
0 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
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,48 @@ | ||
import { Meta, Story } from "@storybook/addon-docs"; | ||
import { ContentBrowser } from "./contentbrowser.stories.js"; | ||
|
||
<Meta title="Patterns/ContentBrowser" /> | ||
|
||
# Contentbrowser | ||
|
||
Show a widget to select items in an offcanvas miller-column browser. | ||
|
||
## Configuration | ||
|
||
```md | ||
| Option | Type | Default | Description | | ||
| :------------------: | :-----: | :-------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------: | | ||
| vocabularyUrl | string | null | This is a URL to a JSON-formatted file used to populate the list | | ||
| attributes | array | ['UID', 'Title', 'portal_type', 'path'] | This list is passed to the server during an AJAX request to specify the attributes which should be included on each item. | | ||
| rootPath | string | "/" | Browsing/searching root path. You will not get beneath this path | | ||
| rootUrl | string | | Browsing/searching root url. | | ||
| basePath | string | set to rootPath. | Start browse/search in this path. | | ||
| contextPath | string | | Path of the object, which is currently edited. If this path is given, this object will not be selectable. | | ||
| favorites | array | [] | Array of objects. These are favorites, which can be used to quickly jump to different locations. Objects have the attributes "title" and "path". | | ||
| maximumSelectionSize | integer | -1 | The maximum number of items that can be selected in a multi-select control. If this number is less than 1 selection is not limited. | | ||
| mode | string | "browse" | Toggle between "browse" and "search" | | ||
| width | integer | | Override the width of the selected items field | | ||
| bSize | integer | 10 | Batch size of the items listed in levels | | ||
| maxDepth | integer | | Maximum level depth for "browse" mode | | ||
| separator | string | ',' | Select2 option. String which separates multiple items. | | ||
| upload | boolean | | Allow file and image uploads from within the related items widget. | | ||
| recentlyUsed | boolean | false | Show the recently used items dropdown. | | ||
| recentlyUsedKey | integer | | Storage key for saving the recently used items. This is generated with fieldname and username in the patternoptions. | | ||
| recentlyUsedMaxItems | integer | 20 | Maximum items to keep in recently used list. 0: no restriction. | | ||
| customComponentKeys | dict | {} | Register custom components. Currently only "SelectedItem" implemented | | ||
``` | ||
|
||
## Examples | ||
|
||
### Simple | ||
|
||
<br /> | ||
<Story name="Content Browser" of={ContentBrowser} /> | ||
|
||
```html | ||
<input | ||
type="text" | ||
class="pat-contentbrowser" | ||
data-pat-contentbrowser='{"selectableTypes": ["Document"], "vocabularyUrl": "contentbrowser-test.json"}' | ||
/> | ||
``` |
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,45 @@ | ||
import $ from "jquery"; | ||
import { RenderHTML } from "../../../.storybook/setup.js"; | ||
import ContentBrowserComponent from "./contentbrowser.js"; | ||
|
||
export default { | ||
title: "Patterns/ContentBrowser", | ||
parameters: { | ||
mockData: [ | ||
{ | ||
url: "/contentbrowser-test.json", // Fake API URL | ||
method: "GET", | ||
status: 200, | ||
response: { | ||
items: [ | ||
{ | ||
UID: "1234", | ||
Title: "Example Document", | ||
path: "/example-document", | ||
}, | ||
{ UID: "5678", Title: "Another Item", path: "/another-item" }, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
// Basic Contentbrowser | ||
const getContentBrowser = (args) => ` | ||
<input | ||
type="text" | ||
class="pat-contentbrowser" | ||
data-pat-contentbrowser='{"vocabularyUrl": "${args.vocabularyUrl}"}' | ||
/> | ||
`; | ||
|
||
// TODO: | ||
// Story for this component: error Invalid URL | ||
// Check svelte components mocks ? | ||
export const ContentBrowser = { | ||
render: (args) => RenderHTML(args, getContentBrowser), | ||
args: { | ||
vocabularyUrl: "/contentbrowser-test.json", | ||
}, | ||
}; |
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,17 @@ | ||
console.log("Using App:", import.meta.url); | ||
|
||
// TODO: | ||
// How to prevent App.svelte from running ? | ||
// both mock and real App.svelte are running rn | ||
if (typeof window !== "undefined") { | ||
console.log({ aqui: window.ContentBrowserApp }); | ||
window.ContentBrowserApp = "alala"; | ||
console.log({ aqui: window.ContentBrowserApp }); | ||
} | ||
|
||
export default function MockContentBrowserApp({ target, props }) { | ||
console.log("MockSelectedItem initialized with", props); | ||
target.innerHTML = `<div style="border: 2px solid blue; padding: 10px;"> | ||
Mocked Content Browser App | ||
</div>`; | ||
} |
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,6 @@ | ||
export default function MockSelectedItem({ target, props }) { | ||
console.log("MockSelectedItem initialized with", props); | ||
target.innerHTML = `<div style="border: 2px solid blue; padding: 10px;"> | ||
Mocked Selected Item | ||
</div>`; | ||
} |