Skip to content

Commit

Permalink
added deselection of the previous scope . and removed unwanted cheks …
Browse files Browse the repository at this point in the history
…from save meta
  • Loading branch information
sijumoncy committed Nov 10, 2023
1 parent a5cd3e6 commit e923848
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function SelectBook({
selectedBooks,
setSelectedBooks,
scope,
existingScope = [],
}) {
const [openNT, setOpenNT] = useState(true);
const [openOT, setOpenOT] = useState(true);
Expand Down Expand Up @@ -46,7 +47,9 @@ export default function SelectBook({
} else {
const _selectedBooks = [...selectedBooks];
const selectedIndex = _selectedBooks.indexOf(bookID.toUpperCase());
if (!(scope === 'Other' && existingScope?.length > 0 && existingScope.includes(bookID.toUpperCase()))) {
_selectedBooks.splice(selectedIndex, 1);
}
setSelectedBooks(_selectedBooks);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export default function AdvancedSettingsDropdown({ call, project, projectType })
setCurrentScope({ title: t('label-other'), currentScope: vals });
}
};
// console.log('canon spec : ', { canonSpecification });
// selectNew variable is used to track whether its a new selection or loading from the list
const setALicense = (licenceTitle, selectNew) => {
if (isElectron()) {
Expand Down Expand Up @@ -375,6 +374,7 @@ export default function AdvancedSettingsDropdown({ call, project, projectType })
bibleNav={bibleNav}
closeBibleNav={() => closeBooks()}
handleNav={handleNav}
project={project}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import SelectBook from '@/components/EditorPage/Navigation/reference/SelectBook'
import { ProjectContext } from '../../context/ProjectContext';
import * as logger from '../../../logger';

const CustomCanonSpecification = ({ bibleNav, closeBibleNav, handleNav }) => {
const CustomCanonSpecification = ({
bibleNav, closeBibleNav, handleNav, project,
}) => {
const initialBook = 'mat';
const initialChapter = '1';
const initialVerse = '1';
Expand All @@ -18,6 +20,7 @@ const CustomCanonSpecification = ({ bibleNav, closeBibleNav, handleNav }) => {
states: { canonSpecification, canonList },
actions: { setcanonSpecification },
} = React.useContext(ProjectContext);

const [selectedBooks, setSelectedBooks] = React.useState([]);
const [lock, setLock] = React.useState();
const {
Expand All @@ -36,6 +39,7 @@ const CustomCanonSpecification = ({ bibleNav, closeBibleNav, handleNav }) => {
});
closeBibleNav();
};

React.useEffect(() => {
if (handleNav === 'edit') {
setLock(canonSpecification.locked);
Expand All @@ -44,6 +48,7 @@ const CustomCanonSpecification = ({ bibleNav, closeBibleNav, handleNav }) => {
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleNav]);

return (
<Transition
show={bibleNav}
Expand Down Expand Up @@ -82,6 +87,7 @@ const CustomCanonSpecification = ({ bibleNav, closeBibleNav, handleNav }) => {
selectedBooks={selectedBooks}
setSelectedBooks={setSelectedBooks}
scope={name}
existingScope={Object.keys(project?.type?.flavorType?.currentScope)}
>
<button
type="button"
Expand Down
21 changes: 11 additions & 10 deletions renderer/src/core/projects/saveProjetcsMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ export const saveProjectsMeta = async (projectMetaObj) => {
}
});

if (projectMetaObj.call === 'edit' && !checker((projectMetaObj.canonSpecification.currentScope), Object.keys(projectMetaObj.project.type.flavorType.currentScope))) {
checkCanon = true;
logger.warn('saveProjectsMeta.js', 'Not allowed to remove previous scope');
status.push({ type: 'warning', value: 'You are not allowed to remove previous scope.' });
}
// commetend because deselection of exisitng scope is not allowd in the ui itself
// if (projectMetaObj.call === 'edit' && !checker((projectMetaObj.canonSpecification.currentScope), Object.keys(projectMetaObj.project.type.flavorType.currentScope))) {
// checkCanon = true;
// logger.warn('saveProjectsMeta.js', 'Not allowed to remove previous scope');
// status.push({ type: 'warning', value: 'You are not allowed to remove previous scope.' });
// }

if (checkCanon === false) {
let id;
Expand Down Expand Up @@ -230,11 +231,11 @@ export const saveProjectsMeta = async (projectMetaObj) => {
}
});

if (projectMetaObj.call === 'edit' && !checker((projectMetaObj.canonSpecification.currentScope), Object.keys(projectMetaObj.project.type.flavorType.currentScope))) {
checkCanon = true;
logger.warn('saveProjectsMeta.js', 'Not allowed to remove previous scope');
status.push({ type: 'warning', value: 'You are not allowed to remove previous scope.' });
}
// if (projectMetaObj.call === 'edit' && !checker((projectMetaObj.canonSpecification.currentScope), Object.keys(projectMetaObj.project.type.flavorType.currentScope))) {
// checkCanon = true;
// logger.warn('saveProjectsMeta.js', 'Not allowed to remove previous scope');
// status.push({ type: 'warning', value: 'You are not allowed to remove previous scope.' });
// }

if (checkCanon === false) {
let id;
Expand Down

0 comments on commit e923848

Please sign in to comment.