@hrbolek/uoisfrontend-template 0.6.2 → 0.6.3

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.
Files changed (68) hide show
  1. package/dist/cjs/index.js +17 -17
  2. package/dist/es/index.js +38 -31
  3. package/dist/umd/index.js +31 -31
  4. package/package.json +1 -1
  5. package/src/Base/Components/Link.jsx +13 -8
  6. package/src/Base/Mutations/General.jsx +3 -1
  7. package/src/Base/Mutations/Update.jsx +5 -0
  8. package/src/EventGQLModel/Components/A4Plan/A4Plan.jsx +363 -0
  9. package/src/EventGQLModel/Components/A4Plan/index.js +1 -0
  10. package/src/EventGQLModel/Components/CardCapsule.jsx +43 -0
  11. package/src/EventGQLModel/Components/Children.jsx +31 -0
  12. package/src/EventGQLModel/Components/ConfirmEdit.jsx +61 -0
  13. package/src/EventGQLModel/Components/Filter.jsx +14 -0
  14. package/src/EventGQLModel/Components/LargeCard.jsx +54 -0
  15. package/src/EventGQLModel/Components/Link.jsx +55 -0
  16. package/src/EventGQLModel/Components/LiveEdit.jsx +111 -0
  17. package/src/EventGQLModel/Components/MediumCard.jsx +39 -0
  18. package/src/EventGQLModel/Components/MediumContent.jsx +96 -0
  19. package/src/EventGQLModel/Components/MediumEditableContent.jsx +35 -0
  20. package/src/EventGQLModel/Components/Plan/PlanRow.jsx +470 -0
  21. package/src/EventGQLModel/Components/Plan/_utils.js +971 -0
  22. package/src/EventGQLModel/Components/Plan/calendarReducer.js +535 -0
  23. package/src/EventGQLModel/Components/Plan/index.js +3 -0
  24. package/src/EventGQLModel/Components/Table.jsx +7 -0
  25. package/src/EventGQLModel/Components/index.js +15 -0
  26. package/src/EventGQLModel/Mutations/Create.jsx +202 -0
  27. package/src/EventGQLModel/Mutations/Delete.jsx +173 -0
  28. package/src/EventGQLModel/Mutations/InteractiveMutations.jsx +30 -0
  29. package/src/EventGQLModel/Mutations/Update.jsx +147 -0
  30. package/src/EventGQLModel/Mutations/helpers.jsx +7 -0
  31. package/src/EventGQLModel/Pages/PageBase.jsx +56 -0
  32. package/src/EventGQLModel/Pages/PageCreateItem.jsx +28 -0
  33. package/src/EventGQLModel/Pages/PageDeleteItem.jsx +16 -0
  34. package/src/EventGQLModel/Pages/PageNavbar.jsx +160 -0
  35. package/src/EventGQLModel/Pages/PagePlan.jsx +42 -0
  36. package/src/EventGQLModel/Pages/PageReadItem.jsx +11 -0
  37. package/src/EventGQLModel/Pages/PageReadItemEx.jsx +42 -0
  38. package/src/EventGQLModel/Pages/PageSubevents.jsx +43 -0
  39. package/src/EventGQLModel/Pages/PageUpdateItem.jsx +14 -0
  40. package/src/EventGQLModel/Pages/PageVector.jsx +80 -0
  41. package/src/EventGQLModel/Pages/RouterSegment.jsx +82 -0
  42. package/src/EventGQLModel/Pages/index.js +2 -0
  43. package/src/EventGQLModel/Queries/DeleteAsyncAction.jsx +32 -0
  44. package/src/EventGQLModel/Queries/Fragments.jsx +123 -0
  45. package/src/EventGQLModel/Queries/InsertAsyncAction.jsx +40 -0
  46. package/src/EventGQLModel/Queries/ReadAsyncAction.jsx +44 -0
  47. package/src/EventGQLModel/Queries/ReadPageAsyncAction.jsx +13 -0
  48. package/src/EventGQLModel/Queries/ReadSubEventsAsyncAction.jsx +44 -0
  49. package/src/EventGQLModel/Queries/SearchAsyncAction.jsx +16 -0
  50. package/src/EventGQLModel/Queries/UpdateAsyncAction.jsx +40 -0
  51. package/src/EventGQLModel/Queries/index.js +6 -0
  52. package/src/EventGQLModel/Scalars/ScalarAttribute.jsx +54 -0
  53. package/src/EventGQLModel/Scalars/TemplateScalarAttribute.jsx +88 -0
  54. package/src/EventGQLModel/Scalars/index.js +1 -0
  55. package/src/EventGQLModel/Vectors/TemplateVectorsAttribute.jsx +326 -0
  56. package/src/EventGQLModel/Vectors/VectorAttribute.jsx +56 -0
  57. package/src/EventGQLModel/Vectors/index.js +1 -0
  58. package/src/EventGQLModel/WhatToDo.md +44 -0
  59. package/src/EventGQLModel/index.js +71 -0
  60. package/src/GroupGQLModel/Mutations/Create.jsx +8 -2
  61. package/src/GroupGQLModel/Mutations/Delete.jsx +8 -2
  62. package/src/GroupGQLModel/Mutations/Update.jsx +8 -8
  63. package/src/GroupGQLModel/Queries/Fragments.jsx +17 -1
  64. package/src/GroupGQLModel/Scalars/RBACObject.jsx +17 -5
  65. package/src/GroupGQLModel/Vectors/GroupMemberships.jsx +1 -1
  66. package/src/UserGQLModel/Components/MediumContent.jsx +9 -3
  67. package/src/UserGQLModel/Queries/Fragments.jsx +6 -0
  68. package/src/_Template/WhatToDo.md +1 -1
