summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2025-02-04 13:41:48 +0530
committerSunil Shetye2025-02-04 13:48:48 +0530
commit3d4bca7df0ce5b20e2f8678593a54818ffcaaee9 (patch)
treef28d3a62f340ae35d189bae6e9aa74973b9e4cdb
parent7590fce5d05c2ea564cd6be045835028bc726696 (diff)
downloadCommon-Interface-Project-3d4bca7df0ce5b20e2f8678593a54818ffcaaee9.tar.gz
Common-Interface-Project-3d4bca7df0ce5b20e2f8678593a54818ffcaaee9.tar.bz2
Common-Interface-Project-3d4bca7df0ce5b20e2f8678593a54818ffcaaee9.zip
fix message when book has already been selected
-rw-r--r--blocks/eda-frontend/.babelrc.json3
-rw-r--r--blocks/eda-frontend/src/pages/Gallery.js42
-rw-r--r--blocks/eda-frontend/src/utils/GalleryUtils.js2
3 files changed, 39 insertions, 8 deletions
diff --git a/blocks/eda-frontend/.babelrc.json b/blocks/eda-frontend/.babelrc.json
new file mode 100644
index 00000000..7dd5e9df
--- /dev/null
+++ b/blocks/eda-frontend/.babelrc.json
@@ -0,0 +1,3 @@
+{
+ "presets": ["@babel/preset-react"]
+}
diff --git a/blocks/eda-frontend/src/pages/Gallery.js b/blocks/eda-frontend/src/pages/Gallery.js
index a316c5a3..b448c241 100644
--- a/blocks/eda-frontend/src/pages/Gallery.js
+++ b/blocks/eda-frontend/src/pages/Gallery.js
@@ -240,13 +240,18 @@ export default function Gallery () {
? GallerySchSample // Show all schematics for 'All Books'
: GallerySchSample.filter((sch) => sch.book_id === parseInt(selectedBookId))
+ const st = searchTerm.trim().toLowerCase()
+
// Then, filter based on the search term (independent from book selection)
- const finalfilteredSchematics = filteredSchematics.filter((sch) => {
- return (
- sch.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
- sch.description.toLowerCase().includes(searchTerm.toLowerCase())
- )
- })
+ const finalfilteredSchematics =
+ st === ''
+ ? filteredSchematics
+ : filteredSchematics.filter((sch) => {
+ return (
+ sch.name.toLowerCase().includes(st) ||
+ sch.description.toLowerCase().includes(st)
+ )
+ })
return (
<div className={classes.root}>
@@ -273,7 +278,30 @@ export default function Gallery () {
</Grid>
{/* Display a message or blank gallery */}
- {finalfilteredSchematics.length === 0 ? (<Grid item xs={12}><Typography variant='h6' align='center' color='textSecondary'>No schematics to display. Please select a book.</Typography></Grid>) : (finalfilteredSchematics.map((sch) => (<Grid item xs={12} sm={6} lg={4} key={sch.save_id}><SchematicCard sch={sch} /></Grid>)))}</Grid>
+ {finalfilteredSchematics.length === 0
+ ? (
+ <Grid item xs={12}>
+ <Typography variant='h6' align='center' color='textSecondary'>
+ {'No ' + process.env.REACT_APP_SMALL_DIAGRAMS_NAME + ' to display. '}
+ {
+ selectedBookId === ''
+ ? 'Please select a book.'
+ : selectedBookId === 'all'
+ ? 'Please try another search term.'
+ : 'Please select another book or try another search term.'
+ }
+ </Typography>
+ </Grid>
+ )
+ : (
+ finalfilteredSchematics.map((sch) => (
+ <Grid item xs={12} sm={6} lg={4} key={sch.save_id}>
+ <SchematicCard sch={sch} />
+ </Grid>
+ ))
+ )
+ }
+ </Grid>
</Container>
</div>
)
diff --git a/blocks/eda-frontend/src/utils/GalleryUtils.js b/blocks/eda-frontend/src/utils/GalleryUtils.js
index 6727edb9..1dad8222 100644
--- a/blocks/eda-frontend/src/utils/GalleryUtils.js
+++ b/blocks/eda-frontend/src/utils/GalleryUtils.js
@@ -143,7 +143,7 @@ export const getDate = (jsonDate) => {
return `${day}-${month}-${year}`
}
-export function styleToObject (style) {
+export const styleToObject = (style) => {
// To add semicolon at the end if it isn't already present.
if (style[style.length - 1] !== ';') {
style = style + ';'