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

Get SchemaWidget field factories from backend #2651

Merged
merged 3 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Internal

- Get SchemaWidget field factories from backend @avoinea

## 13.13.0 (2021-09-01)

### Feature
Expand Down
22 changes: 7 additions & 15 deletions src/components/manage/Widgets/SchemaWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,7 @@ const messages = defineMessages({
});

/**
* Makes a list of field types formated for select widget
* @param {Object[]} listOfTypes array of strings
* @param {*} intl
* @returns {Object[]} example [['text', 'text']]
*/
const makeFieldTypes = (listOfTypes, intl) => {
const result = listOfTypes.map((type) => [type.title, type.title]);
return result;
};

/**
* Makes a list of fieldset types formated for select widget
* Makes a list of fieldset types formatted for select widget
* @param {Object[]} listOfTypes array of strings
* @param {*} intl
* @returns {Object[]} example [['default', 'default']]
Expand Down Expand Up @@ -327,7 +316,7 @@ const getItemStyle = (isDragging, draggableStyle) => ({
// change background colour if dragging
background: isDragging ? 'white' : 'transparent',

// styles we need to apply on draggables
// styles we need to apply on draggable
...draggableStyle,
});

Expand Down Expand Up @@ -1081,7 +1070,7 @@ class SchemaWidget extends Component {
const lastUserCreatedFieldsIndex = hasChangeNote
? this.props.value.fieldsets[this.state.currentFieldset].fields.length - 1
: this.props.value.fieldsets[this.state.currentFieldset].fields.length;
// fields that were not created by the user, but are part of a behaviour
// fields that were not created by the user, but are part of a behavior
const makeNonUserFields = () =>
map(
this.props.value.fieldsets[this.state.currentFieldset].fields.slice(
Expand Down Expand Up @@ -1311,8 +1300,11 @@ class SchemaWidget extends Component {
properties: {
factory: {
type: 'string',
factory: 'Choice',
title: this.props.intl.formatMessage(messages.type),
choices: makeFieldTypes(vocabularyFields?.items),
vocabulary: {
'@id': `Fields`,
},
},
title: {
type: 'string',
Expand Down