sef-global / sef-site

Official Website for Sustainable Education Foundation
https://sefglobal.org
MIT License
50 stars 137 forks source link

Implement Industry filters with Dynamic Checkboxes #1511

Closed janithlahirukariyawasam closed 1 year ago

janithlahirukariyawasam commented 1 year ago

Purpose

The purpose of this PR is to fix #1465

Goals

To implement Industry Filters on the archive page. To dynamically render checkboxes based on the data source updates.

Approach

Screenshots

Preview Link

https://pr-1511-sef-site.surge.sh/scholarx/archive/ https://pr-1511-sef-site.surge.sh/

Checklist

Related PRs

## Learning
anjula-sack commented 1 year ago

can you resolve conflicts? @janithlahirukariyawasam

janithlahirukariyawasam commented 1 year ago

First Issue I have used relevant industry names to name the checkbox's HTML ID attribute. (Eg: "Computer Science") but when we use "Computer Science" to HTML ID attribute, HTML only consider it's first word. So it's mean Computer Science Checkbox's id is just only "Computer" So What I can do for this? The reason is if we have two different checkboxes called Computer Science and Computer Engineering there will be an issue. (Both things first word is Computer)

Seond Issue To render dynamic checkboxes I have to find unique industry names inside the dataset. and I able to do it, but I got also empty string as a new industry. I have to remove it manually. But I don't know how the empty string occur. image

When you review this PR please go through the Archive page Google Sheet.

anjula-sack commented 1 year ago

First Issue I have used relevant industry names to name the checkbox's HTML ID attribute. (Eg: "Computer Science") but when we use "Computer Science" to HTML ID attribute, HTML only consider it's first word. So it's mean Computer Science Checkbox's id is just only "Computer" So What I can do for this? The reason is if we have two different checkboxes called Computer Science and Computer Engineering there will be an issue. (Both things first word is Computer)

Seond Issue To render dynamic checkboxes I have to find unique industry names inside the dataset. and I able to do it, but I got also empty string as a new industry. I have to remove it manually. But I don't know how the empty string occur. image

When you review this PR please go through the Archive page Google Sheet.

For the first issue we can convert id with js to turn Computer Science -> computer_science then it will be resolved. Here's a sample,

let industry = "Computer Science";
industry = industry.replace(/\s+/g, '_').toLowerCase();
console.log(industry); // computer_science
janithlahirukariyawasam commented 1 year ago

image

There was a crash it is due to if we have an empty industry cell , that is also considered as an unique industry. So I used this above function to avoid these kind of failures. Can you check the implementation with archive page google sheet changers. @anjula-sack

anjula-sack commented 1 year ago

image

There was a crash it is due to if we have an empty industry cell , that is also considered as an unique industry. So I used this above function to avoid these kind of failures. Can you check the implementation with archive page google sheet changers. @anjula-sack

This might happen for the year and other filters as well right? @janithlahirukariyawasam

janithlahirukariyawasam commented 1 year ago

image There was a crash it is due to if we have an empty industry cell , that is also considered as an unique industry. So I used this above function to avoid these kind of failures. Can you check the implementation with archive page google sheet changers. @anjula-sack

This might happen for the year and other filters as well right? @janithlahirukariyawasam

I didn't encounter it for years.Anyway I also added filtering capabilities for the years