Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions website/src/pages/documents/edit-document-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export const EditDocumentModal: React.FC<EditDocumentModalProps> = ({

const [creator, setCreator] = useState(documentMetadata.creators ?? [])
const [keywords, setKeywords] = useState(documentMetadata.keywords ?? [])
const [freeKeyword, setFreeKeyword] = useState("")
const [languages, setLanguages] = useState(documentMetadata.languages ?? [])
const [spatialCoverage, setSpatialCoverage] = useState(
documentMetadata.spatialCoverage ?? []
Expand Down Expand Up @@ -792,8 +793,45 @@ export const EditDocumentModal: React.FC<EditDocumentModalProps> = ({
newTags={newKeywords}
onAdd={(tagName) => addKeyword(tagName)}
onRemove={removeKeyword}
addButtonLabel="Add Keyword"
/>
addButtonLabel="Add Pre-existing Keywords"
>
{isEditing && (
<div
style={{
display: "flex",
gap: "8px",
marginBottom: "12px",
alignItems: "center",
}}
>
<input
type="text"
className={styles.input}
placeholder="Enter keyword..."
value={freeKeyword}
onChange={(e) => setFreeKeyword(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter" && freeKeyword.trim()) {
addKeyword(freeKeyword.trim())
setFreeKeyword("")
}
}}
/>
<button
type="button"
className={styles.addTagButton}
onClick={() => {
if (freeKeyword.trim()) {
addKeyword(freeKeyword.trim())
setFreeKeyword("")
}
}}
>
Add Keyword
</button>
</div>
)}
</TagSelector>

<TagSelector
label="Subject Headings"
Expand Down
3 changes: 3 additions & 0 deletions website/src/pages/documents/tag-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface TagSelectorProps {
onRemove?: (index: number) => void
addButtonLabel: string
customForm?: React.ReactNode
children?: React.ReactNode
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to be slightly more clear about the purpose of children, either with a comment or renaming it to something like freeInput.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or additionalForm like you use for subject headings

}

export const TagSelector: React.FC<TagSelectorProps> = ({
Expand All @@ -21,6 +22,7 @@ export const TagSelector: React.FC<TagSelectorProps> = ({
onRemove,
addButtonLabel,
customForm,
children,
}) => {
const [showDropdown, setShowDropdown] = useState(false)

Expand Down Expand Up @@ -50,6 +52,7 @@ export const TagSelector: React.FC<TagSelectorProps> = ({
</div>

<div className={styles.tagDropdownContainer}>
{children}
<button
type="button"
onClick={() => setShowDropdown(!showDropdown)}
Expand Down
Loading