From 931a63f18b5d5d41cf663dd5910c5f1999369ae8 Mon Sep 17 00:00:00 2001 From: EdsonNhancale Date: Tue, 14 Jan 2025 22:11:28 +0200 Subject: [PATCH 01/13] feat: implemented searchUrl to be able to access the ou and pe --- i18n/en.pot | 24 ++++----- .../InformationBlock/FilterDialog.js | 6 +++ .../InformationBlock/FilterSelector.js | 2 + src/pages/view/FilterBar/FilterBar.js | 4 ++ src/reducers/searchparams.js | 52 +++++++++++++++++++ 5 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 src/reducers/searchparams.js diff --git a/i18n/en.pot b/i18n/en.pot index fa8cab2e1..eae9541e1 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-12-19T11:30:27.893Z\n" -"PO-Revision-Date: 2024-12-19T11:30:27.893Z\n" +"POT-Creation-Date: 2025-01-14T18:01:43.873Z\n" +"PO-Revision-Date: 2025-01-14T18:01:43.874Z\n" msgid "Untitled dashboard" msgstr "Untitled dashboard" @@ -226,12 +226,12 @@ msgid "No data to display" msgstr "No data to display" msgid "" -"Install Line Listing app version ${minLLVersion.join(\n" -" '.'\n" +"Install Line Listing app version ${minLLVersion.join(\r\n" +" '.'\r\n" " )} or higher in order to display this item." msgstr "" -"Install Line Listing app version ${minLLVersion.join(\n" -" '.'\n" +"Install Line Listing app version ${minLLVersion.join(\r\n" +" '.'\r\n" " )} or higher in order to display this item." msgid "Show without filters" @@ -384,18 +384,18 @@ msgid "Dashboard filter settings" msgstr "Dashboard filter settings" msgid "" -"Dashboards can be filtered by dimensions to change\n" +"Dashboards can be filtered by dimensions to change\r\n" " the data shown. By default, all " -"dimensions are available\n" +"dimensions are available\r\n" " as filters. Alternatively, only " -"selected dimensions can\n" +"selected dimensions can\r\n" " be made available on a dashboard." msgstr "" -"Dashboards can be filtered by dimensions to change\n" +"Dashboards can be filtered by dimensions to change\r\n" " the data shown. By default, all " -"dimensions are available\n" +"dimensions are available\r\n" " as filters. Alternatively, only " -"selected dimensions can\n" +"selected dimensions can\r\n" " be made available on a dashboard." msgid "Available Filters" diff --git a/src/components/DashboardsBar/InformationBlock/FilterDialog.js b/src/components/DashboardsBar/InformationBlock/FilterDialog.js index 78d3e0443..5e20e94c6 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterDialog.js +++ b/src/components/DashboardsBar/InformationBlock/FilterDialog.js @@ -34,6 +34,7 @@ import { import { sGetItemFiltersRoot } from '../../../reducers/itemFilters.js' import { useSystemSettings } from '../../SystemSettingsProvider.js' import { useUserSettings } from '../../UserSettingsProvider.js' +import { searchParams } from '../../../reducers/searchparams.js' const FilterDialog = ({ dimension, @@ -46,6 +47,7 @@ const FilterDialog = ({ const { userSettings } = useUserSettings() const { systemSettings } = useSystemSettings() const { rootOrgUnits } = useCachedDataQuery() + const paramsHandler = searchParams(); const onSelectItems = ({ dimensionId, items }) => { setFilters({ [dimensionId]: items }) @@ -60,8 +62,12 @@ const FilterDialog = ({ id, value: [...filterItems], }) + console.log("Added Item Filter") + paramsHandler.addSearchParamsToUrl(id, filters[id].map(x=> x.id).join(';')) } else { removeItemFilter(id) + console.log("Removed Item Filter", id, filters[id]) + paramsHandler.overrideValueBasedOnKey(id, filters[id].map(x=> x.id).join(';')) } onClose(id) diff --git a/src/components/DashboardsBar/InformationBlock/FilterSelector.js b/src/components/DashboardsBar/InformationBlock/FilterSelector.js index 69221edf9..bf662d0d8 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterSelector.js +++ b/src/components/DashboardsBar/InformationBlock/FilterSelector.js @@ -57,6 +57,8 @@ const FilterSelector = (props) => { ) + console.log(props) + return props.restrictFilters && !props.allowedFilters?.length ? null : ( <> { const { isConnected: online } = useDhis2ConnectionStatus() const [dialogIsOpen, setDialogIsOpen] = useState(false) + const paramsHandler = searchParams(); const onRemoveFilter = (filterId) => { if (!online && filters.length > 1) { setDialogIsOpen(true) } else { removeFilter(filterId) + console.log("Removed Item Filter basedonId id") + paramsHandler.removeSearchParamsFromUrlByKey(filterId) } } diff --git a/src/reducers/searchparams.js b/src/reducers/searchparams.js new file mode 100644 index 000000000..b5101c171 --- /dev/null +++ b/src/reducers/searchparams.js @@ -0,0 +1,52 @@ +import { useLocation, useHistory } from "react-router-dom"; + +export const searchParams = () => { + const location = useLocation(); + const history = useHistory(); + + const addSearchParamsToUrl = (key, value) => { + const searchParams = new URLSearchParams(location.search); + searchParams.set(key, value); + + // Update the URL with new query params + history.push({ + pathname: location.pathname, + search: `?${searchParams.toString()}`, + }); + }; + + const removeSearchParamsFromUrlByKey = (key) => { + const searchParams = new URLSearchParams(location.search); + searchParams.delete(key); + + // Update the URL after removing the query parameter + history.push({ + pathname: location.pathname, + search: searchParams.toString() ? `?${searchParams.toString()}` : "", + }); + }; + + const overrideValueBasedOnKey = (key, newValues) => { + const searchParams = new URLSearchParams(location.search); + + if (newValues.length > 0) { + // Overwrite the key parameter with new values + searchParams.set(key, newValues.join(";")); + } else { + // If newValues is empty, remove the key from the URL + searchParams.delete(key); + } + + // Update the URL with the overridden query parameters + history.push({ + pathname: location.pathname, + search: `?${searchParams.toString()}`, + }); + }; + + return { + addSearchParamsToUrl, + removeSearchParamsFromUrlByKey, + overrideValueBasedOnKey + }; +}; From b2d2dac3f88efbb4876442609809aff7f8651f9d Mon Sep 17 00:00:00 2001 From: EdsonNhancale Date: Wed, 15 Jan 2025 06:57:31 +0200 Subject: [PATCH 02/13] feat: added pe on iframesrc to use in custom widgets --- src/actions/itemFilters.js | 2 + .../InformationBlock/FilterDialog.js | 4 -- src/components/Item/AppItem/getIframeSrc.js | 9 +++- src/pages/view/FilterBar/FilterBar.js | 2 - src/reducers/searchparams.js | 52 ------------------- 5 files changed, 10 insertions(+), 59 deletions(-) delete mode 100644 src/reducers/searchparams.js diff --git a/src/actions/itemFilters.js b/src/actions/itemFilters.js index 2b5c1b20c..1e4576a0f 100644 --- a/src/actions/itemFilters.js +++ b/src/actions/itemFilters.js @@ -6,6 +6,8 @@ import { export const FILTER_ORG_UNIT = 'ou' +export const FILTER_PE = 'pe' + // actions export const acAddItemFilter = (filter) => ({ diff --git a/src/components/DashboardsBar/InformationBlock/FilterDialog.js b/src/components/DashboardsBar/InformationBlock/FilterDialog.js index 5e20e94c6..5c6a86f67 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterDialog.js +++ b/src/components/DashboardsBar/InformationBlock/FilterDialog.js @@ -62,12 +62,8 @@ const FilterDialog = ({ id, value: [...filterItems], }) - console.log("Added Item Filter") - paramsHandler.addSearchParamsToUrl(id, filters[id].map(x=> x.id).join(';')) } else { removeItemFilter(id) - console.log("Removed Item Filter", id, filters[id]) - paramsHandler.overrideValueBasedOnKey(id, filters[id].map(x=> x.id).join(';')) } onClose(id) diff --git a/src/components/Item/AppItem/getIframeSrc.js b/src/components/Item/AppItem/getIframeSrc.js index ae2b1c2c8..e5afe0bca 100644 --- a/src/components/Item/AppItem/getIframeSrc.js +++ b/src/components/Item/AppItem/getIframeSrc.js @@ -1,4 +1,4 @@ -import { FILTER_ORG_UNIT } from '../../../actions/itemFilters.js' +import { FILTER_ORG_UNIT, FILTER_PE } from '../../../actions/itemFilters.js' export const getIframeSrc = (appDetails, item, itemFilters) => { let iframeSrc = `${appDetails.launchUrl}?dashboardItemId=${item.id}` @@ -11,5 +11,12 @@ export const getIframeSrc = (appDetails, item, itemFilters) => { iframeSrc += `&userOrgUnit=${ouIds.join(',')}` } + // Add period (pe) to iframeSrc + if (itemFilters[FILTER_PE] && itemFilters[FILTER_PE].length) { + const peValues = itemFilters[FILTER_PE].map(x => x.id).join(';'); + iframeSrc += `&pe=${peValues}`; + } + + return iframeSrc } diff --git a/src/pages/view/FilterBar/FilterBar.js b/src/pages/view/FilterBar/FilterBar.js index 116b299ec..0d8f72ac5 100644 --- a/src/pages/view/FilterBar/FilterBar.js +++ b/src/pages/view/FilterBar/FilterBar.js @@ -23,8 +23,6 @@ const FilterBar = ({ filters, removeFilter, removeAllFilters }) => { setDialogIsOpen(true) } else { removeFilter(filterId) - console.log("Removed Item Filter basedonId id") - paramsHandler.removeSearchParamsFromUrlByKey(filterId) } } diff --git a/src/reducers/searchparams.js b/src/reducers/searchparams.js deleted file mode 100644 index b5101c171..000000000 --- a/src/reducers/searchparams.js +++ /dev/null @@ -1,52 +0,0 @@ -import { useLocation, useHistory } from "react-router-dom"; - -export const searchParams = () => { - const location = useLocation(); - const history = useHistory(); - - const addSearchParamsToUrl = (key, value) => { - const searchParams = new URLSearchParams(location.search); - searchParams.set(key, value); - - // Update the URL with new query params - history.push({ - pathname: location.pathname, - search: `?${searchParams.toString()}`, - }); - }; - - const removeSearchParamsFromUrlByKey = (key) => { - const searchParams = new URLSearchParams(location.search); - searchParams.delete(key); - - // Update the URL after removing the query parameter - history.push({ - pathname: location.pathname, - search: searchParams.toString() ? `?${searchParams.toString()}` : "", - }); - }; - - const overrideValueBasedOnKey = (key, newValues) => { - const searchParams = new URLSearchParams(location.search); - - if (newValues.length > 0) { - // Overwrite the key parameter with new values - searchParams.set(key, newValues.join(";")); - } else { - // If newValues is empty, remove the key from the URL - searchParams.delete(key); - } - - // Update the URL with the overridden query parameters - history.push({ - pathname: location.pathname, - search: `?${searchParams.toString()}`, - }); - }; - - return { - addSearchParamsToUrl, - removeSearchParamsFromUrlByKey, - overrideValueBasedOnKey - }; -}; From 1e291f2e643ac76b67116afe951f34bf916670e7 Mon Sep 17 00:00:00 2001 From: EdsonNhancale Date: Wed, 15 Jan 2025 07:02:03 +0200 Subject: [PATCH 03/13] fix: removed unnecessary imports --- src/components/DashboardsBar/InformationBlock/FilterDialog.js | 1 - .../DashboardsBar/InformationBlock/FilterSelector.js | 4 +--- src/pages/view/FilterBar/FilterBar.js | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/DashboardsBar/InformationBlock/FilterDialog.js b/src/components/DashboardsBar/InformationBlock/FilterDialog.js index 5c6a86f67..ed22693e4 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterDialog.js +++ b/src/components/DashboardsBar/InformationBlock/FilterDialog.js @@ -47,7 +47,6 @@ const FilterDialog = ({ const { userSettings } = useUserSettings() const { systemSettings } = useSystemSettings() const { rootOrgUnits } = useCachedDataQuery() - const paramsHandler = searchParams(); const onSelectItems = ({ dimensionId, items }) => { setFilters({ [dimensionId]: items }) diff --git a/src/components/DashboardsBar/InformationBlock/FilterSelector.js b/src/components/DashboardsBar/InformationBlock/FilterSelector.js index bf662d0d8..705baae48 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterSelector.js +++ b/src/components/DashboardsBar/InformationBlock/FilterSelector.js @@ -56,9 +56,7 @@ const FilterSelector = (props) => { /> ) - - console.log(props) - + return props.restrictFilters && !props.allowedFilters?.length ? null : ( <> { const { isConnected: online } = useDhis2ConnectionStatus() From 305e701490e591bd34315b5e6fb532783f442250 Mon Sep 17 00:00:00 2001 From: EdsonNhancale Date: Wed, 15 Jan 2025 07:05:33 +0200 Subject: [PATCH 04/13] fix: removed unnecessary imports --- src/components/DashboardsBar/InformationBlock/FilterDialog.js | 1 - src/pages/view/FilterBar/FilterBar.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/DashboardsBar/InformationBlock/FilterDialog.js b/src/components/DashboardsBar/InformationBlock/FilterDialog.js index ed22693e4..78d3e0443 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterDialog.js +++ b/src/components/DashboardsBar/InformationBlock/FilterDialog.js @@ -34,7 +34,6 @@ import { import { sGetItemFiltersRoot } from '../../../reducers/itemFilters.js' import { useSystemSettings } from '../../SystemSettingsProvider.js' import { useUserSettings } from '../../UserSettingsProvider.js' -import { searchParams } from '../../../reducers/searchparams.js' const FilterDialog = ({ dimension, diff --git a/src/pages/view/FilterBar/FilterBar.js b/src/pages/view/FilterBar/FilterBar.js index 81e7d370e..526918240 100644 --- a/src/pages/view/FilterBar/FilterBar.js +++ b/src/pages/view/FilterBar/FilterBar.js @@ -15,7 +15,6 @@ import classes from './styles/FilterBar.module.css' const FilterBar = ({ filters, removeFilter, removeAllFilters }) => { const { isConnected: online } = useDhis2ConnectionStatus() const [dialogIsOpen, setDialogIsOpen] = useState(false) - const paramsHandler = searchParams(); const onRemoveFilter = (filterId) => { if (!online && filters.length > 1) { From ab57d7d1262575775e615bb6dfc5986bae83b2c2 Mon Sep 17 00:00:00 2001 From: Edson Nhancale <54271761+EdsonNhancale@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:32:46 +0200 Subject: [PATCH 05/13] refactor: update delimiter for `pe` values in iframe source URL Changed the delimiter for `pe` values from semicolon (`;`) to comma (`,`), aligning with the standard format for query parameters. This change improves consistency and simplifies downstream processing. Co-authored-by: Kai Vandivier <49666798+KaiVandivier@users.noreply.github.com> --- src/components/Item/AppItem/getIframeSrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Item/AppItem/getIframeSrc.js b/src/components/Item/AppItem/getIframeSrc.js index e5afe0bca..6d02d3c7a 100644 --- a/src/components/Item/AppItem/getIframeSrc.js +++ b/src/components/Item/AppItem/getIframeSrc.js @@ -13,7 +13,7 @@ export const getIframeSrc = (appDetails, item, itemFilters) => { // Add period (pe) to iframeSrc if (itemFilters[FILTER_PE] && itemFilters[FILTER_PE].length) { - const peValues = itemFilters[FILTER_PE].map(x => x.id).join(';'); + const peValues = itemFilters[FILTER_PE].map(x => x.id).join(','); iframeSrc += `&pe=${peValues}`; } From 29e1316aa4a7bff0368793c211c503c8b0bdf972 Mon Sep 17 00:00:00 2001 From: Edson Nhancale <54271761+EdsonNhancale@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:34:32 +0200 Subject: [PATCH 06/13] refactor: use optional chaining to simplify null/undefined checks Replaced the explicit `if` condition `itemFilters[FILTER_PE] && itemFilters[FILTER_PE].length` with the optional chaining expression `itemFilters[FILTER_PE]?.length`, as recommended by SonarQube. Co-authored-by: Kai Vandivier <49666798+KaiVandivier@users.noreply.github.com> --- src/components/Item/AppItem/getIframeSrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Item/AppItem/getIframeSrc.js b/src/components/Item/AppItem/getIframeSrc.js index 6d02d3c7a..de6cc345a 100644 --- a/src/components/Item/AppItem/getIframeSrc.js +++ b/src/components/Item/AppItem/getIframeSrc.js @@ -12,7 +12,7 @@ export const getIframeSrc = (appDetails, item, itemFilters) => { } // Add period (pe) to iframeSrc - if (itemFilters[FILTER_PE] && itemFilters[FILTER_PE].length) { + if (itemFilters[FILTER_PE]?.length) { const peValues = itemFilters[FILTER_PE].map(x => x.id).join(','); iframeSrc += `&pe=${peValues}`; } From 837177edfdfded0f08a229ded4c118e5f303ed3c Mon Sep 17 00:00:00 2001 From: Edson Nhancale <54271761+EdsonNhancale@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:35:49 +0200 Subject: [PATCH 07/13] refactor: rename `pe` parameter to `period` for clarity and consistency Updated the query parameter `pe` to `period` in the iframe source URL to improve readability and better match the naming convention of the org unit parameter. Co-authored-by: Kai Vandivier <49666798+KaiVandivier@users.noreply.github.com> --- src/components/Item/AppItem/getIframeSrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Item/AppItem/getIframeSrc.js b/src/components/Item/AppItem/getIframeSrc.js index de6cc345a..0c7a559b6 100644 --- a/src/components/Item/AppItem/getIframeSrc.js +++ b/src/components/Item/AppItem/getIframeSrc.js @@ -14,7 +14,7 @@ export const getIframeSrc = (appDetails, item, itemFilters) => { // Add period (pe) to iframeSrc if (itemFilters[FILTER_PE]?.length) { const peValues = itemFilters[FILTER_PE].map(x => x.id).join(','); - iframeSrc += `&pe=${peValues}`; + iframeSrc += `&period=${peValues}`; } From a6aaf7be73fe6abea957be977e32acfed641d5d3 Mon Sep 17 00:00:00 2001 From: Edson Nhancale <54271761+EdsonNhancale@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:39:16 +0200 Subject: [PATCH 08/13] fix: remove `i18n/en.pot` file to avoid conflicts Deleted the `i18n/en.pot` file to prevent potential conflicts with other translations or resources. This resolves issues with unnecessary file changes during development and ensures consistency in localization files. --- i18n/en.pot | 614 ---------------------------------------------------- 1 file changed, 614 deletions(-) delete mode 100644 i18n/en.pot diff --git a/i18n/en.pot b/i18n/en.pot deleted file mode 100644 index eae9541e1..000000000 --- a/i18n/en.pot +++ /dev/null @@ -1,614 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: i18next-conv\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2025-01-14T18:01:43.873Z\n" -"PO-Revision-Date: 2025-01-14T18:01:43.874Z\n" - -msgid "Untitled dashboard" -msgstr "Untitled dashboard" - -msgid "Dashboards" -msgstr "Dashboards" - -msgid "The dashboard couldn't be made available offline. Try again." -msgstr "The dashboard couldn't be made available offline. Try again." - -msgid "Remove from offline storage" -msgstr "Remove from offline storage" - -msgid "Make available offline" -msgstr "Make available offline" - -msgid "Sync offline data now" -msgstr "Sync offline data now" - -msgid "Unstar dashboard" -msgstr "Unstar dashboard" - -msgid "Star dashboard" -msgstr "Star dashboard" - -msgid "Hide description" -msgstr "Hide description" - -msgid "Show description" -msgstr "Show description" - -msgid "Print" -msgstr "Print" - -msgid "Dashboard layout" -msgstr "Dashboard layout" - -msgid "One item per page" -msgstr "One item per page" - -msgid "Close dashboard" -msgstr "Close dashboard" - -msgid "No dashboard items to show in slideshow" -msgstr "No dashboard items to show in slideshow" - -msgid "Not available offline" -msgstr "Not available offline" - -msgid "Edit" -msgstr "Edit" - -msgid "Share" -msgstr "Share" - -msgid "Slideshow" -msgstr "Slideshow" - -msgid "Clear dashboard filters?" -msgstr "Clear dashboard filters?" - -msgid "" -"A dashboard's filters can’t be saved offline. Do you want to remove the " -"filters and make this dashboard available offline?" -msgstr "" -"A dashboard's filters can’t be saved offline. Do you want to remove the " -"filters and make this dashboard available offline?" - -msgid "No, cancel" -msgstr "No, cancel" - -msgid "Yes, clear filters and sync" -msgstr "Yes, clear filters and sync" - -msgid "Cancel" -msgstr "Cancel" - -msgid "Confirm" -msgstr "Confirm" - -msgid "Filter" -msgstr "Filter" - -msgid "Failed to unstar the dashboard" -msgstr "Failed to unstar the dashboard" - -msgid "Failed to star the dashboard" -msgstr "Failed to star the dashboard" - -msgid "Offline data last updated {{timeAgo}}" -msgstr "Offline data last updated {{timeAgo}}" - -msgid "Synced {{timeAgo}}" -msgstr "Synced {{timeAgo}}" - -msgid "Cannot unstar this dashboard while offline" -msgstr "Cannot unstar this dashboard while offline" - -msgid "Cannot star this dashboard while offline" -msgstr "Cannot star this dashboard while offline" - -msgid "No dashboards available." -msgstr "No dashboards available." - -msgid "Create a new dashboard using the + button." -msgstr "Create a new dashboard using the + button." - -msgid "Search for a dashboard" -msgstr "Search for a dashboard" - -msgid "No dashboards found" -msgstr "No dashboards found" - -msgid "{{appKey}} app not found" -msgstr "{{appKey}} app not found" - -msgid "Remove this item" -msgstr "Remove this item" - -msgid "This item has been shortened to fit on one page" -msgstr "This item has been shortened to fit on one page" - -msgid "Remove" -msgstr "Remove" - -msgid "Messages" -msgstr "Messages" - -msgid "See all messages" -msgstr "See all messages" - -msgid "Item type \"{{type}}\" is not supported" -msgstr "Item type \"{{type}}\" is not supported" - -msgid "The item type is missing" -msgstr "The item type is missing" - -msgid "Filters applied" -msgstr "Filters applied" - -msgid "Spacer" -msgstr "Spacer" - -msgid "Use a spacer to create empty vertical space between other dashboard items." -msgstr "Use a spacer to create empty vertical space between other dashboard items." - -msgid "Text box" -msgstr "Text box" - -msgid "Add text here" -msgstr "Add text here" - -msgid "Back to all interpretations" -msgstr "Back to all interpretations" - -msgid "Filters are not applied to line list dashboard items" -msgstr "Filters are not applied to line list dashboard items" - -msgid "Filters not applied" -msgstr "Filters not applied" - -msgid "Only Period and Organisation unit filters can be applied to this item" -msgstr "Only Period and Organisation unit filters can be applied to this item" - -msgid "Some filters not applied" -msgstr "Some filters not applied" - -msgid "There was a problem loading this dashboard item" -msgstr "There was a problem loading this dashboard item" - -msgid "Hide details and interpretations" -msgstr "Hide details and interpretations" - -msgid "Show details and interpretations" -msgstr "Show details and interpretations" - -msgid "Open menu" -msgstr "Open menu" - -msgid "Open in {{appName}} app" -msgstr "Open in {{appName}} app" - -msgid "View fullscreen" -msgstr "View fullscreen" - -msgid "This map can't be displayed as a chart" -msgstr "This map can't be displayed as a chart" - -msgid "This map can't be displayed as a pivot table" -msgstr "This map can't be displayed as a pivot table" - -msgid "This visualization can't be displayed as a pivot table" -msgstr "This visualization can't be displayed as a pivot table" - -msgid "This visualization can't be displayed as a map" -msgstr "This visualization can't be displayed as a map" - -msgid "View as Chart" -msgstr "View as Chart" - -msgid "View as Pivot table" -msgstr "View as Pivot table" - -msgid "View as Map" -msgstr "View as Map" - -msgid "There was a problem loading interpretations for this item" -msgstr "There was a problem loading interpretations for this item" - -msgid "The plugin for rendering this item is not available" -msgstr "The plugin for rendering this item is not available" - -msgid "Install the {{appName}} app from the App Hub" -msgstr "Install the {{appName}} app from the App Hub" - -msgid "No data to display" -msgstr "No data to display" - -msgid "" -"Install Line Listing app version ${minLLVersion.join(\r\n" -" '.'\r\n" -" )} or higher in order to display this item." -msgstr "" -"Install Line Listing app version ${minLLVersion.join(\r\n" -" '.'\r\n" -" )} or higher in order to display this item." - -msgid "Show without filters" -msgstr "Show without filters" - -msgid "Maps with Earth Engine layers cannot be displayed when offline" -msgstr "Maps with Earth Engine layers cannot be displayed when offline" - -msgid "Unable to load the plugin for this item" -msgstr "Unable to load the plugin for this item" - -msgid "There was an error loading data for this item" -msgstr "There was an error loading data for this item" - -msgid "Open this item in {{appName}}" -msgstr "Open this item in {{appName}}" - -msgid "Resources" -msgstr "Resources" - -msgid "Reports" -msgstr "Reports" - -msgid "Visualizations" -msgstr "Visualizations" - -msgid "Pivot tables" -msgstr "Pivot tables" - -msgid "Charts" -msgstr "Charts" - -msgid "Maps" -msgstr "Maps" - -msgid "Event reports" -msgstr "Event reports" - -msgid "Event charts" -msgstr "Event charts" - -msgid "Line lists" -msgstr "Line lists" - -msgid "Apps" -msgstr "Apps" - -msgid "Users" -msgstr "Users" - -msgid "" -"Failed to save dashboard. You might be offline or not have access to edit " -"this dashboard." -msgstr "" -"Failed to save dashboard. You might be offline or not have access to edit " -"this dashboard." - -msgid "" -"Failed to save dashboard. This code is already being used on another " -"dashboard." -msgstr "" -"Failed to save dashboard. This code is already being used on another " -"dashboard." - -msgid "" -"Failed to delete dashboard. You might be offline or not have access to edit " -"this dashboard." -msgstr "" -"Failed to delete dashboard. You might be offline or not have access to edit " -"this dashboard." - -msgid "Cannot save this dashboard while offline" -msgstr "Cannot save this dashboard while offline" - -msgid "Save changes" -msgstr "Save changes" - -msgid "Exit print preview" -msgstr "Exit print preview" - -msgid "Print preview" -msgstr "Print preview" - -msgid "Filter settings" -msgstr "Filter settings" - -msgid "Translate" -msgstr "Translate" - -msgid "Cannot delete this dashboard while offline" -msgstr "Cannot delete this dashboard while offline" - -msgid "Delete" -msgstr "Delete" - -msgid "Exit without saving" -msgstr "Exit without saving" - -msgid "Go to dashboards" -msgstr "Go to dashboards" - -msgid "Delete dashboard" -msgstr "Delete dashboard" - -msgid "" -"Deleting dashboard \"{{ dashboardName }}\" will remove it for all users. " -"This action cannot be undone. Are you sure you want to permanently delete " -"this dashboard?" -msgstr "" -"Deleting dashboard \"{{ dashboardName }}\" will remove it for all users. " -"This action cannot be undone. Are you sure you want to permanently delete " -"this dashboard?" - -msgid "Discard changes" -msgstr "Discard changes" - -msgid "" -"This dashboard has unsaved changes. Are you sure you want to leave and " -"discard these unsaved changes?" -msgstr "" -"This dashboard has unsaved changes. Are you sure you want to leave and " -"discard these unsaved changes?" - -msgid "No, stay here" -msgstr "No, stay here" - -msgid "Yes, discard changes" -msgstr "Yes, discard changes" - -msgid "No access" -msgstr "No access" - -msgid "Not supported" -msgstr "Not supported" - -msgid "" -"Editing dashboards on small screens is not supported. Resize your screen to " -"return to edit mode." -msgstr "" -"Editing dashboards on small screens is not supported. Resize your screen to " -"return to edit mode." - -msgid "Allow filtering by all dimensions" -msgstr "Allow filtering by all dimensions" - -msgid "Only allow filtering by selected dimensions" -msgstr "Only allow filtering by selected dimensions" - -msgid "Dashboard filter settings" -msgstr "Dashboard filter settings" - -msgid "" -"Dashboards can be filtered by dimensions to change\r\n" -" the data shown. By default, all " -"dimensions are available\r\n" -" as filters. Alternatively, only " -"selected dimensions can\r\n" -" be made available on a dashboard." -msgstr "" -"Dashboards can be filtered by dimensions to change\r\n" -" the data shown. By default, all " -"dimensions are available\r\n" -" as filters. Alternatively, only " -"selected dimensions can\r\n" -" be made available on a dashboard." - -msgid "Available Filters" -msgstr "Available Filters" - -msgid "Selected Filters" -msgstr "Selected Filters" - -msgid "There are no items on this dashboard" -msgstr "There are no items on this dashboard" - -msgid "Show fewer" -msgstr "Show fewer" - -msgid "Show more" -msgstr "Show more" - -msgid "Open visualization in new tab" -msgstr "Open visualization in new tab" - -msgid "Insert" -msgstr "Insert" - -msgid "Search for items to add to this dashboard" -msgstr "Search for items to add to this dashboard" - -msgid "Search for visualizations, reports and more" -msgstr "Search for visualizations, reports and more" - -msgid "Cannot search for dashboard items while offline" -msgstr "Cannot search for dashboard items while offline" - -msgid "Additional items" -msgstr "Additional items" - -msgid "Freeflow" -msgstr "Freeflow" - -msgid "Dashboard items can be placed anywhere, at any size." -msgstr "Dashboard items can be placed anywhere, at any size." - -msgid "Fixed columns" -msgstr "Fixed columns" - -msgid "" -"Dashboard items are automatically placed within fixed, horizontal columns. " -"The number of columns can be adjusted." -msgstr "" -"Dashboard items are automatically placed within fixed, horizontal columns. " -"The number of columns can be adjusted." - -msgid "Number of columns" -msgstr "Number of columns" - -msgid "Gap size between columns (px)" -msgstr "Gap size between columns (px)" - -msgid "" -"Default height only applies to items added to a dashboard, this setting " -"will not change existing items" -msgstr "" -"Default height only applies to items added to a dashboard, this setting " -"will not change existing items" - -msgid "Default height for items added to dashboard (rows)" -msgstr "Default height for items added to dashboard (rows)" - -msgid "Save layout" -msgstr "Save layout" - -msgid "Dashboard title" -msgstr "Dashboard title" - -msgid "Dashboard code" -msgstr "Dashboard code" - -msgid "Code can't be longer than 50 characters" -msgstr "Code can't be longer than 50 characters" - -msgid "Dashboard description" -msgstr "Dashboard description" - -msgid "Layout" -msgstr "Layout" - -msgid "{{count}} columns" -msgid_plural "{{count}} columns" -msgstr[0] "{{count}} column" -msgstr[1] "{{count}} columns" - -msgid "Change layout" -msgstr "Change layout" - -msgid "Add new items to" -msgstr "Add new items to" - -msgid "End of dashboard" -msgstr "End of dashboard" - -msgid "Start of dashboard" -msgstr "Start of dashboard" - -msgid "dashboard layout" -msgstr "dashboard layout" - -msgid "one item per page" -msgstr "one item per page" - -msgid "Print Preview" -msgstr "Print Preview" - -msgid "For best print results" -msgstr "For best print results" - -msgid "Use Chrome or Edge web browser" -msgstr "Use Chrome or Edge web browser" - -msgid "Wait for all dashboard items to load before printing" -msgstr "Wait for all dashboard items to load before printing" - -msgid "" -"Use A4 landscape paper size, default margin settings and turn on background " -"graphics in the browser print dialog" -msgstr "" -"Use A4 landscape paper size, default margin settings and turn on background " -"graphics in the browser print dialog" - -msgid "Getting started" -msgstr "Getting started" - -msgid "Search for and open saved dashboards from the top bar." -msgstr "Search for and open saved dashboards from the top bar." - -msgid "" -"Click a dashboard chip to open it. Get back to this screen from the " -"\"More\" menu." -msgstr "" -"Click a dashboard chip to open it. Get back to this screen from the " -"\"More\" menu." - -msgid "Create a new dashboard with the + button." -msgstr "Create a new dashboard with the + button." - -msgid "Your most viewed dashboards" -msgstr "Your most viewed dashboards" - -msgid "No dashboards found. Use the + button to create a new dashboard." -msgstr "No dashboards found. Use the + button to create a new dashboard." - -msgid "Requested dashboard not found" -msgstr "Requested dashboard not found" - -msgid "No description" -msgstr "No description" - -msgid "{{count}} selected" -msgid_plural "{{count}} selected" -msgstr[0] "{{count}} selected" -msgstr[1] "{{count}} selected" - -msgid "Cannot edit filters while offline" -msgstr "Cannot edit filters while offline" - -msgid "Cannot edit filters on a small screen" -msgstr "Cannot edit filters on a small screen" - -msgid "Removing filters while offline" -msgstr "Removing filters while offline" - -msgid "" -"Removing this filter while offline will remove all other filters. Do you " -"want to remove all filters on this dashboard?" -msgstr "" -"Removing this filter while offline will remove all other filters. Do you " -"want to remove all filters on this dashboard?" - -msgid "Yes, remove filters" -msgstr "Yes, remove filters" - -msgid "Exit slideshow" -msgstr "Exit slideshow" - -msgid "Previous item" -msgstr "Previous item" - -msgid "Next item" -msgstr "Next item" - -msgid "{{name}}: {{filter}}" -msgstr "{{name}}: {{filter}}" - -msgid "{{count}} filters active" -msgid_plural "{{count}} filters active" -msgstr[0] "{{count}} filter active" -msgstr[1] "{{count}} filters active" - -msgid "Loading dashboard – {{name}}" -msgstr "Loading dashboard – {{name}}" - -msgid "Loading dashboard" -msgstr "Loading dashboard" - -msgid "Load dashboard failed" -msgstr "Load dashboard failed" - -msgid "This dashboard could not be loaded. Please try again later." -msgstr "This dashboard could not be loaded. Please try again later." - -msgid "Offline" -msgstr "Offline" - -msgid "This dashboard cannot be loaded while offline." -msgstr "This dashboard cannot be loaded while offline." - -msgid "Go to start page" -msgstr "Go to start page" From 99d4ddda817bd5396b540b4ca449bb8a0d04f09d Mon Sep 17 00:00:00 2001 From: Edson Nhancale <54271761+EdsonNhancale@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:43:58 +0200 Subject: [PATCH 09/13] refactor: remove unnecessary changes in `FilterSelector.js` Cleaned up the `FilterSelector.js` file by removing redundant or unnecessary changes. --- src/components/DashboardsBar/InformationBlock/FilterSelector.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/DashboardsBar/InformationBlock/FilterSelector.js b/src/components/DashboardsBar/InformationBlock/FilterSelector.js index 705baae48..135f4903d 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterSelector.js +++ b/src/components/DashboardsBar/InformationBlock/FilterSelector.js @@ -56,7 +56,6 @@ const FilterSelector = (props) => { /> ) - return props.restrictFilters && !props.allowedFilters?.length ? null : ( <> Date: Wed, 15 Jan 2025 09:52:00 +0200 Subject: [PATCH 10/13] fix: fix: remove erroneous changes in `en.pot` Reverted unintended changes in the `i18n/en.pot` --- i18n/en.pot | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index eae9541e1..fa8cab2e1 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2025-01-14T18:01:43.873Z\n" -"PO-Revision-Date: 2025-01-14T18:01:43.874Z\n" +"POT-Creation-Date: 2024-12-19T11:30:27.893Z\n" +"PO-Revision-Date: 2024-12-19T11:30:27.893Z\n" msgid "Untitled dashboard" msgstr "Untitled dashboard" @@ -226,12 +226,12 @@ msgid "No data to display" msgstr "No data to display" msgid "" -"Install Line Listing app version ${minLLVersion.join(\r\n" -" '.'\r\n" +"Install Line Listing app version ${minLLVersion.join(\n" +" '.'\n" " )} or higher in order to display this item." msgstr "" -"Install Line Listing app version ${minLLVersion.join(\r\n" -" '.'\r\n" +"Install Line Listing app version ${minLLVersion.join(\n" +" '.'\n" " )} or higher in order to display this item." msgid "Show without filters" @@ -384,18 +384,18 @@ msgid "Dashboard filter settings" msgstr "Dashboard filter settings" msgid "" -"Dashboards can be filtered by dimensions to change\r\n" +"Dashboards can be filtered by dimensions to change\n" " the data shown. By default, all " -"dimensions are available\r\n" +"dimensions are available\n" " as filters. Alternatively, only " -"selected dimensions can\r\n" +"selected dimensions can\n" " be made available on a dashboard." msgstr "" -"Dashboards can be filtered by dimensions to change\r\n" +"Dashboards can be filtered by dimensions to change\n" " the data shown. By default, all " -"dimensions are available\r\n" +"dimensions are available\n" " as filters. Alternatively, only " -"selected dimensions can\r\n" +"selected dimensions can\n" " be made available on a dashboard." msgid "Available Filters" From 229d25e56fefd9d89dea72d7d63705acdfb522e9 Mon Sep 17 00:00:00 2001 From: EdsonNhancale Date: Wed, 15 Jan 2025 09:56:30 +0200 Subject: [PATCH 11/13] fix: remove erroneous changes in `FilterSelector.js` Reverted unintended changes in the `FilterSelector.js` file --- src/components/DashboardsBar/InformationBlock/FilterSelector.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/DashboardsBar/InformationBlock/FilterSelector.js b/src/components/DashboardsBar/InformationBlock/FilterSelector.js index 135f4903d..69221edf9 100644 --- a/src/components/DashboardsBar/InformationBlock/FilterSelector.js +++ b/src/components/DashboardsBar/InformationBlock/FilterSelector.js @@ -56,6 +56,7 @@ const FilterSelector = (props) => { /> ) + return props.restrictFilters && !props.allowedFilters?.length ? null : ( <> Date: Wed, 15 Jan 2025 12:02:09 +0200 Subject: [PATCH 12/13] test: added unit tests for period (pe) filter functionality in getIframeSrc - Added tests to validate the behavior of the period (pe) filter with single and multiple values. - Ensured proper handling when both pe and ou filters are applied together. - Included a test to confirm pe filter is omitted when empty. - Verified the generated iframeSrc matches the expected URL for all scenarios. --- .../AppItem/__tests__/getIframeSrc.spec.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js b/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js index fd85d6037..3807f1dea 100644 --- a/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js +++ b/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js @@ -103,4 +103,64 @@ describe('getIframeSrc', () => { `${expectedSrc}&userOrgUnit=USER_ORGUNIT_CHILDREN,USER_ORGUNIT_GRANDCHILDREN,USER_ORGUNIT` ) }) + + it('only period filter with a single value', () => { + const peFilter = [{ id: 'LAST_MONTH' }]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter }); + expect(src).toEqual(`${expectedSrc}&period=LAST_MONTH`); + }); + + it('only period filter with multiple values', () => { + const peFilter = [ + { id: 'LAST_MONTH' }, + { id: 'LAST_3_MONTHS' }, + ]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter }); + expect(src).toEqual(`${expectedSrc}&period=LAST_MONTH,LAST_3_MONTHS`); + }); + + it('period filter and org unit filter', () => { + const peFilter = [{ id: 'LAST_MONTH' }]; + const ouFilter = [ + { + id: 'fdc6uOvgoji', + path: '/ImspTQPwCqd/fdc6uOvgoji', + name: 'Bombali', + }, + ]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter, ou: ouFilter }); + expect(src).toEqual(`${expectedSrc}&userOrgUnit=fdc6uOvgoji&period=LAST_MONTH`); + }); + + it('period filter with multiple values and org unit filter', () => { + const peFilter = [ + { id: 'LAST_MONTH' }, + { id: 'LAST_3_MONTHS' }, + ]; + const ouFilter = [ + { + id: 'fdc6uOvgoji', + path: '/ImspTQPwCqd/fdc6uOvgoji', + name: 'Bombali', + }, + { + id: 'lc3eMKXaEfw', + path: '/ImspTQPwCqd/lc3eMKXaEfw', + name: 'Bonthe', + }, + ]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter, ou: ouFilter }); + expect(src).toEqual(`${expectedSrc}&userOrgUnit=fdc6uOvgoji,lc3eMKXaEfw&period=LAST_MONTH,LAST_3_MONTHS`); + }); + + it('empty pe filter', () => { + const peFilter = []; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter }); + expect(src).toEqual(expectedSrc); + }); }) From dab875735635bebd51b71550e9367417b1db5965 Mon Sep 17 00:00:00 2001 From: EdsonNhancale Date: Wed, 15 Jan 2025 12:02:09 +0200 Subject: [PATCH 13/13] test: added unit tests for period (pe) filter functionality in getIframeSrc - Added tests to validate the behavior of the period (pe) filter with single and multiple values. - Ensured proper handling when both pe and ou filters are applied together. - Included a test to confirm pe filter is omitted when empty. - Verified the generated iframeSrc matches the expected URL for all scenarios. --- .../AppItem/__tests__/getIframeSrc.spec.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js b/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js index fd85d6037..3807f1dea 100644 --- a/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js +++ b/src/components/Item/AppItem/__tests__/getIframeSrc.spec.js @@ -103,4 +103,64 @@ describe('getIframeSrc', () => { `${expectedSrc}&userOrgUnit=USER_ORGUNIT_CHILDREN,USER_ORGUNIT_GRANDCHILDREN,USER_ORGUNIT` ) }) + + it('only period filter with a single value', () => { + const peFilter = [{ id: 'LAST_MONTH' }]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter }); + expect(src).toEqual(`${expectedSrc}&period=LAST_MONTH`); + }); + + it('only period filter with multiple values', () => { + const peFilter = [ + { id: 'LAST_MONTH' }, + { id: 'LAST_3_MONTHS' }, + ]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter }); + expect(src).toEqual(`${expectedSrc}&period=LAST_MONTH,LAST_3_MONTHS`); + }); + + it('period filter and org unit filter', () => { + const peFilter = [{ id: 'LAST_MONTH' }]; + const ouFilter = [ + { + id: 'fdc6uOvgoji', + path: '/ImspTQPwCqd/fdc6uOvgoji', + name: 'Bombali', + }, + ]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter, ou: ouFilter }); + expect(src).toEqual(`${expectedSrc}&userOrgUnit=fdc6uOvgoji&period=LAST_MONTH`); + }); + + it('period filter with multiple values and org unit filter', () => { + const peFilter = [ + { id: 'LAST_MONTH' }, + { id: 'LAST_3_MONTHS' }, + ]; + const ouFilter = [ + { + id: 'fdc6uOvgoji', + path: '/ImspTQPwCqd/fdc6uOvgoji', + name: 'Bombali', + }, + { + id: 'lc3eMKXaEfw', + path: '/ImspTQPwCqd/lc3eMKXaEfw', + name: 'Bonthe', + }, + ]; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter, ou: ouFilter }); + expect(src).toEqual(`${expectedSrc}&userOrgUnit=fdc6uOvgoji,lc3eMKXaEfw&period=LAST_MONTH,LAST_3_MONTHS`); + }); + + it('empty pe filter', () => { + const peFilter = []; + + const src = getIframeSrc(appDetails, dashboardItem, { pe: peFilter }); + expect(src).toEqual(expectedSrc); + }); })