From 27b7b72a576f1e47dcfee4ca499b900a6e5ac4d7 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Tue, 16 Mar 2021 19:02:11 +0000 Subject: [PATCH] Improve data netry list UI for new entry --- .../multi-data-entry/multi-data-entry.tsx | 95 +++++++++++-------- .../dynamics/dynamics-data-entry.tsx | 5 +- app/src/frontend/building/sidebar.css | 8 +- app/src/frontend/styles/forms.css | 4 +- 4 files changed, 64 insertions(+), 48 deletions(-) diff --git a/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx b/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx index 3614e642..50e38742 100644 --- a/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx +++ b/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx @@ -5,6 +5,7 @@ import './multi-data-entry.css'; import { BaseDataEntryProps } from '../data-entry'; import { DataEntryInput, TextDataEntryInputProps } from '../data-entry-input'; import { DataTitleCopyable } from '../data-title'; +import { CloseIcon, SaveIcon } from '../../../components/icons'; interface MultiDataEntryProps extends BaseDataEntryProps, TextDataEntryInputProps { value: string[]; @@ -42,6 +43,9 @@ export const MultiDataEntry: React.FC = ({ props.onChange(props.slug, editedValues); }, [newValue, values, props.onChange, props.slug]); + const clearNew = useCallback(() => { + setNewValue(null); + }, []); const remove = useCallback((index: number) => { const editedValues = values.slice(); @@ -65,13 +69,13 @@ export const MultiDataEntry: React.FC = ({ copy={copyable ? props.copy : undefined} />
-
    - { - values.length === 0 && !isEditing && -
    - -
    - } + { + values.length === 0 && !isEditing && +
    + +
    + } +
      { values.map((val, i) => (
    • @@ -95,46 +99,55 @@ export const MultiDataEntry: React.FC = ({
      + data-index={i} className="btn btn-outline-dark data-entry-list-button">
      }
    • )) } + { + !isDisabled && +
    • + setNewValue(val)} + onConfirm={(_key, val) => addNew(val)} + + maxLength={props.maxLength} + placeholder={props.placeholder} + isUrl={props.isUrl} + valueTransform={props.valueTransform} + confirmOnEnter={confirmOnEnter} + + autofill={props.autofill} + showAllOptionsOnEmpty={props.showAllOptionsOnEmpty} + confirmOnAutofillSelect={true} + /> + { + newValue != undefined && + <> +
      + +
      +
      + +
      + + } +
    • + }
    - { - !isDisabled && -
    - setNewValue(val)} - onConfirm={(_key, val) => addNew(val)} - - maxLength={props.maxLength} - placeholder={props.placeholder} - isUrl={props.isUrl} - valueTransform={props.valueTransform} - confirmOnEnter={confirmOnEnter} - - autofill={props.autofill} - showAllOptionsOnEmpty={props.showAllOptionsOnEmpty} - confirmOnAutofillSelect={true} - /> -
    - -
    -
    - }
) }; diff --git a/app/src/frontend/building/data-containers/dynamics/dynamics-data-entry.tsx b/app/src/frontend/building/data-containers/dynamics/dynamics-data-entry.tsx index 193ee940..53e7d780 100644 --- a/app/src/frontend/building/data-containers/dynamics/dynamics-data-entry.tsx +++ b/app/src/frontend/building/data-containers/dynamics/dynamics-data-entry.tsx @@ -10,6 +10,7 @@ import { MultiDataEntry } from '../../data-components/multi-data-entry/multi-dat import { NumberRangeDataEntry } from './number-range-data-entry'; import './dynamics-data-entry.css'; +import { CloseIcon } from '../../../components/icons'; type DemolishedBuilding = (BuildingAttributes['demolished_buildings'][number]); @@ -211,7 +212,7 @@ export const DynamicsDataEntry: React.FC = (props) => { } -
    +
      { values.length === 0 &&
      @@ -229,7 +230,7 @@ export const DynamicsDataEntry: React.FC = (props) => { title="Delete Record" onClick={() => remove(id)} data-index={id} - >x + > }