mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-19 22:00:45 +00:00
Merge branch 'feature/sprint-27' into feature/custom-filter-panel
This commit is contained in:
@ -707,6 +707,20 @@ const booleanNotEmptyOperator: GridFilterOperator = {
|
||||
|
||||
export const QGridBooleanOperators = [booleanTrueOperator, booleanFalseOperator, booleanEmptyOperator, booleanNotEmptyOperator];
|
||||
|
||||
const blobEmptyOperator: GridFilterOperator = {
|
||||
label: "is empty",
|
||||
value: "isEmpty",
|
||||
getApplyFilterFn: (filterItem: GridFilterItem, column: GridColDef) => null
|
||||
};
|
||||
|
||||
const blobNotEmptyOperator: GridFilterOperator = {
|
||||
label: "is not empty",
|
||||
value: "isNotEmpty",
|
||||
getApplyFilterFn: (filterItem: GridFilterItem, column: GridColDef) => null
|
||||
};
|
||||
|
||||
export const QGridBlobOperators = [blobNotEmptyOperator, blobEmptyOperator];
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// input element for possible values //
|
||||
|
@ -97,12 +97,31 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
const tableName = table.name;
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const [showSuccessfullyDeletedAlert, setShowSuccessfullyDeletedAlert] = useState(searchParams.has("deleteSuccess"));
|
||||
const [showSuccessfullyDeletedAlert, setShowSuccessfullyDeletedAlert] = useState(false);
|
||||
const [warningAlert, setWarningAlert] = useState(null as string);
|
||||
const [successAlert, setSuccessAlert] = useState(null as string);
|
||||
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
if(location.state)
|
||||
{
|
||||
let state: any = location.state;
|
||||
if(state["deleteSuccess"])
|
||||
{
|
||||
setShowSuccessfullyDeletedAlert(true);
|
||||
delete state["deleteSuccess"];
|
||||
}
|
||||
|
||||
if(state["warning"])
|
||||
{
|
||||
setWarningAlert(state["warning"]);
|
||||
delete state["warning"];
|
||||
}
|
||||
|
||||
window.history.replaceState(state, "");
|
||||
}
|
||||
|
||||
const pathParts = location.pathname.replace(/\/+$/, "").split("/");
|
||||
|
||||
////////////////////////////////////////////
|
||||
@ -982,7 +1001,9 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
//////////////////////////////////////
|
||||
const dateString = ValueUtils.formatDateTimeForFileName(new Date());
|
||||
const filename = `${tableMetaData.label} Export ${dateString}.${format}`;
|
||||
const url = `/data/${tableMetaData.name}/export/${filename}?filter=${encodeURIComponent(JSON.stringify(buildQFilter(tableMetaData, filterModel)))}&fields=${visibleFields.join(",")}`;
|
||||
const url = `/data/${tableMetaData.name}/export/${filename}`;
|
||||
|
||||
const encodedFilterJSON = encodeURIComponent(JSON.stringify(buildQFilter(tableMetaData, filterModel)));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// open a window (tab) with a little page that says the file is being generated. //
|
||||
@ -999,6 +1020,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
<script>
|
||||
setTimeout(() =>
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// need to encode and decode this value, so set it in the form here, instead of literally below //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
document.getElementById("filter").value = decodeURIComponent("${encodedFilterJSON}");
|
||||
|
||||
document.getElementById("exportForm").submit();
|
||||
}, 1);
|
||||
</script>
|
||||
@ -1007,6 +1033,8 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
Generating file <u>${filename}</u>${totalRecords ? " with " + totalRecords.toLocaleString() + " record" + (totalRecords == 1 ? "" : "s") : ""}...
|
||||
<form id="exportForm" method="post" action="${url}" >
|
||||
<input type="hidden" name="Authorization" value="${qController.getAuthorizationHeaderValue()}">
|
||||
<input type="hidden" name="fields" value="${visibleFields.join(",")}">
|
||||
<input type="hidden" name="filter" id="filter">
|
||||
</form>
|
||||
</body>
|
||||
</html>`);
|
||||
@ -1795,23 +1823,20 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
||||
)}
|
||||
{
|
||||
(tableLabel && showSuccessfullyDeletedAlert) ? (
|
||||
<Alert color="success" sx={{mb: 3}} onClose={() =>
|
||||
{
|
||||
setShowSuccessfullyDeletedAlert(false);
|
||||
}}>
|
||||
{`${tableLabel} successfully deleted`}
|
||||
</Alert>
|
||||
<Alert color="success" sx={{mb: 3}} onClose={() => setShowSuccessfullyDeletedAlert(false)}>{`${tableLabel} successfully deleted`}</Alert>
|
||||
) : null
|
||||
}
|
||||
{
|
||||
(successAlert) ? (
|
||||
<Collapse in={Boolean(successAlert)}>
|
||||
<Alert color="success" sx={{mb: 3}} onClose={() =>
|
||||
{
|
||||
setSuccessAlert(null);
|
||||
}}>
|
||||
{successAlert}
|
||||
</Alert>
|
||||
<Alert color="success" sx={{mb: 3}} onClose={() => setSuccessAlert(null)}>{successAlert}</Alert>
|
||||
</Collapse>
|
||||
) : null
|
||||
}
|
||||
{
|
||||
(warningAlert) ? (
|
||||
<Collapse in={Boolean(warningAlert)}>
|
||||
<Alert color="warning" sx={{mb: 3}} onClose={() => setWarningAlert(null)}>{warningAlert}</Alert>
|
||||
</Collapse>
|
||||
) : null
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import Menu from "@mui/material/Menu";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Modal from "@mui/material/Modal";
|
||||
import React, {useContext, useEffect, useState} from "react";
|
||||
import {useLocation, useNavigate, useParams, useSearchParams} from "react-router-dom";
|
||||
import {useLocation, useNavigate, useParams} from "react-router-dom";
|
||||
import QContext from "QContext";
|
||||
import AuditBody from "qqq/components/audits/AuditBody";
|
||||
import {QActionsMenuButton, QCancelButton, QDeleteButton, QEditButton} from "qqq/components/buttons/DefaultButtons";
|
||||
@ -53,6 +53,7 @@ import DashboardWidgets from "qqq/components/widgets/DashboardWidgets";
|
||||
import BaseLayout from "qqq/layouts/BaseLayout";
|
||||
import ProcessRun from "qqq/pages/processes/ProcessRun";
|
||||
import HistoryUtils from "qqq/utils/HistoryUtils";
|
||||
import HtmlUtils from "qqq/utils/HtmlUtils";
|
||||
import Client from "qqq/utils/qqq/Client";
|
||||
import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
|
||||
import TableUtils from "qqq/utils/qqq/TableUtils";
|
||||
@ -97,10 +98,10 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
const [tableProcesses, setTableProcesses] = useState([] as QProcessMetaData[]);
|
||||
const [allTableProcesses, setAllTableProcesses] = useState([] as QProcessMetaData[]);
|
||||
const [actionsMenu, setActionsMenu] = useState(null);
|
||||
const [notFoundMessage, setNotFoundMessage] = useState(null);
|
||||
const [notFoundMessage, setNotFoundMessage] = useState(null as string);
|
||||
const [errorMessage, setErrorMessage] = useState(null as string)
|
||||
const [successMessage, setSuccessMessage] = useState(null as string);
|
||||
const [warningMessage, setWarningMessage] = useState(null as string);
|
||||
const [searchParams] = useSearchParams();
|
||||
const {setPageHeader} = useContext(QContext);
|
||||
const [activeModalProcess, setActiveModalProcess] = useState(null as QProcessMetaData);
|
||||
const [reloadCounter, setReloadCounter] = useState(0);
|
||||
@ -116,6 +117,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
{
|
||||
setSuccessMessage(null);
|
||||
setNotFoundMessage(null);
|
||||
setErrorMessage(null);
|
||||
setAsyncLoadInited(false);
|
||||
setTableMetaData(null);
|
||||
setRecord(null);
|
||||
@ -316,13 +318,16 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
|
||||
setPageHeader(record.recordLabel);
|
||||
|
||||
try
|
||||
if(!launchingProcess)
|
||||
{
|
||||
HistoryUtils.push({label: `${tableMetaData?.label}: ${record.recordLabel}`, path: location.pathname, iconName: table.iconName});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error("Error pushing history: " + e);
|
||||
try
|
||||
{
|
||||
HistoryUtils.push({label: `${tableMetaData?.label}: ${record.recordLabel}`, path: location.pathname, iconName: table.iconName});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.error("Error pushing history: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
@ -423,14 +428,26 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
setSectionFieldElements(sectionFieldElements);
|
||||
setNonT1TableSections(nonT1TableSections);
|
||||
|
||||
if (searchParams.get("createSuccess") || searchParams.get("updateSuccess"))
|
||||
if(location.state)
|
||||
{
|
||||
setSuccessMessage(`${tableMetaData.label} successfully ${searchParams.get("createSuccess") ? "created" : "updated"}`);
|
||||
}
|
||||
if (searchParams.get("warning"))
|
||||
{
|
||||
setWarningMessage(searchParams.get("warning"));
|
||||
let state: any = location.state;
|
||||
if (state["createSuccess"] || state["updateSuccess"])
|
||||
{
|
||||
setSuccessMessage(`${tableMetaData.label} successfully ${state["createSuccess"] ? "created" : "updated"}`);
|
||||
}
|
||||
|
||||
if (state["warning"])
|
||||
{
|
||||
setWarningMessage(state["warning"]);
|
||||
}
|
||||
|
||||
delete state["createSuccess"]
|
||||
delete state["updateSuccess"]
|
||||
delete state["warning"]
|
||||
|
||||
window.history.replaceState(state, "");
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
@ -452,8 +469,25 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
await qController.delete(tableName, id)
|
||||
.then(() =>
|
||||
{
|
||||
const path = `${pathParts.slice(0, -1).join("/")}?deleteSuccess=true`;
|
||||
navigate(path);
|
||||
const path = pathParts.slice(0, -1).join("/");
|
||||
navigate(path, {state: {deleteSuccess: true}});
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
setDeleteConfirmationOpen(false);
|
||||
console.log("Caught:");
|
||||
console.log(error);
|
||||
|
||||
if(error.message.toLowerCase().startsWith("warning"))
|
||||
{
|
||||
const path = pathParts.slice(0, -1).join("/");
|
||||
navigate(path, {state: {deleteSuccess: true, warning: error.message}});
|
||||
}
|
||||
else
|
||||
{
|
||||
setErrorMessage(error.message);
|
||||
HtmlUtils.autoScroll(0);
|
||||
}
|
||||
});
|
||||
})();
|
||||
};
|
||||
@ -648,7 +682,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
<Box pb={3}>
|
||||
{
|
||||
successMessage ?
|
||||
<Alert color="success" sx={{mb: 3}} onClose={() =>
|
||||
<Alert color="success" sx={{mb: 3}} onClose={() =>
|
||||
{
|
||||
setSuccessMessage(null);
|
||||
}}>
|
||||
@ -666,6 +700,16 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
||||
</Alert>
|
||||
: ("")
|
||||
}
|
||||
{
|
||||
errorMessage ?
|
||||
<Alert color="error" sx={{mb: 3}} onClose={() =>
|
||||
{
|
||||
setErrorMessage(null);
|
||||
}}>
|
||||
{errorMessage}
|
||||
</Alert>
|
||||
: ("")
|
||||
}
|
||||
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12} lg={3}>
|
||||
|
Reference in New Issue
Block a user