Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date converter form #395

Merged
merged 87 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
956b29e
Implement Mesopotamian date, editing component & date converter (WiP)
khoidt Jul 19, 2023
4b3111e
Improve
khoidt Jul 19, 2023
c150438
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Jul 19, 2023
bec1458
Extend (WiP)
khoidt Jul 31, 2023
84c3d60
Fix and update tests
khoidt Aug 1, 2023
d5d212a
Fix tsc
khoidt Aug 1, 2023
36b15ad
Improve & update tests
khoidt Aug 1, 2023
357fdda
Fix tsc
khoidt Aug 1, 2023
0492249
Refactor
khoidt Aug 1, 2023
92dd7c9
Adjust and unify
khoidt Aug 2, 2023
5c1f265
Update & fix
khoidt Aug 5, 2023
1b9279f
Implement date display in fragmentarium search
khoidt Aug 5, 2023
8546d86
Date paleography
khoidt Aug 7, 2023
81e1ccb
Fix tests
khoidt Aug 7, 2023
5b42cba
Make `date` optional in `CroppedAnnotation`
khoidt Aug 7, 2023
3123ba0
Update style
khoidt Aug 7, 2023
e505fd6
Refactor & update
khoidt Aug 7, 2023
e41636e
Add tests & update
khoidt Aug 7, 2023
c3d21d5
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Aug 10, 2023
bb435be
Implement date delete & fix display issue
khoidt Aug 14, 2023
fc1a5d7
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Aug 16, 2023
525ed06
Implement dates in text
khoidt Aug 24, 2023
ad96479
Add tests
khoidt Aug 25, 2023
b0bfd7c
Add more tests
khoidt Aug 25, 2023
22166ea
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Aug 28, 2023
fbfedb7
Adjust date display
khoidt Aug 28, 2023
bf526e1
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Aug 29, 2023
41a0257
Implement eponyms (WiP)
khoidt Sep 4, 2023
5b6675c
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Sep 4, 2023
4df82dc
Add phases and improve selection
khoidt Sep 4, 2023
7460ee8
Extend eponym
khoidt Sep 5, 2023
088c5d3
Improve & add tests
khoidt Sep 5, 2023
111df01
Add & update tests
khoidt Sep 6, 2023
03fc524
Add test for date with eponym string
khoidt Sep 6, 2023
ba52efd
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Sep 7, 2023
ae397c3
Implement date converter
khoidt Sep 21, 2023
b325ede
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Sep 22, 2023
4768f48
Refactor
khoidt Sep 22, 2023
c3fa9fb
Refactor more
khoidt Sep 22, 2023
2f4d3e9
Refactor more
khoidt Sep 22, 2023
1a875b6
Add tests
khoidt Sep 22, 2023
bb5cdcf
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Sep 23, 2023
da5a92a
Patch approximate dates conversion
khoidt Sep 23, 2023
5ae999f
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Sep 25, 2023
725fee6
Restructure
khoidt Sep 25, 2023
14ecf92
Add basic form
khoidt Sep 25, 2023
06860d4
Reorder about tabs
khoidt Sep 25, 2023
d6e6818
Add routes & breadcrumbs to About section
khoidt Sep 26, 2023
3be1327
Add routes to About
khoidt Oct 1, 2023
4d5ced6
Implement form functionality, design & refactor
khoidt Oct 2, 2023
cac6554
Add copy json button & refactor style
khoidt Oct 3, 2023
596a84a
Implement broken date display
khoidt Oct 3, 2023
1c28754
Add options & text display for modern date fields
khoidt Oct 4, 2023
6bec43b
Update description
khoidt Oct 5, 2023
674f3be
Fix cjdn calculator
khoidt Oct 5, 2023
20f9ce2
Julian and Gregorian dates correction (WiP)
khoidt Oct 9, 2023
6bf7be2
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Oct 9, 2023
306a4d3
Implement Gregorian dates
khoidt Oct 10, 2023
9c95b43
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Oct 11, 2023
866c826
Implement Gregorian string output, correct, update & refactor
khoidt Oct 12, 2023
29d7879
Uddate converter & tests (WiP)
khoidt Oct 16, 2023
2560722
Update Gregrian date converter & restrict day fields
khoidt Oct 17, 2023
e509ac7
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Dec 12, 2023
6cd9dbd
Update snap
khoidt Dec 12, 2023
d04d68b
Refactor & improve style
khoidt Dec 12, 2023
7b983b8
Improve & refactor
khoidt Dec 13, 2023
06d046f
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Dec 13, 2023
3dec050
Improve & refactor
khoidt Dec 18, 2023
45c41ea
Improve & refactor
khoidt Dec 18, 2023
1f4bf60
Improve & refactor
khoidt Dec 18, 2023
4fe8bae
Refactor
khoidt Dec 18, 2023
5efd8cb
Improve & refactor
khoidt Dec 20, 2023
f1b442d
Improve & refactor
khoidt Dec 26, 2023
ff9da56
Improve & add tests
khoidt Jan 2, 2024
f6de167
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Jan 2, 2024
43d7c1e
Update snapshots
khoidt Jan 2, 2024
4bc979d
Add tests, refactor & extend options fields (WiP)
khoidt Jan 2, 2024
d7274c6
Implement advanced field options & limits (WiP)
khoidt Jan 4, 2024
e6b5089
Refactor
khoidt Jan 4, 2024
9c2ad93
Work on options and restrictions (WiP)
khoidt Jan 5, 2024
86fb42f
Fix regnal years calculation & tests
khoidt Jan 8, 2024
79b1bbc
Implement ruler selection and Brinkman names
khoidt Jan 8, 2024
bac49d4
Implement tools page & Mes. date guards, improve
khoidt Jan 15, 2024
863c0cb
Merge remote-tracking branch 'origin/master' into add-date-to-fragment
khoidt Jan 15, 2024
01df76d
Add tests
khoidt Jan 16, 2024
139dcb9
Update tests
khoidt Jan 16, 2024
32e3d43
Clean up
khoidt Jan 16, 2024
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
11 changes: 11 additions & 0 deletions src/about/ui/__snapshots__/about.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ exports[`Snapshot 1`] = `
>
Dictionary
</a>
<a
aria-controls="about-tabpane-date-converter"
aria-selected="false"
class="nav-item nav-link"
data-rb-event-key="date-converter"
href="#"
id="about-tab-date-converter"
role="tab"
>
Date converter
</a>
<a
aria-controls="about-tabpane-bibliography"
aria-selected="false"
Expand Down
7 changes: 7 additions & 0 deletions src/about/ui/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import AboutSigns from 'about/ui/signs'
import AboutDictionary from 'about/ui/dictionary'
import AboutBibliography from 'about/ui/bibliography'
import AboutListOfKings from 'about/ui/chronology'
import DateConverterForm, {
AboutDateConverter,
} from 'chronology/ui/DateConverterForm'
import _ from 'lodash'

export const tabIds = [
Expand Down Expand Up @@ -69,6 +72,10 @@ export default function About({
<Tab eventKey="dictionary" title="Dictionary">
{AboutDictionary(markupService)}
</Tab>
<Tab eventKey="date-converter" title="Date converter">
{AboutDateConverter(markupService)}
<DateConverterForm />
</Tab>
<Tab eventKey="bibliography" title="Bibliography">
{AboutBibliography(markupService)}
</Tab>
Expand Down
4 changes: 2 additions & 2 deletions src/about/ui/chronology.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import { Markdown } from 'common/Markdown'
import BrinkmanKingsTable from 'common/BrinkmanKings'
import BrinkmanKingsTable from 'chronology/ui/BrinkmanKings'

export default function AboutChronology(): JSX.Element {
export default function AboutListOfKings(): JSX.Element {
return (
<>
<Markdown
Expand Down
97 changes: 97 additions & 0 deletions src/chronology/application/DateConverterFormChange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import DateConverter from 'chronology/domain/DateConverter'
import { CalendarProps } from 'chronology/domain/DateConverterBase'
import { FormChangeProps } from 'chronology/ui/DateConverterForm'

export function handleDateConverterFormChange({
event,
scenario,
formData,
dateConverter,
setFormData,
}: FormChangeProps): void {
const { name, value } = event.target
const data = {
...formData,
[name]: name === 'ruler' ? value : parseInt(value),
} as CalendarProps
if (scenario === 'setToGregorianDate') {
setFormToGregorianDate(data, dateConverter)
} else if (scenario === 'setToJulianDate') {
setFormToJulianDate(data, dateConverter)
} else if (isSetSeBabylonianDate(scenario, data)) {
setFormToSeBabylonianDate(data, dateConverter)
} else if (isSetMesopotamianDate(scenario, data)) {
setFormToMesopotamianDate(data, dateConverter)
}
setFormData({ ...dateConverter.calendar })
}

function isSetSeBabylonianDate(scenario: string, data: CalendarProps): boolean {
const setToSeBabylonianDateArgs = [
data.seBabylonianYear,
data.mesopotamianMonth,
data.mesopotamianDay,
]
return !!(
scenario === 'setToSeBabylonianDate' &&
!setToSeBabylonianDateArgs.includes(undefined)
)
}

function isSetMesopotamianDate(scenario: string, data: CalendarProps): boolean {
const setToMesopotamianDateArgs = [
data.ruler,
data.regnalYear,
data.mesopotamianMonth,
data.mesopotamianDay,
]
return !!(
scenario === 'setToMesopotamianDate' &&
!setToMesopotamianDateArgs.includes(undefined)
)
}

function setFormToGregorianDate(
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 3 locations. Consider refactoring.

data: CalendarProps,
dateConverter: DateConverter
): void {
dateConverter.setToGregorianDate(
data.gregorianYear as number,
data.gregorianMonth as number,
data.gregorianDay as number
)
}

function setFormToSeBabylonianDate(
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 3 locations. Consider refactoring.

data: CalendarProps,
dateConverter: DateConverter
): void {
dateConverter.setToSeBabylonianDate(
data.seBabylonianYear as number,
data.mesopotamianMonth as number,
data.mesopotamianDay as number
)
}

function setFormToMesopotamianDate(
data: CalendarProps,
dateConverter: DateConverter
): void {
dateConverter.setToMesopotamianDate(
data.ruler as string,
data.regnalYear as number,
data.mesopotamianMonth as number,
data.mesopotamianDay as number
)
}

function setFormToJulianDate(
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 3 locations. Consider refactoring.

data: CalendarProps,
dateConverter: DateConverter
): void {
dateConverter.setToJulianDate(
data.julianYear as number,
data.julianMonth as number,
data.julianDay as number
)
}
151 changes: 151 additions & 0 deletions src/chronology/application/DateConverterFormFieldData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
const generalInformationFields = [
{
name: 'gregorianYear',
type: 'number',
placeholder: 'Year',
required: true,
help: 'The modern (proleptic Gregorian) year.',
},
{
name: 'gregorianMonth',
type: 'number',
placeholder: 'Month',
required: true,
help: 'The modern (proleptic Gregorian) month.',
},
{
name: 'gregorianDay',
type: 'number',
placeholder: 'Day',
required: true,
help: 'The modern (proleptic Gregorian) day of the month.',
},
{
name: 'weekDay',
type: 'number',
placeholder: 'Week Day',
required: true,
help: 'The modern day of the week.',
},
]

const julianDateInformationFields = [
{
name: 'julianYear',
type: 'number',
placeholder: 'Julian Year',
required: true,
help: 'The (proleptic) Julian year.',
},
{
name: 'julianMonth',
type: 'number',
placeholder: 'Julian Month',
required: true,
help: 'The (proleptic) Julian month.',
},
{
name: 'julianDay',
type: 'number',
placeholder: 'Julian Day',
required: true,
help: 'The (proleptic) Julian day of the month.',
},
]

const specializedDateInformationFields = [
{
name: 'cjdn',
type: 'number',
placeholder: 'CJDN',
required: true,
help:
'Chronological Julian Day Number, a continuous count of days since the beginning of the Julian Period.',
},
{
name: 'lunationNabonassar',
type: 'number',
placeholder: 'Lunation Nabonassar',
help:
'Lunation following the Nabonassar (Nabû-nāṣir, 747-734 BCE) Era. Begins on Wednesday, February 26, 747 BCE.',
required: true,
},
]

const seleucidEraInformationFields = [
{
name: 'seBabylonianYear',
type: 'number',
placeholder: 'SE Babylonian Year',
required: true,
help: 'Seleucid Era Babylonian year, counting from the year 312 BCE.',
},
{
name: 'seMacedonianYear',
type: 'number',
placeholder: 'SE Macedonian Year',
help: 'Seleucid Era Macedonian year, counting from the year 312 BCE.',
},
{
name: 'seArsacidYear',
type: 'number',
placeholder: 'SE Arsacid Year',
help: 'Year count during the Arsacid (Parthian) Dynasty, 247 BCE - 224 CE.',
},
]

const mesopotamianDateInformationFields = [
{
name: 'ruler',
type: 'text',
placeholder: 'Ruler',
help: 'Name of the ruler or king reigning at the time.',
},
{
name: 'regnalYear',
type: 'number',
placeholder: 'Regnal Year',
help:
'Regnal year, or the year of the ruler’s reign, as a number starting from 1.',
},
{
name: 'mesopotamianMonth',
type: 'number',
placeholder: 'Mesopotamian Month',
required: true,
help:
'Mesopotamian month as a number from 1 to 12 or 13 (depending on the year).',
},
{
name: 'mesopotamianDay',
type: 'number',
placeholder: 'Mesopotamian Day',
help:
'Mesopotamian day of the month as a number from 1 to 29-30 (depending on the month) or 31 (Nabonassar lunation 2916)',
},
{
name: 'mesopotamianMonthLength',
type: 'number',
placeholder: 'Mesopotamian Month Length',
help: 'Length of the Mesopotamian month, either 29 or 30 days.',
},
]

export const sections = [
{ title: 'Modern', fields: generalInformationFields },
{ title: 'Julian', fields: julianDateInformationFields },
{ title: 'Mesopotamian', fields: mesopotamianDateInformationFields },
{ title: 'Seleucid', fields: seleucidEraInformationFields },
{
title: 'Specialized',
fields: specializedDateInformationFields,
},
]

export type Field = {
name: string
type: string
placeholder: string
required?: boolean
help: string
}
Loading
Loading