diff --git a/importApp/src/components/FieldInput.js b/importApp/src/components/FieldInput.js
index 9306f2e8..b51ceb2d 100644
--- a/importApp/src/components/FieldInput.js
+++ b/importApp/src/components/FieldInput.js
@@ -12,7 +12,6 @@ import {
Control,
Input,
Help,
- Select as SimpleSelect
} from 'design-workshop'
@@ -37,7 +36,7 @@ class FieldInput extends React.Component {
let options;
if (fieldSchema.constraints && fieldSchema.constraints.enum) {
- options = getEnumOptions(fieldSchema.constraints.enum, fieldSchema.constraints.required)
+ options = getEnumOptions(fieldSchema.constraints.enum)
}
return {
fieldSchema,
@@ -165,15 +164,10 @@ class FieldInput extends React.Component {
}
else if (fieldSchema.constraints && fieldSchema.constraints.enum) {
return (
-
- {
- this.state.options.map((item, index) => {
- return (
-
- )
- })
- }
-
+
)
}
else {
diff --git a/importApp/src/components/ReferenceResourceForm.js b/importApp/src/components/ReferenceResourceForm.js
index 05f96d76..8fd0306b 100644
--- a/importApp/src/components/ReferenceResourceForm.js
+++ b/importApp/src/components/ReferenceResourceForm.js
@@ -1,7 +1,7 @@
import React from 'react';
import {Table} from 'tableschema';
-import {keys, values, mapValues, capitalize, pick} from 'lodash';
+import {keys, values, mapValues, capitalize, trim, pick, sortBy} from 'lodash';
import {
Button,
@@ -31,10 +31,7 @@ class ReferenceResourceForm extends React.Component {
const newResource = schema.fields.reduce((res, field) => {
let value = '';
let valid = true;
- if (field.constraints && field.constraints.enum) {
- const enumList = field.constraints.enum
- value = enumList[0]
- }
+
if (field.constraints && field.constraints.required && !field.constraints.enum ) {
valid = false
}
@@ -248,7 +245,8 @@ class ReferenceResourceForm extends React.Component {
New row to "{resourceDescriptor.name}" table
{
- schema.fields.map((field, index) => {
+ sortBy(schema.fields, (field) => field.constraints && field.constraints.required)
+ .map((field, index) => {
return (
{
+export const getEnumOptions = (enumList) => {
const options = enumList.map((e) => {
return {
label: e,
value: e
}
})
- if (!required) {
- options.unshift({
- value: '',
- label: 'none'
- })
- }
return options
}