diff --git a/src/qqq/components/misc/SavedViews.tsx b/src/qqq/components/misc/SavedViews.tsx index 2000137..000cca6 100644 --- a/src/qqq/components/misc/SavedViews.tsx +++ b/src/qqq/components/misc/SavedViews.tsx @@ -44,6 +44,7 @@ import QContext from "QContext"; import colors from "qqq/assets/theme/base/colors"; import {QCancelButton, QDeleteButton, QSaveButton} from "qqq/components/buttons/DefaultButtons"; import RecordQueryView from "qqq/models/query/RecordQueryView"; +import {QueryScreenUsage} from "qqq/pages/records/query/RecordQuery"; import FilterUtils from "qqq/utils/qqq/FilterUtils"; import {SavedViewUtils} from "qqq/utils/qqq/SavedViewUtils"; import React, {useContext, useEffect, useRef, useState} from "react"; @@ -60,9 +61,10 @@ interface Props viewAsJson?: string; viewOnChangeCallback?: (selectedSavedViewId: number) => void; loadingSavedView: boolean + queryScreenUsage: QueryScreenUsage; } -function SavedViews({qController, metaData, tableMetaData, currentSavedView, tableDefaultView, view, viewAsJson, viewOnChangeCallback, loadingSavedView}: Props): JSX.Element +function SavedViews({qController, metaData, tableMetaData, currentSavedView, tableDefaultView, view, viewAsJson, viewOnChangeCallback, loadingSavedView, queryScreenUsage}: Props): JSX.Element { const navigate = useNavigate(); @@ -91,6 +93,14 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab const {accentColor, accentColorLight} = useContext(QContext); + ///////////////////////////////////////////////////////////////////////////////////////// + // this component is used by - but that component has different usages - // + // e.g., the full-fledged query screen, but also, within other screens (e.g., a modal // + // under the ReportSetupWidget). So, there are some behaviors we only want when we're // + // on the full-fledged query screen, such as changing the URL with saved view ids. // + ///////////////////////////////////////////////////////////////////////////////////////// + const isQueryScreen = queryScreenUsage == "queryScreen"; + const openSavedViewsMenu = (event: any) => setSavedViewsMenu(event.currentTarget); const closeSavedViewsMenu = () => setSavedViewsMenu(null); @@ -142,7 +152,10 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab setSaveFilterPopupOpen(false); closeSavedViewsMenu(); viewOnChangeCallback(record.values.get("id")); - navigate(`${metaData.getTablePathByName(tableMetaData.name)}/savedView/${record.values.get("id")}`); + if(isQueryScreen) + { + navigate(`${metaData.getTablePathByName(tableMetaData.name)}/savedView/${record.values.get("id")}`); + } }; @@ -175,7 +188,10 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab case CLEAR_OPTION: setSaveFilterPopupOpen(false) viewOnChangeCallback(null); - navigate(metaData.getTablePathByName(tableMetaData.name)); + if(isQueryScreen) + { + navigate(metaData.getTablePathByName(tableMetaData.name)); + } break; case RENAME_OPTION: if(currentSavedView != null) @@ -419,7 +435,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab > View Actions { - hasStorePermission && + isQueryScreen && hasStorePermission && Save your current filters, columns and settings, for quick re-use at a later time.

You will be prompted to enter a name if you choose this option.}> handleDropdownOptionClick(SAVE_OPTION)}> save @@ -428,7 +444,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
} { - hasStorePermission && currentSavedView != null && + isQueryScreen && hasStorePermission && currentSavedView != null && handleDropdownOptionClick(RENAME_OPTION)}> edit @@ -437,7 +453,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab } { - hasStorePermission && currentSavedView != null && + isQueryScreen && hasStorePermission && currentSavedView != null && handleDropdownOptionClick(DUPLICATE_OPTION)}> content_copy @@ -446,7 +462,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab } { - hasDeletePermission && currentSavedView != null && + isQueryScreen && hasDeletePermission && currentSavedView != null && handleDropdownOptionClick(DELETE_OPTION)}> delete @@ -580,19 +596,23 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab { !currentSavedView && viewIsModified && <> - - Unsaved Changes -
    - { - viewDiffs.map((s: string, i: number) =>
  • {s}
  • ) - } -
- }> - -
+ { + isQueryScreen && <> + + Unsaved Changes +
    + { + viewDiffs.map((s: string, i: number) =>
  • {s}
  • ) + } +
+ }> + +
- {/* vertical rule */} - + {/* vertical rule */} + + + }