@compill/admin 1.0.102 → 1.0.103
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/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.jsx → InvalidateButton.js} +2 -1
- package/dist/lib/buttons/{NavigateButton.jsx → NavigateButton.js} +2 -3
- package/dist/lib/buttons/{PublishButton.jsx → PublishButton.js} +2 -3
- package/dist/lib/buttons/{UpdateButton.jsx → UpdateButton.js} +2 -3
- package/dist/lib/buttons/{ViewButton.jsx → ViewButton.js} +2 -3
- package/dist/lib/cells/{OrderCell.jsx → OrderCell.js} +2 -11
- package/dist/lib/json/{DetailsView.jsx → DetailsView.js} +9 -36
- package/dist/lib/json/{EditItemView.jsx → EditItemView.js} +2 -1
- package/dist/lib/json/{MultiQueryWrapper.jsx → MultiQueryWrapper.js} +4 -3
- package/dist/lib/json/{QueryWrapper.jsx → QueryWrapper.js} +2 -1
- package/dist/lib/json/{ScreenRenderer.jsx → ScreenRenderer.js} +7 -6
- package/dist/lib/json/ScreenTopBar.js +18 -0
- package/dist/lib/json/{TabbedView.jsx → TabbedView.js} +5 -12
- 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.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.jsx → MultiQueryWrapperDialog.js} +2 -1
- package/dist/lib/json/dialog/{QueryWrapperDialog.jsx → QueryWrapperDialog.js} +2 -1
- package/dist/lib/json/table/{RefreshButton.jsx → RefreshButton.js} +2 -3
- package/dist/lib/json/table/{TableRowActionsView.jsx → TableRowActionsView.js} +4 -13
- package/dist/lib/json/table/{TableRowPublishPostButton.jsx → TableRowPublishPostButton.js} +2 -3
- package/dist/lib/json/table/TableView.js +65 -0
- package/dist/lib/json/table/{TableViewContext.jsx → TableViewContext.js} +4 -3
- package/dist/lib/json/table/{useTableProps.jsx → useTableProps.js} +2 -1
- package/dist/lib/layout/AdminLayout.js +15 -0
- 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.js +12 -0
- package/dist/lib/layout/menu/Menu.js +23 -0
- package/dist/lib/layout/menu/MenuButton.js +5 -0
- package/dist/lib/layout/menu/MenuItem.js +11 -0
- package/dist/lib/layout/menu/NextMenuItem.js +11 -0
- package/dist/lib/layout/menu/SelectedIndicator.js +4 -0
- 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} +4 -3
- 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.jsx → PageTopBar.js} +4 -18
- package/dist/lib/status/{StatusBadge.jsx → StatusBadge.js} +2 -1
- package/dist/lib/table/TableContainer.js +6 -0
- package/dist/lib/table/{TableContainerContext.jsx → TableContainerContext.js} +2 -1
- package/dist/lib/table/{TableCreateButton.jsx → TableCreateButton.js} +2 -4
- package/dist/lib/table/TableFilterButton.js +8 -0
- package/dist/lib/table/{TableFilters.jsx → TableFilters.js} +3 -22
- 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.js +6 -0
- package/dist/lib/table/{TableRowDeleteButton.jsx → TableRowDeleteButton.js} +2 -1
- package/dist/lib/table/{TableRowEditButton.jsx → TableRowEditButton.js} +2 -3
- package/dist/lib/table/{TableRowNavigateButton.jsx → TableRowNavigateButton.js} +2 -1
- package/dist/lib/table/{TableRowPublishPostButton.jsx → TableRowPublishPostButton.js} +2 -1
- package/dist/lib/table/{TableRowViewButton.jsx → TableRowViewButton.js} +2 -1
- package/dist/lib/table/TableTopBar.js +5 -0
- package/package.json +9 -9
- package/dist/lib/SectionTitle.jsx +0 -3
- package/dist/lib/breadcrumbs/BreadCrumbs.jsx +0 -43
- package/dist/lib/json/ScreenTopBar.jsx +0 -39
- 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/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/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
- /package/dist/lib/table/{TableColumnButton.jsx → TableColumnButton.js} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@soperio/jsx-runtime";
|
|
2
|
+
import { useApiQuery } from "@compill/api";
|
|
3
|
+
import { Shimmer } from "@compill/components";
|
|
4
|
+
import { mdiCircleSmall } from "@mdi/js";
|
|
5
|
+
import { Icon } from "@valerya/ui";
|
|
6
|
+
import { isArray } from "es-toolkit/compat";
|
|
7
|
+
import Link from "next/link";
|
|
8
|
+
import { useParams } from "react-router-dom";
|
|
9
|
+
export function Breadcrumbs({ breadcrumbs, ...props }) {
|
|
10
|
+
if (isArray(breadcrumbs)) {
|
|
11
|
+
return (_jsx("div", { dflex: true, alignItems: "center", trait: "typo.h5", ...props, children: breadcrumbs.map((b, index) => _jsx(BreadcrumbItem, { breadcrumb: b, showSeparator: index > 0 }, index)) }));
|
|
12
|
+
}
|
|
13
|
+
return _jsx(QueryBreadcrumbs, { queryFn: breadcrumbs.queryFn, queryField: breadcrumbs.queryField, generate: breadcrumbs.generate });
|
|
14
|
+
}
|
|
15
|
+
function QueryBreadcrumbs({ queryFn, queryField, generate, ...props }) {
|
|
16
|
+
const params = useParams();
|
|
17
|
+
const id = queryField ? params[queryField] : undefined;
|
|
18
|
+
const { data, isLoading, isError } = useApiQuery([""], queryFn, id);
|
|
19
|
+
if (isLoading || isError) {
|
|
20
|
+
return (_jsxs("div", { dflex: true, alignItems: "center", children: [_jsx(Shimmer, { h: "8", w: "24" }), _jsx(Icon, { path: mdiCircleSmall, mx: "1" }), _jsx(Shimmer, { h: "8", w: "20" })] }));
|
|
21
|
+
}
|
|
22
|
+
const breadcrumbs = generate(data);
|
|
23
|
+
return (_jsx("div", { dflex: true, alignItems: "center", trait: "typo.h5", ...props, children: breadcrumbs.map((b, index) => _jsx(BreadcrumbItem, { breadcrumb: b, showSeparator: index > 0 }, index)) }));
|
|
24
|
+
}
|
|
25
|
+
function BreadcrumbItem({ breadcrumb, showSeparator }) {
|
|
26
|
+
return (_jsxs(_Fragment, { children: [showSeparator && _jsx(Icon, { path: mdiCircleSmall, mx: "1" }), _jsx(Link, { href: `/${breadcrumb.path || "#"}`, children: _jsx("span", {
|
|
27
|
+
// onClick={breadcrumb.path ? handleClick : undefined}
|
|
28
|
+
hover_textDecoration: breadcrumb.path ? "underline" : undefined, cursor: breadcrumb.path ? "pointer" : undefined, children: breadcrumb.label }) })] }));
|
|
29
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { Button } from "@valerya/ui";
|
|
2
3
|
import React from "react";
|
|
3
4
|
export function DialogButton({ buildDialog, ...props }) {
|
|
@@ -10,8 +11,5 @@ export function DialogButton({ buildDialog, ...props }) {
|
|
|
10
11
|
const onCloseDialog = React.useCallback(() => {
|
|
11
12
|
setShowDialog(false);
|
|
12
13
|
}, [setShowDialog]);
|
|
13
|
-
return (
|
|
14
|
-
<Button onClick={onShowDialog} {...props}/>
|
|
15
|
-
{showDialog && buildDialog(onCloseDialog)}
|
|
16
|
-
</>);
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: onShowDialog, ...props }), showDialog && buildDialog(onCloseDialog)] }));
|
|
17
15
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { INVALIDATE_API } from "@compill/admin-api";
|
|
2
3
|
import { useApiMutation, useMutate } from "@compill/api";
|
|
3
4
|
import { mdiDatabaseRefreshOutline } from "@mdi/js";
|
|
@@ -6,5 +7,5 @@ export function InvalidateButton({ pathOrPermalink, ...props }) {
|
|
|
6
7
|
const api = INVALIDATE_API.new(pathOrPermalink);
|
|
7
8
|
const mutation = useApiMutation(api.invalidate, api.queryKey);
|
|
8
9
|
const invalidate = useMutate(mutation, { successMsg: "Page successfully invalidated" });
|
|
9
|
-
return (
|
|
10
|
+
return (_jsx(ButtonBarButton, { title: "Regenerate", disabled: mutation.isLoading, onClick: invalidate, icon: mdiDatabaseRefreshOutline, ...props }));
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { mdiPost } from "@mdi/js";
|
|
2
3
|
import { Button, Icon } from "@valerya/ui";
|
|
3
4
|
import React from "react";
|
|
@@ -7,7 +8,5 @@ export function NavigateButton({ path, ...props }) {
|
|
|
7
8
|
const handleClick = React.useCallback(() => {
|
|
8
9
|
navigate(path);
|
|
9
10
|
}, [navigate, path]);
|
|
10
|
-
return (
|
|
11
|
-
<Icon path={mdiPost}/>
|
|
12
|
-
</Button>);
|
|
11
|
+
return (_jsx(Button, { type: "submit", scheme: "dark", variant: "glass", corners: "pill", w: "10", h: "10", onClick: handleClick, ...props, children: _jsx(Icon, { path: mdiPost }) }));
|
|
13
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useInvalidateMutation } from "@compill/api";
|
|
2
3
|
import { mdiEye, mdiEyeOff } from "@mdi/js";
|
|
3
4
|
import React from "react";
|
|
@@ -12,7 +13,5 @@ export function PublishButton({ status, queryId, api, ...props }) {
|
|
|
12
13
|
.then(() => toast.success(isDraft ? "Published!" : "Unpublished!"))
|
|
13
14
|
.catch(error => toast.error(`Error: ${error}`));
|
|
14
15
|
}, [mutation, queryId]);
|
|
15
|
-
return (
|
|
16
|
-
{isDraft ? "Publish" : "Switch to draft"}
|
|
17
|
-
</ButtonBarButton>);
|
|
16
|
+
return (_jsx(ButtonBarButton, { disabled: mutation.isLoading, onClick: publish, icon: isDraft ? mdiEye : mdiEyeOff, ...props, children: isDraft ? "Publish" : "Switch to draft" }));
|
|
18
17
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { mdiCloudUpload } from "@mdi/js";
|
|
2
3
|
import { useFormikContext } from "formik";
|
|
3
4
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
@@ -6,7 +7,5 @@ export function UpdateButton({ ...props }) {
|
|
|
6
7
|
const { dirty, handleSubmit } = useFormikContext() ?? { dirty: false, handleSubmit: undefined, values: {} };
|
|
7
8
|
useHotkeys('ctrl+s', () => { if (dirty && !props.disabled)
|
|
8
9
|
handleSubmit(); }, { preventDefault: true }, [dirty, props, handleSubmit]);
|
|
9
|
-
return (
|
|
10
|
-
Update
|
|
11
|
-
</ButtonBarSubmitButton>);
|
|
10
|
+
return (_jsx(ButtonBarSubmitButton, { icon: mdiCloudUpload, ...props, children: "Update" }));
|
|
12
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { mdiOpenInNew } from "@mdi/js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { ButtonBarButton } from "../layout/ButtonBar";
|
|
@@ -5,9 +6,7 @@ export function ViewButton({ label, path, icon, ...props }) {
|
|
|
5
6
|
const openPage = React.useCallback(() => {
|
|
6
7
|
window.open(path, '_blank');
|
|
7
8
|
}, [path]);
|
|
8
|
-
return (
|
|
9
|
-
{label}
|
|
10
|
-
</ButtonBarButton>);
|
|
9
|
+
return (_jsx(ButtonBarButton, { onClick: openPage, dflex: true, alignItems: "center", gap: "2", icon: icon || mdiOpenInNew, ...props, children: label }));
|
|
11
10
|
// return (
|
|
12
11
|
// <IconButton icon={icon ? icon : mdiOpenInNew} type="submit" scheme="dark" variant="glass" size="md" onClick={openPage} {...props}/>
|
|
13
12
|
// )
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { FlexCenter } from "@compill/components";
|
|
2
3
|
import { useInvalidateMutation } from "@compill/api";
|
|
3
4
|
import { mdiArrowDownBoldBox, mdiArrowUpBoldBox } from "@mdi/js";
|
|
@@ -21,15 +22,5 @@ export function OrderCell({ api, postId, order }) {
|
|
|
21
22
|
toast.error(`Error: ${error}`);
|
|
22
23
|
});
|
|
23
24
|
}, [mutationUp, postId]);
|
|
24
|
-
return (
|
|
25
|
-
{order}
|
|
26
|
-
|
|
27
|
-
<Button ms="3" variant="borderless" scheme="dark" onClick={moveUp}>
|
|
28
|
-
<Icon path={mdiArrowUpBoldBox}/>
|
|
29
|
-
</Button>
|
|
30
|
-
|
|
31
|
-
<Button variant="borderless" scheme="dark" onClick={moveDown}>
|
|
32
|
-
<Icon path={mdiArrowDownBoldBox}/>
|
|
33
|
-
</Button>
|
|
34
|
-
</FlexCenter>);
|
|
25
|
+
return (_jsxs(FlexCenter, { placeContent: "start", numericFontVariant: "tabular-nums", children: [order, _jsx(Button, { ms: "3", variant: "borderless", scheme: "dark", onClick: moveUp, children: _jsx(Icon, { path: mdiArrowUpBoldBox }) }), _jsx(Button, { variant: "borderless", scheme: "dark", onClick: moveDown, children: _jsx(Icon, { path: mdiArrowDownBoldBox }) })] }));
|
|
35
26
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useInvalidateParentMutation, useMutate } from "@compill/api";
|
|
2
3
|
import { FormProvider, FormRenderer, TextArea } from "@compill/form";
|
|
3
4
|
import { runIfFn } from "@soperio/react";
|
|
@@ -22,9 +23,7 @@ function useQueryField(queryField, useNextRouter) {
|
|
|
22
23
|
export function DetailsView({ queryField, api, useNextRouter, processInput, screen, tabbed, ...props }) {
|
|
23
24
|
const id = useQueryField(queryField, useNextRouter);
|
|
24
25
|
const ref = React.useRef(null);
|
|
25
|
-
return (
|
|
26
|
-
{(item) => <Internal item={item} screen={screen} api={api} tabbed={tabbed} processInput={processInput} containerRef={ref}/>}
|
|
27
|
-
</PageQueryStateContainer>);
|
|
26
|
+
return (_jsx(PageQueryStateContainer, { api: api, apiFn: "get", queryId: id, ref: ref, p: "5", ...props, children: (item) => _jsx(Internal, { item: item, screen: screen, api: api, tabbed: tabbed, processInput: processInput, containerRef: ref }) }));
|
|
28
27
|
}
|
|
29
28
|
function Internal({ item, screen, api, processInput, tabbed, containerRef }) {
|
|
30
29
|
const pScreen = runIfFn(screen, item);
|
|
@@ -45,36 +44,12 @@ function Internal({ item, screen, api, processInput, tabbed, containerRef }) {
|
|
|
45
44
|
editorMaxW = "calc(1280px - 28rem)";
|
|
46
45
|
else if (type == "section")
|
|
47
46
|
editorMaxW = "calc(1280px - 22rem)";
|
|
48
|
-
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(<div p="5" bgColor="slate-100" rounded="lg">
|
|
55
|
-
<PageContainer w={editorMaxW ? "auto" : "full"} size="x2" id="pagecontainer">
|
|
56
|
-
{header}
|
|
57
|
-
|
|
58
|
-
<div dflex gap="5">
|
|
59
|
-
<div dflex flexCol gap="8" flexGrow>
|
|
60
|
-
{pScreen.editor?.type != "textarea" &&
|
|
61
|
-
(
|
|
62
|
-
// TODO Find a way to make this editor shrink in width when resizing the window...
|
|
63
|
-
<PageContentEditor name="content" maxW={editorMaxW} minW="144" shadow rounded="lg"/>)}
|
|
64
|
-
|
|
65
|
-
{pScreen.editor?.type == "textarea" &&
|
|
66
|
-
(<TextArea name={pScreen.editor?.name} maxW={editorMaxW} minW={editorMaxW} w={editorMaxW} minH="128" rows={25} bgColor="white" border="0" shadow p="5" textColor="slate-800"/>)}
|
|
67
|
-
|
|
68
|
-
{pScreen.editorFooter}
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<PageSidebar>
|
|
72
|
-
{sections?.map((section, index) => (<Section key={index} section={section} item={item} cardStyle/>))}
|
|
73
|
-
</PageSidebar>
|
|
74
|
-
</div>
|
|
75
|
-
</PageContainer>
|
|
76
|
-
</div>)}
|
|
77
|
-
</FormProvider>);
|
|
47
|
+
return (_jsxs(FormProvider, { initialValues: runIfFn(initialValues, item), validationSchema: schema, onSubmit: save, enableReinitialize: true, children: [_jsx(ScreenTopBar, { tabbed: tabbed, api: api, breadcrumbs: breadcrumbs, buttonBar: buttonBar, item: item, isLoading: mutation.isLoading, trackingRef: containerRef?.current }), type == "form" && sections?.map((section, index) => (_jsx(Section, { section: section, item: item }, index))), (pScreen.type == "post" || pScreen.type == "section") &&
|
|
48
|
+
(_jsx("div", { p: "5", bgColor: "slate-100", rounded: "lg", children: _jsxs(PageContainer, { w: editorMaxW ? "auto" : "full", size: "x2", id: "pagecontainer", children: [header, _jsxs("div", { dflex: true, gap: "5", children: [_jsxs("div", { dflex: true, flexCol: true, gap: "8", flexGrow: true, children: [pScreen.editor?.type != "textarea" &&
|
|
49
|
+
(
|
|
50
|
+
// TODO Find a way to make this editor shrink in width when resizing the window...
|
|
51
|
+
_jsx(PageContentEditor, { name: "content", maxW: editorMaxW, minW: "144", shadow: true, rounded: "lg" })), pScreen.editor?.type == "textarea" &&
|
|
52
|
+
(_jsx(TextArea, { name: pScreen.editor?.name, maxW: editorMaxW, minW: editorMaxW, w: editorMaxW, minH: "128", rows: 25, bgColor: "white", border: "0", shadow: true, p: "5", textColor: "slate-800" })), pScreen.editorFooter] }), _jsx(PageSidebar, { children: sections?.map((section, index) => (_jsx(Section, { section: section, item: item, cardStyle: true }, index))) })] })] }) }))] }));
|
|
78
53
|
}
|
|
79
54
|
function Section({ section, item, cardStyle }) {
|
|
80
55
|
if (section.type === "section") {
|
|
@@ -86,9 +61,7 @@ function Section({ section, item, cardStyle }) {
|
|
|
86
61
|
textSize: "sm",
|
|
87
62
|
shadow: true
|
|
88
63
|
} : {};
|
|
89
|
-
return (
|
|
90
|
-
<FormRenderer form={runIfFn(section.form, item)}/>
|
|
91
|
-
</PageSidebarSection>);
|
|
64
|
+
return (_jsx(PageSidebarSection, { title: section.title, ...style, children: _jsx(FormRenderer, { form: runIfFn(section.form, item) }) }));
|
|
92
65
|
}
|
|
93
66
|
if (section.type === "custom")
|
|
94
67
|
return runIfFn(section.component, item);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { runIfFn } from "@soperio/react";
|
|
2
3
|
import { ItemEditDialog } from "./dialog/ItemEditDialog";
|
|
3
4
|
export function EditItemView({ initialValues, ...props }) {
|
|
4
|
-
return (
|
|
5
|
+
return (_jsx(ItemEditDialog, { ...props, initialValues: runIfFn(initialValues, null), show: true }));
|
|
5
6
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiQueries } from "@compill/api";
|
|
2
3
|
import { useQueryClient } from "@tanstack/react-query";
|
|
3
4
|
import React from "react";
|
|
@@ -53,8 +54,8 @@ export function MultiQueryWrapper({ queries, config, tabbed, ...props }) {
|
|
|
53
54
|
const { data, isFetching, isError } = useQueries(queries);
|
|
54
55
|
const invalidate = useInvalidate(queries);
|
|
55
56
|
if (isFetching)
|
|
56
|
-
return
|
|
57
|
+
return _jsx(QueryLoadingState, { w: "full", h: "100vh" });
|
|
57
58
|
if (isError || !data)
|
|
58
|
-
return
|
|
59
|
-
return
|
|
59
|
+
return _jsx(RetryOnError, { p: "0", w: "full", h: "100vh", onClick: invalidate });
|
|
60
|
+
return _jsx(ScreenRenderer, { config: config(...data), tabbed: tabbed, ...props });
|
|
60
61
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { ScreenRenderer } from "./ScreenRenderer";
|
|
3
4
|
import { isFunction, runIfFn } from "@soperio/react";
|
|
@@ -24,5 +25,5 @@ export function QueryWrapper({ api, queryField, fn, transformFn, config, tabbed,
|
|
|
24
25
|
// TODO states
|
|
25
26
|
if (!data)
|
|
26
27
|
return null;
|
|
27
|
-
return
|
|
28
|
+
return _jsx(ScreenRenderer, { config: config(transformedData), tabbed: tabbed, ...props });
|
|
28
29
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "@soperio/jsx-runtime";
|
|
1
2
|
import { DetailsView } from "./DetailsView";
|
|
2
3
|
import { QueryWrapper } from "./QueryWrapper";
|
|
3
4
|
import { TabbedView } from "./TabbedView";
|
|
@@ -5,14 +6,14 @@ import { TableView } from "./table/TableView";
|
|
|
5
6
|
import { MultiQueryWrapper } from "./MultiQueryWrapper";
|
|
6
7
|
export function ScreenRenderer({ config, tabbed, ...props }) {
|
|
7
8
|
if (config.type === "table")
|
|
8
|
-
return
|
|
9
|
+
return _jsx(TableView, { ...config, ...props });
|
|
9
10
|
if (config.type === "tabbed")
|
|
10
|
-
return
|
|
11
|
+
return _jsx(TabbedView, { ...config, ...props });
|
|
11
12
|
if (config.type === "details")
|
|
12
|
-
return
|
|
13
|
+
return _jsx(DetailsView, { ...config, tabbed: tabbed, ...props });
|
|
13
14
|
if (config.type === "query")
|
|
14
|
-
return
|
|
15
|
+
return _jsx(QueryWrapper, { ...config, tabbed: tabbed, ...props });
|
|
15
16
|
if (config.type === "multiQuery")
|
|
16
|
-
return
|
|
17
|
-
return
|
|
17
|
+
return _jsx(MultiQueryWrapper, { ...config, tabbed: tabbed, ...props });
|
|
18
|
+
return _jsx(_Fragment, {});
|
|
18
19
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
2
|
+
import { API } from "@compill/admin-api";
|
|
3
|
+
import { InvalidateButton } from "../buttons/InvalidateButton";
|
|
4
|
+
import { PublishButton } from "../buttons/PublishButton";
|
|
5
|
+
import { UpdateButton } from "../buttons/UpdateButton";
|
|
6
|
+
import { ViewButton } from "../buttons/ViewButton";
|
|
7
|
+
import { PageTopBar, PageTopBarToolbar } from "../page/PageTopBar";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { ButtonBar } from "../layout/ButtonBar";
|
|
10
|
+
export function ScreenTopBar({ tabbed, breadcrumbs, api, item, isLoading, buttonBar, trackingRef }) {
|
|
11
|
+
return (_jsxs(_Fragment, { children: [tabbed &&
|
|
12
|
+
(_jsx(PageTopBarToolbar, { trackingRef: trackingRef, children: _jsx(Buttons, { api: api, item: item, isLoading: isLoading, buttonBar: buttonBar }) })), !tabbed &&
|
|
13
|
+
(_jsx(PageTopBar, { breadcrumbs: breadcrumbs, children: _jsx(Buttons, { api: api, item: item, isLoading: isLoading, buttonBar: buttonBar }) }))] }));
|
|
14
|
+
}
|
|
15
|
+
function Buttons({ api, item, isLoading, buttonBar }) {
|
|
16
|
+
return (_jsxs(_Fragment, { children: [buttonBar && buttonBar.length > 0 &&
|
|
17
|
+
(_jsx(ButtonBar, { children: buttonBar.map((button, index) => (_jsxs(React.Fragment, { children: [button.type === "link" && _jsx(ViewButton, { label: button.label, path: button.path, icon: button.icon }), button.type === "invalidate" && _jsx(InvalidateButton, { pathOrPermalink: button.pathOrPermalink }), button.type == "custom" && button.render(item)] }, index))) })), _jsxs(ButtonBar, { children: [api instanceof API && _jsx(PublishButton, { api: api, queryId: item.id, status: item.status, disabled: isLoading }), _jsx(UpdateButton, { disabled: isLoading })] })] }));
|
|
18
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useParams } from "react-router-dom";
|
|
2
3
|
import { PageQueryStateContainer } from "../page/PageQueryStateContainer";
|
|
3
4
|
import { PageTabbedTopBar, PageTabbedTopBarProvider } from "../page/PageTopBar";
|
|
@@ -6,23 +7,15 @@ import { runIfFn } from "@soperio/react";
|
|
|
6
7
|
import { ScreenRenderer } from "./ScreenRenderer";
|
|
7
8
|
export function TabbedView({ queryField, api, screen, ...props }) {
|
|
8
9
|
const { [queryField]: id } = useParams();
|
|
9
|
-
return (
|
|
10
|
-
{(city) => {
|
|
10
|
+
return (_jsx(PageQueryStateContainer, { queryId: id, api: api, apiFn: "get", p: "5", children: (city) => {
|
|
11
11
|
const { breadcrumbs, tabs } = runIfFn(screen, city);
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<TabContainer tabs={tabs.map(tab => tab.label)} saveKey={`tab-${id}`} mt="-3" mb="3" id="fff">
|
|
16
|
-
{tabs.map((tab, index) => <TabView key={index} tab={tab}/>)}
|
|
17
|
-
</TabContainer>
|
|
18
|
-
</PageTabbedTopBarProvider>);
|
|
19
|
-
}}
|
|
20
|
-
</PageQueryStateContainer>);
|
|
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
|
+
} }));
|
|
21
14
|
}
|
|
22
15
|
function TabView({ tab }) {
|
|
23
16
|
if (!tab.component && !tab.config)
|
|
24
17
|
throw new Error(`Screen config for tabbed view: one of your tabs does not have a component or config declared: ${tab.label}`);
|
|
25
18
|
if (tab.component)
|
|
26
19
|
return tab.component();
|
|
27
|
-
return
|
|
20
|
+
return _jsx(ScreenRenderer, { config: tab.config, tabbed: true, p: "0" });
|
|
28
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
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
2
|
+
import { ItemEditDialog } from "./ItemEditDialog";
|
|
3
|
+
import { QueryWrapperDialog } from "./QueryWrapperDialog";
|
|
4
|
+
import { MultiQueryWrapperDialog } from "./MultiQueryWrapperDialog";
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiQueries } from "@compill/api";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { ItemEditDialog } from "./ItemEditDialog";
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@soperio/jsx-runtime";
|
|
1
2
|
import { useApiQuery } from "@compill/api";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { ItemEditDialog } from "./ItemEditDialog";
|
|
@@ -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,3 +1,4 @@
|
|
|
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";
|
|
@@ -6,7 +7,5 @@ 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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@soperio/jsx-runtime";
|
|
1
2
|
import { mdiDelete, mdiEye, mdiOpenInNew, mdiPencil } from "@mdi/js";
|
|
2
3
|
import { Icon } from "@valerya/ui";
|
|
3
4
|
import { TableRowPublishPostButton } from "./TableRowPublishPostButton";
|
|
@@ -6,18 +7,8 @@ import { TableRowActionButton } from "@compill/admin";
|
|
|
6
7
|
import { runIfFn } from "@soperio/react";
|
|
7
8
|
export function TableRowActionsView({ row, onAction, rowActions, api, queryKey }) {
|
|
8
9
|
const item = row.original;
|
|
9
|
-
return (
|
|
10
|
-
|
|
11
|
-
{action.type === "publish" && <TableRowPublishPostButton id={item.id} api={action.api ?? api} status={item.status} invalidateQueryKey={queryKey}/>}
|
|
12
|
-
|
|
13
|
-
{action.type == "custom" && <>{action.component(item, queryKey, action.icon, action.label)}</>}
|
|
14
|
-
|
|
15
|
-
{!["publish", "custom"].includes(action.type) &&
|
|
16
|
-
(<ActionButton onClick={() => onAction(action, item)} scheme={schemes[action.type]}>
|
|
17
|
-
<Icon path={icons[action.type]} size="sm"/>
|
|
18
|
-
</ActionButton>)}
|
|
19
|
-
</React.Fragment>))}
|
|
20
|
-
</div>);
|
|
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))) }));
|
|
21
12
|
}
|
|
22
13
|
function ActionButton({ onClick, ...props }) {
|
|
23
14
|
const handleClick = React.useCallback((event) => {
|
|
@@ -25,7 +16,7 @@ function ActionButton({ onClick, ...props }) {
|
|
|
25
16
|
event?.stopPropagation();
|
|
26
17
|
onClick?.(event);
|
|
27
18
|
}, [onClick]);
|
|
28
|
-
return (
|
|
19
|
+
return (_jsx(TableRowActionButton, { onClick: handleClick, ...props }));
|
|
29
20
|
}
|
|
30
21
|
const icons = {
|
|
31
22
|
"link": mdiOpenInNew,
|
|
@@ -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
|
}
|