Closed felideon closed 1 month ago
The changes involve modifications to the SurveyTaskList
component and its associated Storybook stories. The SurveyTaskList.stories.tsx
file has been refactored to use a new render
function for story definitions, replacing the previous Template
function. Additionally, several stories have been updated or added to enhance their structure. In the SurveyTaskList.tsx
file, new optional properties hideIfEmpty
and emptyText
have been introduced to the component's props, and the logic has been updated to handle an "Empty" state, improving the component's flexibility in managing task displays.
File Path | Change Summary |
---|---|
src/components/container/SurveyTaskList/SurveyTaskList.stories.tsx |
- Refactored story definitions to use a new render function instead of Template . - Updated existing stories and added new stories ( EmptyIncomplete , EmptyComplete ). |
src/components/container/SurveyTaskList/SurveyTaskList.tsx |
- Added optional properties hideIfEmpty and emptyText to SurveyTaskListProps . - Expanded SurveyTaskListListPreviewState to include "Empty". - Updated rendering logic to handle empty states. |
src/helpers/strings-de.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/helpers/strings-en.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/helpers/strings-es.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/helpers/strings-fr.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/helpers/strings-it.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/helpers/strings-nl.ts |
- Added keys "empty-tasks-incomplete" and "empty-tasks-complete" without removing any existing keys. |
src/helpers/strings-pl.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/helpers/strings-pt.ts |
- Removed key "all-tasks-complete" and added keys "empty-tasks-incomplete" and "empty-tasks-complete" . |
src/components/container/SurveyTaskList/SurveyTaskList.tsx
[error] 19-19: Don't use 'Function' as a type. Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs. (lint/complexity/noBannedTypes)
src/components/container/SurveyTaskList/SurveyTaskList.tsx (5)
`28-29`: **Added 'hideIfEmpty' and 'emptyText' properties to SurveyTaskListProps** The inclusion of the optional `hideIfEmpty` and `emptyText` properties enhances the component's flexibility, allowing for conditional rendering and custom empty messages. --- `32-32`: **Updated 'SurveyTaskListListPreviewState' to include 'Empty' state** Extending the `SurveyTaskListListPreviewState` type with the `"Empty"` state improves the component's preview capabilities, enabling simulation of empty task lists. --- `93-97`: **Properly handle the 'Empty' preview state** The implementation correctly handles the `"Empty"` preview state by setting `tasks` to an empty array and updating the loading state, ensuring accurate previews. --- `143-147`: **Correctly manage 'hideIfEmpty' based on 'status'** The logic ensures that when `status` is `"complete"`, `hideIfEmpty` defaults to `true`, maintaining backward compatibility and aligning with expected behavior. --- `162-164`: **Simplified rendering of the empty message** Using `props.emptyText?.trim() || language(\`empty-tasks-\${props.status}\`)` enhances readability and efficiently handles the empty message display.
Overview
Adds
hideIfEmpty
andemptyText
props to the SurveyTaskList component.incomplete
task lists,hideIfEmpty
helps users not have to implement their own conditionals using schedules/custom fields, and makes it nice to use multiple task lists on the same view, which the surveyCategory property now makes more likely to occur.complete
task lists were always hidden if empty. The new property allows users to display an empty complete task list, but, by default (i.e. ifhideIfEmpty
is undefined) will keep the previous behavior.emptyText
provides a way for users to override the default string for empty lists, which was also changed (and re-translated). Previously, onlyincomplete
task lists had a message when empty, but now there's also a default message for emptycomplete
task lists.Also includes a refactor to make the SurveyTaskList stories code consistent with more recent components, fixing a type deprecation.
Security
REMINDER: All file contents are public.
Checklist
Testing
Documentation
Consider "Squash and merge" as needed to keep the commit history reasonable on
main
.Summary by CodeRabbit
Summary by CodeRabbit
New Features
SurveyTaskList
component to manage and display empty states with customizable messages.SurveyTaskList
, includingEmptyIncomplete
andEmptyComplete
.Bug Fixes