-
Notifications
You must be signed in to change notification settings - Fork 129
Add the functionality of response ratio #3370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the functionality of response ratio #3370
Conversation
@@ -0,0 +1,291 @@ | |||
<script lang="ts"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this component to common folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
function handleChange(index, event) { | ||
const isEmpty = event.detail === "" || event.detail === null; | ||
const activeResponse = activeResponses[index]; | ||
const responseId = activeResponse.id; | ||
|
||
const oldValue = Number(inputValues.get(responseId) || 0); | ||
|
||
const newNumericValue = isEmpty ? 0 : Number(event.detail); | ||
|
||
const potentialTotal = totalPercentage - oldValue + newNumericValue; | ||
inputValues.set(responseId, isEmpty ? null : newNumericValue); | ||
|
||
// Recalculate total | ||
calculateTotal(); | ||
|
||
// Handle error state | ||
if (potentialTotal <= 100) { | ||
exceededLimit = false; | ||
lastModifiedIndex = null; | ||
} else { | ||
exceededLimit = true; | ||
lastModifiedIndex = index; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it arrow function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
function calculateTotal() { | ||
totalPercentage = 0; | ||
|
||
activeResponses.forEach((response) => { | ||
const value = inputValues.get(response.id); | ||
totalPercentage += | ||
value === null || value === undefined || value === "" | ||
? 0 | ||
: Number(value); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it arrow function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
71f5a04
into
sparrowapp-dev:mock-response-ratio
🎉 This PR is included in version 2.27.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
In this pr, I have added the functionality of setting the mock response ratio.
Add Issue Number
Fixes #<your_issue_number>
Add Screenshots/GIFs
Add Known Issue
If applicable, add any known issues.
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.