@compill/admin 1.0.102 → 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +50 -50
- package/dist/index.js +50 -50
- package/dist/lib/SectionTitle.js +4 -0
- package/dist/lib/breadcrumbs/BreadCrumbs.js +29 -0
- package/dist/lib/buttons/{DialogButton.jsx → DialogButton.js} +2 -4
- package/dist/lib/buttons/InvalidateButton.d.ts +1 -1
- package/dist/lib/buttons/{InvalidateButton.jsx → InvalidateButton.js} +3 -2
- package/dist/lib/buttons/{NavigateButton.jsx → NavigateButton.js} +2 -3
- package/dist/lib/buttons/{PublishButton.jsx → PublishButton.js} +3 -4
- package/dist/lib/buttons/{UpdateButton.jsx → UpdateButton.js} +3 -4
- package/dist/lib/buttons/ViewButton.d.ts +1 -1
- package/dist/lib/buttons/{ViewButton.jsx → ViewButton.js} +3 -4
- package/dist/lib/cells/{OrderCell.jsx → OrderCell.js} +2 -11
- package/dist/lib/json/DetailsView.d.ts +1 -1
- package/dist/lib/json/DetailsView.js +69 -0
- package/dist/lib/json/EditItemView.d.ts +1 -1
- package/dist/lib/json/EditItemView.js +6 -0
- package/dist/lib/json/MultiQueryWrapper.d.ts +1 -1
- package/dist/lib/json/{MultiQueryWrapper.jsx → MultiQueryWrapper.js} +5 -4
- package/dist/lib/json/QueryWrapper.d.ts +1 -1
- package/dist/lib/json/{QueryWrapper.jsx → QueryWrapper.js} +3 -2
- package/dist/lib/json/ScreenRenderer.d.ts +1 -1
- package/dist/lib/json/ScreenRenderer.js +19 -0
- package/dist/lib/json/ScreenTopBar.d.ts +2 -2
- package/dist/lib/json/ScreenTopBar.js +18 -0
- package/dist/lib/json/TabbedView.d.ts +1 -1
- package/dist/lib/json/TabbedView.js +21 -0
- package/dist/lib/json/buttons/{ActionButton.jsx → ActionButton.js} +2 -4
- package/dist/lib/json/buttons/{ConfirmationActionButton.jsx → ConfirmationActionButton.js} +3 -20
- package/dist/lib/json/dialog/DialogRenderer.d.ts +3 -3
- package/dist/lib/json/dialog/DialogRenderer.js +14 -0
- package/dist/lib/json/dialog/ItemDeleteDialog.js +14 -0
- package/dist/lib/json/dialog/ItemEditDialog.js +77 -0
- package/dist/lib/json/dialog/MultiQueryWrapperDialog.d.ts +1 -1
- package/dist/lib/json/dialog/{MultiQueryWrapperDialog.jsx → MultiQueryWrapperDialog.js} +3 -2
- package/dist/lib/json/dialog/QueryWrapperDialog.d.ts +2 -2
- package/dist/lib/json/dialog/{QueryWrapperDialog.jsx → QueryWrapperDialog.js} +3 -2
- package/dist/lib/json/table/{RefreshButton.jsx → RefreshButton.js} +3 -4
- package/dist/lib/json/table/TableRowActionsView.d.ts +1 -1
- package/dist/lib/json/table/TableRowActionsView.js +36 -0
- package/dist/lib/json/table/{TableRowPublishPostButton.jsx → TableRowPublishPostButton.js} +2 -3
- package/dist/lib/json/table/TableView.d.ts +1 -1
- package/dist/lib/json/table/TableView.js +65 -0
- package/dist/lib/json/table/TableViewContext.d.ts +1 -1
- package/dist/lib/json/table/{TableViewContext.jsx → TableViewContext.js} +6 -5
- package/dist/lib/json/table/useTableProps.d.ts +1 -1
- package/dist/lib/json/table/{useTableProps.jsx → useTableProps.js} +4 -3
- package/dist/lib/json/types/DetailsView.d.ts +1 -1
- package/dist/lib/json/types/EditItemDialog.d.ts +1 -1
- package/dist/lib/json/types/MultiQueryWrapper.d.ts +3 -3
- package/dist/lib/json/types/MultiQueryWrapperDialog.d.ts +1 -1
- package/dist/lib/json/types/QueryWrapper.d.ts +3 -3
- package/dist/lib/json/types/QueryWrapperDialog.d.ts +1 -1
- package/dist/lib/json/types/ScreenConfig.d.ts +6 -6
- package/dist/lib/json/types/TabbedView.d.ts +5 -5
- package/dist/lib/json/types/TableView.d.ts +4 -4
- package/dist/lib/layout/AdminLayout.d.ts +1 -1
- package/dist/lib/layout/AdminLayout.js +15 -0
- package/dist/lib/layout/ButtonBar.d.ts +1 -1
- package/dist/lib/layout/ButtonBar.js +19 -0
- package/dist/lib/layout/Content.js +9 -0
- package/dist/lib/layout/PageTitleBar.js +4 -0
- package/dist/lib/layout/Sidebar.d.ts +1 -1
- package/dist/lib/layout/Sidebar.js +12 -0
- package/dist/lib/layout/menu/Menu.d.ts +1 -1
- package/dist/lib/layout/menu/Menu.js +23 -0
- package/dist/lib/layout/menu/MenuButton.js +5 -0
- package/dist/lib/layout/menu/MenuItem.d.ts +1 -1
- package/dist/lib/layout/menu/MenuItem.js +11 -0
- package/dist/lib/layout/menu/NextMenuItem.d.ts +1 -1
- package/dist/lib/layout/menu/NextMenuItem.js +11 -0
- package/dist/lib/layout/menu/SelectedIndicator.js +4 -0
- package/dist/lib/layout/menu/UserBlock.d.ts +1 -1
- package/dist/lib/layout/menu/UserBlock.js +34 -0
- package/dist/lib/modal/{AttachDialog.jsx → AttachDialog.js} +4 -40
- package/dist/lib/modal/FormActionDialog.js +20 -0
- package/dist/lib/page/PageContainer.js +5 -0
- package/dist/lib/page/PageContentEditor.js +10 -0
- package/dist/lib/page/PageMain.js +5 -0
- package/dist/lib/page/{PageQueryStateContainer.jsx → PageQueryStateContainer.js} +5 -4
- package/dist/lib/page/PageSectionTitle.js +4 -0
- package/dist/lib/page/PageSidebar.js +4 -0
- package/dist/lib/page/PageSidebarSection.js +5 -0
- package/dist/lib/page/PageStateContainer.js +7 -0
- package/dist/lib/page/PageSubSectionTitle.js +4 -0
- package/dist/lib/page/PageTitle.js +4 -0
- package/dist/lib/page/PageTopBar.d.ts +1 -1
- package/dist/lib/page/{PageTopBar.jsx → PageTopBar.js} +6 -20
- package/dist/lib/status/{StatusBadge.jsx → StatusBadge.js} +2 -1
- package/dist/lib/table/{TableColumnButton.jsx → TableColumnButton.js} +1 -1
- package/dist/lib/table/TableContainer.js +6 -0
- package/dist/lib/table/{TableContainerContext.jsx → TableContainerContext.js} +2 -1
- package/dist/lib/table/TableCreateButton.d.ts +1 -1
- package/dist/lib/table/TableCreateButton.js +7 -0
- package/dist/lib/table/TableFilterButton.js +8 -0
- package/dist/lib/table/{TableFilters.jsx → TableFilters.js} +4 -23
- package/dist/lib/table/TableMassActions.d.ts +1 -1
- package/dist/lib/table/TableMassActions.js +9 -0
- package/dist/lib/table/TableRowActionBar.js +8 -0
- package/dist/lib/table/TableRowActionButton.js +5 -0
- package/dist/lib/table/TableRowActionDialogButton.d.ts +1 -1
- package/dist/lib/table/TableRowActionDialogButton.js +6 -0
- package/dist/lib/table/TableRowDeleteButton.d.ts +1 -1
- package/dist/lib/table/{TableRowDeleteButton.jsx → TableRowDeleteButton.js} +3 -2
- package/dist/lib/table/TableRowEditButton.d.ts +1 -1
- package/dist/lib/table/{TableRowEditButton.jsx → TableRowEditButton.js} +3 -4
- package/dist/lib/table/{TableRowNavigateButton.jsx → TableRowNavigateButton.js} +3 -2
- package/dist/lib/table/{TableRowPublishPostButton.jsx → TableRowPublishPostButton.js} +3 -2
- package/dist/lib/table/{TableRowViewButton.jsx → TableRowViewButton.js} +3 -2
- package/dist/lib/table/TableTopBar.d.ts +1 -1
- package/dist/lib/table/TableTopBar.js +5 -0
- package/package.json +17 -17
- package/dist/lib/SectionTitle.jsx +0 -3
- package/dist/lib/breadcrumbs/BreadCrumbs.jsx +0 -43
- package/dist/lib/json/DetailsView.jsx +0 -96
- package/dist/lib/json/EditItemView.jsx +0 -5
- package/dist/lib/json/ScreenRenderer.jsx +0 -18
- package/dist/lib/json/ScreenTopBar.jsx +0 -39
- package/dist/lib/json/TabbedView.jsx +0 -28
- package/dist/lib/json/dialog/DialogRenderer.jsx +0 -13
- package/dist/lib/json/dialog/ItemDeleteDialog.jsx +0 -36
- package/dist/lib/json/dialog/ItemEditDialog.jsx +0 -124
- package/dist/lib/json/table/TableRowActionsView.jsx +0 -45
- package/dist/lib/json/table/TableView.jsx +0 -100
- package/dist/lib/layout/AdminLayout.jsx +0 -24
- package/dist/lib/layout/ButtonBar.jsx +0 -29
- package/dist/lib/layout/Content.jsx +0 -10
- package/dist/lib/layout/PageTitleBar.jsx +0 -12
- package/dist/lib/layout/Sidebar.jsx +0 -24
- package/dist/lib/layout/menu/Menu.jsx +0 -30
- package/dist/lib/layout/menu/MenuButton.jsx +0 -7
- package/dist/lib/layout/menu/MenuItem.jsx +0 -20
- package/dist/lib/layout/menu/NextMenuItem.jsx +0 -20
- package/dist/lib/layout/menu/SelectedIndicator.jsx +0 -3
- package/dist/lib/layout/menu/UserBlock.jsx +0 -55
- package/dist/lib/modal/FormActionDialog.jsx +0 -46
- package/dist/lib/page/PageContainer.jsx +0 -4
- package/dist/lib/page/PageContentEditor.jsx +0 -11
- package/dist/lib/page/PageMain.jsx +0 -4
- package/dist/lib/page/PageSectionTitle.jsx +0 -3
- package/dist/lib/page/PageSidebar.jsx +0 -3
- package/dist/lib/page/PageSidebarSection.jsx +0 -7
- package/dist/lib/page/PageStateContainer.jsx +0 -9
- package/dist/lib/page/PageSubSectionTitle.jsx +0 -3
- package/dist/lib/page/PageTitle.jsx +0 -3
- package/dist/lib/table/TableContainer.jsx +0 -11
- package/dist/lib/table/TableCreateButton.jsx +0 -9
- package/dist/lib/table/TableFilterButton.jsx +0 -16
- package/dist/lib/table/TableMassActions.jsx +0 -15
- package/dist/lib/table/TableRowActionBar.jsx +0 -14
- package/dist/lib/table/TableRowActionButton.jsx +0 -7
- package/dist/lib/table/TableRowActionDialogButton.jsx +0 -8
- package/dist/lib/table/TableTopBar.jsx +0 -17
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
2
|
+
import { useParams } from "react-router-dom";
|
|
3
|
+
import { PageQueryStateContainer } from "../page/PageQueryStateContainer.js";
|
|
4
|
+
import { PageTabbedTopBar, PageTabbedTopBarProvider } from "../page/PageTopBar.js";
|
|
5
|
+
import { TabContainer } from "@compill/components";
|
|
6
|
+
import { runIfFn } from "@soperio/react";
|
|
7
|
+
import { ScreenRenderer } from "./ScreenRenderer.js";
|
|
8
|
+
export function TabbedView({ queryField, api, screen, ...props }) {
|
|
9
|
+
const { [queryField]: id } = useParams();
|
|
10
|
+
return (_jsx(PageQueryStateContainer, { queryId: id, api: api, apiFn: "get", p: "5", children: (city) => {
|
|
11
|
+
const { breadcrumbs, tabs } = runIfFn(screen, city);
|
|
12
|
+
return (_jsxs(PageTabbedTopBarProvider, { children: [_jsx(PageTabbedTopBar, { breadcrumbs: breadcrumbs, mb: "-3" }), _jsx(TabContainer, { tabs: tabs.map(tab => tab.label), saveKey: `tab-${id}`, mt: "-3", mb: "3", id: "fff", children: tabs.map((tab, index) => _jsx(TabView, { tab: tab }, index)) })] }));
|
|
13
|
+
} }));
|
|
14
|
+
}
|
|
15
|
+
function TabView({ tab }) {
|
|
16
|
+
if (!tab.component && !tab.config)
|
|
17
|
+
throw new Error(`Screen config for tabbed view: one of your tabs does not have a component or config declared: ${tab.label}`);
|
|
18
|
+
if (tab.component)
|
|
19
|
+
return tab.component();
|
|
20
|
+
return _jsx(ScreenRenderer, { config: tab.config, tabbed: true, p: "0" });
|
|
21
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiMutation, useInvalidateParentMutation, useMutate } from "@compill/api";
|
|
2
3
|
import { Button, Icon } from "@valerya/ui";
|
|
3
4
|
export function ActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }) {
|
|
@@ -6,8 +7,5 @@ export function ActionButton({ label, buttonProps, icon, queryKey, queryFn, succ
|
|
|
6
7
|
successMsg,
|
|
7
8
|
errorMsg
|
|
8
9
|
});
|
|
9
|
-
return (
|
|
10
|
-
{icon && <Icon path={icon}/>}
|
|
11
|
-
{label}
|
|
12
|
-
</Button>);
|
|
10
|
+
return (_jsxs(Button, { display: "flex", alignItems: "center", gap: "3", ...buttonProps, onClick: mutate, disabled: mutation.isLoading, children: [icon && _jsx(Icon, { path: icon }), label] }));
|
|
13
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiMutation, useInvalidateParentMutation, useMutate } from "@compill/api";
|
|
2
3
|
import { ModalLoadingOverlay } from "@compill/components";
|
|
3
4
|
import { Button, Icon, Modal, ModalBody, ModalFooter, ModalHeader } from "@valerya/ui";
|
|
@@ -7,10 +8,7 @@ export function ConfirmationActionButton({ label, buttonProps, icon, queryKey, q
|
|
|
7
8
|
successMsg,
|
|
8
9
|
errorMsg
|
|
9
10
|
});
|
|
10
|
-
return (
|
|
11
|
-
{icon && <Icon path={icon}/>}
|
|
12
|
-
{label}
|
|
13
|
-
</Button>);
|
|
11
|
+
return (_jsxs(Button, { display: "flex", alignItems: "center", gap: "3", ...buttonProps, onClick: mutate, disabled: mutation.isLoading, children: [icon && _jsx(Icon, { path: icon }), label] }));
|
|
14
12
|
}
|
|
15
13
|
export function ConfirmationDialog({ title, text, positiveButtonLabel, negativeButtonLabel, queryKey, queryFn, successMsg, errorMsg, invalidateParent, show, onClose }) {
|
|
16
14
|
const mutation = invalidateParent ? useInvalidateParentMutation(queryFn, queryKey) : useApiMutation(queryFn, queryKey);
|
|
@@ -18,20 +16,5 @@ export function ConfirmationDialog({ title, text, positiveButtonLabel, negativeB
|
|
|
18
16
|
successMsg,
|
|
19
17
|
errorMsg
|
|
20
18
|
});
|
|
21
|
-
return (
|
|
22
|
-
<ModalHeader>
|
|
23
|
-
<div textSize="xl" fontWeight="600">{title}</div>
|
|
24
|
-
</ModalHeader>
|
|
25
|
-
|
|
26
|
-
<ModalBody>
|
|
27
|
-
{text}
|
|
28
|
-
</ModalBody>
|
|
29
|
-
|
|
30
|
-
<ModalFooter dflex gap="3" alignItems="center" placeContent="end">
|
|
31
|
-
<Button>{negativeButtonLabel || "Cancel"}</Button>
|
|
32
|
-
<Button onClick={mutate}>{positiveButtonLabel || "OK"}</Button>
|
|
33
|
-
</ModalFooter>
|
|
34
|
-
|
|
35
|
-
{mutation.isLoading && <ModalLoadingOverlay />}
|
|
36
|
-
</Modal>);
|
|
19
|
+
return (_jsxs(Modal, { show: show, onClose: onClose, children: [_jsx(ModalHeader, { children: _jsx("div", { textSize: "xl", fontWeight: "600", children: title }) }), _jsx(ModalBody, { children: text }), _jsxs(ModalFooter, { dflex: true, gap: "3", alignItems: "center", placeContent: "end", children: [_jsx(Button, { children: negativeButtonLabel || "Cancel" }), _jsx(Button, { onClick: mutate, children: positiveButtonLabel || "OK" })] }), mutation.isLoading && _jsx(ModalLoadingOverlay, {})] }));
|
|
37
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EditItemDialogConfig } from "../types/EditItemDialog";
|
|
2
|
-
import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog";
|
|
3
|
-
import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog";
|
|
1
|
+
import { EditItemDialogConfig } from "../types/EditItemDialog.js";
|
|
2
|
+
import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog.js";
|
|
3
|
+
import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog.js";
|
|
4
4
|
interface DialogRendererProps {
|
|
5
5
|
config: EditItemDialogConfig | QueryWrapperDialogConfig<any> | MultiQueryWrapperDialogConfig;
|
|
6
6
|
onClose: () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
2
|
+
import { ItemEditDialog } from "./ItemEditDialog.js";
|
|
3
|
+
import { QueryWrapperDialog } from "./QueryWrapperDialog.js";
|
|
4
|
+
import { MultiQueryWrapperDialog } from "./MultiQueryWrapperDialog.js";
|
|
5
|
+
export function DialogRenderer({ config, onClose, invalidateQueryKey, queryId }) {
|
|
6
|
+
const { type, ...props } = config;
|
|
7
|
+
if (config.type === "dialog")
|
|
8
|
+
return _jsx(ItemEditDialog, { ...props, queryId: queryId, invalidateQueryKey: invalidateQueryKey, show: true, onClose: onClose });
|
|
9
|
+
if (config.type === "query")
|
|
10
|
+
return _jsx(QueryWrapperDialog, { ...props, queryId: queryId, invalidateQueryKey: invalidateQueryKey, onClose: onClose });
|
|
11
|
+
if (config.type === "multiQuery")
|
|
12
|
+
return _jsx(MultiQueryWrapperDialog, { ...props, queryId: queryId, invalidateQueryKey: invalidateQueryKey, onClose: onClose });
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
2
|
+
import { useApiMutation, useInvalidateParentMutation, useMutate } from "@compill/api";
|
|
3
|
+
import { ModalLoadingOverlay } from "@compill/components";
|
|
4
|
+
import { runIfFn } from "@soperio/react";
|
|
5
|
+
import { Button, Modal } from "@valerya/ui";
|
|
6
|
+
import React from "react";
|
|
7
|
+
export function ItemDeleteDialog({ title, actionButtonLabel, closeActionButtonLabel = "Cancel", itemLabel, queryId = "", api, apiFn, invalidateQueriesOnSuccess = true, invalidateQueryKey, size = "lg", md_boxSizing, msg, show, onClose, onSuccess, ...props }) {
|
|
8
|
+
const fn = apiFn ? api[apiFn] : api.delete;
|
|
9
|
+
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(fn, invalidateQueryKey ?? api.queryKey)
|
|
10
|
+
: useApiMutation(fn, api.queryKey);
|
|
11
|
+
const mutate = useMutate(mutation, { onSuccess: () => { onClose?.(); onSuccess?.(); } });
|
|
12
|
+
const handleDelete = React.useCallback(() => mutate(queryId), [mutate, queryId]);
|
|
13
|
+
return (_jsxs(Modal, { size: size, show: show, onClose: onClose, scheme: "danger", variant: "glass", transition: true, ...props, children: [_jsx(Modal.Header, { children: title || `Delete ${itemLabel}` }), _jsxs(Modal.Body, { pb: "6", children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && runIfFn(msg, itemLabel)] }), _jsxs(Modal.Footer, { dflex: true, placeContent: "end", spaceX: "3", children: [_jsx(Button, { disabled: mutation.isPending, onClick: onClose, variant: "borderless", scheme: "dark", me: "2", children: closeActionButtonLabel }), _jsx(Button, { scheme: "danger", disabled: mutation.isPending, onClick: handleDelete, children: actionButtonLabel || "Delete" })] }), mutation.isPending && _jsx(ModalLoadingOverlay, {})] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
2
|
+
import { useApiMutation, useApiQuery, useInvalidateParentMutation } from "@compill/api";
|
|
3
|
+
import { ModalLoadingOverlay, QueryLoadingState, RetryOnError } from "@compill/components";
|
|
4
|
+
import { FormRenderer } from "@compill/form";
|
|
5
|
+
import { isFunction } from "@soperio/react";
|
|
6
|
+
import { Button, Modal } from "@valerya/ui";
|
|
7
|
+
import { Form, Formik } from "formik";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { toast } from "react-toastify";
|
|
10
|
+
const defaultErrorMsg = "Oops, something went wrong...";
|
|
11
|
+
function nonNullValues(data) {
|
|
12
|
+
if (data) {
|
|
13
|
+
const nonNullData = { ...data };
|
|
14
|
+
for (const key in data)
|
|
15
|
+
nonNullData[key] = nonNullData[key] ?? "";
|
|
16
|
+
return nonNullData;
|
|
17
|
+
}
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
export function ItemEditDialog({ initialValues, itemLabel, queryId = "", api, queryFetchOptions, querySaveOptions, onSuccess, onFetchError, fetchErrorMsg = defaultErrorMsg, onSaveError, saveErrorMsg = defaultErrorMsg, fetchToFormData, formToQueryData, invalidateQueriesOnSuccess = true, invalidateQueryKey, retryText = "Retry", cancelLabel = "Cancel", saveLabel, size = "lg", title, form, show, onClose, formikProps, ...props }) {
|
|
21
|
+
const { isInitialLoading, isFetching, data, isError, error /*, error*/, refetch } = useApiQuery(api.queryKey, api.get, queryId, {
|
|
22
|
+
enabled: !( /*queryId == 0 || */queryId == "" || queryId == null || queryId == undefined), // means than this query is only enabled if the id is defined
|
|
23
|
+
onError: onFetchError,
|
|
24
|
+
...queryFetchOptions
|
|
25
|
+
});
|
|
26
|
+
// const [activeTab, setActiveTab] = React.useState(form && Array.isArray(form) ? form[0].key : "");
|
|
27
|
+
// const [showTab, setShowTab] = React.useState(true);
|
|
28
|
+
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.upsert, invalidateQueryKey ?? api.queryKey, querySaveOptions)
|
|
29
|
+
: useApiMutation(api.upsert, api.queryKey, queryId, querySaveOptions);
|
|
30
|
+
const retry = React.useCallback(() => refetch(), [refetch]);
|
|
31
|
+
const saveItem = React.useCallback(async (item, actions) => {
|
|
32
|
+
// Clear mutation error if any
|
|
33
|
+
mutation.reset();
|
|
34
|
+
const formItem = formToQueryData ? formToQueryData(item) : { ...item };
|
|
35
|
+
await mutation.mutateAsync(formItem)
|
|
36
|
+
.then((response) => {
|
|
37
|
+
if (onSuccess)
|
|
38
|
+
onSuccess(formItem, response);
|
|
39
|
+
else
|
|
40
|
+
toast.success(`${title ? title(formItem) : formItem.name ?? formItem.title} ${queryId ? "saved" : "created"}`);
|
|
41
|
+
// closing delete modal
|
|
42
|
+
onClose?.();
|
|
43
|
+
})
|
|
44
|
+
.catch(error => {
|
|
45
|
+
console.error("on error", error);
|
|
46
|
+
if (onSaveError)
|
|
47
|
+
onSaveError(item);
|
|
48
|
+
else
|
|
49
|
+
toast.error(`Couldn't save ${title ? title(formItem) : formItem.name ?? formItem.title}`);
|
|
50
|
+
actions.setSubmitting(false);
|
|
51
|
+
});
|
|
52
|
+
}, [mutation, formToQueryData, onSuccess, onSaveError, onClose]);
|
|
53
|
+
// const switchTab = React.useCallback((tab: string) =>
|
|
54
|
+
// {
|
|
55
|
+
// setActiveTab(tab);
|
|
56
|
+
// setShowTab(false);
|
|
57
|
+
// setTimeout(function ()
|
|
58
|
+
// {
|
|
59
|
+
// setActiveTab(tab);
|
|
60
|
+
// setShowTab(true);
|
|
61
|
+
// }, 150);
|
|
62
|
+
// }, [setActiveTab])
|
|
63
|
+
return (_jsxs(Modal, { size: size, show: show, onClose: onClose, scheme: "light", transition: true, ...props, children: [_jsxs(Modal.Header, { children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : data?.["name"] ?? data?.["title"] ?? data?.["name"] ?? ""}`, !queryId && `Create new ${itemLabel ?? "item"}`, Array.isArray(form) && (_jsx(_Fragment, {})
|
|
64
|
+
// <ul className="nav nav-bold nav-pills">
|
|
65
|
+
// {form.map(item =>
|
|
66
|
+
// <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
|
|
67
|
+
// <span className={clsx("nav-link", activeTab === item.key && "active")} data-toggle="tab">{item.label}</span>
|
|
68
|
+
// </li>
|
|
69
|
+
// )}
|
|
70
|
+
// </ul>
|
|
71
|
+
)] }), isInitialLoading && (_jsx(Modal.Body, { children: _jsx(QueryLoadingState, { minW: "72" }) })), isError && (_jsx(Modal.Body, { children: _jsx(RetryOnError, { label: `${fetchErrorMsg} ${error}`, onClick: retry }) })), !isInitialLoading && !isError &&
|
|
72
|
+
(_jsx(_Fragment, { children: _jsx(Formik
|
|
73
|
+
// initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
|
|
74
|
+
, {
|
|
75
|
+
// initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
|
|
76
|
+
initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(initialValues(data)) ?? {}, onSubmit: saveItem, ...formikProps, children: ({ setFieldValue, dirty, handleSubmit, isValid, values }) => (_jsxs(_Fragment, { children: [_jsx(Modal.Body, { pb: "6", children: _jsxs(Form, { children: [React.isValidElement(form) && form, Array.isArray(form) && _jsx(FormRenderer, { form: form }), isFunction(form) && _jsx(FormRenderer, { form: form(data ?? values) })] }) }), _jsxs(Modal.Footer, { dflex: true, placeContent: "end", spaceX: "3", children: [_jsx(Button, { disabled: mutation.isLoading, onClick: onClose, variant: "borderless", me: "2", children: cancelLabel }), _jsx(Button, { type: "submit", disabled: !dirty || mutation.isLoading /* || !isValid*/, onClick: () => handleSubmit(), children: saveLabel ? saveLabel : (queryId ? "Update" : "Create") })] })] })) }) })), mutation.isLoading && _jsx(ModalLoadingOverlay, {})] }));
|
|
77
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog";
|
|
1
|
+
import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog.js";
|
|
2
2
|
export type MultiQueryWrapperDialogProps = Omit<MultiQueryWrapperDialogConfig, "type"> & {
|
|
3
3
|
queryId?: string;
|
|
4
4
|
onClose: () => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiQueries } from "@compill/api";
|
|
2
3
|
import React from "react";
|
|
3
|
-
import { ItemEditDialog } from "./ItemEditDialog";
|
|
4
|
+
import { ItemEditDialog } from "./ItemEditDialog.js";
|
|
4
5
|
export function MultiQueryWrapperDialog({ queries, config, onClose, queryId, invalidateQueryKey }) {
|
|
5
6
|
const { data, isFetching, isError } = useApiQueries(queries.map(q => ({
|
|
6
7
|
queryKey: q.api.queryKey,
|
|
@@ -18,5 +19,5 @@ export function MultiQueryWrapperDialog({ queries, config, onClose, queryId, inv
|
|
|
18
19
|
// if (isFetching)
|
|
19
20
|
// return null
|
|
20
21
|
// @ts-ignore
|
|
21
|
-
return
|
|
22
|
+
return _jsx(ItemEditDialog, { isPreloading: isFetching, ...config(...transformedData), queryId: queryId, invalidateQueryKey: invalidateQueryKey, show: true, onClose: onClose });
|
|
22
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CRUDAPI, CRUD_MODEL } from "@compill/api";
|
|
2
|
-
import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog";
|
|
3
|
-
import { EditItemDialogConfig } from "../types/EditItemDialog";
|
|
2
|
+
import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog.js";
|
|
3
|
+
import { EditItemDialogConfig } from "../types/EditItemDialog.js";
|
|
4
4
|
export type QueryWrapperDialogProps<T extends CRUD_MODEL, U> = Omit<QueryWrapperDialogConfig<T, U>, "type"> & {
|
|
5
5
|
api: CRUDAPI<any>;
|
|
6
6
|
fn: "get" | "getTransformed" | "getAll" | "getAllTransformed";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiQuery } from "@compill/api";
|
|
2
3
|
import React from "react";
|
|
3
|
-
import { ItemEditDialog } from "./ItemEditDialog";
|
|
4
|
+
import { ItemEditDialog } from "./ItemEditDialog.js";
|
|
4
5
|
export function QueryWrapperDialog({ api, fn, transformFn, config, onClose, queryId, invalidateQueryKey }) {
|
|
5
6
|
const { data, isFetching } = useApiQuery(api.queryKey, fn === "get" || fn === "getTransformed" ? api.get : api.getAll, undefined, { retryOnMount: false, refetchOnMount: false, refetchOnWindowFocus: false });
|
|
6
7
|
const transformedData = React.useMemo(() => {
|
|
@@ -15,5 +16,5 @@ export function QueryWrapperDialog({ api, fn, transformFn, config, onClose, quer
|
|
|
15
16
|
if (isFetching)
|
|
16
17
|
return null;
|
|
17
18
|
// @ts-ignore
|
|
18
|
-
return
|
|
19
|
+
return _jsx(ItemEditDialog, { ...config(transformedData), queryId: queryId, invalidateQueryKey: invalidateQueryKey, show: true, onClose: onClose });
|
|
19
20
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useInvalidateQuery } from "@compill/api";
|
|
2
3
|
import { mdiRefresh } from "@mdi/js";
|
|
3
4
|
import { Icon } from "@valerya/ui";
|
|
4
|
-
import { ButtonBarButton } from "../../layout/ButtonBar";
|
|
5
|
+
import { ButtonBarButton } from "../../layout/ButtonBar.js";
|
|
5
6
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
6
7
|
export function RefreshButton({ queryKey }) {
|
|
7
8
|
const invalidate = useInvalidateQuery(queryKey);
|
|
8
9
|
useHotkeys('ctrl+r', () => invalidate(), { preventDefault: true }, [invalidate]);
|
|
9
|
-
return (
|
|
10
|
-
<Icon path={mdiRefresh}/>
|
|
11
|
-
</ButtonBarButton>);
|
|
10
|
+
return (_jsx(ButtonBarButton, { scheme: "dark", size: "sm", aspectRatio: "square", variant: "borderless", onClick: invalidate, children: _jsx(Icon, { path: mdiRefresh }) }));
|
|
12
11
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
2
|
+
import { mdiDelete, mdiEye, mdiOpenInNew, mdiPencil } from "@mdi/js";
|
|
3
|
+
import { Icon } from "@valerya/ui";
|
|
4
|
+
import { TableRowPublishPostButton } from "./TableRowPublishPostButton.js";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { TableRowActionButton } from "@compill/admin";
|
|
7
|
+
import { runIfFn } from "@soperio/react";
|
|
8
|
+
export function TableRowActionsView({ row, onAction, rowActions, api, queryKey }) {
|
|
9
|
+
const item = row.original;
|
|
10
|
+
return (_jsx("div", { dflex: true, w: "full", alignItems: "stretch", placeContent: "end", h: "full", children: runIfFn(rowActions, item)?.map((action, index) => (_jsxs(React.Fragment, { children: [action.type === "publish" && _jsx(TableRowPublishPostButton, { id: item.id, api: action.api ?? api, status: item.status, invalidateQueryKey: queryKey }), action.type == "custom" && _jsx(_Fragment, { children: action.component(item, queryKey, action.icon, action.label) }), !["publish", "custom"].includes(action.type) &&
|
|
11
|
+
(_jsx(ActionButton, { onClick: () => onAction(action, item), scheme: schemes[action.type], children: _jsx(Icon, { path: icons[action.type], size: "sm" }) }))] }, index))) }));
|
|
12
|
+
}
|
|
13
|
+
function ActionButton({ onClick, ...props }) {
|
|
14
|
+
const handleClick = React.useCallback((event) => {
|
|
15
|
+
event?.preventDefault();
|
|
16
|
+
event?.stopPropagation();
|
|
17
|
+
onClick?.(event);
|
|
18
|
+
}, [onClick]);
|
|
19
|
+
return (_jsx(TableRowActionButton, { onClick: handleClick, ...props }));
|
|
20
|
+
}
|
|
21
|
+
const icons = {
|
|
22
|
+
"link": mdiOpenInNew,
|
|
23
|
+
"view": mdiEye,
|
|
24
|
+
"edit": mdiPencil,
|
|
25
|
+
"delete": mdiDelete,
|
|
26
|
+
"publish": mdiDelete,
|
|
27
|
+
"custom": ""
|
|
28
|
+
};
|
|
29
|
+
const schemes = {
|
|
30
|
+
"link": "dark",
|
|
31
|
+
"view": "dark",
|
|
32
|
+
"edit": "dark",
|
|
33
|
+
"delete": "dark",
|
|
34
|
+
"publish": "dark",
|
|
35
|
+
"custom": "dark"
|
|
36
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { Icon } from "@valerya/ui";
|
|
2
3
|
import { mdiPublish, mdiPublishOff } from "@mdi/js";
|
|
3
4
|
import { Button } from "@valerya/ui";
|
|
@@ -15,7 +16,5 @@ export function TableRowPublishPostButton({ id, api, status, invalidateQueryKey,
|
|
|
15
16
|
.then(() => toast.success(isDraft ? "Published!" : "Unpublished!"))
|
|
16
17
|
.catch(error => toast.error(`Error: ${error}`));
|
|
17
18
|
}, [mutation, id]);
|
|
18
|
-
return (
|
|
19
|
-
<Icon path={isDraft ? mdiPublish : mdiPublishOff} size="sm"/>
|
|
20
|
-
</Button>);
|
|
19
|
+
return (_jsx(Button, { variant: "borderless", corners: "square", scheme: "dark", onClick: publish, ...props, children: _jsx(Icon, { path: isDraft ? mdiPublish : mdiPublishOff, size: "sm" }) }));
|
|
21
20
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SoperioComponent } from "@soperio/react";
|
|
2
|
-
import { TableViewConfig } from "../types/TableView";
|
|
2
|
+
import { TableViewConfig } from "../types/TableView.js";
|
|
3
3
|
export declare function TableView({ queryField, title, subtitle, screen, ...props }: Omit<TableViewConfig, "type"> & SoperioComponent): JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
|
|
2
|
+
import { Table, useTableContext } from "@compill/table";
|
|
3
|
+
import { isFunction, runIfFn } from "@soperio/react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { useParams } from "react-router-dom";
|
|
6
|
+
import { InvalidateButton } from "../../buttons/InvalidateButton.js";
|
|
7
|
+
import { PageContainer } from "../../page/PageContainer.js";
|
|
8
|
+
import { TableContainer } from "../../table/TableContainer.js";
|
|
9
|
+
import { TableCreateButton } from "../../table/TableCreateButton.js";
|
|
10
|
+
import { TableFilterButton } from "../../table/TableFilterButton.js";
|
|
11
|
+
import { TableTopBar } from "../../table/TableTopBar.js";
|
|
12
|
+
import { ButtonBar } from "../../layout/ButtonBar.js";
|
|
13
|
+
import { TableFilters } from "../../table/TableFilters.js";
|
|
14
|
+
import { TableMassActions } from "../../table/TableMassActions.js";
|
|
15
|
+
import { DialogRenderer } from "../dialog/DialogRenderer.js";
|
|
16
|
+
import { RefreshButton } from "./RefreshButton.js";
|
|
17
|
+
import { TableViewProvider, useTableViewContext } from "./TableViewContext.js";
|
|
18
|
+
import { useTableProps } from "./useTableProps.js";
|
|
19
|
+
function useId(queryField) {
|
|
20
|
+
const params = useParams();
|
|
21
|
+
if (queryField === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
const { [queryField]: id } = params;
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
export function TableView({ queryField, title, subtitle, screen, ...props }) {
|
|
27
|
+
const id = useId(queryField);
|
|
28
|
+
const _screen = runIfFn(screen, id);
|
|
29
|
+
return (_jsx(PageContainer, { bgColor: "white", ...props, children: _jsx(TableContainer, { columns: _screen.table.columns, initialVisibleColumns: _screen.table.initialVisibleColumns, filtersMethod: _screen.table.filtersMethod, children: _jsx(TT, { id: id, title: title, subtitle: subtitle, screen: _screen }) }) }));
|
|
30
|
+
}
|
|
31
|
+
function TT({ id, title, subtitle, screen }) {
|
|
32
|
+
const { setRowSelection } = useTableContext();
|
|
33
|
+
const { api, table, filters, massActions, buttonBar, rowActions, createView, editView, deleteItem, breadcrumbs } = screen;
|
|
34
|
+
const tableApi = runIfFn(api, id ?? "");
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(TableTopBar, { title: title, breadcrumbs: breadcrumbs, children: _jsx(TableButtonBar, { buttonBar: buttonBar, createView: createView, editView: editView, api: tableApi, queryKey: tableApi.queryKey, children: filters && _jsx(TableFilterButton, {}) }) }), filters &&
|
|
36
|
+
(_jsx(TableFilters, { form: filters.form, initialValues: filters.initialValues, schema: filters.schema, processInput: filters.processInput })), massActions && _jsx(TableMassActions, { actions: massActions.items }), _jsxs(TableViewProvider, { queryKey: tableApi.queryKey, editView: editView, deleteItem: deleteItem, children: [_jsx(TableWrapper, { table: { ...table, onSelectionChange: setRowSelection }, rowActions: rowActions, api: tableApi, subtitle: subtitle, queryParams: screen.queryParams }), _jsx(TableDialogManager, {})] })] }));
|
|
37
|
+
}
|
|
38
|
+
function TableButtonBar({ buttonBar, queryKey, createView, editView, api, children }) {
|
|
39
|
+
const createDialogFn = React.useCallback((data) => {
|
|
40
|
+
return (onClose) => {
|
|
41
|
+
const view = runIfFn(createView, data) ?? runIfFn(editView, null);
|
|
42
|
+
if (view.type == "customDialog")
|
|
43
|
+
return view.render({ show: true, onClose });
|
|
44
|
+
else
|
|
45
|
+
return _jsx(DialogRenderer, { config: view, onClose: onClose, invalidateQueryKey: api.queryKey });
|
|
46
|
+
};
|
|
47
|
+
}, [createView, editView, api]);
|
|
48
|
+
return (_jsxs(ButtonBar, { children: [_jsx(RefreshButton, { queryKey: queryKey }), buttonBar && buttonBar.map((button, index) => _jsxs(React.Fragment, { children: [button.type === "create" && editView &&
|
|
49
|
+
(_jsx(TableCreateButton, { buildDialog: createDialogFn(button.data), icon: button.icon, children: button.label })), button.type === "invalidate" && _jsx(InvalidateButton, { pathOrPermalink: button.pathOrPermalink }), button.type === "custom" && button.render()] }, index)), children] }));
|
|
50
|
+
}
|
|
51
|
+
function TableWrapper({ table, subtitle, rowActions, api, queryParams }) {
|
|
52
|
+
const tableProps = useTableProps(api, table, rowActions, queryParams);
|
|
53
|
+
const _subtitle = React.useMemo(() => {
|
|
54
|
+
if (!subtitle)
|
|
55
|
+
return undefined;
|
|
56
|
+
return (data) => {
|
|
57
|
+
return (_jsx("div", { textSize: "lg", textColor: "#475569", fontWeight: "600", children: isFunction(subtitle) ? subtitle(data) : subtitle }));
|
|
58
|
+
};
|
|
59
|
+
}, [subtitle]);
|
|
60
|
+
return _jsx(Table, { ...tableProps, p: "8", title: _subtitle });
|
|
61
|
+
}
|
|
62
|
+
function TableDialogManager() {
|
|
63
|
+
const { dialog } = useTableViewContext();
|
|
64
|
+
return dialog;
|
|
65
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TableRowAction, TableViewDeleteItem, TableViewEditView } from "../types/TableView";
|
|
2
|
+
import { TableRowAction, TableViewDeleteItem, TableViewEditView } from "../types/TableView.js";
|
|
3
3
|
type TableViewContextProps = {
|
|
4
4
|
onAction: (action: TableRowAction, item: any) => void;
|
|
5
5
|
dialog?: React.ReactNode;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useOpenLink } from "@compill/hooks";
|
|
2
3
|
import { createContext, runIfFn } from "@soperio/react";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import { useNavigate } from "react-router-dom";
|
|
5
|
-
import { DialogRenderer } from "../dialog/DialogRenderer";
|
|
6
|
-
import { ItemDeleteDialog } from "../dialog/ItemDeleteDialog";
|
|
6
|
+
import { DialogRenderer } from "../dialog/DialogRenderer.js";
|
|
7
|
+
import { ItemDeleteDialog } from "../dialog/ItemDeleteDialog.js";
|
|
7
8
|
import { AppEnv } from "@compill/env";
|
|
8
9
|
const [provider, useContext] = createContext();
|
|
9
10
|
function TableViewProvider({ editView, deleteItem, queryKey, children }) {
|
|
@@ -31,7 +32,7 @@ function TableViewProvider({ editView, deleteItem, queryKey, children }) {
|
|
|
31
32
|
setDialog(editConfig.render({ show: true, onClose: onCloseDialog }));
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
|
-
setDialog(
|
|
35
|
+
setDialog(_jsx(DialogRenderer, { onClose: onCloseDialog, config: editConfig, queryId: item.id, invalidateQueryKey: queryKey }));
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
break;
|
|
@@ -39,7 +40,7 @@ function TableViewProvider({ editView, deleteItem, queryKey, children }) {
|
|
|
39
40
|
case "delete":
|
|
40
41
|
{
|
|
41
42
|
const deleteConfig = runIfFn(deleteItem, item);
|
|
42
|
-
setDialog(
|
|
43
|
+
setDialog(_jsx(ItemDeleteDialog, { show: true, onClose: onCloseDialog, queryId: item.id, invalidateQueryKey: queryKey, msg: item.msg, ...deleteConfig, itemLabel: runIfFn(deleteConfig.itemLabel, item) }));
|
|
43
44
|
// TODO
|
|
44
45
|
// const { initialValues, ...props } = editItem!!
|
|
45
46
|
// setDialog(<ItemEditDialog {...props} initialValues={runIfFn(initialValues, item)} show queryId={item?.id} onClose={onCloseDialog} />)
|
|
@@ -52,6 +53,6 @@ function TableViewProvider({ editView, deleteItem, queryKey, children }) {
|
|
|
52
53
|
dialog,
|
|
53
54
|
onAction
|
|
54
55
|
};
|
|
55
|
-
return
|
|
56
|
+
return _jsx(Provider, { value: value, children: children });
|
|
56
57
|
}
|
|
57
58
|
export { TableViewProvider, useContext as useTableViewContext };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { API } from "@compill/admin-api";
|
|
2
|
-
import { TableRowAction, TableViewTable } from "../types/TableView";
|
|
2
|
+
import { TableRowAction, TableViewTable } from "../types/TableView.js";
|
|
3
3
|
export declare function useTableProps(api: API<any>, table: TableViewTable, rowActions?: TableRowAction[] | ((item?: any) => TableRowAction[]), queryParams?: any): any;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useOpenLink } from "@compill/hooks";
|
|
2
3
|
import { runIfFn } from "@soperio/react";
|
|
3
4
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
4
5
|
import React from "react";
|
|
5
6
|
import { useNavigate } from "react-router-dom";
|
|
6
|
-
import { TableRowActionsView } from "./TableRowActionsView";
|
|
7
|
-
import { useTableViewContext } from "./TableViewContext";
|
|
7
|
+
import { TableRowActionsView } from "./TableRowActionsView.js";
|
|
8
|
+
import { useTableViewContext } from "./TableViewContext.js";
|
|
8
9
|
import { useRouter } from "next/router";
|
|
9
10
|
import { AppEnv } from "@compill/env";
|
|
10
11
|
export function useTableProps(api, table, rowActions, queryParams) {
|
|
@@ -41,7 +42,7 @@ export function useTableProps(api, table, rowActions, queryParams) {
|
|
|
41
42
|
columns.push(createColumnHelper().display({
|
|
42
43
|
id: "actions",
|
|
43
44
|
header: "Actions",
|
|
44
|
-
cell: props =>
|
|
45
|
+
cell: props => _jsx(TableRowActionsView, { row: props.row, onAction: onAction, rowActions: rowActions, api: api, queryKey: api.queryKey })
|
|
45
46
|
}));
|
|
46
47
|
}
|
|
47
48
|
return columns;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API } from "@compill/admin-api";
|
|
2
2
|
import * as Yup from "yup";
|
|
3
|
-
import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
|
|
3
|
+
import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs.js";
|
|
4
4
|
import { FormRendererConfig } from "@compill/form";
|
|
5
5
|
import { CRUDAPI } from "@compill/api";
|
|
6
6
|
export type DetailsViewConfig<T = any> = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CRUDAPI } from "@compill/api";
|
|
2
|
-
import { DetailsViewConfig } from "./DetailsView";
|
|
3
|
-
import { TabbedViewConfig } from "./TabbedView";
|
|
4
|
-
import { TableViewConfig } from "./TableView";
|
|
2
|
+
import { DetailsViewConfig } from "./DetailsView.js";
|
|
3
|
+
import { TabbedViewConfig } from "./TabbedView.js";
|
|
4
|
+
import { TableViewConfig } from "./TableView.js";
|
|
5
5
|
type SubScreen = TableViewConfig | DetailsViewConfig | TabbedViewConfig;
|
|
6
6
|
export type QueryDef = {
|
|
7
7
|
api: CRUDAPI<any> | ((id: string) => CRUDAPI<any>);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CRUDAPI, CRUD_MODEL } from "@compill/api";
|
|
2
|
-
import { DetailsViewConfig } from "./DetailsView";
|
|
3
|
-
import { TabbedViewConfig } from "./TabbedView";
|
|
4
|
-
import { TableViewConfig } from "./TableView";
|
|
2
|
+
import { DetailsViewConfig } from "./DetailsView.js";
|
|
3
|
+
import { TabbedViewConfig } from "./TabbedView.js";
|
|
4
|
+
import { TableViewConfig } from "./TableView.js";
|
|
5
5
|
type SubScreen<T extends CRUD_MODEL, U> = TableViewConfig | DetailsViewConfig | TabbedViewConfig | QueryWrapperConfig<T, U>;
|
|
6
6
|
export type QueryWrapperConfig<T extends CRUD_MODEL, U = T> = {
|
|
7
7
|
type: "query";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CRUDAPI, CRUD_MODEL } from "@compill/api";
|
|
2
|
-
import { EditItemDialogConfig } from "./EditItemDialog";
|
|
2
|
+
import { EditItemDialogConfig } from "./EditItemDialog.js";
|
|
3
3
|
export type QueryWrapperDialogConfig<T extends CRUD_MODEL, U = T> = {
|
|
4
4
|
type: "query";
|
|
5
5
|
api: CRUDAPI<any>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ItemEditDialogProps } from "../dialog/ItemEditDialog";
|
|
2
|
-
import { DetailsViewConfig } from "./DetailsView";
|
|
3
|
-
import { MultiQueryWrapperConfig } from "./MultiQueryWrapper";
|
|
4
|
-
import { QueryWrapperConfig } from "./QueryWrapper";
|
|
5
|
-
import { TabbedViewConfig } from "./TabbedView";
|
|
6
|
-
import { TableViewConfig } from "./TableView";
|
|
1
|
+
import { ItemEditDialogProps } from "../dialog/ItemEditDialog.js";
|
|
2
|
+
import { DetailsViewConfig } from "./DetailsView.js";
|
|
3
|
+
import { MultiQueryWrapperConfig } from "./MultiQueryWrapper.js";
|
|
4
|
+
import { QueryWrapperConfig } from "./QueryWrapper.js";
|
|
5
|
+
import { TabbedViewConfig } from "./TabbedView.js";
|
|
6
|
+
import { TableViewConfig } from "./TableView.js";
|
|
7
7
|
export type ScreenConfig = TableViewConfig | DetailsViewConfig | TabbedViewConfig | QueryWrapperConfig<any, any> | MultiQueryWrapperConfig;
|
|
8
8
|
export type TableViewEditItem = Omit<ItemEditDialogProps, "show" | "onClose">;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CRUDAPI } from "@compill/api";
|
|
2
|
-
import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
|
|
3
|
-
import { DetailsViewConfig } from "./DetailsView";
|
|
4
|
-
import { QueryWrapperConfig } from "./QueryWrapper";
|
|
5
|
-
import { TableViewConfig } from "./TableView";
|
|
6
|
-
import { MultiQueryWrapperConfig } from "./MultiQueryWrapper";
|
|
2
|
+
import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs.js";
|
|
3
|
+
import { DetailsViewConfig } from "./DetailsView.js";
|
|
4
|
+
import { QueryWrapperConfig } from "./QueryWrapper.js";
|
|
5
|
+
import { TableViewConfig } from "./TableView.js";
|
|
6
|
+
import { MultiQueryWrapperConfig } from "./MultiQueryWrapper.js";
|
|
7
7
|
export type TabbedViewConfig<T extends any = any> = {
|
|
8
8
|
type: "tabbed";
|
|
9
9
|
queryField: string;
|
|
@@ -2,10 +2,10 @@ import { API } from "@compill/admin-api";
|
|
|
2
2
|
import { FormRendererConfig } from "@compill/form";
|
|
3
3
|
import { TableProps } from "@compill/table";
|
|
4
4
|
import { ButtonProps, ModalProps } from "@valerya/ui";
|
|
5
|
-
import { Breadcrumb, QueryBreadcrumbs } from "../../breadcrumbs/BreadCrumbs";
|
|
6
|
-
import { ItemDeleteDialogProps } from "../dialog/ItemDeleteDialog";
|
|
7
|
-
import { EditItemDialogConfig } from "./EditItemDialog";
|
|
8
|
-
import { QueryWrapperDialogConfig } from "./QueryWrapperDialog";
|
|
5
|
+
import { Breadcrumb, QueryBreadcrumbs } from "../../breadcrumbs/BreadCrumbs.js";
|
|
6
|
+
import { ItemDeleteDialogProps } from "../dialog/ItemDeleteDialog.js";
|
|
7
|
+
import { EditItemDialogConfig } from "./EditItemDialog.js";
|
|
8
|
+
import { QueryWrapperDialogConfig } from "./QueryWrapperDialog.js";
|
|
9
9
|
import * as Yup from "yup";
|
|
10
10
|
import { MutationQueryFn, MutationQueryKey } from "@compill/api";
|
|
11
11
|
export type TableViewScreen = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color, ParentComponent, SoperioComponent } from "@soperio/react";
|
|
2
|
-
import { MenuConfig } from "./menu/MenuConfig";
|
|
2
|
+
import { MenuConfig } from "./menu/MenuConfig.js";
|
|
3
3
|
interface LayoutProps extends SoperioComponent, ParentComponent {
|
|
4
4
|
color: Color;
|
|
5
5
|
darkMode?: boolean;
|