CenterForTheBuiltEnvironment / comfort-dash

Revision of the CBE Comfort Tool using Dash.
2 stars 12 forks source link

Remove some duplications and create select box for met and clo #27

Closed ZhouTongworking closed 1 month ago

ZhouTongworking commented 2 months ago

Description

Remove the duplications in my_config_file.py and create the select box for met and clo.

Types of change

Implementation

For each value in the model, the code first checks to see if an item called "Metabolic Rate" has been encountered. If so, it calls a specialized function, create_metabolic_rate_input, to create a custom input component, which is then added to the inputs list. Similarly, if an item named "Clothing Level" is encountered, the code calls the create_clothing_level_input function to create another special input component, also adding it to the inputs list. image

These two functions are designed to create a special user input interface specifically for handling the metabolic rate and clothing level parameters in the environmental comfort model. They utilize an Autocomplete component to provide a flexible and user-friendly input method. This design allows users to enter specific values directly, while also potentially selecting common activities or clothing types from a predefined selection. image image

These two callback functions are designed for the metabolic rate and clothing level input fields, and are triggered when the user enters or selects content in these fields, potentially updating the list of options based on the user's input, verifying and converting the input values in real time, ensuring data consistency, and providing immediate feedback. image image

These functions are called when the user enters content in the input field. They first try to interpret the input as a numerical value. If successful, the function searches the list of predefined options to find those whose values are close to those entered by the user. The goal is to provide the user with the most relevant options, allowing the user to quickly find the right option even if they are unsure of the exact value. If the user enters something other than a numeric value, or if no matching option is found, the function returns a complete list of options. image image

By setting allow_duplicate=True, these callbacks update the same component that triggers them, allowing for an immediate response to the input field. Also, prevent_initial_call=True ensures that the callback is triggered only when the user actually enters it, not when the page first loads. image image

Their main purpose is to extract and return the corresponding numeric value when the user selects the value from the predefined options. If the selected value does not conform to the expected format, the function takes appropriate error handling action. image image

Remove duplications:

Put the same code all in the same class image image image

Current issue:

The drop-down search function for the met and clo input fields is implemented in the same way, causing code duplication issues that need to be modified

FedericoTartarini commented 2 months ago

@ZhouTongworking This branch has conflicts that must be resolved before accepting the pull request

ZhouTongworking commented 2 months ago

Okay, I'll update on the latest branch

ZhouTongworking commented 2 months ago

Hi Federico, We have a applay a new pull request, and we changed the code in the new version. For details, you can check out Xuhui wang's pull request. Thank you.

FedericoTartarini commented 1 month ago

Is this Pull reuqest still needed or shall we close it? If there are some important changes included in this pull request please keep it open.

ZhouTongworking commented 1 month ago

Yes,we can close it, all changes in the lastest version

FedericoTartarini commented 1 month ago

Okay, so please close this in the future.