mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
Add tableSection.isHidden; table.capabilities; adornmentType.CODE_EDITOR
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Capability} from "@kingsrook/qqq-frontend-core/lib/model/metaData/Capability";
|
||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||
@ -73,6 +74,8 @@ function EntityForm({table, id}: Props): JSX.Element
|
||||
const [tableSections, setTableSections] = useState(null as QTableSection[]);
|
||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||
|
||||
const [noCapabilityError, setNoCapabilityError] = useState(null as string);
|
||||
|
||||
const {pageHeader, setPageHeader} = useContext(QContext);
|
||||
|
||||
const navigate = useNavigate();
|
||||
@ -140,11 +143,21 @@ function EntityForm({table, id}: Props): JSX.Element
|
||||
});
|
||||
|
||||
setFormValues(formValues);
|
||||
|
||||
if(!tableMetaData.capabilities.has(Capability.TABLE_UPDATE))
|
||||
{
|
||||
setNoCapabilityError("You may not edit records in this table");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setFormTitle(`Creating New ${tableMetaData?.label}`);
|
||||
setPageHeader(`Creating New ${tableMetaData?.label}`);
|
||||
|
||||
if(!tableMetaData.capabilities.has(Capability.TABLE_INSERT))
|
||||
{
|
||||
setNoCapabilityError("You may not create records in this table");
|
||||
}
|
||||
}
|
||||
setInitialValues(initialValues);
|
||||
|
||||
@ -168,6 +181,11 @@ function EntityForm({table, id}: Props): JSX.Element
|
||||
const section = tableSections[i];
|
||||
const sectionDynamicFormFields: any[] = [];
|
||||
|
||||
if(section.isHidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < section.fieldNames.length; j++)
|
||||
{
|
||||
const fieldName = section.fieldNames[j];
|
||||
@ -277,6 +295,19 @@ function EntityForm({table, id}: Props): JSX.Element
|
||||
|
||||
const formId = id != null ? `edit-${tableMetaData?.name}-form` : `create-${tableMetaData?.name}-form`;
|
||||
|
||||
if(noCapabilityError)
|
||||
{
|
||||
return <MDBox mb={3}>
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
<MDBox mb={3}>
|
||||
<Alert severity="error">{noCapabilityError}</Alert>
|
||||
</MDBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</MDBox>;
|
||||
}
|
||||
|
||||
return (
|
||||
<MDBox mb={3}>
|
||||
<Grid container spacing={3}>
|
||||
|
@ -71,7 +71,7 @@ interface QDeleteButtonProps
|
||||
export function QDeleteButton({onClickHandler}: QDeleteButtonProps): JSX.Element
|
||||
{
|
||||
return (
|
||||
<MDBox ml={3} mr={3} width={standardWidth}>
|
||||
<MDBox ml={3} width={standardWidth}>
|
||||
<MDButton variant="gradient" color="primary" size="small" onClick={onClickHandler} fullWidth startIcon={<Icon>delete</Icon>}>
|
||||
Delete
|
||||
</MDButton>
|
||||
@ -82,7 +82,7 @@ export function QDeleteButton({onClickHandler}: QDeleteButtonProps): JSX.Element
|
||||
export function QEditButton(): JSX.Element
|
||||
{
|
||||
return (
|
||||
<MDBox width={standardWidth}>
|
||||
<MDBox ml={3} width={standardWidth}>
|
||||
<Link to="edit">
|
||||
<MDButton variant="gradient" color="dark" size="small" fullWidth startIcon={<Icon>edit</Icon>}>
|
||||
Edit
|
||||
|
@ -59,6 +59,11 @@ function QRecordSidebar({tableSections, widgetMetaDataList, light, stickyTop}: P
|
||||
const sidebarEntries = [] as SidebarEntry[];
|
||||
tableSections && tableSections.forEach((section, index) =>
|
||||
{
|
||||
if(section.isHidden)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (index === 1 && widgetMetaDataList)
|
||||
{
|
||||
widgetMetaDataList.forEach((widget) =>
|
||||
|
Reference in New Issue
Block a user