-
-
Notifications
You must be signed in to change notification settings - Fork 5
Stephen #238
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
Open
siyche
wants to merge
26
commits into
sillsdev:develop
Choose a base branch
from
markjpratt31:Stephen
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Stephen #238
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
89feff7
Commit
siyche2 8b05aaf
REF fix
siyche2 2c681e6
Verse Marking fixed
siyche2 2da0f4e
cypress fix
siyche2 dd80b2e
half of table works
siyche2 d7ab968
table fix
siyche2 ab9048f
table fix
siyche2 c0227ce
remove highlight
siyche2 dc9ce36
fix
siyche2 4e59a03
editreferences and reset
siyche2 2f65942
cleanup
siyche2 9d30e34
table highlights
siyche2 014b8b5
reset fix
siyche2 a0b4378
SplitVerse kinda works
siyche2 2f6fbd3
update
siyche2 5cb1ea7
old line delete fix for table
siyche2 c1acc00
SplitVerses Undo Button
siyche2 8ab6e92
Remove Milliseconds
siyche2 a502517
Remove Milliseconds
siyche2 34719bf
C
siyche2 f0171e6
c
siyche2 4520190
c
siyche2 78a65c0
c
siyche2 4e21557
c
siyche2 cf7889f
cc
siyche2 01bfd8f
Update package.json
siyche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
262 changes: 262 additions & 0 deletions
262
src/renderer/src/components/PassageDetail/mobile/MarkVerses/EditReferenceDropdown.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,262 @@ | ||||
| import { | ||||
| Box, | ||||
| Button, | ||||
| Checkbox, | ||||
| Dialog, | ||||
| DialogActions, | ||||
| DialogContent, | ||||
| DialogTitle, | ||||
| FormControlLabel, | ||||
| NativeSelect, | ||||
| Typography, | ||||
| } from '@mui/material'; | ||||
| import type { ChangeEvent } from 'react'; | ||||
| import { useEffect, useState } from 'react'; | ||||
|
|
||||
| const suffixOptions = ['', 'a', 'b', 'c', 'd', 'e']; | ||||
| const selectSx = { | ||||
| minWidth: 64, | ||||
| '& .MuiNativeSelect-select': { | ||||
| fontSize: 40, | ||||
| lineHeight: 1.1, | ||||
| textAlign: 'center', | ||||
| pr: 3, | ||||
| }, | ||||
| '& .MuiNativeSelect-icon': { | ||||
| fontSize: 24, | ||||
| right: 0, | ||||
| }, | ||||
| }; | ||||
| const verseSelectSx = { | ||||
| ...selectSx, | ||||
| '& .MuiNativeSelect-select': { | ||||
| ...selectSx['& .MuiNativeSelect-select'], | ||||
| fontSize: 28, | ||||
| }, | ||||
| }; | ||||
| const suffixOptionStyle = { | ||||
| fontSize: 50, | ||||
| }; | ||||
| const verseOptionStyle = { | ||||
| fontSize: 48, | ||||
| }; | ||||
|
|
||||
| export interface EditReferenceValue { | ||||
| splitVerse: boolean; | ||||
| canSplit: boolean; | ||||
| startChapter: number; | ||||
| startVerse: number; | ||||
| startSuffix: string; | ||||
| endChapter: number; | ||||
| endVerse: number; | ||||
| endSuffix: string; | ||||
| } | ||||
|
|
||||
| interface EditReferenceDropdownProps { | ||||
| open: boolean; | ||||
| limits: string; | ||||
| maxVerse: number; | ||||
| verseOptions: number[]; | ||||
| title: string; | ||||
| cancelLabel: string; | ||||
| saveLabel: string; | ||||
| splitVerseLabel: string; | ||||
| value: EditReferenceValue; | ||||
| onCancel: () => void; | ||||
| onSave: (value: EditReferenceValue) => void; | ||||
| } | ||||
|
|
||||
| export default function EditReferenceDropdown({ | ||||
| open, | ||||
| limits, | ||||
| maxVerse, | ||||
| verseOptions, | ||||
| title, | ||||
| cancelLabel, | ||||
| saveLabel, | ||||
| splitVerseLabel, | ||||
| value, | ||||
| onCancel, | ||||
| onSave, | ||||
| }: EditReferenceDropdownProps) { | ||||
| const [draft, setDraft] = useState<EditReferenceValue>(value); | ||||
| const verseNumberOptions = Array.from( | ||||
| new Set([...verseOptions, draft.startVerse, draft.endVerse, maxVerse]) | ||||
| ).sort((left, right) => left - right); | ||||
|
|
||||
| useEffect(() => { | ||||
| setDraft(value); | ||||
| }, [value]); | ||||
|
|
||||
| const handleSplitChange = ( | ||||
| event: ChangeEvent<HTMLInputElement>, | ||||
| checked: boolean | ||||
| ) => { | ||||
| setDraft((current) => ({ | ||||
| ...current, | ||||
| splitVerse: checked, | ||||
| })); | ||||
| }; | ||||
|
|
||||
| const handleSuffixChange = | ||||
| (key: 'startSuffix' | 'endSuffix') => | ||||
| (event: ChangeEvent<HTMLSelectElement>) => { | ||||
| const nextSuffix = event.target.value.toLowerCase(); | ||||
| setDraft((current) => ({ | ||||
| ...current, | ||||
| [key]: nextSuffix, | ||||
| })); | ||||
| }; | ||||
|
|
||||
| const handleVerseChange = | ||||
| (key: 'startVerse' | 'endVerse') => | ||||
| (event: ChangeEvent<HTMLSelectElement>) => { | ||||
| const nextVerse = parseInt(event.target.value, 10); | ||||
| if (Number.isNaN(nextVerse)) return; | ||||
|
|
||||
| setDraft((current) => ({ | ||||
| ...current, | ||||
| [key]: nextVerse, | ||||
| })); | ||||
| }; | ||||
|
|
||||
| const displayEndChapter = draft.endChapter; | ||||
| const displayEndVerse = draft.endVerse; | ||||
| const canEditEndSuffix = draft.canSplit || draft.splitVerse; | ||||
|
|
||||
| return ( | ||||
| <Dialog | ||||
| open={open} | ||||
| onClose={onCancel} | ||||
| aria-labelledby="edit-reference-dialog-title" | ||||
| fullWidth | ||||
| maxWidth="xs" | ||||
| > | ||||
| <DialogTitle id="edit-reference-dialog-title"> | ||||
| {`${title} ${limits}`} | ||||
| </DialogTitle> | ||||
| <DialogContent sx={{ pt: 1 }}> | ||||
| <Box | ||||
| sx={{ | ||||
| display: 'flex', | ||||
| justifyContent: 'center', | ||||
| alignItems: 'center', | ||||
| gap: 1.5, | ||||
| mb: 2, | ||||
| fontVariantNumeric: 'tabular-nums', | ||||
| }} | ||||
| > | ||||
| <Box sx={{ textAlign: 'center' }}> | ||||
| <Box | ||||
| sx={{ | ||||
| display: 'flex', | ||||
| alignItems: 'center', | ||||
| justifyContent: 'center', | ||||
| gap: 0.5, | ||||
| }} | ||||
| > | ||||
| <Typography | ||||
| sx={{ fontSize: 28 }} | ||||
| >{`${draft.startChapter}:`}</Typography> | ||||
| <NativeSelect | ||||
| value={draft.startVerse} | ||||
| onChange={handleVerseChange('startVerse')} | ||||
| inputProps={{ 'aria-label': 'start verse number' }} | ||||
| sx={verseSelectSx} | ||||
| > | ||||
| {verseNumberOptions.map((option) => ( | ||||
| <option | ||||
| key={`start-verse-${option}`} | ||||
| value={option} | ||||
| style={verseOptionStyle} | ||||
| > | ||||
| {option} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| <NativeSelect | ||||
| value={draft.startSuffix} | ||||
| onChange={handleSuffixChange('startSuffix')} | ||||
| inputProps={{ 'aria-label': 'start verse suffix' }} | ||||
| sx={selectSx} | ||||
| > | ||||
| {suffixOptions.map((option) => ( | ||||
| <option | ||||
| key={option || 'none-start'} | ||||
| value={option} | ||||
| style={suffixOptionStyle} | ||||
| > | ||||
| {option || ' '} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| <Typography variant="h6">-</Typography> | ||||
| <Box sx={{ textAlign: 'center' }}> | ||||
| <Box | ||||
| sx={{ | ||||
| display: 'flex', | ||||
| alignItems: 'center', | ||||
| justifyContent: 'center', | ||||
| gap: 0.5, | ||||
| }} | ||||
| > | ||||
| <Typography | ||||
| sx={{ fontSize: 24 }} | ||||
| >{`${displayEndChapter}:`}</Typography> | ||||
| <NativeSelect | ||||
| value={displayEndVerse} | ||||
| onChange={handleVerseChange('endVerse')} | ||||
| disabled={!draft.splitVerse} | ||||
| inputProps={{ 'aria-label': 'end verse number' }} | ||||
| sx={verseSelectSx} | ||||
| > | ||||
| {verseNumberOptions.map((option) => ( | ||||
| <option | ||||
| key={`end-verse-${option}`} | ||||
| value={option} | ||||
| style={verseOptionStyle} | ||||
| > | ||||
| {option} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| <NativeSelect | ||||
| value={draft.endSuffix} | ||||
| onChange={handleSuffixChange('endSuffix')} | ||||
| disabled={!canEditEndSuffix} | ||||
| inputProps={{ 'aria-label': 'end verse suffix' }} | ||||
| sx={selectSx} | ||||
| > | ||||
| {suffixOptions.map((option) => ( | ||||
| <option | ||||
| key={option || 'none-end'} | ||||
| value={option} | ||||
| style={suffixOptionStyle} | ||||
| > | ||||
| {option || ' '} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| </Box> | ||||
|
|
||||
| <FormControlLabel | ||||
| control={ | ||||
| <Checkbox checked={draft.splitVerse} onChange={handleSplitChange} /> | ||||
| } | ||||
| label={splitVerseLabel} | ||||
| /> | ||||
| </DialogContent> | ||||
| <DialogActions sx={{ px: 3, pb: 2 }}> | ||||
| <Button onClick={onCancel}>{cancelLabel}</Button> | ||||
| <Button variant="contained" onClick={() => onSave(draft)}> | ||||
| {saveLabel} | ||||
| </Button> | ||||
| </DialogActions> | ||||
| </Dialog> | ||||
| ); | ||||
| } | ||||
| // test | ||||
|
||||
| // test |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadSegments()now preferssuggestedSegmentswhenever it’s a non-empty string. Several callers pass placeholder values like'{}'(or a stale value from a previous render), so this can prevent loading the mediafile’s saved segments and show the wrong segments on initial load. Prefer always loading fromgetSegments(allowSegment, segs)on mediafile change, and keep the separate effect that appliessuggestedSegmentsonly when the user actually provides an override.