Skip to content

Commit

Permalink
Merge pull request #114 from oarepo/mirekys/add-form-files
Browse files Browse the repository at this point in the history
Add files data to forms
  • Loading branch information
mirekys authored Dec 4, 2023
2 parents 75dd68d + 5580c0f commit b9543f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions oarepo_ui/templates/EditForm.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
{%- if permissions %}
<input id="record-permissions" type="hidden" name="record-permissions" value='{{permissions | tojson }}' />
{%- endif %}
{%- if extra_context.get('files') %}
<input id="files" type="hidden" name="files" value='{{extra_context.files | tojson }}' />
{%- endif %}
<input id="links" type="hidden" name="links" value='{{ui_links | tojson }}' />
<div id="form-app"></div>
{%- endblock form_main_content -%}
Expand Down
7 changes: 5 additions & 2 deletions oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Overridable, {
*/

const queryClient = new QueryClient();
export function createFormAppInit(
export function createFormAppInit (
defaultComponents,
autoInit = true,
ContainerComponent = React.Fragment
Expand All @@ -30,6 +30,7 @@ export function createFormAppInit(
const record = getInputFromDOM("record");
const formConfig = getInputFromDOM("form-config");
const recordPermissions = getInputFromDOM("record-permissions");
const files = getInputFromDOM('files');
const links = getInputFromDOM("links");

console.debug("Initializing Formik form app...");
Expand All @@ -40,6 +41,8 @@ export function createFormAppInit(
formConfig,
"\n[recordPermissions]",
recordPermissions,
"\n[files]",
files,
"\n[UI links]",
links
);
Expand All @@ -51,7 +54,7 @@ export function createFormAppInit(
<Router>
<OverridableContext.Provider value={overrideStore.getAll()}>
<FormConfigProvider
value={{ record, formConfig, recordPermissions, links }}
value={{ record, formConfig, recordPermissions, files, links }}
>
<Overridable id="FormApp.layout">
<Container fluid>
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-ui
version = 5.0.87
version = 5.0.88
description = UI module for invenio 3.5+
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit b9543f8

Please sign in to comment.