-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
13 changed files
with
249 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"name" | ||
], | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"title": "label.bundle-name", | ||
"description": "tooltip.bundle-name", | ||
"minLength": 1, | ||
"maxLength": 255 | ||
}, | ||
"attributes": { | ||
"type": "array", | ||
"title": "label.attributes", | ||
"description": "Attribute table - select the attributes you want to bundle (default unchecked)", | ||
"items": { | ||
"type": "string", | ||
"enum": [ | ||
"eduPersonPrincipalName", | ||
"uid", | ||
"mail", | ||
"surname", | ||
"givenName", | ||
"eduPersonAffiliation", | ||
"eduPersonScopedAffiliation", | ||
"eduPersonPrimaryAffiliation", | ||
"eduPersonEntitlement", | ||
"eduPersonAssurance", | ||
"eduPersonUniqueId", | ||
"employeeNumber" | ||
] | ||
}, | ||
"uniqueItems": true | ||
} | ||
} | ||
} |
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,38 @@ | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"name" | ||
], | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"title": "label.bundle-name", | ||
"description": "tooltip.bundle-name", | ||
"minLength": 1, | ||
"maxLength": 255 | ||
}, | ||
"attributes": { | ||
"type": "array", | ||
"title": "label.attributes", | ||
"description": "Attribute table - select the attributes you want to bundle (default unchecked)", | ||
"items": { | ||
"type": "string", | ||
"enum": [ | ||
"eduPersonPrincipalName", | ||
"uid", | ||
"mail", | ||
"surname", | ||
"givenName", | ||
"eduPersonAffiliation", | ||
"eduPersonScopedAffiliation", | ||
"eduPersonPrimaryAffiliation", | ||
"eduPersonEntitlement", | ||
"eduPersonAssurance", | ||
"eduPersonUniqueId", | ||
"employeeNumber" | ||
] | ||
}, | ||
"uniqueItems": true | ||
} | ||
} | ||
} |
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
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,56 @@ | ||
import React from 'react'; | ||
import { MetadataFormContext, setFormDataAction, setFormErrorAction } from '../hoc/MetadataFormContext'; | ||
import { MetadataDefinitionContext, MetadataSchemaContext } from '../hoc/MetadataSchema'; | ||
import { transformErrors } from '../domain/transform'; | ||
|
||
import Form from '@rjsf/bootstrap-4'; | ||
|
||
import { fields, widgets } from '../../form/component'; | ||
import { templates } from '../../form/component'; | ||
|
||
function ErrorListTemplate() { | ||
return (<></>); | ||
} | ||
|
||
export function AttributeBundleEditor({ children }) { | ||
|
||
const definition = React.useContext(MetadataDefinitionContext); | ||
const schema = React.useContext(MetadataSchemaContext); | ||
|
||
const { state, dispatch } = React.useContext(MetadataFormContext); | ||
const { metadata, errors } = state; | ||
|
||
const onChange = (changes) => { | ||
dispatch(setFormDataAction(changes.formData)); | ||
dispatch(setFormErrorAction(changes.errors)); | ||
// setBlocking(true); | ||
}; | ||
|
||
return ( | ||
<div className="container-fluid"> | ||
<div className="d-flex justify-content-end align-items-center"> | ||
{children(metadata, errors)} | ||
</div> | ||
<hr /> | ||
<div className="row"> | ||
<div className="col-12 col-lg-12 order-2"> | ||
<Form formData={metadata} | ||
noHtml5Validate={true} | ||
onChange={(form) => onChange(form)} | ||
schema={schema} | ||
uiSchema={definition.uiSchema} | ||
FieldTemplate={templates.FieldTemplate} | ||
ObjectFieldTemplate={templates.ObjectFieldTemplate} | ||
ArrayFieldTemplate={templates.ArrayFieldTemplate} | ||
fields={fields} | ||
widgets={widgets} | ||
liveValidate={true} | ||
ErrorList={ErrorListTemplate} | ||
transformErrors={transformErrors}> | ||
<></> | ||
</Form> | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react'; | ||
import { faSave, faSpinner } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import Button from 'react-bootstrap/Button'; | ||
|
||
import { Prompt, useHistory } from 'react-router'; | ||
import Translate from '../../i18n/components/translate'; | ||
|
||
import { AttributeBundleDefinition } from '../domain/attribute/AttributeBundleDefinition'; | ||
import MetadataSchema from '../hoc/MetadataSchema'; | ||
import { MetadataForm } from '../hoc/MetadataFormContext'; | ||
import { AttributeBundleEditor } from '../editor/AttributeBundleEditor'; | ||
import { AttributeBundleApi } from '../hoc/attribute/AttributeBundleApi'; | ||
|
||
export function NewBundle() { | ||
const history = useHistory(); | ||
|
||
console.log('hi') | ||
|
||
const definition = AttributeBundleDefinition; | ||
|
||
const [blocking, setBlocking] = React.useState(false); | ||
|
||
const cancel = () => { | ||
gotoDetail(); | ||
}; | ||
|
||
const gotoDetail = (state = null) => { | ||
setBlocking(false); | ||
history.push(`/metadata/attributes/bundles`, state); | ||
}; | ||
|
||
return ( | ||
<AttributeBundleApi> | ||
{(load, find, create, update, remove, loading) => | ||
<div className="container-fluid p-3"> | ||
<Prompt | ||
when={blocking} | ||
message={location => | ||
`message.unsaved-editor` | ||
} | ||
/> | ||
<section className="section" tabIndex="0"> | ||
<div className="section-header bg-info p-2 text-white"> | ||
<div className="row justify-content-between"> | ||
<div className="col-md-12"> | ||
<span className="display-6"><Translate value="label.new-attribute-bundle">Add a new attribute bundle</Translate></span> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="section-body p-4 border border-top-0 border-info"> | ||
<MetadataSchema type={AttributeBundleDefinition}> | ||
<MetadataForm> | ||
<AttributeBundleEditor definition={definition}> | ||
{(bundle, errors) => | ||
<React.Fragment> | ||
<Button variant="info" className="mr-2" | ||
type="button" | ||
onClick={() => create(bundle)} | ||
disabled={errors.length > 0 || loading} | ||
aria-label="Save changes to the metadata source. You will return to the dashboard"> | ||
<FontAwesomeIcon icon={loading ? faSpinner : faSave} pulse={loading} /> | ||
<Translate value="action.save">Save</Translate> | ||
</Button> | ||
<Button variant="secondary" | ||
type="button" | ||
onClick={() => cancel()} aria-label="Cancel changes, go back to dashboard"> | ||
<Translate value="action.cancel">Cancel</Translate> | ||
</Button> | ||
</React.Fragment> | ||
} | ||
</AttributeBundleEditor> | ||
</MetadataForm> | ||
</MetadataSchema> | ||
</div> | ||
</section> | ||
</div> | ||
} | ||
</AttributeBundleApi> | ||
); | ||
} |
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
Oops, something went wrong.