mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-19 05:40:44 +00:00
CE-1115 Add sort indication to report setup; make recordQuery, when being used for report setup, not write local storage;
This commit is contained in:
@ -141,6 +141,34 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
const [firstRender, setFirstRender] = useState(true);
|
||||
const [isFirstRenderAfterChangingTables, setIsFirstRenderAfterChangingTables] = useState(false);
|
||||
|
||||
const [loadedFilterFromInitialFilterParam, setLoadedFilterFromInitialFilterParam] = useState(false);
|
||||
|
||||
const mayWriteLocalStorage = usage == "queryScreen";
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
function localStorageSet(key: string, value: string)
|
||||
{
|
||||
if(mayWriteLocalStorage)
|
||||
{
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
function localStorageRemove(key: string)
|
||||
{
|
||||
if(mayWriteLocalStorage)
|
||||
{
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
useImperativeHandle(ref, () =>
|
||||
{
|
||||
return {
|
||||
@ -232,13 +260,14 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
{
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// allow a caller to send in an initial filter & set of columns. //
|
||||
// only to be used on "first render" //
|
||||
// only to be used on "first render". //
|
||||
// JSON.parse(JSON.stringify()) to do deep clone and keep object clean //
|
||||
// unclear why not needed on initialColumns... //
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
if (initialQueryFilter)
|
||||
{
|
||||
defaultView.queryFilter = JSON.parse(JSON.stringify(initialQueryFilter));
|
||||
setLoadedFilterFromInitialFilterParam(true);
|
||||
}
|
||||
|
||||
if (initialColumns)
|
||||
@ -720,7 +749,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
{
|
||||
FilterUtils.stripAwayIncompleteCriteria(viewForLocalStorage.queryFilter)
|
||||
}
|
||||
localStorage.setItem(viewLocalStorageKey, JSON.stringify(viewForLocalStorage));
|
||||
localStorageSet(viewLocalStorageKey, JSON.stringify(viewForLocalStorage));
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
@ -1108,7 +1137,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
if (state && state.density && state.density.value !== density)
|
||||
{
|
||||
setDensity(state.density.value);
|
||||
localStorage.setItem(densityLocalStorageKey, JSON.stringify(state.density.value));
|
||||
localStorageSet(densityLocalStorageKey, JSON.stringify(state.density.value));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1605,7 +1634,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
////////////////////////////////////////////////////////////////
|
||||
// todo can/should/does this move into the view's "identity"? //
|
||||
////////////////////////////////////////////////////////////////
|
||||
localStorage.setItem(currentSavedViewLocalStorageKey, `${savedViewRecord.values.get("id")}`);
|
||||
localStorageSet(currentSavedViewLocalStorageKey, `${savedViewRecord.values.get("id")}`);
|
||||
};
|
||||
|
||||
|
||||
@ -1615,7 +1644,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
const doClearCurrentSavedView = () =>
|
||||
{
|
||||
setCurrentSavedView(null);
|
||||
localStorage.removeItem(currentSavedViewLocalStorageKey);
|
||||
localStorageRemove(currentSavedViewLocalStorageKey);
|
||||
};
|
||||
|
||||
|
||||
@ -1662,7 +1691,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
// wipe away the saved view //
|
||||
//////////////////////////////
|
||||
setCurrentSavedView(null);
|
||||
localStorage.removeItem(currentSavedViewLocalStorageKey);
|
||||
localStorageRemove(currentSavedViewLocalStorageKey);
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// activate a new default view for the table //
|
||||
@ -2484,7 +2513,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
||||
// if the last time we were on this table, a currentSavedView was written to local storage - //
|
||||
// then navigate back to that view's URL - unless - it looks like we're on a process! //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (localStorage.getItem(currentSavedViewLocalStorageKey) && !urlLooksLikeProcess())
|
||||
if (localStorage.getItem(currentSavedViewLocalStorageKey) && !urlLooksLikeProcess() && !loadedFilterFromInitialFilterParam)
|
||||
{
|
||||
const currentSavedViewId = Number.parseInt(localStorage.getItem(currentSavedViewLocalStorageKey));
|
||||
console.log(`returning to previously active saved view ${currentSavedViewId}`);
|
||||
|
Reference in New Issue
Block a user