@@ -0,0 +1,55 @@
1
+ import { URIRoot } from "../../uriroot";
2
+ import { registerLink } from "../../../../_template/src/Base/Components/Link";
3
+ import { ProxyLink } from "../../../../_template/src/Base/Components/ProxyLink";
4
+
5
+ const modelURI = `${URIRoot}/EventGQLModel`
6
+ export const ListURI = `${modelURI}/list/`;
7
+ export const CreateURI = `${modelURI}/create/`;
8
+ export const ReadURI = `${modelURI}/view/`;
9
+ export const UpdateURI = `${modelURI}/edit/`;
10
+ export const DeleteURI = `${modelURI}/delete/`;
11
+
12
+ export const LinkURI = ReadURI;
13
+ export const VectorItemsURI = ListURI;
14
+
15
+ const idParam = ":id"
16
+ export const ReadItemURI = `${LinkURI}${idParam}`;
17
+ export const UpdateItemURI = `${UpdateURI}${idParam}`;
18
+ export const DeleteItemURI = `${DeleteURI}${idParam}`;
19
+ export const PlanItemURI = `${LinkURI}${idParam}`;
20
+
21
+ /**
22
+ * A React component that renders a `ProxyLink` to an "template" entity's view page.
23
+ *
24
+ * The target URL is dynamically constructed using the `template` object's `id`, and the link displays
25
+ * the `template` object's `name` as its clickable content.
26
+ *
27
+ * @function TemplateLink
28
+ * @param {Object} props - The properties for the `TemplateLink` component.
29
+ * @param {Object} props.template - The object representing the "template" entity.
30
+ * @param {string|number} props.template.id - The unique identifier for the "template" entity. Used to construct the target URL.
31
+ * @param {string} props.template.name - The display name for the "template" entity. Used as the link text.
32
+ *
33
+ * @returns {JSX.Element} A `ProxyLink` component linking to the specified "template" entity's view page.
34
+ *
35
+ * @example
36
+ * // Example usage with a sample template entity:
37
+ * const templateEntity = { id: 123, name: "Example Template Entity" };
38
+ *
39
+ * <TemplateLink template={templateEntity} />
40
+ * // Renders: <ProxyLink to="/template/template/view/123">Example Template Entity</ProxyLink>
41
+ *
42
+ * @remarks
43
+ * - This component utilizes `ProxyLink` to ensure consistent link behavior, including parameter preservation and conditional reloads.
44
+ * - The URL format `/template/template/view/:id` must be supported by the application routing.
45
+ *
46
+ * @see ProxyLink - The base component used for rendering the link.
47
+ */
48
+ export const Link = ({ item, LinkURI: LinkURI_ = LinkURI, action="view", children, ...props}) => {
49
+ const targetURI = LinkURI_.replace('view', action);
50
+ return <ProxyLink to={targetURI + item?.id} {...props}>{children || item?.fullname || item?.name || item?.id || "Nevim"}</ProxyLink>
51
+ // return <BaseUI.Link item={item} />
52
+ // return <a>{children || item?.fullname || item?.name || item?.id || "Nevim"}</a>
53
+ }
54
+
55
+ registerLink('EventGQLModel', Link)
@@ -0,0 +1,111 @@
1
+ import { useCallback } from "react";
2
+ import { useMemo } from "react";
3
+
4
+ import { UpdateAsyncAction } from "../Queries";
5
+ import { CreateDelayer, ErrorHandler, LoadingSpinner } from "@hrbolek/uoisfrontend-shared";
6
+ import { MediumEditableContent } from "./MediumEditableContent";
7
+ import { useEditAction } from "../../../../dynamic/src/Hooks/useEditAction";
8
+
9
+ /**
10
+ * TemplateLiveEdit Component
11
+ *
12
+ * Interaktivní React komponenta pro live editaci entity `template` s podporou optimistického fetchování a debounce delaye.
13
+ *
14
+ * - Používá `useAsyncAction` k načítání a update entit (např. GraphQL mutation).
15
+ * - Pokud se hodnota pole změní, spustí se update po krátkém zpoždění (`delayer`) — uživatelské změny nejsou ihned posílány, ale až po pauze.
16
+ * - Zobrazuje loading a error stav pomocí komponent `LoadingSpinner` a `ErrorHandler`.
17
+ * - Předává editované hodnoty do komponenty `TemplateMediumEditableContent`, která zajišťuje zobrazení a editaci jednotlivých polí šablony (`template`).
18
+ *
19
+ * @component
20
+ * @param {Object} props - Props objekt.
21
+ * @param {Object} props.template - Objekt reprezentující editovanou šablonu (template entity).
22
+ * @param {React.ReactNode} [props.children] - Libovolné children, které se vloží pod editační komponentu.
23
+ * @param {Function} [props.asyncAction=TemplateUpdateAsyncAction] - Asynchronní akce pro update (`useAsyncAction`), typicky GraphQL update mutation.
24
+ *
25
+ * @example
26
+ * // Standardní použití
27
+ * <TemplateLiveEdit template={templateEntity} />
28
+ *
29
+ * @example
30
+ * // S vlastním asyncAction a doplňkovým obsahem
31
+ * <TemplateLiveEdit template={templateEntity} asyncAction={myUpdateAction}>
32
+ * <div>Extra obsah nebo poznámka</div>
33
+ * </TemplateLiveEdit>
34
+ *
35
+ * @returns {JSX.Element}
36
+ * Interaktivní komponenta pro live editaci šablony, včetně spinneru a error handleru.
37
+ */
38
+ export const LiveEdit_ = ({ children, asyncAction=UpdateAsyncAction}) => {
39
+ const { onChange, onBlur, item } = useGQLEntityContext()
40
+ return (
41
+ <AsyncActionProvider
42
+ item={item}
43
+ queryAsyncAction={asyncAction}
44
+ options={{deferred: true, network: true}}
45
+ onChange={onChange}
46
+ onBlur={onBlur}
47
+ >
48
+ <LiveEditWrapper item={item}>
49
+ {children}
50
+ {/* <hr />
51
+ <pre>{JSON.stringify(item, null, 2)}</pre> */}
52
+ </LiveEditWrapper>
53
+ </AsyncActionProvider>
54
+ )
55
+ }
56
+
57
+ const LiveEditWrapper = ({ item, children }) => {
58
+ const { run , error, loading, entity, data, onChange, onBlur } = useGQLEntityContext()
59
+
60
+ const handleEvent = useCallback((handler) => async (e) => {
61
+ const {id, value} = e?.target || {}
62
+ if (id === undefined || value === undefined) return
63
+ if (item?.[id] === value) {
64
+ return;
65
+ }
66
+ const newItem = { ...item, [e.target.id]: e.target.value }
67
+ const newEvent = { target: { value: newItem } }
68
+ // console.log("LiveEditWrapper localOnChange start e", e, '=>', newEvent)
69
+ // const result = await delayer(()=>onChange(newEvent))
70
+ const result = await handler(newEvent)
71
+ // console.log("LiveEditWrapper localOnChange end e", e, '=>', newItem, '=>', result)
72
+ return result
73
+ }, [item])
74
+
75
+ const bindedOnChange = useMemo(() => handleEvent(onChange), [onChange, handleEvent])
76
+ const bindedOnBlur = useMemo(() => handleEvent(onBlur), [onBlur, handleEvent])
77
+
78
+ return (
79
+ <MediumEditableContent item={item} onChange={bindedOnChange} onBlur={bindedOnBlur} >
80
+ {children}
81
+ {/* <hr />
82
+ <pre>{JSON.stringify(item, null, 2)}</pre> */}
83
+ </MediumEditableContent>
84
+ )
85
+ }
86
+
87
+
88
+ export const LiveEdit = ({ item, children, asyncMutationAction=UpdateAsyncAction }) => {
89
+ // const { run , error, loading, entity, data, onChange: contextOnChange, onBlur: contextOnBlur } = useGQLEntityContext()
90
+ const {
91
+ draft,
92
+ dirty,
93
+ loading: saving,
94
+ onChange,
95
+ onBlur,
96
+ onCancel,
97
+ onConfirm,
98
+ } = useEditAction(asyncMutationAction, item, {
99
+ mode: "live",
100
+ // onCommit: contextOnChange
101
+ })
102
+
103
+ return (
104
+
105
+ <MediumEditableContent item={item} onChange={onChange} onBlur={onBlur} >
106
+ {saving && <LoadingSpinner/>}
107
+ {children}
108
+ </MediumEditableContent>
109
+
110
+ )
111
+ }
@@ -0,0 +1,39 @@
1
+ import { PersonFill } from "react-bootstrap-icons"
2
+ import { CardCapsule } from "./CardCapsule"
3
+ import { MediumContent } from "./MediumContent"
4
+ import { Link } from "./Link"
5
+
6
+ /**
7
+ * A card component that displays detailed content for an template entity.
8
+ *
9
+ * This component combines `TemplateCardCapsule` and `TemplateMediumContent` to create a card layout
10
+ * with a title and medium-level content. The title includes a `PersonFill` icon and a link to
11
+ * the template entity's details, while the body displays serialized details of the entity along
12
+ * with any additional children passed to the component.
13
+ *
14
+ * @component
15
+ * @param {Object} props - The properties for the TemplateMediumCard component.
16
+ * @param {Object} props.template - The object representing the template entity.
17
+ * @param {string|number} props.template.id - The unique identifier for the template entity.
18
+ * @param {string} props.template.name - The name or label of the template entity.
19
+ * @param {React.ReactNode} [props.children=null] - Additional content to render inside the card body.
20
+ *
21
+ * @returns {JSX.Element} A JSX element combining a card with a title and detailed content.
22
+ *
23
+ * @example
24
+ * // Example usage:
25
+ * const templateEntity = { id: 123, name: "Sample Entity" };
26
+ *
27
+ * <TemplateMediumCard template={templateEntity}>
28
+ * <p>Additional details or actions for the entity.</p>
29
+ * </TemplateMediumCard>
30
+ */
31
+ export const MediumCard = ({ item, children }) => {
32
+ return (
33
+ <CardCapsule title={<><PersonFill /> <Link item={item} /></>}>
34
+ {children}
35
+ <MediumContent item={item}>
36
+ </MediumContent>
37
+ </CardCapsule>
38
+ )
39
+ }
@@ -0,0 +1,96 @@
1
+ import { Col } from "../../../../_template/src/Base/Components/Col"
2
+ import { Row } from "../../../../_template/src/Base/Components/Row"
3
+ import { Link } from "./Link"
4
+ /**
5
+ * A component that displays medium-level content for an template entity.
6
+ *
7
+ * This component renders a label "TemplateMediumContent" followed by a serialized representation of the `template` object
8
+ * and any additional child content. It is designed to handle and display information about an template entity object.
9
+ *
10
+ * @component
11
+ * @param {Object} props - The properties for the TemplateMediumContent component.
12
+ * @param {Object} props.template - The object representing the template entity.
13
+ * @param {string|number} props.template.id - The unique identifier for the template entity.
14
+ * @param {string} props.template.name - The name or label of the template entity.
15
+ * @param {React.ReactNode} [props.children=null] - Additional content to render after the serialized `template` object.
16
+ *
17
+ * @returns {JSX.Element} A JSX element displaying the entity's details and optional content.
18
+ *
19
+ * @example
20
+ * // Example usage:
21
+ * const templateEntity = { id: 123, name: "Sample Entity" };
22
+ *
23
+ * <TemplateMediumContent template={templateEntity}>
24
+ * <p>Additional information about the entity.</p>
25
+ * </TemplateMediumContent>
26
+ */
27
+ // export const MediumContent = ({ item, children}) => {
28
+ // return (
29
+ // <MediumContent_ item={item}>
30
+ // {children}
31
+ // </MediumContent_>
32
+ // )
33
+ // }
34
+
35
+ // export const MediumContent_ = ({ item, children }) => {
36
+ // return (
37
+ // <>
38
+ // {Object.entries(item).map(([attribute_name, attribute_value]) => {
39
+ // // if (attribute_name !== "id") return null
40
+ // if (Array.isArray(attribute_value)) return null
41
+ // if (typeof attribute_value === "object" && attribute_value !== null) return null
42
+ // let attribute_value_result = attribute_value
43
+ // // let attribute_value_result = attribute_value
44
+ // if (Array.isArray(attribute_value))
45
+ // // attribute_value_result = <CardCapsule><Table data={attribute_value} /></CardCapsule>
46
+ // return null
47
+ // else if (typeof attribute_value === "object" && attribute_value !== null)
48
+ // // attribute_value_result = <MediumCard item={attribute_value} />
49
+ // return null
50
+ // else if (attribute_name === "__typename") {
51
+ // /*attribute_value_result = <Link item={attribute_value} />*/
52
+ // // console.log("else1", attribute_name, attribute_value)
53
+ // }
54
+ // if (attribute_name === "id")
55
+ // attribute_value_result = <Link item={item}>{item?.id || "Data error"}</Link>
56
+ // if (attribute_name === "name")
57
+ // attribute_value_result = <Link item={item} />
58
+ // // else return null
59
+ // if (attribute_value)
60
+ // return (
61
+ // <Row key={attribute_name}>
62
+ // <Col className="col-4"><b>{attribute_name}</b></Col>
63
+ // <Col className="col-8">{attribute_value_result}</Col>
64
+ // </Row>
65
+ // )
66
+ // else return null
67
+ // })}
68
+ // {Object.entries(item).map(([attribute_name, attribute_value]) => {
69
+ // if (attribute_value !== null) return null
70
+ // let attribute_value_result = JSON.stringify(attribute_value)
71
+ // if (Array.isArray(attribute_value))
72
+ // // attribute_value_result = <CardCapsule><Table data={attribute_value} /></CardCapsule>
73
+ // return null
74
+ // else if (typeof attribute_value === "object" && attribute_value !== null)
75
+ // // attribute_value_result = <MediumCard item={attribute_value} />
76
+ // return null
77
+ // else if (attribute_name === "__typename") {
78
+ // /*attribute_value_result = <Link item={attribute_value} />*/
79
+ // console.log("else2", attribute_name, attribute_value)
80
+ // }
81
+ // if (attribute_value)
82
+ // return null
83
+ // else
84
+ // return (
85
+ // <Row key={attribute_name}>
86
+ // <Col className="col-4"><b>{attribute_name}</b></Col>
87
+ // <Col className="col-8">{attribute_value_result}</Col>
88
+ // </Row>
89
+ // )
90
+ // })}
91
+ // {children}
92
+ // </>
93
+ // )
94
+ // }
95
+
96
+ export { MediumContent } from "../../../../_template/src/Base/Components/MediumContent"
@@ -0,0 +1,35 @@
1
+ import { Input } from "../../../../_template/src/Base/FormControls/Input"
2
+
3
+ /**
4
+ * A component that displays medium-level content for an template entity.
5
+ *
6
+ * This component renders a label "TemplateMediumContent" followed by a serialized representation of the `template` object
7
+ * and any additional child content. It is designed to handle and display information about an template entity object.
8
+ *
9
+ * @component
10
+ * @param {Object} props - The properties for the TemplateMediumContent component.
11
+ * @param {Object} props.template - The object representing the template entity.
12
+ * @param {string|number} props.template.id - The unique identifier for the template entity.
13
+ * @param {string} props.template.name - The name or label of the template entity.
14
+ * @param {React.ReactNode} [props.children=null] - Additional content to render after the serialized `template` object.
15
+ *
16
+ * @returns {JSX.Element} A JSX element displaying the entity's details and optional content.
17
+ *
18
+ * @example
19
+ * // Example usage:
20
+ * const templateEntity = { id: 123, name: "Sample Entity" };
21
+ *
22
+ * <TemplateMediumContent template={templateEntity}>
23
+ * <p>Additional information about the entity.</p>
24
+ * </TemplateMediumContent>
25
+ */
26
+ export const MediumEditableContent = ({ item, onChange=(e)=>null, onBlur=(e)=>null, children}) => {
27
+ return (
28
+ <>
29
+ {/* defaultValue={item?.name|| "Název"} */}
30
+ <Input id={"name"} label={"Jméno"} className="form-control" value={item?.name|| "Název"} onChange={onChange} onBlur={onBlur} />
31
+ <Input id={"nameEn"} label={"Anglický název"} className="form-control" value={item?.nameEn|| "Anglický název"} onChange={onChange} onBlur={onBlur} />
32
+ {children}
33
+ </>
34
+ )
35
+ }