Skip to content

Commit

Permalink
Feature kintsoogi 484 delete tsv (#587)
Browse files Browse the repository at this point in the history
* Add delete tsv functionality and pure setItemIndex

* Small fix for newQuote

* update dependencies

---------

Co-authored-by: PhotoNomad0 <[email protected]>
  • Loading branch information
kintsoogi and PhotoNomad0 authored Nov 21, 2023
1 parent 19c7052 commit f85dc07
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
"regenerator-runtime": "^0.13.7",
"resource-workspace-rcl": "2.1.4",
"scripture-resources-rcl": "5.4.1",
"scripture-tsv": "0.2.1",
"scripture-tsv": "0.3.0",
"single-scripture-rcl": "3.4.15",
"tailwindcss": "^2.0.4",
"tc-ui-toolkit": "5.3.3",
"translation-helps-rcl": "3.5.11",
"translation-helps-rcl": "3.5.12",
"use-deep-compare-effect": "^1.3.1",
"word-aligner": "^1.0.0",
"word-aligner-rcl": "1.0.4"
Expand Down
28 changes: 23 additions & 5 deletions src/components/ResourceCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
AddRowButton,
AddRowDialog,
AddRowForm,

DeleteRowButton,
DeleteRowDialog
} from 'scripture-tsv'
const { getChapterVerse } = tsvRowUtils
const { tsvsObjectToFileString } = tsvDataActions
Expand Down Expand Up @@ -82,6 +83,7 @@ export default function ResourceCard({
const [content, setContent] = useState('')
const [saved, setSaved] = useState(true)
const [isSaving, setIsSaving] = useState(false)
const [isTsvDeleteDialogOpen, setIsTsvDeleteDialogOpen] = useState(false)
const [fetchConfig, setFetchConfig] = useState({
basicReference,
config: HTTP_CONFIG,
Expand Down Expand Up @@ -264,7 +266,7 @@ export default function ResourceCard({
item, headers, filters, fontSize, itemIndex, markdownView,
},
actions: {
setFilters, setFontSize, setItemIndex, setMarkdownView,
setFilters, setFontSize, setItemIndex, setItemIndexPure, setMarkdownView,
},
} = useCardState({
id,
Expand Down Expand Up @@ -421,7 +423,7 @@ export default function ResourceCard({
: onTsvAdd(row, chapter, verse, itemIndex)

handleSaveEdit(tsvsObjectToFileString(newTsvs))
setItemIndex(itemIndex + 1)
if (itemIndex !== 0) setItemIndexPure(itemIndex + 1)
} catch (error) {
console.error(
'Input reference in new row is not of type chapter:verse',
Expand All @@ -430,7 +432,14 @@ export default function ResourceCard({
}
}

const { onTsvAdd, onTsvEdit } = isResourceTsv
const deleteTsvRow = () => {
const newTsvs = onTsvDelete(itemIndex)
handleSaveEdit(tsvsObjectToFileString(newTsvs))
setIsTsvDeleteDialogOpen(false)
if (itemIndex !== 0) setItemIndexPure(itemIndex - 1)
}

const { getTsvRow, onTsvAdd, onTsvDelete, onTsvEdit } = isResourceTsv
? useTsvData({ tsvs, verse, chapter, itemIndex, setContent: updateTempContent })
: {}

Expand Down Expand Up @@ -466,6 +475,14 @@ export default function ResourceCard({
onSubmit={submitRowEdits}
tsvForm={TsvForm}
/>

<DeleteRowButton onClick={() => setIsTsvDeleteDialogOpen(true)} />
<DeleteRowDialog
open={isTsvDeleteDialogOpen}
onClose={() => setIsTsvDeleteDialogOpen(false)}
onSubmit={deleteTsvRow}
currentRow={getTsvRow(itemIndex)}
/>
</>
)
: null
Expand Down Expand Up @@ -536,7 +553,8 @@ export default function ResourceCard({
selectedQuote={selectedQuote}
setContent={setContent}
setCurrentCheck={setCurrentCheck}
setItemIndex={setItemIndex}
setItemIndex={setItemIndexPure}
shouldDisableClick={isAddRowDialogOpen || isTsvDeleteDialogOpen}
showSaveChangesPrompt={showSaveChangesPrompt}
updateTaDetails={updateTaDetails}
viewMode={viewMode}
Expand Down
4 changes: 2 additions & 2 deletions src/components/WorkspaceContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ function WorkspaceContainer() {
_setQuote(_quote)
}

if (newQuote && !isEqual(newQuote.reference, currentVerseReference)){
setState( { currentVerseReference: newQuote.reference })
if (_quote && !isEqual(_quote.reference, currentVerseReference)){
setState( { currentVerseReference: _quote.reference })
}
}

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9898,10 +9898,10 @@ [email protected]:
word-aligner "^1.0.0"
xregexp "^4.1.1"

scripture-tsv@0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/scripture-tsv/-/scripture-tsv-0.2.1.tgz#9dcaffbe445018994efe0f288f057658e82620b5"
integrity sha512-NyX5qIL3kVKhzcwdUh8Zt6Dt5VJTeQAu6ydkCHRK8qw6bNmJQgve0LzVHqGUawcwnCpU51vSLqASnGRkPrvPGA==
scripture-tsv@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/scripture-tsv/-/scripture-tsv-0.3.0.tgz#057152de97423ad6047e840bb16f306a18a7971d"
integrity sha512-zsAR2dJa/P0nYykPvxUu78ZjMLbMWB+0i4xedwSUTQjJePqH+FMj7K6Ze1zmEjRRnYuA32ZYNw3N/2Jg0ds+rA==
dependencies:
"@emotion/react" "^11.9.3"
"@emotion/styled" "^11.9.3"
Expand Down Expand Up @@ -10875,10 +10875,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/transform-runtime/-/transform-runtime-0.0.0.tgz#e714d9b69211dd9537939d50e3aa5788c442b85c"
integrity sha512-PX3vXzO8lucrVm82vZb7BABBLHyMDPGzn9zElHr+DnvtS3JPXtqwB1iTRe+D6iFXYmjtAF3zH7O0Xc5XpLpMEg==

[email protected].11:
version "3.5.11"
resolved "https://registry.yarnpkg.com/translation-helps-rcl/-/translation-helps-rcl-3.5.11.tgz#3bf1eaa81e136468b2e6dd3853ea30ca14ee63ac"
integrity sha512-bNVl6Kwgwk2ufNSIBYtnF47x3fki+c5kwOkDyytJlihCdZqhp2LkifvB8u10dOqwVnlPSW2bz6502dwlMGCcEQ==
[email protected].12:
version "3.5.12"
resolved "https://registry.yarnpkg.com/translation-helps-rcl/-/translation-helps-rcl-3.5.12.tgz#e58427750877c72162aa713fba4033b0e79b40de"
integrity sha512-uXj4uWrePiSf2F7eYWauVb1+qp5Rjexu2BYkAe7rGJotG9Z4RI6nbbK56mlG+XHGlbnRkLkIGSZJXOdFDpi8AQ==
dependencies:
"@gwdevs/extensible-rcl" "^1.0.1"
"@mui/styled-engine" "npm:@mui/styled-engine-sc@latest"
Expand Down

0 comments on commit f85dc07

Please sign in to comment.