From eab772f26cc7dfb7a8fb87c21052856d6e6901c9 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 23 Apr 2019 16:30:16 +0200 Subject: [PATCH] prototype metadata edit mode --- .../routes/Details/AssetDetails.module.scss | 18 +++ client/src/routes/Details/AssetDetails.tsx | 109 ++++++++++++++++-- 2 files changed, 115 insertions(+), 12 deletions(-) diff --git a/client/src/routes/Details/AssetDetails.module.scss b/client/src/routes/Details/AssetDetails.module.scss index de65a0c..c9a9663 100644 --- a/client/src/routes/Details/AssetDetails.module.scss +++ b/client/src/routes/Details/AssetDetails.module.scss @@ -93,3 +93,21 @@ width: 70%; } } + +.metadataActions { + text-align: right; + + button { + font-size: $font-size-small; + margin-left: $spacer; + + &:not(:first-child) { + color: $brand-grey-light; + + &:hover, + &:focus { + color: $brand-pink; + } + } + } +} diff --git a/client/src/routes/Details/AssetDetails.tsx b/client/src/routes/Details/AssetDetails.tsx index 655cd9c..9768404 100644 --- a/client/src/routes/Details/AssetDetails.tsx +++ b/client/src/routes/Details/AssetDetails.tsx @@ -1,16 +1,60 @@ -import React, { PureComponent } from 'react' +import React, { PureComponent, ChangeEvent } from 'react' import { Link } from 'react-router-dom' import Moment from 'react-moment' import { DDO, MetaData, File } from '@oceanprotocol/squid' +import Input from '../../components/atoms/Form/Input' import Markdown from '../../components/atoms/Markdown' import styles from './AssetDetails.module.scss' import AssetFilesDetails from './AssetFilesDetails' +import Button from '../../components/atoms/Button' + +const { steps } = require('../../data/form-publish.json') // eslint-disable-line interface AssetDetailsProps { metadata: MetaData ddo: DDO } +interface AssetDetailsState { + isEditMode?: boolean + isLoading?: boolean + dateCreated?: string + description?: string + copyrightHolder?: string + categories?: string +} + +export default class AssetDetails extends PureComponent< + AssetDetailsProps, + AssetDetailsState +> { + public state = { + isEditMode: false, + isLoading: false + } + + private inputChange = ( + event: ChangeEvent | ChangeEvent + ) => { + this.setState({ + [event.currentTarget.name]: event.currentTarget.value + }) + } + + private toggleEditMode = () => { + this.setState({ isEditMode: !this.state.isEditMode }) + } + + private updateAsset = () => { + this.setState({ isLoading: true }) + // TODO: update asset metadata + } + + private retireAsset = () => { + this.setState({ isLoading: true }) + // TODO: retire asset + } + export function datafilesLine(files: File[]) { if (files.length === 1) { return {files.length} data file @@ -45,24 +89,69 @@ export default class AssetDetails extends PureComponent { /> - {base.categories && ( - // TODO: Make this link to search for respective category - - {base.categories[0]} - - )} + {base.categories && + (this.state.isEditMode ? ( + + ) : ( + // TODO: Make this link to search for respective category + + {base.categories[0]} + + ))} {base.files && datafilesLine(base.files)} - {base.description && ( + {this.state.isEditMode ? ( + + ) : ( )} +
+ {this.state.isEditMode ? ( + + ) : ( + <> + + + + + )} +
+
  • @@ -90,10 +179,6 @@ export default class AssetDetails extends PureComponent { files={base.files ? base.files : []} ddo={ddo} /> - - {/*
    -                    {JSON.stringify(metadata, null, 2)}
    -                
    */} ) }