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