From 7d1b90342fec6bdf1ceef95cc6b4390403a724f1 Mon Sep 17 00:00:00 2001 From: Ilya Khait Date: Thu, 7 Mar 2024 20:42:52 +0000 Subject: [PATCH] Implement editor (WiP) --- src/colophons/ui/ColophonEditor.tsx | 355 +++++++++++++++++- .../ui/fragment/CuneiformFragmentEditor.tsx | 53 +-- 2 files changed, 368 insertions(+), 40 deletions(-) diff --git a/src/colophons/ui/ColophonEditor.tsx b/src/colophons/ui/ColophonEditor.tsx index ca389bea6..250aed4f8 100644 --- a/src/colophons/ui/ColophonEditor.tsx +++ b/src/colophons/ui/ColophonEditor.tsx @@ -1,5 +1,354 @@ -import React from 'react' +import React, { FormEvent, useState } from 'react' +import { Form, Col, Button, Row } from 'react-bootstrap' +import Select from 'react-select' -export default function Editor(): JSX.Element { - return <> +import { Provenance } from 'corpus/domain/provenance' +import { Fragment } from 'fragmentarium/domain/fragment' + +enum ColophonStatus { + Yes = 'Yes', + No = 'No', + Broken = 'Broken', + OnlyColophon = 'Only Colophon', +} + +enum ColophonType { + AsbA = 'Asb a', + AsbB = 'Asb b', + AsbC = 'Asb c', + AsbD = 'Asb d', + AsbE = 'Asb e', + AsbF = 'Asb f', + AsbG = 'Asb g', // BAK 321 + AsbH = 'Asb h', + AsbI = 'Asb i', + AsbK = 'Asb k', + AsbL = 'Asb l', + AsbM = 'Asb m', + AsbN = 'Asb n', + AsbO = 'Asb o', + AsbP = 'Asb p', + AsbQ = 'Asb q', + AsbRS = 'Asb r/s', + AsbT = 'Asb t', + AsbU = 'Asb u', + AsbV = 'Asb v', + AsbW = 'Asb w', + AsbUnclear = 'Asb Unclear', + NzkBAK293 = 'Nzk BAK 293', + NzkBAK294 = 'Nzk BAK 294', + NzkBAK295 = 'Nzk BAK 295', + NzkBAK296 = 'Nzk BAK 296', + NzkBAK297 = 'Nzk BAK 297', +} + +enum ColophonOwnership { + Library = 'Library', + Private = 'Private', + Individual = 'Individual', +} + +enum IndividualType { + Owner = 'Owner', + Scribe = 'Scribe', + Other = 'Other', +} + +interface Name { + value: string + isBroken: boolean + isUncertain: boolean } + +interface Individual { + name?: Name + sonOf?: Name + grandsonOf?: Name + family?: Name + nativeOf?: Provenance + type?: IndividualType +} + +export interface Colophon { + colophonStatus: ColophonStatus + colophonOwnership?: ColophonOwnership + colophonType?: ColophonType + originalFrom?: Provenance + writtenIn?: Provenance + notesToScribalProcess?: string + individuals?: Individual[] +} + +interface Props { + fragment: Fragment + updateColophon: (colophon: Colophon) => Promise + disabled?: boolean +} + +const ColophonStatusInput = ({ + colophonStatus, + onChange, +}: { + colophonStatus: ColophonStatus + onChange +}) => { + const options = Object.values(ColophonStatus).map((status) => ({ + value: status, + label: status, + })) + return ( + + Colophon Status + + + ) +} + +const ColophonTypeInput = ({ + colophonType, + onChange, +}: { + colophonType?: ColophonType + onChange +}) => { + const options = Object.values(ColophonType).map((type) => ({ + value: type, + label: type, + })) + return ( + + Colophon Type +