mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
categories error fix, files adding validation, files removing
This commit is contained in:
parent
2f4d4ac93a
commit
5046ccf0f2
@ -1,10 +1,11 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import React, { PureComponent, ChangeEvent } from 'react'
|
||||
import { CSSTransition, TransitionGroup } from 'react-transition-group'
|
||||
import Button from '../../../components/atoms/Button'
|
||||
import Help from '../../../components/atoms/Form/Help'
|
||||
import ItemForm from './ItemForm'
|
||||
import Item from './Item'
|
||||
import styles from './index.module.scss'
|
||||
import { Logger } from '@oceanprotocol/squid';
|
||||
|
||||
interface FilesProps {
|
||||
files: any[]
|
||||
@ -32,12 +33,26 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
||||
|
||||
public addItem = (value: string) => {
|
||||
this.props.files.push({ url: value })
|
||||
// this.props.resetForm()
|
||||
const event = {
|
||||
currentTarget: {
|
||||
name: 'files',
|
||||
value: this.props.files
|
||||
}
|
||||
}
|
||||
this.props.onChange(event as any)
|
||||
this.setState({ isFormShown: !this.state.isFormShown })
|
||||
}
|
||||
|
||||
public removeItem = (index: number) => {
|
||||
this.props.files.splice(index, 1)
|
||||
const event = {
|
||||
currentTarget: {
|
||||
name: 'files',
|
||||
value: this.props.files
|
||||
}
|
||||
}
|
||||
this.props.onChange(event as any)
|
||||
this.forceUpdate()
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
@ -91,7 +91,7 @@ export default class Step extends PureComponent<StepProps, {}> {
|
||||
Object.entries(fields).map(([key, value]) => {
|
||||
let onChange = inputChange
|
||||
|
||||
if (key === 'files' || key === 'categories') {
|
||||
if (key === 'categories') {
|
||||
onChange = inputToArrayChange
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ interface PublishState {
|
||||
type?: AssetType
|
||||
license?: string
|
||||
copyrightHolder?: string
|
||||
categories?: string[]
|
||||
categories?: string
|
||||
tags?: string[]
|
||||
isPublishing?: boolean
|
||||
isPublished?: boolean
|
||||
@ -43,7 +43,7 @@ class Publish extends Component<{}, PublishState> {
|
||||
type: 'dataset' as AssetType,
|
||||
license: '',
|
||||
copyrightHolder: '',
|
||||
categories: [],
|
||||
categories: '',
|
||||
isPublishing: false,
|
||||
isPublished: false,
|
||||
publishedDid: '',
|
||||
@ -110,7 +110,7 @@ class Publish extends Component<{}, PublishState> {
|
||||
type: 'dataset' as AssetType,
|
||||
license: '',
|
||||
copyrightHolder: '',
|
||||
categories: [],
|
||||
categories: '',
|
||||
isPublishing: false,
|
||||
isPublished: false,
|
||||
currentStep: 1
|
||||
@ -159,10 +159,7 @@ class Publish extends Component<{}, PublishState> {
|
||||
//
|
||||
// Step 1
|
||||
//
|
||||
// TODO: also validate files with validationStatus[1].files here,
|
||||
// change event for hidden file input is not working
|
||||
//
|
||||
if (validationStatus[1].name) {
|
||||
if (validationStatus[1].name && validationStatus[1].files) {
|
||||
this.setState(prevState => ({
|
||||
validationStatus: {
|
||||
...prevState.validationStatus,
|
||||
@ -174,14 +171,9 @@ class Publish extends Component<{}, PublishState> {
|
||||
}))
|
||||
}
|
||||
|
||||
// console.log(validationStatus[1])
|
||||
|
||||
//
|
||||
// Step 2
|
||||
//
|
||||
// TODO: validationStatus[2].categories is not working,
|
||||
// select change event is not firing
|
||||
//
|
||||
if (validationStatus[2].description && validationStatus[2].categories) {
|
||||
this.setState(prevState => ({
|
||||
validationStatus: {
|
||||
@ -194,14 +186,9 @@ class Publish extends Component<{}, PublishState> {
|
||||
}))
|
||||
}
|
||||
|
||||
// console.log(validationStatus[2])
|
||||
|
||||
//
|
||||
// Step 3
|
||||
//
|
||||
// TODO: validationStatus[3].license is not working,
|
||||
// select change event is not firing
|
||||
//
|
||||
if (
|
||||
validationStatus[3].author &&
|
||||
validationStatus[3].copyrightHolder &&
|
||||
@ -217,8 +204,6 @@ class Publish extends Component<{}, PublishState> {
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
// console.log(validationStatus[3])
|
||||
}
|
||||
|
||||
private registerAsset = async (event: FormEvent<HTMLFormElement>) => {
|
||||
|
Loading…
Reference in New Issue
Block a user