RESQUE-Framework / collector-app

A web app for applicants: Enter the RESQUE indicators for your 10 best papers.
https://resque-framework.github.io/collector-app/
MIT License
2 stars 0 forks source link

Preview: value:0 not shown #35

Closed nicebread closed 2 days ago

nicebread commented 2 days ago

In the preview mode, scores with value:0 are not shown ("not available" should have 0P):

image

If I define it as a string, it is correctly shown:

"options": [
                {
                    "id": "NotApplicable",
                    "text": "Not applicable [provide explanation]",
                    "value": 0
                },
                {
                    "id": "NotAvailable",
                    "text": "Not available",
                    "value": "0"
                },
                {
                    "id": "YesParts",
                    "text": "Yes, parts of material [provide doi or URL]",
                    "value": 0.5
                },
nicebread commented 2 days ago

Fixed: <i><span style="background-color: yellow;" x-show="option.value !== undefined && $store.showPoints" x-text="(${option.value}P) "></span></i>

The issue lies in how the JavaScript expression option.value is being evaluated. In JavaScript, the number 0 is considered a falsy value, meaning that it evaluates to false in a Boolean context. As a result, when you use x-show="option.value", the element will not be displayed because 0 evaluates to false.