From a9850e29815d79b36db820cc3be776f34dce03d7 Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:52:00 +0200 Subject: [PATCH] Surveys list: fixed "only own" filtering (#3552) Co-authored-by: Stefano Ricci Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../survey/repository/surveyRepository.js | 2 ++ .../survey/Surveys/HeaderLeft/HeaderLeft.js | 32 +++++++++---------- webapp/components/survey/Surveys/Surveys.scss | 10 ++++-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/server/modules/survey/repository/surveyRepository.js b/server/modules/survey/repository/surveyRepository.js index e24600a019..184e9fe9d7 100644 --- a/server/modules/survey/repository/surveyRepository.js +++ b/server/modules/survey/repository/surveyRepository.js @@ -172,6 +172,7 @@ export const fetchUserSurveys = async ( sortBy = Survey.sortableKeys.dateModified, sortOrder = 'DESC', includeOwnerEmailAddress = false, + onlyOwn = false, }, client = db ) => { @@ -189,6 +190,7 @@ export const fetchUserSurveys = async ( sortBy, sortOrder, includeOwnerEmailAddress, + onlyOwn, }), { userUuid: User.getUuid(user), template, search }, (def) => DB.transformCallback(def, true) diff --git a/webapp/components/survey/Surveys/HeaderLeft/HeaderLeft.js b/webapp/components/survey/Surveys/HeaderLeft/HeaderLeft.js index 1a84dfdd79..b57b7c024a 100644 --- a/webapp/components/survey/Surveys/HeaderLeft/HeaderLeft.js +++ b/webapp/components/survey/Surveys/HeaderLeft/HeaderLeft.js @@ -6,37 +6,37 @@ import { ButtonDownload } from '@webapp/components/buttons' import { useAuthCanExportSurveysList, useUserIsSystemAdmin } from '@webapp/store/user/hooks' const HeaderLeft = (props) => { - const { handleSearch, onlyOwn = false, search, setOnlyOwn = null, totalCount } = props + const { count, handleSearch, onlyOwn = false, search, setOnlyOwn = null } = props const isSystemAdmin = useUserIsSystemAdmin() const canExportSurveys = useAuthCanExportSurveysList() - if (!totalCount) return null - return ( <> - { - handleSearch(val) - }} - placeholder="surveysView.filterPlaceholder" - /> - {isSystemAdmin && setOnlyOwn && ( - setOnlyOwn(!onlyOwn)} /> - )} - {canExportSurveys && } +
+ { + handleSearch(val) + }} + placeholder="surveysView.filterPlaceholder" + /> + {isSystemAdmin && setOnlyOwn && ( + setOnlyOwn(!onlyOwn)} /> + )} +
+ {canExportSurveys && count > 0 && } ) } HeaderLeft.propTypes = { + count: PropTypes.number.isRequired, handleSearch: PropTypes.func.isRequired, onlyOwn: PropTypes.bool, search: PropTypes.string.isRequired, setOnlyOwn: PropTypes.func, - totalCount: PropTypes.number.isRequired, } export default HeaderLeft diff --git a/webapp/components/survey/Surveys/Surveys.scss b/webapp/components/survey/Surveys/Surveys.scss index 1b8e69b18e..453132c654 100644 --- a/webapp/components/survey/Surveys/Surveys.scss +++ b/webapp/components/survey/Surveys/Surveys.scss @@ -2,9 +2,13 @@ .table__header { column-gap: 5rem; - input { - width: 25rem; - padding: 0.5rem; + .filter-container { + display: flex; + gap: 2rem; + + .surveys__header-left__input-search { + width: 25rem; + } } }