diff --git a/src/qqq/components/misc/SavedViews.tsx b/src/qqq/components/misc/SavedViews.tsx index 6ce7e8a..0fd6886 100644 --- a/src/qqq/components/misc/SavedViews.tsx +++ b/src/qqq/components/misc/SavedViews.tsx @@ -282,6 +282,12 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, vie { try { + if(!savedView.queryColumns || !savedView.queryColumns.columns || savedView.queryColumns.columns.length == 0) + { + viewDiffs.push("This view did not previously have columns saved with it, so the next time you save it they will be initialized."); + return; + } + //////////////////////////////////////////////////////////// // nested function to help diff visible status of columns // //////////////////////////////////////////////////////////// @@ -390,7 +396,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, vie if(savedView.queryColumns.columns.map(c => c.name).join(",") != activeView.queryColumns.columns.map(c => c.name).join(",")) { - viewDiffs.push("Changed the order of 1 or more columns."); + viewDiffs.push("Changed the order columns."); } diffWidthsFunction(savedView.queryColumns, activeView.queryColumns, "Changed width for "); @@ -452,12 +458,26 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, vie if(savedView.mode != activeView.mode) { - viewDiffs.push(`Mode changed from ${savedView.mode} to ${activeView.mode}`) + if(savedView.mode) + { + viewDiffs.push(`Mode changed from ${savedView.mode} to ${activeView.mode}`) + } + else + { + viewDiffs.push(`Mode set to ${activeView.mode}`) + } } if(savedView.rowsPerPage != activeView.rowsPerPage) { - viewDiffs.push(`Rows per page changed from ${savedView.rowsPerPage} to ${activeView.rowsPerPage}`) + if(savedView.rowsPerPage) + { + viewDiffs.push(`Rows per page changed from ${savedView.rowsPerPage} to ${activeView.rowsPerPage}`) + } + else + { + viewDiffs.push(`Rows per page set to ${activeView.rowsPerPage}`) + } } if(viewDiffs.length > 0) diff --git a/src/qqq/components/query/BasicAndAdvancedQueryControls.tsx b/src/qqq/components/query/BasicAndAdvancedQueryControls.tsx index b43dc6f..16d2697 100644 --- a/src/qqq/components/query/BasicAndAdvancedQueryControls.tsx +++ b/src/qqq/components/query/BasicAndAdvancedQueryControls.tsx @@ -350,7 +350,6 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo if(criteria && criteria.fieldName && criteria.operator) { const [field, fieldTable] = TableUtils.getFieldAndTable(tableMetaData, criteria.fieldName); - const valuesString = FilterUtils.getValuesString(field, criteria); counter++; return ( diff --git a/src/qqq/components/query/QuickFilter.tsx b/src/qqq/components/query/QuickFilter.tsx index adb3141..7cb5b96 100644 --- a/src/qqq/components/query/QuickFilter.tsx +++ b/src/qqq/components/query/QuickFilter.tsx @@ -383,8 +383,17 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData buttonAdditionalStyles.color = "white !important"; buttonClassName = "filterActive"; + let valuesString = FilterUtils.getValuesString(fieldMetaData, criteria); + if(fieldMetaData.type == QFieldType.BOOLEAN) + { + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // for booleans, in here, the operator-label is "equals yes" or "equals no", so we don't want the values string // + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + valuesString = ""; + } + buttonContent = ( - + {buttonContent} ); diff --git a/src/qqq/pages/records/query/RecordQuery.tsx b/src/qqq/pages/records/query/RecordQuery.tsx index 2e7e975..59fc00f 100644 --- a/src/qqq/pages/records/query/RecordQuery.tsx +++ b/src/qqq/pages/records/query/RecordQuery.tsx @@ -600,39 +600,6 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element doSetCurrentSavedView(null); } } - - //... if (currentSavedViewId != null) - //... { - //... /* hmm... - //... if(currentSavedView && currentSavedView.values.get("id") == currentSavedViewId) - //... { - //... console.log("@dk - mmm, current saved filter is already the one we're trying to go to, so, avoid double-dipping..."); - //... } - //... else - //... */ - //... { - //... console.log("@dk - have saved filter in url, going to query it now."); - //... (async () => - //... { - //... const formData = new FormData(); - //... formData.append("id", currentSavedViewId); - //... formData.append(QController.STEP_TIMEOUT_MILLIS_PARAM_NAME, 60 * 1000); - //... const processResult = await qController.processInit("querySavedView", formData, qController.defaultMultipartFormDataHeaders()); - //... if (processResult instanceof QJobError) - //... { - //... const jobError = processResult as QJobError; - //... console.error("Could not retrieve saved filter: " + jobError.userFacingError); - //... } - //... else - //... { - //... const result = processResult as QJobComplete; - //... const qRecord = new QRecord(result.values.savedViewList[0]); - //... console.log("@dk - got saved filter from backend, going to set it now"); - //... doSetCurrentSavedView(qRecord); - //... } - //... })(); - //... } - //... } } catch (e) { @@ -755,7 +722,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element return; } - console.log(`@dk In updateTable for ${reason} ${JSON.stringify(queryFilter)}`); + console.log(`In updateTable for ${reason} ${JSON.stringify(queryFilter)}`); setLoading(true); setRows([]); (async () => @@ -1155,7 +1122,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element *******************************************************************************/ const doSetQueryFilter = (queryFilter: QQueryFilter, isFromActivateView = false): void => { - console.log(`@dk Setting a new query filter: ${JSON.stringify(queryFilter)}`); + console.log(`Setting a new query filter: ${JSON.stringify(queryFilter)}`); /////////////////////////////////////////////////// // in case there's no orderBys, set default here // @@ -1449,6 +1416,12 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element const viewJson = savedView.values.get("viewJson") const newView = RecordQueryView.buildFromJSON(viewJson); newView.viewIdentity = "savedView:" + savedView.values.get("id"); + + /////////////////////////////////////////////////////////////////// + // e.g., translate possible values from ids to objects w/ labels // + /////////////////////////////////////////////////////////////////// + await FilterUtils.cleanupValuesInFilerFromQueryString(qController, tableMetaData, newView.queryFilter); + activateView(newView); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2006,7 +1979,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element //////////////////////////////////////////////////////////// if (pageState == "initial") { - console.log("@dk - page state is initial - going to loadingMetaData..."); + console.log("page state is initial - going to loadingMetaData..."); setPageState("loadingMetaData"); pageLoadingState.setLoading(); @@ -2037,7 +2010,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element ////////////////////////////////////////////////////////////////////////////////////////////////////// if (pageState == "loadedMetaData") { - console.log("@dk - page state is loadedMetaData - going to loadingView..."); + console.log("page state is loadedMetaData - going to loadingView..."); setPageState("loadingView"); (async () => @@ -2137,7 +2110,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element ////////////////////////////////////////////////////////////////////////////////////////////// if (pageState == "loadedView") { - console.log("@dk - page state is loadedView - going to preparingGrid..."); + console.log("page state is loadedView - going to preparingGrid..."); setPageState("preparingGrid"); (async () => @@ -2191,10 +2164,12 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element } */ - console.log("@dk - finished preparing grid, going to page state ready"); + console.log("finished preparing grid, going to page state ready"); setPageState("ready"); - // todo - is this sufficient? + //////////////////////////////////////////// + // if we need a variant, show that prompt // + //////////////////////////////////////////// if (tableMetaData?.usesVariants && !tableVariant) { promptForTableVariantSelection(); @@ -2277,7 +2252,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element /////////////////////////////////////////////////////////// if(pageState != "ready") { - console.log(`@dk - page state is ${pageState}... no-op while those complete async's run...`); + console.log(`page state is ${pageState}... no-op while those complete async's run...`); return (getLoadingScreen()); } diff --git a/src/qqq/utils/qqq/FilterUtils.tsx b/src/qqq/utils/qqq/FilterUtils.tsx index 633f535..c99149b 100644 --- a/src/qqq/utils/qqq/FilterUtils.tsx +++ b/src/qqq/utils/qqq/FilterUtils.tsx @@ -311,7 +311,7 @@ class FilterUtils public static getValuesString(fieldMetaData: QFieldMetaData, criteria: QFilterCriteria, maxValuesToShow: number = 3): string { let valuesString = ""; - if (criteria.values && criteria.values.length && fieldMetaData.type !== QFieldType.BOOLEAN) + if (criteria.values && criteria.values.length) { let labels = [] as string[]; @@ -323,7 +323,11 @@ class FilterUtils for (let i = 0; i < maxLoops; i++) { - if (criteria.values[i] && criteria.values[i].label) + if(fieldMetaData.type == QFieldType.BOOLEAN) + { + labels.push(criteria.values[i] == true ? "yes" : "no") + } + else if (criteria.values[i] && criteria.values[i].label) { labels.push(criteria.values[i].label); }