From d8a22bc6693d6d1aca730707f361f83b5fcbf6f4 Mon Sep 17 00:00:00 2001 From: danielc-n Date: Thu, 18 Apr 2024 12:10:02 +0200 Subject: [PATCH] FIX : bug that prevented some resources to show up. and FIX : bug that was throwing an error when a user where to search for a resource in the resource search field, and click on 'no match found' --- .../src/components/Projects/ImportPopUp.js | 41 +++++------ .../CreateProject/AdvancedSettingsDropdown.js | 2 +- .../ResourceUtils/CustomMultiComboBox.js | 6 +- .../createDownloadedResourceSB.js | 16 ++--- .../src/core/projects/saveProjetcsMeta.js | 5 +- styles/globals.css | 71 +++++++++++-------- 6 files changed, 76 insertions(+), 65 deletions(-) diff --git a/renderer/src/components/Projects/ImportPopUp.js b/renderer/src/components/Projects/ImportPopUp.js index 6c2a6e113..0ec51a751 100644 --- a/renderer/src/components/Projects/ImportPopUp.js +++ b/renderer/src/components/Projects/ImportPopUp.js @@ -12,6 +12,7 @@ import styles from './ImportPopUp.module.css'; import * as logger from '../../logger'; import CloseIcon from '@/illustrations/close-button-black.svg'; import { updateJsonJuxta } from './utils/updateJsonJuxta'; +import { ReferenceContext } from '@/components/context/ReferenceContext'; const grammar = require('usfm-grammar'); const advanceSettings = require('../../lib/AdvanceSettings.json'); @@ -236,30 +237,26 @@ export default function ImportPopUp(props) { break; } }); - if(canonSpecification) { - // importedBookCodes.forEach((bc) => { - // if(bookCodeList.indexOf(bc) === -1) { - // bookCodeList.push(bc); - // } - // }); - let newCanonSpecification = { - currentScope: bookCodeList, - id: 4, - locked: true, - title: 'Other', - } - if (bookCodeList.length === advanceSettings.canonSpecification[2].length - && compareArrays(advanceSettings.currentScope, bookCodeList)) { - newCanonSpecification.title = advanceSettings.canonSpecification[2].title; - } else if (bookCodeList.length === advanceSettings.canonSpecification[1].length - && compareArrays(advanceSettings.currentScope, bookCodeList)) { - newCanonSpecification.title = advanceSettings.canonSpecification[1].title; - } else if (bookCodeList.length === advanceSettings.canonSpecification[0].length + let newCanonSpecification = { + currentScope: bookCodeList, + id: 4, + locked: false, + title: t('label-other'), + } + if (bookCodeList.length === advanceSettings.canonSpecification[2].length && compareArrays(advanceSettings.currentScope, bookCodeList)) { - newCanonSpecification.title = advanceSettings.canonSpecification[0].title; - } - setCanonSpecification(newCanonSpecification); + newCanonSpecification.title = advanceSettings.canonSpecification[2].title; + newCanonSpecification.id = advanceSettings.canonSpecification[2].id; + } else if (bookCodeList.length === advanceSettings.canonSpecification[1].length + && compareArrays(advanceSettings.currentScope, bookCodeList)) { + newCanonSpecification.title = advanceSettings.canonSpecification[1].title; + newCanonSpecification.id = advanceSettings.canonSpecification[2].id; + } else if (bookCodeList.length === advanceSettings.canonSpecification[0].length + && compareArrays(advanceSettings.currentScope, bookCodeList)) { + newCanonSpecification.title = advanceSettings.canonSpecification[0].title; + newCanonSpecification.id = advanceSettings.canonSpecification[0].id; } + setCanonSpecification(newCanonSpecification); setImportedBookCodes(bookCodeList); setImportedFiles(files); close(); diff --git a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js index 4e8c22b7e..5acd145ed 100644 --- a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js +++ b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js @@ -54,7 +54,7 @@ export default function AdvancedSettingsDropdown({ call, project, projectType }) setCopyRight, }, } = React.useContext(ProjectContext); - const [isShow, setIsShow] = React.useState(!projectType === 'Juxta'); + const [isShow, setIsShow] = React.useState(true); const [bibleNav, setBibleNav] = React.useState(false); const [handleNav, setHandleNav] = React.useState(); const [currentScope, setCurrentScope] = React.useState(); diff --git a/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js b/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js index b9effa78e..09c1e3f69 100644 --- a/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js +++ b/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js @@ -56,18 +56,18 @@ function CustomMultiComboBox({ {filteredData.length > 0 ? filteredData.map((data) => ( // - + {data[filterParams] } {' '} {showLangCode.show && ( - + ( {data[showLangCode.langkey]} ) )} - )) : query?.length > 2 && No Match Found } + )) : query?.length > 2 && No Match Found } diff --git a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js index b69e83acf..fee229ef8 100644 --- a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js +++ b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js @@ -294,7 +294,7 @@ export const handleDownloadResources = async (resourceData, selectResource, acti const existingResource = fs.readdirSync(folder, { withFileTypes: true }).filter((dir) => dir.isDirectory()); // eslint-disable-next-line no-loop-func existingResource.forEach((element) => { - logger.debug('blablabla', path.join(folder, element.name, 'metadata.json')); + logger.debug('createDownloadedResourceSB.js metadatapath', path.join(folder, element.name, 'metadata.json')); if (fs.existsSync(path.join(folder, element.name, 'metadata.json'))) { let filecontentMeta = fs.readFileSync(path.join(folder, element.name, 'metadata.json'), 'utf8'); filecontentMeta = JSON.parse(filecontentMeta); @@ -450,13 +450,13 @@ export const handleDownloadResources = async (resourceData, selectResource, acti // finally remove zip and rename base folder to projectname_id logger.debug('createDownloadedResourceSB.js', 'deleting zip file - rename project with project + id in scribe format'); - // if (fs.existsSync(folder)) { - // fs.renameSync(path.join(folder, currentResourceProject.name), path.join(folder, currentProjectName)); - // fs.unlinkSync(path.join(folder, `${currentProjectName}.zip`), () => { - // logger.debug('createDownloadedResourceSB.js', 'error in deleting zip'); - // throw new Error(`Removing Resource Zip Failed : ${currentResourceProject.name}`); - // }); - // } + if (fs.existsSync(folder)) { + fs.renameSync(path.join(folder, currentResourceProject.name), path.join(folder, currentProjectName)); + fs.unlinkSync(path.join(folder, `${currentProjectName}.zip`), () => { + logger.debug('createDownloadedResourceSB.js', 'error in deleting zip'); + throw new Error(`Removing Resource Zip Failed : ${currentResourceProject.name}`); + }); + } }).catch((err) => { throw new Error(`Download Resource file Failed : ${err}`); }); diff --git a/renderer/src/core/projects/saveProjetcsMeta.js b/renderer/src/core/projects/saveProjetcsMeta.js index a9ca9c3f6..e2bf3cbfe 100644 --- a/renderer/src/core/projects/saveProjetcsMeta.js +++ b/renderer/src/core/projects/saveProjetcsMeta.js @@ -248,7 +248,10 @@ export const saveProjectsMeta = async (projectMetaObj) => { // Switch Project Creation if (projectNameExists === false || projectMetaObj.call === 'edit') { - await burritoChecksAndCreation(projectMetaObj.projectType, projectMetaObj.projectType === 'Translation'); + await burritoChecksAndCreation( + projectMetaObj.projectType, + (projectMetaObj.projectType === 'Translation' || projectMetaObj.projectType === 'Juxta') + ); } else { logger.warn('saveProjectsMeta.js', 'Project already exists'); status.push({ type: 'error', value: 'Project already exists' }); diff --git a/styles/globals.css b/styles/globals.css index f62ef7878..956f6ff48 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -3,29 +3,32 @@ @tailwind utilities; @font-face { - font-family: 'Inter'; - src: url('../renderer/src/assets/fonts/Inter/Inter-Medium.ttf'), - url('../renderer/src/assets/fonts/Inter/Inter-Regular.ttf'), - url('../renderer/src/assets/fonts/Inter/Inter-SemiBold.ttf'), - url('../renderer/src/assets/fonts/Inter/Inter-Thin.ttf'), - url('../renderer/src/assets/fonts/Inter/Inter-Light.ttf'), - url('../renderer/src/assets/fonts/Inter/Inter-ExtraLight.ttf'); - font-weight: 100 500; + font-family: 'Inter'; + src: url('../renderer/src/assets/fonts/Inter/Inter-Medium.ttf'), + url('../renderer/src/assets/fonts/Inter/Inter-Regular.ttf'), + url('../renderer/src/assets/fonts/Inter/Inter-SemiBold.ttf'), + url('../renderer/src/assets/fonts/Inter/Inter-Thin.ttf'), + url('../renderer/src/assets/fonts/Inter/Inter-Light.ttf'), + url('../renderer/src/assets/fonts/Inter/Inter-ExtraLight.ttf'); + font-weight: 100 500; } /* Chrome, Safari and Opera */ .no-scrollbars::-webkit-scrollbar { - display: none; + display: none; } .no-scrollbars { - -ms-overflow-style: none; /* IE and Edge */ - scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; + /* IE and Edge */ + scrollbar-width: none; + /* Firefox */ } #content { - @apply rounded-sm overflow-hidden; + @apply rounded-sm overflow-hidden; } + /* .section { @apply border-2 border-black text-sm rounded-sm overflow-hidden; } */ @@ -37,16 +40,16 @@ .perf .title .section, .perf .heading .section, .sectionBody .paragraph { - @apply mx-3; + @apply mx-3; } .perf .title .section, .perf .heading .section { - @apply flex items-center; + @apply flex items-center; } .editor { - @apply my-2; + @apply my-2; } /* .sectionHeading> .expand { @@ -55,8 +58,9 @@ /* .title .mt, */ .heading .ms { - @apply uppercase text-lg tracking-wider text-primary; + @apply uppercase text-lg tracking-wider text-primary; } + /* .title .mt { @apply hidden; } */ @@ -65,42 +69,43 @@ @apply hidden; } */ .editor *[contenteditable='true']:focus { - @apply bg-primary-50 outline-none rounded-sm; + @apply bg-primary-50 outline-none rounded-sm; } .mark.chapter { - @apply border-b mb-2 pb-1 uppercase tracking-wider font-semibold break-before-column block before:content-['Chapter_:_']; + @apply border-b mb-2 pb-1 uppercase tracking-wider font-semibold break-before-column block before:content-['Chapter_:_']; } p.paragraph:has(.chapter) { - @apply mt-2; + @apply mt-2; } .mark.verse { - @apply text-xs mr-1 text-primary font-semibold; + @apply text-xs mr-1 text-primary font-semibold; } .major-title, .major-secondary-heading { - @apply text-primary; + @apply text-primary; } .graft { - @apply text-primary text-sm align-super; + @apply text-primary text-sm align-super; } .editor .perf .footnote:before { - @apply cursor-pointer font-semibold; - content: ' ‡'; + @apply cursor-pointer font-semibold; + content: ' ‡'; } + .editor .perf .xref:before { - @apply cursor-pointer font-semibold; - content: ' x'; + @apply cursor-pointer font-semibold; + content: ' x'; } .perf .xq, .perf .fq { - @apply text-primary text-sm; + @apply text-primary text-sm; } .ref-editor ::selection { @@ -121,8 +126,8 @@ p.paragraph:has(.chapter) { .no-spinner::-webkit-inner-spin-button, .no-spinner::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; + -webkit-appearance: none; + margin: 0; } /* html { @@ -266,7 +271,7 @@ p.paragraph:has(.chapter) { margin: 0.1em; } */ .button { - @apply flex h-8 cursor-pointer items-center justify-center rounded-lg p-2 text-xs font-bold outline-none xl:px-4; + @apply flex h-8 cursor-pointer items-center justify-center rounded-lg p-2 text-xs font-bold outline-none xl:px-4; } #sundesmosToolbar { @@ -293,4 +298,10 @@ div.draggable { .source-text { color: #121212; } +} + +.prevent-select { + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; } \ No newline at end of file