Skip to content

Commit

Permalink
FIX : bug that prevented some resources to show up. and FIX : bug tha…
Browse files Browse the repository at this point in the history
…t was throwing an error when a user where to search for a resource in the resource search field, and click on 'no match found'
  • Loading branch information
danielc-n committed Apr 18, 2024
1 parent 58605c8 commit d8a22bc
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 65 deletions.
41 changes: 19 additions & 22 deletions renderer/src/components/Projects/ImportPopUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ function CustomMultiComboBox({
{filteredData.length > 0
? filteredData.map((data) => (
// <Combobox.Option key={data?.id || data?.pk} className={`${selectedList.includes(data) ? 'bg-gray-400' : ''} hover:bg-gray-300 p-1`} value={data}>
<Combobox.Option key={data?.name || data?.id || data?.pk} className=" hover:bg-gray-300 p-1" value={data} aria-label={data[filterParams]}>
<Combobox.Option key={data?.name || data?.id || data?.pk} className=" hover:bg-gray-300 p-1 prevent-select" value={data} aria-label={data[filterParams]}>
{data[filterParams] }
{' '}
{showLangCode.show && (
<span className="text-green-600">
<span className="text-green-600 prevent-select">
(
{data[showLangCode.langkey]}
)
</span>
)}
</Combobox.Option>
)) : query?.length > 2 && <Combobox.Option> No Match Found </Combobox.Option>}
)) : query?.length > 2 && <Combobox.Option disabled className="prevent-select"> No Match Found </Combobox.Option>}
</div>
</div>
</Combobox.Options>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}`);
});
Expand Down
5 changes: 4 additions & 1 deletion renderer/src/core/projects/saveProjetcsMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
71 changes: 41 additions & 30 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
} */
Expand All @@ -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 {
Expand All @@ -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;
} */
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -293,4 +298,10 @@ div.draggable {
.source-text {
color: #121212;
}
}

.prevent-select {
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}

0 comments on commit d8a22bc

Please sign in to comment.