@pajapaja/student 0.6.2
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/cjs/index.js +1 -0
- package/dist/es/index.js +1 -0
- package/dist/umd/index.js +1 -0
- package/package.json +29 -0
- package/src/UserGQLModel/Components/CardCapsule.jsx +43 -0
- package/src/UserGQLModel/Components/Children.jsx +31 -0
- package/src/UserGQLModel/Components/ConfirmEdit.jsx +61 -0
- package/src/UserGQLModel/Components/Filter.jsx +14 -0
- package/src/UserGQLModel/Components/LargeCard.jsx +50 -0
- package/src/UserGQLModel/Components/Link.jsx +54 -0
- package/src/UserGQLModel/Components/LiveEdit.jsx +111 -0
- package/src/UserGQLModel/Components/MediumCard.jsx +39 -0
- package/src/UserGQLModel/Components/MediumContent.jsx +136 -0
- package/src/UserGQLModel/Components/MediumEditableContent.jsx +35 -0
- package/src/UserGQLModel/Components/Table.jsx +7 -0
- package/src/UserGQLModel/Components/index.js +13 -0
- package/src/UserGQLModel/Mutations/Create.jsx +202 -0
- package/src/UserGQLModel/Mutations/Delete.jsx +173 -0
- package/src/UserGQLModel/Mutations/InteractiveMutations.jsx +30 -0
- package/src/UserGQLModel/Mutations/Update.jsx +147 -0
- package/src/UserGQLModel/Mutations/helpers.jsx +7 -0
- package/src/UserGQLModel/Pages/PageBase.jsx +56 -0
- package/src/UserGQLModel/Pages/PageCreateItem.jsx +28 -0
- package/src/UserGQLModel/Pages/PageDeleteItem.jsx +16 -0
- package/src/UserGQLModel/Pages/PageNavbar.jsx +160 -0
- package/src/UserGQLModel/Pages/PageReadItem.jsx +11 -0
- package/src/UserGQLModel/Pages/PageReadItemEx.jsx +42 -0
- package/src/UserGQLModel/Pages/PageUpdateItem.jsx +14 -0
- package/src/UserGQLModel/Pages/PageVector.jsx +80 -0
- package/src/UserGQLModel/Pages/RouterSegment.jsx +72 -0
- package/src/UserGQLModel/Pages/index.js +2 -0
- package/src/UserGQLModel/Queries/DeleteAsyncAction.jsx +32 -0
- package/src/UserGQLModel/Queries/Fragments.jsx +88 -0
- package/src/UserGQLModel/Queries/InsertAsyncAction.jsx +40 -0
- package/src/UserGQLModel/Queries/ReadAsyncAction.jsx +44 -0
- package/src/UserGQLModel/Queries/ReadPageAsyncAction.jsx +13 -0
- package/src/UserGQLModel/Queries/SearchAsyncAction.jsx +16 -0
- package/src/UserGQLModel/Queries/UpdateAsyncAction.jsx +40 -0
- package/src/UserGQLModel/Queries/index.js +6 -0
- package/src/UserGQLModel/Scalars/ScalarAttribute.jsx +54 -0
- package/src/UserGQLModel/Scalars/TemplateScalarAttribute.jsx +88 -0
- package/src/UserGQLModel/Scalars/index.js +1 -0
- package/src/UserGQLModel/Vectors/TemplateVectorsAttribute.jsx +326 -0
- package/src/UserGQLModel/Vectors/VectorAttribute.jsx +56 -0
- package/src/UserGQLModel/Vectors/index.js +1 -0
- package/src/UserGQLModel/WhatToDo.md +44 -0
- package/src/UserGQLModel/index.js +71 -0
- package/src/index.js +0 -0
- package/src/uriroot.js +158 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import Nav from 'react-bootstrap/Nav'
|
|
2
|
+
import { Link, LinkURI } from '../Components'
|
|
3
|
+
import { ProxyLink } from '../../../../_template/src/Base/Components/ProxyLink';
|
|
4
|
+
import { NavDropdown } from 'react-bootstrap';
|
|
5
|
+
import { UpdateLink } from '../Mutations/Update';
|
|
6
|
+
import { CreateButton } from '../Mutations/Create';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Allow to use HashContainer for determination which component at page will be rendered.
|
|
10
|
+
* That must be manually inserted at TemplatePageContent, usually this should be done
|
|
11
|
+
* as children of TemplateLargeCard.
|
|
12
|
+
* <TemplateLargeCard>
|
|
13
|
+
* <HashContainer>
|
|
14
|
+
* <VectorA id="history"/>
|
|
15
|
+
* <VectorB id="roles"/>
|
|
16
|
+
* <VectorC id="graph"/>
|
|
17
|
+
* </HashContainer>
|
|
18
|
+
* </TemplateLargeCard>
|
|
19
|
+
* it is usefull to define globally active "areas" like science, administration, teaching, ...
|
|
20
|
+
*/
|
|
21
|
+
// const TemplatePageSegments = [
|
|
22
|
+
// { segment: 'education', label: 'Výuka' },
|
|
23
|
+
// { segment: 'reaserach', label: 'Tvůrčí činnost' },
|
|
24
|
+
// { segment: 'administration', label: 'Organizační činnost' },
|
|
25
|
+
// { segment: 'development', label: 'Rozvoj' },
|
|
26
|
+
// ]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A navigation button component that generates a URL based on the template's ID and a specific segment.
|
|
30
|
+
* The button uses a `ProxyLink` to navigate while preserving hash and query parameters.
|
|
31
|
+
*
|
|
32
|
+
* ### Features:
|
|
33
|
+
* - Dynamically constructs the URL with a hash fragment pointing to the specified segment.
|
|
34
|
+
* - Displays a label for the navigation link.
|
|
35
|
+
* - Integrates seamlessly with `ProxyLink` for enhanced navigation.
|
|
36
|
+
*
|
|
37
|
+
* @component
|
|
38
|
+
* @param {Object} props - The properties for the TitleNavButton component.
|
|
39
|
+
* @param {Object} props.template - The template object containing details about the template.
|
|
40
|
+
* @param {string|number} props.template.id - The unique identifier for the template.
|
|
41
|
+
* @param {string} props.segment - The segment to append as a hash fragment in the URL.
|
|
42
|
+
* @param {string} props.label - The text to display as the label for the navigation button.
|
|
43
|
+
*
|
|
44
|
+
* @returns {JSX.Element} A styled navigation button linking to the constructed URL.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Example 1: Basic usage with a template and segment
|
|
48
|
+
* const template = { id: 123 };
|
|
49
|
+
* const segment = "details";
|
|
50
|
+
* const label = "View Details";
|
|
51
|
+
*
|
|
52
|
+
* <TitleNavButton template={template} segment={segment} label={label} />
|
|
53
|
+
* // Resulting URL: `/ug/template/view/123#details`
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Example 2: Different segment and label
|
|
57
|
+
* <TitleNavButton template={{ id: 456 }} segment="settings" label="Template Settings" />
|
|
58
|
+
* // Resulting URL: `/ug/template/view/456#settings`
|
|
59
|
+
*/
|
|
60
|
+
// const TitleNavButton = ({ item, segment, label, ...props }) => {
|
|
61
|
+
// // const urlbase = (segment) => `/templates/template/${segment}/${template?.id}`;
|
|
62
|
+
// const urlbase = (segment) => `${LinkURI}${item?.id}#${segment}`;
|
|
63
|
+
// return (
|
|
64
|
+
// <Nav.Link as={"span"} {...props}>
|
|
65
|
+
// {/* <ProxyLink to={urlbase(segment)}>{label}</ProxyLink> */}
|
|
66
|
+
// </Nav.Link>
|
|
67
|
+
// );
|
|
68
|
+
// };
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Renders the navigation bar for an Template page.
|
|
72
|
+
*
|
|
73
|
+
* This component uses a custom hook, `useHash()`, to determine the current hash
|
|
74
|
+
* and highlights the active segment. It displays a navigation bar (using MyNavbar)
|
|
75
|
+
* with several segments (e.g. "history", "roles", "graph"), each rendered as a
|
|
76
|
+
* TitleNavButton. The segments are hardcoded in this component and only rendered
|
|
77
|
+
* if an `template` object is provided.
|
|
78
|
+
*
|
|
79
|
+
* @component
|
|
80
|
+
* @param {Object} props - The component properties.
|
|
81
|
+
* @param {Object} props.template - The template entity object that provides context for the page.
|
|
82
|
+
* @param {string|number} props.template.id - The unique identifier for the template.
|
|
83
|
+
* @param {Function} props.onSearchChange - Callback function to handle changes in the search input.
|
|
84
|
+
*
|
|
85
|
+
* @returns {JSX.Element} The rendered TemplatePageNavbar component.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // Example usage:
|
|
89
|
+
* const template = { id: 123, ... };
|
|
90
|
+
* <TemplatePageNavbar template={template} onSearchChange={handleSearchChange} />
|
|
91
|
+
*/
|
|
92
|
+
// export const PageNavbar = ({ item, children, onSearchChange }) => {
|
|
93
|
+
// // const [currentHash, setHash] = useHash(); // Use the custom hook to manage hash
|
|
94
|
+
// const currentHash = "da"
|
|
95
|
+
// return (
|
|
96
|
+
// <div className='screen-only'>
|
|
97
|
+
// <MyNavbar onSearchChange={onSearchChange} >
|
|
98
|
+
// {item && TemplatePageSegments.map(({ segment, label }) => (
|
|
99
|
+
// <Nav.Item key={segment} >
|
|
100
|
+
// <TitleNavButton
|
|
101
|
+
// template={item}
|
|
102
|
+
// segment={segment}
|
|
103
|
+
// label={label}
|
|
104
|
+
// className={segment === currentHash ? "active" : ""} aria-current={segment === currentHash ? "page" : undefined}
|
|
105
|
+
// />
|
|
106
|
+
// </Nav.Item>
|
|
107
|
+
// ))}
|
|
108
|
+
// {children}
|
|
109
|
+
// </MyNavbar>
|
|
110
|
+
// </div>
|
|
111
|
+
// );
|
|
112
|
+
// };
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
export const MyNavDropdown = ({ item }) => {
|
|
116
|
+
const { __typename } = item || {}
|
|
117
|
+
const hasProperType = __typename === "TemplateGQLModel"
|
|
118
|
+
return (
|
|
119
|
+
<NavDropdown title="Skupiny">
|
|
120
|
+
<NavDropdown.Item as={ProxyLink} to={VectorItemsURI}>
|
|
121
|
+
Seznam všech
|
|
122
|
+
</NavDropdown.Item>
|
|
123
|
+
|
|
124
|
+
<NavDropdown.Item as={Link} item={item} action="roles" disabled={!hasProperType}>
|
|
125
|
+
Role<br/><Link item={item} />
|
|
126
|
+
</NavDropdown.Item>
|
|
127
|
+
<NavDropdown.Item as={Link} item={item} action="subgroups" disabled={!hasProperType}>
|
|
128
|
+
Podskupiny<br/><Link item={item} />
|
|
129
|
+
</NavDropdown.Item>
|
|
130
|
+
<NavDropdown.Item as={Link} item={item} action="memberships" disabled={!hasProperType}>
|
|
131
|
+
Členové<br/><Link item={item} />
|
|
132
|
+
</NavDropdown.Item>
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
<NavDropdown.Divider />
|
|
136
|
+
|
|
137
|
+
<NavDropdown.Item
|
|
138
|
+
as={UpdateLink}
|
|
139
|
+
item={item}
|
|
140
|
+
disabled={!hasProperType}
|
|
141
|
+
>
|
|
142
|
+
Upravit<br/><Link item={item} />
|
|
143
|
+
</NavDropdown.Item>
|
|
144
|
+
<NavDropdown.Item
|
|
145
|
+
as={CreateButton}
|
|
146
|
+
item={item}
|
|
147
|
+
disabled={!hasProperType}
|
|
148
|
+
item={{
|
|
149
|
+
group: item,
|
|
150
|
+
groupId: item?.groupId
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
Nové<br/><Link item={item} />
|
|
154
|
+
</NavDropdown.Item>
|
|
155
|
+
|
|
156
|
+
<NavDropdown.Divider />
|
|
157
|
+
<NavDropdown.Item as={ProxyLink} to={`/generic/${item?.__typename}/__def/${item?.id}`} reloadDocument={false}>Definice</NavDropdown.Item >
|
|
158
|
+
</NavDropdown>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GeneratedContentBase } from "../../../../_template/src/Base/Pages/Page"
|
|
2
|
+
import { PageItemBase } from "./PageBase"
|
|
3
|
+
|
|
4
|
+
export const PageReadItem = ({
|
|
5
|
+
SubPage=GeneratedContentBase,
|
|
6
|
+
...props
|
|
7
|
+
}) => {
|
|
8
|
+
return (
|
|
9
|
+
<PageItemBase SubPage={SubPage} {...props}/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { GeneratedContentBase } from "../../../../_template/src/Base/Pages/Page"
|
|
2
|
+
import { ReadItemURI } from "../Components"
|
|
3
|
+
import { ReadAsyncAction } from "../Queries"
|
|
4
|
+
import { PageReadItem } from "./PageReadItem"
|
|
5
|
+
|
|
6
|
+
export const RolesOnURI = ReadItemURI.replace("view", "roleson")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Základní obálka pro „read“ stránku entity podle `:id` z routy.
|
|
11
|
+
*
|
|
12
|
+
* Využívá `PageItemBase`, který zajistí:
|
|
13
|
+
* - získání `id` z URL (`useParams`)
|
|
14
|
+
* - načtení entity přes `AsyncActionProvider` pomocí `queryAsyncAction`
|
|
15
|
+
* - vložení navigace (`PageNavbar`)
|
|
16
|
+
*
|
|
17
|
+
* Uvnitř provideru vykreslí `ReadWithComponent`, který si vezme načtený `item`
|
|
18
|
+
* z `useGQLEntityContext()` a zobrazí ho v zadané komponentě (defaultně `LargeCard`).
|
|
19
|
+
*
|
|
20
|
+
* @component
|
|
21
|
+
* @param {object} props
|
|
22
|
+
* @param {Function} [props.queryAsyncAction=ReadAsyncAction]
|
|
23
|
+
* Async action (např. thunk) pro načtení entity z backendu/GraphQL dle `id`.
|
|
24
|
+
* @param {Object<string, any>} [props]
|
|
25
|
+
* Další props předané do `ReadWithComponent` (např. `Component`, layout props).
|
|
26
|
+
*
|
|
27
|
+
* @returns {import("react").JSX.Element}
|
|
28
|
+
*/
|
|
29
|
+
export const PageReadItemRolesOn = ({
|
|
30
|
+
queryAsyncAction=ReadAsyncAction,
|
|
31
|
+
children,
|
|
32
|
+
...props
|
|
33
|
+
}) => {
|
|
34
|
+
return (
|
|
35
|
+
<PageReadItem
|
|
36
|
+
queryAsyncAction={queryAsyncAction}
|
|
37
|
+
SubPage={GeneratedContentBase}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReadPageAsyncAction } from "../Queries"
|
|
3
|
+
import { useInfiniteScroll } from "../../../../dynamic/src/Hooks/useInfiniteScroll"
|
|
4
|
+
import { PageBase } from "./PageBase"
|
|
5
|
+
import { Table } from "../Components/Table"
|
|
6
|
+
import { Filter } from "../Components/Filter"
|
|
7
|
+
import { FilterButton, ResetFilterButton } from "../../../../_template/src/Base/FormControls/Filter"
|
|
8
|
+
import { useSearchParams } from "react-router"
|
|
9
|
+
import { useEffect } from "react"
|
|
10
|
+
import { useMemo } from "react"
|
|
11
|
+
import { AsyncStateIndicator } from "../../../../_template/src/Base/Helpers/AsyncStateIndicator"
|
|
12
|
+
import { Collapsible } from "../../../../_template/src/Base/FormControls/Collapsible"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
function safeParseWhere(sp, paramName = "where") {
|
|
16
|
+
const raw = sp.get(paramName);
|
|
17
|
+
if (!raw) return null;
|
|
18
|
+
try {
|
|
19
|
+
const obj = JSON.parse(raw);
|
|
20
|
+
return obj && typeof obj === "object" ? obj : null;
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//
|
|
27
|
+
const filterParameterName = "gr_where"
|
|
28
|
+
export const PageVector = ({ children, queryAsyncAction = ReadPageAsyncAction }) => {
|
|
29
|
+
|
|
30
|
+
const [sp] = useSearchParams();
|
|
31
|
+
|
|
32
|
+
const whereFromUrl = useMemo(() => safeParseWhere(sp, filterParameterName), [sp.toString()]);
|
|
33
|
+
|
|
34
|
+
const { items, loading, error, hasMore, sentinelRef, loadMore, restart } = useInfiniteScroll(
|
|
35
|
+
{
|
|
36
|
+
asyncAction: queryAsyncAction,
|
|
37
|
+
actionParams: { skip: 0, limit: 25, where: whereFromUrl },
|
|
38
|
+
// reset: whereFromUrl
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const params = {skip: 0, limit: 25, where: whereFromUrl}
|
|
44
|
+
restart(params)
|
|
45
|
+
}, [whereFromUrl]);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<PageBase>
|
|
50
|
+
<Collapsible
|
|
51
|
+
className="form-control btn btn-outline-primary"
|
|
52
|
+
buttonLabelCollapsed="Zobrazit filtr"
|
|
53
|
+
buttonLabelExpanded="Skrýt filtr"
|
|
54
|
+
>
|
|
55
|
+
<Filter>
|
|
56
|
+
<FilterButton
|
|
57
|
+
className="form-control btn btn-outline-success"
|
|
58
|
+
paramName={filterParameterName}
|
|
59
|
+
>
|
|
60
|
+
Filtrovat
|
|
61
|
+
</FilterButton>
|
|
62
|
+
<ResetFilterButton
|
|
63
|
+
className="form-control btn btn-warning"
|
|
64
|
+
paramName={filterParameterName}
|
|
65
|
+
>
|
|
66
|
+
Vymazat filtr
|
|
67
|
+
</ResetFilterButton>
|
|
68
|
+
</Filter>
|
|
69
|
+
</Collapsible>
|
|
70
|
+
|
|
71
|
+
<Table data={items} />
|
|
72
|
+
|
|
73
|
+
<AsyncStateIndicator error={error} loading={loading} text="Nahrávám další..." />
|
|
74
|
+
|
|
75
|
+
{hasMore && <div ref={sentinelRef} style={{ height: 80, backgroundColor: "lightgray" }} />}
|
|
76
|
+
{hasMore && <button className="btn btn-success form-control" onClick={() => loadMore()}>Více</button>}
|
|
77
|
+
</PageBase>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { PageVector } from "./PageVector"
|
|
2
|
+
import { PageUpdateItem } from "./PageUpdateItem"
|
|
3
|
+
import { PageCreateItem } from "./PageCreateItem"
|
|
4
|
+
import { PageReadItem } from "./PageReadItem"
|
|
5
|
+
import { PageDeleteItem } from "./PageDeleteItem"
|
|
6
|
+
|
|
7
|
+
import { DeleteItemURI, UpdateItemURI } from "../Components"
|
|
8
|
+
import { CreateURI, ReadItemURI, VectorItemsURI } from "../Components"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Definice segmentů rout pro Template stránky.
|
|
12
|
+
*
|
|
13
|
+
* Každý objekt v tomto poli popisuje jednu trasu (route) v aplikaci:
|
|
14
|
+
* - `path`: Stringová URL s parametrem `:id`, která identifikuje konkrétní instanci template entity.
|
|
15
|
+
* - `element`: React komponenta, která se má renderovat při shodě s cestou.
|
|
16
|
+
*
|
|
17
|
+
* Pokud komponenta stránky podporuje children jako render funkci,
|
|
18
|
+
* všechny children předané přes router budou dostávat objekt:
|
|
19
|
+
* - `template` — načtená entita podle `:id`
|
|
20
|
+
* - `onChange` — callback pro změnu hodnoty pole
|
|
21
|
+
* - `onBlur` — callback pro blur event (například při opuštění pole)
|
|
22
|
+
*
|
|
23
|
+
* @constant
|
|
24
|
+
* @type {Array<{ path: string, element: JSX.Element }>}
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Tato route reaguje na URL jako "/template/123"
|
|
28
|
+
* {
|
|
29
|
+
* path: "/template/:id",
|
|
30
|
+
* element: <TemplatePage />
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* // Editační route: "/template/edit/123"
|
|
34
|
+
* {
|
|
35
|
+
* path: "/template/edit/:id",
|
|
36
|
+
* element: <TemplateEditPage />
|
|
37
|
+
* }
|
|
38
|
+
*/
|
|
39
|
+
export const UserRouterSegments = [
|
|
40
|
+
{
|
|
41
|
+
path: CreateURI,
|
|
42
|
+
element: (<PageCreateItem />),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
path: VectorItemsURI,
|
|
46
|
+
element: (<PageVector />),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: ReadItemURI,
|
|
50
|
+
element: (<PageReadItem />),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
path: UpdateItemURI,
|
|
54
|
+
element: (<PageUpdateItem />),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
path: DeleteItemURI,
|
|
58
|
+
element: (<PageDeleteItem />),
|
|
59
|
+
},
|
|
60
|
+
// {
|
|
61
|
+
// path: "sad",
|
|
62
|
+
// element: (<PageReadItemRolesOn />)
|
|
63
|
+
// },
|
|
64
|
+
{
|
|
65
|
+
path: VectorItemsURI.replace("list", ":any"),
|
|
66
|
+
element: (<PageVector />),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
path: ReadItemURI.replace("view", ":any"),
|
|
70
|
+
element: (<PageReadItem />),
|
|
71
|
+
}
|
|
72
|
+
]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared";
|
|
2
|
+
import { LargeFragment } from "./Fragments";
|
|
3
|
+
import { createAsyncGraphQLAction2 } from "../../../../dynamic/src/Core/createAsyncGraphQLAction2";
|
|
4
|
+
|
|
5
|
+
const DeleteMutationStr = `
|
|
6
|
+
mutation roleTypeDelete(
|
|
7
|
+
$id: UUID! # null,
|
|
8
|
+
$lastchange: DateTime! # null
|
|
9
|
+
) {
|
|
10
|
+
roleTypeDelete(
|
|
11
|
+
roleType: {
|
|
12
|
+
id: $id,
|
|
13
|
+
lastchange: $lastchange}
|
|
14
|
+
) {
|
|
15
|
+
...RoleTypeGQLModelDeleteError
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fragment RoleTypeGQLModelDeleteError on RoleTypeGQLModelDeleteError {
|
|
20
|
+
__typename
|
|
21
|
+
Entity {
|
|
22
|
+
...Large
|
|
23
|
+
}
|
|
24
|
+
msg
|
|
25
|
+
code
|
|
26
|
+
failed
|
|
27
|
+
location
|
|
28
|
+
input
|
|
29
|
+
}
|
|
30
|
+
`
|
|
31
|
+
const DeleteMutation = createQueryStrLazy(`${DeleteMutationStr}`, LargeFragment)
|
|
32
|
+
export const DeleteAsyncAction = createAsyncGraphQLAction2(DeleteMutation)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared"
|
|
2
|
+
|
|
3
|
+
const LinkFragmentStr = `
|
|
4
|
+
fragment Link on UserGQLModel {
|
|
5
|
+
__typename
|
|
6
|
+
id
|
|
7
|
+
lastchange
|
|
8
|
+
created
|
|
9
|
+
fullname
|
|
10
|
+
email
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
const MediumFragmentStr = `
|
|
15
|
+
fragment Medium on UserGQLModel {
|
|
16
|
+
...Link
|
|
17
|
+
rbacobject {
|
|
18
|
+
...RBRoles
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
const LargeFragmentStr = `
|
|
24
|
+
fragment Large on UserGQLModel {
|
|
25
|
+
...Medium
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
/*
|
|
29
|
+
const RoleFragmentStr = `
|
|
30
|
+
fragment Role on RoleGQLModel {
|
|
31
|
+
__typename
|
|
32
|
+
id
|
|
33
|
+
lastchange
|
|
34
|
+
created
|
|
35
|
+
createdbyId
|
|
36
|
+
changedbyId
|
|
37
|
+
rbacobjectId
|
|
38
|
+
createdby { id __typename }
|
|
39
|
+
changedby { id __typename }
|
|
40
|
+
rbacobject { id __typename }
|
|
41
|
+
valid
|
|
42
|
+
deputy
|
|
43
|
+
startdate
|
|
44
|
+
enddate
|
|
45
|
+
roletypeId
|
|
46
|
+
userId
|
|
47
|
+
groupId
|
|
48
|
+
roletype { __typename id }
|
|
49
|
+
user { __typename id fullname }
|
|
50
|
+
group { __typename id name }
|
|
51
|
+
}
|
|
52
|
+
` */
|
|
53
|
+
|
|
54
|
+
const RBACFragmentStr = `
|
|
55
|
+
fragment RBRoles on RBACObjectGQLModel {
|
|
56
|
+
__typename
|
|
57
|
+
id
|
|
58
|
+
currentUserRoles {
|
|
59
|
+
__typename
|
|
60
|
+
id
|
|
61
|
+
lastchange
|
|
62
|
+
valid
|
|
63
|
+
startdate
|
|
64
|
+
enddate
|
|
65
|
+
roletype {
|
|
66
|
+
__typename
|
|
67
|
+
id
|
|
68
|
+
name
|
|
69
|
+
}
|
|
70
|
+
group {
|
|
71
|
+
__typename
|
|
72
|
+
id
|
|
73
|
+
name
|
|
74
|
+
grouptype {
|
|
75
|
+
__typename
|
|
76
|
+
id
|
|
77
|
+
name
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}`
|
|
82
|
+
|
|
83
|
+
// export const RoleFragment = createQueryStrLazy(`${RoleFragmentStr}`)
|
|
84
|
+
export const RBACFragment = createQueryStrLazy(`${RBACFragmentStr}`)
|
|
85
|
+
|
|
86
|
+
export const LinkFragment = createQueryStrLazy(`${LinkFragmentStr}`)
|
|
87
|
+
export const MediumFragment = createQueryStrLazy(`${MediumFragmentStr}`, LinkFragment, RBACFragment)
|
|
88
|
+
export const LargeFragment = createQueryStrLazy(`${LargeFragmentStr}`, MediumFragment, /* RoleFragment */)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared";
|
|
2
|
+
import { LargeFragment } from "./Fragments";
|
|
3
|
+
import { createAsyncGraphQLAction2 } from "../../../../dynamic/src/Core/createAsyncGraphQLAction2";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const InsertMutationStr = `
|
|
7
|
+
mutation roleTypeInsert(
|
|
8
|
+
$mastertypeId: UUID # null,
|
|
9
|
+
$id: UUID # null,
|
|
10
|
+
$name: String # null,
|
|
11
|
+
$nameEn: String # null,
|
|
12
|
+
$subtypes: [RoleTypeInsertGQLModel!] # null
|
|
13
|
+
) {
|
|
14
|
+
roleTypeInsert(
|
|
15
|
+
roleType: {
|
|
16
|
+
mastertypeId: $mastertypeId,
|
|
17
|
+
id: $id,
|
|
18
|
+
name: $name,
|
|
19
|
+
nameEn: $nameEn,
|
|
20
|
+
subtypes: $subtypes}
|
|
21
|
+
) {
|
|
22
|
+
... on InsertError { ...InsertError }
|
|
23
|
+
... on RoleTypeGQLModel { ...Large }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
fragment InsertError on InsertError {
|
|
29
|
+
__typename
|
|
30
|
+
msg
|
|
31
|
+
failed
|
|
32
|
+
code
|
|
33
|
+
location
|
|
34
|
+
input
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
const InsertMutation = createQueryStrLazy(`${InsertMutationStr}`, LargeFragment)
|
|
40
|
+
export const InsertAsyncAction = createAsyncGraphQLAction2(InsertMutation)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared";
|
|
2
|
+
import { LargeFragment } from "./Fragments";
|
|
3
|
+
import { createAsyncGraphQLAction2 } from "../../../../dynamic/src/Core/createAsyncGraphQLAction2";
|
|
4
|
+
|
|
5
|
+
const ReadQueryStr = `
|
|
6
|
+
query userById($id: UUID!) {
|
|
7
|
+
userById(id: $id) {
|
|
8
|
+
...Large
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
const ReadQuery = createQueryStrLazy(`${ReadQueryStr}`, LargeFragment)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An async action for executing a GraphQL query to read entities.
|
|
17
|
+
*
|
|
18
|
+
* This action is created using `createAsyncGraphQLAction` with a predefined `QueryRead` query.
|
|
19
|
+
* It can be dispatched with query variables to fetch data related to entities from the GraphQL API.
|
|
20
|
+
*
|
|
21
|
+
* @constant
|
|
22
|
+
* @type {Function}
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} query_variables - The variables for the GraphQL query.
|
|
25
|
+
* @param {string|number} query_variables.id - The unique identifier for the entity to fetch.
|
|
26
|
+
*
|
|
27
|
+
* @returns {Function} A dispatchable async action that performs the GraphQL query, applies middleware, and dispatches the result.
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} If `query_variables` is not a valid JSON object.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Example usage:
|
|
33
|
+
* const queryVariables = { id: "12345" };
|
|
34
|
+
*
|
|
35
|
+
* dispatch(ReadAsyncAction(queryVariables))
|
|
36
|
+
* .then((result) => {
|
|
37
|
+
* console.log("Fetched data:", result);
|
|
38
|
+
* })
|
|
39
|
+
* .catch((error) => {
|
|
40
|
+
* console.error("Error fetching data:", error);
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
43
|
+
// export const ReadAsyncAction = createAsyncGraphQLAction2(ReadQuery, reduceToFirstEntity("result"))
|
|
44
|
+
export const ReadAsyncAction = createAsyncGraphQLAction2(ReadQuery)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared";
|
|
2
|
+
import { LargeFragment } from "./Fragments";
|
|
3
|
+
import { createAsyncGraphQLAction2 } from "../../../../dynamic/src/Core/createAsyncGraphQLAction2";
|
|
4
|
+
|
|
5
|
+
const ReadPageQueryStr = `
|
|
6
|
+
query userPage($skip: Int, $limit: Int, $orderby: String, $where: UserInputWhereFilter) {
|
|
7
|
+
userPage(skip: $skip, limit: $limit, orderby: $orderby, where: $where) {
|
|
8
|
+
...User
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
const ReadPageQuery = createQueryStrLazy(`${ReadPageQueryStr}`, LargeFragment)
|
|
13
|
+
export const ReadPageAsyncAction = createAsyncGraphQLAction2(ReadPageQuery)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared"
|
|
2
|
+
import { createAsyncGraphQLAction2 } from "../../../../dynamic/src/Core/createAsyncGraphQLAction2"
|
|
3
|
+
import { LargeFragment } from "./Fragments"
|
|
4
|
+
import { reduceToFirstEntity } from "../../../../dynamic/src/Store"
|
|
5
|
+
|
|
6
|
+
const SearchQueryStr = `
|
|
7
|
+
query SearchQuery($skip: Int, $limit: Int, $pattern: String) {
|
|
8
|
+
result: userPage(skip: $skip, limit: $limit, where: {email: {_ilike: $pattern}}) {
|
|
9
|
+
...Large
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const SearchAsyncActionQuery = createQueryStrLazy(`${SearchQueryStr}`, LargeFragment)
|
|
16
|
+
export const SearchAsyncAction = createAsyncGraphQLAction2(SearchAsyncActionQuery)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createQueryStrLazy } from "@hrbolek/uoisfrontend-gql-shared";
|
|
2
|
+
import { LargeFragment } from "./Fragments";
|
|
3
|
+
import { createAsyncGraphQLAction2 } from "../../../../dynamic/src/Core/createAsyncGraphQLAction2";
|
|
4
|
+
import { reduceToFirstEntity, updateItemsFromGraphQLResult } from "../../../../dynamic/src/Store";
|
|
5
|
+
|
|
6
|
+
const UpdateMutationStr = `
|
|
7
|
+
mutation roleTypeUpdate(
|
|
8
|
+
$id: UUID! # null,
|
|
9
|
+
$lastchange: DateTime! # null,
|
|
10
|
+
$name: String # null,
|
|
11
|
+
$nameEn: String # null
|
|
12
|
+
) {
|
|
13
|
+
roleTypeUpdate(
|
|
14
|
+
roleType: {
|
|
15
|
+
id: $id,
|
|
16
|
+
lastchange: $lastchange,
|
|
17
|
+
name: $name,
|
|
18
|
+
nameEn: $nameEn}
|
|
19
|
+
) {
|
|
20
|
+
... on RoleTypeGQLModel { ...Large }
|
|
21
|
+
... on RoleTypeGQLModelUpdateError { ...Error }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fragment Error on RoleTypeGQLModelUpdateError {
|
|
26
|
+
__typename
|
|
27
|
+
Entity {
|
|
28
|
+
...Large
|
|
29
|
+
}
|
|
30
|
+
msg
|
|
31
|
+
failed
|
|
32
|
+
code
|
|
33
|
+
location
|
|
34
|
+
input
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
const UpdateMutation = createQueryStrLazy(`${UpdateMutationStr}`, LargeFragment)
|
|
39
|
+
export const UpdateAsyncAction = createAsyncGraphQLAction2(UpdateMutation,
|
|
40
|
+
updateItemsFromGraphQLResult, reduceToFirstEntity)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
export { InsertAsyncAction } from './InsertAsyncAction'
|
|
3
|
+
export { UpdateAsyncAction } from './UpdateAsyncAction'
|
|
4
|
+
export { DeleteAsyncAction } from './DeleteAsyncAction'
|
|
5
|
+
export { ReadAsyncAction } from './ReadAsyncAction'
|
|
6
|
+
export { ReadPageAsyncAction } from './ReadPageAsyncAction'
|