Skip to content

Commit 89b1a3b

Browse files
authored
Merge pull request #26 from texttree/feature-foxprogs-obs-support
Feature foxprogs obs support
2 parents 260b7dc + 8dc5168 commit 89b1a3b

4 files changed

Lines changed: 108 additions & 9 deletions

File tree

src/components/BibleBookList/BibleBookList.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import React, { useState } from 'react';
22
import BookList from '../BookList';
33
import PropTypes from 'prop-types';
4-
import { BIBLE_LIST, BIBLE_BOOKS } from './config';
4+
import {
5+
OLD_TESTAMENT_LIST,
6+
NEW_TESTAMENT_LIST,
7+
OBS_LIST,
8+
OLD_TESTAMENT,
9+
NEW_TESTAMENT,
10+
OBS,
11+
} from './config';
512
import Checkbox from '@material-ui/core/Checkbox';
613
import { FormControlLabel } from '@material-ui/core';
714

@@ -13,25 +20,39 @@ function BibleBookList({
1320
selectedBookId,
1421
titleOT,
1522
titleNT,
23+
titleOBS,
1624
availableBookList,
1725
titleBooks,
1826
BibleBookListClasses,
1927
bookClasses,
2028
testaments,
2129
sortFirstNT,
30+
showOBS,
2231
}) {
2332
const [checkState, setCheckState] = useState(!showInactive);
24-
const currentBookList = BIBLE_LIST.map((el) => {
33+
let bibleList;
34+
if (showOBS) {
35+
bibleList = OLD_TESTAMENT_LIST.concat(NEW_TESTAMENT_LIST).concat(OBS_LIST);
36+
} else {
37+
bibleList = OLD_TESTAMENT_LIST.concat(NEW_TESTAMENT_LIST);
38+
}
39+
let bibleBooks;
40+
if (showOBS) {
41+
bibleBooks = { ...OLD_TESTAMENT, ...NEW_TESTAMENT, ...OBS };
42+
} else {
43+
bibleBooks = { ...OLD_TESTAMENT, ...NEW_TESTAMENT };
44+
}
45+
const currentBookList = bibleList.map((el) => {
2546
return {
2647
...el,
27-
text: titleBooks[el.identifier] ?? BIBLE_BOOKS[el.identifier],
48+
text: titleBooks[el.identifier] ?? bibleBooks[el.identifier],
2849
isset: availableBookList.includes(el.identifier),
2950
};
3051
});
3152

3253
const currentBookListOT = currentBookList.filter((el) => el.categories === 'bible-ot');
33-
3454
const currentBookListNT = currentBookList.filter((el) => el.categories === 'bible-nt');
55+
const currentBookListOBS = currentBookList.filter((el) => el.categories === 'obs');
3556
const handleChange = () => {
3657
setCheckState((prev) => !prev);
3758
};
@@ -85,6 +106,16 @@ function BibleBookList({
85106
break;
86107
}
87108

109+
if (showOBS) {
110+
testamentList = testamentList.concat({
111+
title: titleOBS,
112+
bookList: currentBookListOBS,
113+
});
114+
if (showCheckbox) {
115+
showCheckbox = allBooksIsSet(currentBookListOBS);
116+
}
117+
}
118+
88119
const checkboxRender = showCheckbox ? (
89120
<FormControlLabel
90121
classes={{
@@ -125,10 +156,12 @@ const bookListRender = testamentList.map((el, index) => {
125156

126157
BibleBookList.defaultProps = {
127158
showCheckbox: true,
159+
showOBS: false,
128160
sortFirstNT: false,
129161
testaments: 'all',
130162
titleOT: '',
131163
titleNT: '',
164+
titleOBS: '',
132165
showInactive: true,
133166
onClickBook: (bookId) => {},
134167
labelForCheckbox: 'Show only existing books',
@@ -140,6 +173,8 @@ BibleBookList.propTypes = {
140173
testaments: PropTypes.oneOf(['all', 'nt', 'ot']),
141174
/** block header of "New Testament" */
142175
titleNT: PropTypes.string,
176+
/** block header of "OBS" */
177+
titleOBS: PropTypes.string,
143178
/** block header of "Old Testament" */
144179
titleOT: PropTypes.string,
145180
/** when true, show first New Testament, second - Old Testament */
@@ -150,6 +185,8 @@ BibleBookList.propTypes = {
150185
titleBooks: PropTypes.object,
151186
/** show or hide checkbox that show only existing books */
152187
showCheckbox: PropTypes.bool,
188+
/** show or hide OBS block */
189+
showOBS: PropTypes.bool,
153190
/** whether to display inactive books */
154191
showInactive: PropTypes.bool,
155192
/** label of checkbox */

src/components/BibleBookList/BibleBookList.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ const titleBooks = {
99
mrk: 'Марк',
1010
luk: 'Лука',
1111
tit: 'Титу',
12+
obs: 'Открытые Библейские Истории',
1213
};
1314

1415
const [selectedBookId, setSelectedBookId] = React.useState('exo');
1516

1617
const onClickBook = (bookId) => setSelectedBookId(bookId);
1718

18-
const availableBookList = ['gen', 'exo', 'lev', 'num', 'mat', 'mrk', 'luk', 'tit'];
19+
const availableBookList = ['gen', 'exo', 'lev', 'num', 'mat', 'mrk', 'luk', 'tit', 'obs'];
1920

2021
const NTBookList = [
2122
'mat',
@@ -53,6 +54,8 @@ const NTBookList = [
5354
showInactive={false}
5455
titleOT="Old Testament"
5556
titleNT="New Testament"
57+
titleOBS="Other"
58+
showOBS={true}
5659
titleBooks={titleBooks}
5760
availableBookList={availableBookList} // replace to NTBookList
5861
selectedBookId={selectedBookId}

src/components/BibleBookList/config.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@ export const NEW_TESTAMENT = {
6969
rev: 'Revelation',
7070
};
7171

72-
export const BIBLE_BOOKS = {
73-
...NEW_TESTAMENT,
74-
...OLD_TESTAMENT,
72+
export const OBS = {
73+
obs: 'Open Bible Story',
7574
};
7675

76+
export const OBS_LIST = [
77+
{
78+
identifier: 'obs',
79+
isset: false,
80+
sort: 70,
81+
categories: 'obs',
82+
},
83+
];
84+
7785
export const OLD_TESTAMENT_LIST = [
7886
{
7987
identifier: 'gen',
@@ -474,4 +482,3 @@ export const NEW_TESTAMENT_LIST = [
474482
categories: 'bible-nt',
475483
},
476484
];
477-
export const BIBLE_LIST = OLD_TESTAMENT_LIST.concat(NEW_TESTAMENT_LIST);

src/components/BibleChapterList/config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,4 +1320,56 @@ export const BOOK_CHAPTERS = {
13201320
21: '27',
13211321
22: '21',
13221322
},
1323+
obs: {
1324+
1: '1',
1325+
2: '1',
1326+
3: '1',
1327+
4: '1',
1328+
5: '1',
1329+
6: '1',
1330+
7: '1',
1331+
8: '1',
1332+
9: '1',
1333+
10: '1',
1334+
11: '1',
1335+
12: '1',
1336+
13: '1',
1337+
14: '1',
1338+
15: '1',
1339+
16: '1',
1340+
17: '1',
1341+
18: '1',
1342+
19: '1',
1343+
20: '1',
1344+
21: '1',
1345+
22: '1',
1346+
23: '1',
1347+
24: '1',
1348+
25: '1',
1349+
26: '1',
1350+
27: '1',
1351+
28: '1',
1352+
29: '1',
1353+
30: '1',
1354+
31: '1',
1355+
32: '1',
1356+
33: '1',
1357+
34: '1',
1358+
35: '1',
1359+
36: '1',
1360+
37: '1',
1361+
38: '1',
1362+
39: '1',
1363+
40: '1',
1364+
41: '1',
1365+
42: '1',
1366+
43: '1',
1367+
44: '1',
1368+
45: '1',
1369+
46: '1',
1370+
47: '1',
1371+
48: '1',
1372+
49: '1',
1373+
50: '1',
1374+
},
13231375
};

0 commit comments

Comments
 (0)