From 4a1557526d9a44cf66d84d2d28978ec7362255f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Tue, 30 Jan 2024 12:57:12 +0100
Subject: [PATCH 01/41] Add RecordRequests React project and initial files
---
.../oarepo_requests_ui/RecordRequests.jinja | 10 +
oarepo_requests/ui/theme/__init__.py | 0
.../ui/theme/assets/semantic-ui/.gitkeep | 0
.../oarepo_requests_ui/custom-components.js | 16 +
.../components/CreateRequestButtonGroup.jsx | 37 ++
.../components/CreateRequestModalContent.jsx | 58 ++
.../components/RecordRequests.jsx | 47 ++
.../components/RequestList.jsx | 56 ++
.../components/RequestListContainer.jsx | 62 ++
.../components/RequestModal.jsx | 315 +++++++++
.../components/RequestModalContent.jsx | 202 ++++++
.../components/common/DefaultView.jsx | 6 +
.../common/ReadOnlyCustomFields.jsx | 89 +++
.../components/common/index.js | 3 +
.../record-requests/components/index.js | 8 +
.../contexts/RequestContext.jsx | 11 +
.../record-requests/contexts/index.js | 1 +
.../record-requests/dummy-record.js | 607 ++++++++++++++++++
.../record-requests/index.js | 17 +
.../record-requests/types.d.ts | 106 +++
.../record-requests/utils/loader.js | 87 +++
.../record-requests/utils/objects.js | 8 +
.../oarepo_requests/custom-components.less | 8 +
.../oarepo_requests/definitions/sample.less | 50 ++
oarepo_requests/ui/theme/webpack.py | 19 +
setup.cfg | 3 +
26 files changed, 1826 insertions(+)
create mode 100644 oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja
create mode 100644 oarepo_requests/ui/theme/__init__.py
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/.gitkeep
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/custom-components.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/DefaultView.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RequestContext.jsx
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/types.d.ts
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/loader.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/objects.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/custom-components.less
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/definitions/sample.less
create mode 100644 oarepo_requests/ui/theme/webpack.py
diff --git a/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja b/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja
new file mode 100644
index 00000000..2b8ecd8c
--- /dev/null
+++ b/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja
@@ -0,0 +1,10 @@
+{#def record #}
+
+{% set record = record | to_dict %}
+
+
+
+{%- block javascript %}
+{{ super() }}
+{{ webpack['oarepo_requests_ui_record_requests.js']}}
+{%- endblock %}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/__init__.py b/oarepo_requests/ui/theme/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/.gitkeep b/oarepo_requests/ui/theme/assets/semantic-ui/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/custom-components.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/custom-components.js
new file mode 100644
index 00000000..9643553c
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/custom-components.js
@@ -0,0 +1,16 @@
+/*
+This is the registration file for custom components. The components should not be included here,
+but only referenced. The sample component below can be used to start up working on your own custom
+component.
+*/
+/*
+
+In the sample-component.js you can define your own javascript functions etc for your custom component.
+Then import the file here
+
+import "./sample-component.js"
+*/
+
+// This file will import the css templates for your custom components
+
+import "../../less/oarepo_requests_ui/custom-components.less";
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
new file mode 100644
index 00000000..dced49ee
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
@@ -0,0 +1,37 @@
+import React, { useState } from "react";
+import PropTypes from "prop-types";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+
+import Overridable from "react-overridable";
+import { List, Segment, Header, Button } from "semantic-ui-react";
+
+import { RequestModal } from "./RequestModal";
+
+/**
+ * @typedef {import("../types").Request} Request
+ * @typedef {import("../types").RequestType} RequestType
+ */
+
+/**
+ * @param {{ requestTypes: RequestType[] }} props
+ */
+export const CreateRequestButtonGroup = ({ requestTypes }) => {
+ const createRequests = requestTypes.filter(requestType => requestType.links.actions?.create);
+
+ return (
+
+ {i18next.t("Create Request")}
+
+ {createRequests.map((requestType) => (
+ }
+ />
+ ))}
+
+
+ );
+}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
new file mode 100644
index 00000000..225a6599
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
@@ -0,0 +1,58 @@
+import React, { useState, useRef, useEffect } from "react";
+import PropTypes from "prop-types";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+import { Dimmer, Loader, Segment, Modal, Button, Header, Icon, Grid, Input, List, Container, Message, Form, Divider } from "semantic-ui-react";
+import { useFormikContext } from "formik";
+
+import _isFunction from "lodash/isFunction";
+
+import { CustomFields } from "react-invenio-forms";
+
+/**
+ * @typedef {import("../types").RequestType} RequestType
+ * @typedef {import("formik").FormikConfig} FormikConfig
+ */
+
+/** @param {{ requestType: RequestType }} props */
+export const CreateRequestModalContent = ({ requestType, extraPreSubmitEvent }) => {
+ const payloadUI = requestType?.payload_ui;
+
+ const { isSubmitting, isValid, handleSubmit } = useFormikContext();
+
+ const customSubmitHandler = (event) => {
+ _isFunction(extraPreSubmitEvent) && extraPreSubmitEvent(event);
+ handleSubmit(event);
+ }
+
+ return (
+ <>
+ {requestType?.description &&
+
+ {requestType.description}
+
+ }
+ {payloadUI &&
+
+
+
+ }
+ >
+ );
+}
+
+CreateRequestModalContent.propTypes = {
+ requestType: PropTypes.object.isRequired,
+ extraPreSubmitEvent: PropTypes.func
+};
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
new file mode 100644
index 00000000..207ea898
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
@@ -0,0 +1,47 @@
+import React, { useState } from "react";
+import PropTypes from "prop-types";
+
+import Overridable, {
+ OverridableContext,
+ overrideStore,
+} from "react-overridable";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+import _sortBy from "lodash/sortBy";
+
+import { List, Segment, Header, Button } from "semantic-ui-react";
+
+import { CreateRequestButtonGroup, RequestListContainer } from ".";
+import { RequestContextProvider } from "../contexts";
+
+/**
+ * @typedef {import("../types").Request} Request
+ * @typedef {import("../types").RequestType} RequestType
+ */
+
+export const RecordRequests = ({ record }) => {
+ /** @type {RequestType[]} */
+ const requestTypes = record.request_types ?? [];
+
+ const requestsState = useState(_sortBy(record.requests, ["status_code"]) ?? []);
+
+ return (
+ <>
+ {/* Context for app - to not reload page after RequestModal submit */}
+ {/* */}
+
+ {requestTypes && (
+
+ )}
+ {record?.requests && (
+
+ )}
+
+ {/* */}
+ >
+ );
+}
+
+RecordRequests.propTypes = {
+ record: PropTypes.object.isRequired,
+};
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx
new file mode 100644
index 00000000..3646b557
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx
@@ -0,0 +1,56 @@
+import React from "react";
+import PropTypes from "prop-types";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+import { List, Segment, SegmentGroup, Header, Button } from "semantic-ui-react";
+import _isEmpty from "lodash/isEmpty";
+
+import { RequestModal } from ".";
+
+/**
+ * @typedef {import("../types").Request} Request
+ * @typedef {import("../types").RequestTypeEnum} RequestTypeEnum
+ */
+
+/**
+ * @param {{ requests: Request[], requestModalType: RequestTypeEnum }} props
+ */
+export const RequestList = ({ requests, requestTypes, requestModalType }) => {
+ return (
+
+ {requests.map((request) => {
+ let modalType = requestModalType;
+ if (_isEmpty(requestModalType)) {
+ if ("submit" in request.links?.actions) {
+ modalType = "submit";
+ } else if ("cancel" in request.links?.actions) {
+ modalType = "cancel";
+ }
+ }
+ return (
+
+ {/* {request?.created && {new Date(request.created)?.toLocaleString("cs-CZ")}} */}
+
+ {request?.status ?? i18next.t("No status")}
+ {new Date(request.created)?.toLocaleString("cs-CZ")}
+
+
+ {request.name}
+ {request.description}
+
+
+ }
+ />
+ )
+ })}
+
+ )
+};
+
+RequestList.propTypes = {
+ requests: PropTypes.array.isRequired,
+ requestTypes: PropTypes.array.isRequired,
+ requestModalType: PropTypes.oneOf(["create", "accept", "submit", "cancel"])
+};
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
new file mode 100644
index 00000000..0539cbdc
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
@@ -0,0 +1,62 @@
+import React, { useContext } from "react";
+import PropTypes from "prop-types";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+import { List, Segment, SegmentGroup, Header, Button } from "semantic-ui-react";
+
+import { RequestList } from ".";
+import { RequestContext } from "../contexts";
+
+/**
+ * @typedef {import("../types").Request} Request
+ * @typedef {import("../types").RequestType} RequestType
+ */
+/**
+ * @param {{ requests: Request[], requestTypes: RequestType[] }} props
+ */
+export const RequestListContainer = ({ requestTypes }) => {
+ const TriggerButtonForRequest = ({ onClick, request }) => (
+
+ {/*
+ } />
+ */}
+
+
+ {request.name}
+
+
+ {request.description}
+
+
+
+ );
+
+ const [requests, setRequests] = useContext(RequestContext);
+
+ let requestsToApprove = [];
+ let otherRequests = [];
+ for (const request of requests) {
+ if ("accept" in request.links?.actions) {
+ requestsToApprove.push(request);
+ } else {
+ otherRequests.push(request);
+ }
+ }
+
+ const SegmentGroupOrEmpty = requestsToApprove.length > 0 && otherRequests.length > 0 ? SegmentGroup : <>>;
+
+ return (
+
+
+ {i18next.t("My Requests")}
+
+
+ {requestsToApprove.length > 0 && (
+
+ {i18next.t("Requests to Approve")}
+
+
+ )}
+
+ );
+};
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
new file mode 100644
index 00000000..07bcb2e5
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
@@ -0,0 +1,315 @@
+import React, { useState, useEffect, useContext, useRef } from "react";
+import PropTypes from "prop-types";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+import { Dimmer, Loader, Segment, Modal, Button, Header, Icon, Message, Confirm } from "semantic-ui-react";
+import { isEmpty } from "lodash";
+
+import { useFormik, FormikContext } from "formik";
+import axios from "axios";
+
+import { RequestModalContent, CreateRequestModalContent } from ".";
+import { REQUEST_TYPE } from "../utils/objects";
+import { RequestContext } from "../contexts";
+
+/**
+ * @typedef {import("../types").Request} Request
+ * @typedef {import("../types").RequestType} RequestType
+ * @typedef {import("../types").RequestTypeEnum} RequestTypeEnum
+ * @typedef {import("react").ReactElement} ReactElement
+ * @typedef {import("semantic-ui-react").ConfirmProps} ConfirmProps
+ */
+
+function delay(t, val) {
+ return new Promise(resolve => setTimeout(resolve, t, val));
+}
+
+const mapPayloadUiToInitialValues = (payloadUi) => {
+ const initialValues = { payload: {} };
+ payloadUi?.forEach(section => {
+ section.fields.forEach(field => {
+ initialValues.payload[field.field] = "";
+ });
+ });
+ return initialValues;
+};
+
+/** @param {{ request: Request, requestTypes: RequestType[], requestModalType: RequestTypeEnum, isEventModal: boolean, triggerButton: ReactElement }} props */
+export const RequestModal = ({ request, requestTypes, requestModalType, isEventModal = false, triggerButton }) => {
+ const [modalOpen, setModalOpen] = useState(false);
+ const [error, setError] = useState(null);
+
+ /** @type {[ConfirmProps, (props: ConfirmProps) => void]} */
+ const [confirmDialogProps, setConfirmDialogProps] = useState({
+ open: false,
+ content: i18next.t("Are you sure?"),
+ cancelButton: i18next.t("Cancel"),
+ confirmButton: i18next.t("OK"),
+ onCancel: () => setConfirmDialogProps(props => ({ ...props, open: false })),
+ onConfirm: () => setConfirmDialogProps(props => ({ ...props, open: false }))
+ });
+
+ const errorMessageRef = useRef(null);
+
+ const [requests, setRequests] = useContext(RequestContext);
+
+ const formik = useFormik({
+ initialValues: !isEmpty(request?.payload) ? { payload: request.payload } : mapPayloadUiToInitialValues(request?.payload_ui),
+ onSubmit: (values) => {
+ console.log(values);
+ if (requestModalType === REQUEST_TYPE.SUBMIT) {
+ confirmAction(REQUEST_TYPE.SUBMIT);
+ } else if (requestModalType === REQUEST_TYPE.CREATE) {
+ confirmAction(REQUEST_TYPE.CREATE);
+ }
+ }
+ });
+
+ useEffect(() => {
+ if (error) {
+ errorMessageRef.current?.scrollIntoView({ behavior: "smooth" });
+ }
+ }, [error]);
+
+ const fetchRequests = () => {
+ axios({
+ method: 'get',
+ url: request.links?.self.split('/').slice(0, -1).join('/'), // TODO: link for /api/{record}/requests ??
+ headers: { 'Content-Type': 'application/json' }
+ })
+ .then(response => {
+ console.log(response);
+ setRequests(response.data);
+ })
+ .catch(error => {
+ console.log(error);
+ });
+ }
+
+ const callApi = async (url, method, doNotHandleResolve = false) => {
+ if (doNotHandleResolve) {
+ // return axios({
+ // method: method,
+ // url: url,
+ // data: formik.values,
+ // headers: { 'Content-Type': 'application/json' }
+ // });
+ return delay(1000)
+ }
+ // axios({
+ // method: method,
+ // url: url,
+ // data: formik.values,
+ // headers: { 'Content-Type': 'application/json' }
+ // })
+ return delay(1000)
+ .then(response => {
+ console.log(response);
+ setModalOpen(false);
+ requestModalType !== REQUEST_TYPE.CREATE && fetchRequests(); // TODO: Replace with state update
+ formik.resetForm();
+ })
+ .catch(error => {
+ console.log(error);
+ setError(error);
+ })
+ .finally(() => {
+ formik.setSubmitting(false);
+ });
+ }
+
+ const createAndSubmitRequest = async () => {
+ try {
+ await callApi(request.links.actions?.create, 'post', true);
+ await callApi(request.links.actions?.submit, 'post', true);
+ setModalOpen(false);
+ formik.resetForm();
+ } catch (error) {
+ console.log(error);
+ setError(error);
+ } finally {
+ formik.setSubmitting(false);
+ }
+ }
+
+ const sendRequest = async (requestType, createAndSubmit = false) => {
+ formik.setSubmitting(true);
+ setError(null);
+ if (createAndSubmit) {
+ return createAndSubmitRequest();
+ }
+ if (requestType === REQUEST_TYPE.SAVE) {
+ return callApi(request.links.self, 'put');
+ }
+ return callApi(!isEventModal ? request.links.actions[requestType] : request.links[requestType], 'post');
+ }
+
+ const confirmAction = (requestType, createAndSubmit = false) => {
+ /** @type {ConfirmProps} */
+ let newConfirmDialogProps = {
+ open: true,
+ onConfirm: () => {
+ setConfirmDialogProps(props => ({ ...props, open: false }));
+ sendRequest(requestType);
+ },
+ onCancel: () => {
+ setConfirmDialogProps(props => ({ ...props, open: false }));
+ formik.setSubmitting(false);
+ }
+ };
+
+ switch (requestType) {
+ case REQUEST_TYPE.CREATE:
+ newConfirmDialogProps.header = i18next.t("Create request");
+ break;
+ case REQUEST_TYPE.SUBMIT:
+ newConfirmDialogProps.header = i18next.t("Submit request");
+ break;
+ case REQUEST_TYPE.CANCEL:
+ newConfirmDialogProps.header = i18next.t("Delete request");
+ newConfirmDialogProps.confirmButton = ;
+ break;
+ case REQUEST_TYPE.ACCEPT:
+ newConfirmDialogProps.header = i18next.t("Accept request");
+ newConfirmDialogProps.confirmButton = ;
+ break;
+ case REQUEST_TYPE.DECLINE:
+ newConfirmDialogProps.header = i18next.t("Decline request");
+ newConfirmDialogProps.confirmButton = ;
+ break;
+ default:
+ break;
+ }
+
+ if (createAndSubmit) {
+ console.log("createAndSubmit");
+ newConfirmDialogProps = {
+ ...newConfirmDialogProps,
+ header: i18next.t("Create and submit request"),
+ confirmButton: ,
+ onConfirm: () => {
+ setConfirmDialogProps(props => ({ ...props, open: false }));
+ sendRequest(REQUEST_TYPE.CREATE, createAndSubmit);
+ }
+ }
+ }
+
+ setConfirmDialogProps(props => ({ ...props, ...newConfirmDialogProps }));
+ }
+
+ const onClose = () => {
+ setModalOpen(false);
+ setError(null);
+ formik.resetForm();
+ }
+
+ const extraPreSubmitEvent = (event) => {
+ if (event?.nativeEvent?.submitter?.name === "create-and-submit-request") {
+ confirmAction(REQUEST_TYPE.SUBMIT, true);
+ }
+ }
+
+ return (
+ <>
+ setModalOpen(true)}
+ open={modalOpen}
+ trigger={triggerButton || }
+ closeIcon
+ closeOnDocumentClick={false}
+ closeOnDimmerClick={false}
+ role="dialog"
+ aria-labelledby="request-modal-header"
+ aria-describedby="request-modal-desc"
+ >
+
+
+
+
+
+ {error &&
+
+ {i18next.t("Error sending request")}
+ {error?.message}
+
+ }
+
+ {requestModalType === REQUEST_TYPE.CREATE &&
+ ||
+
+ }
+
+
+
+ {requestModalType === REQUEST_TYPE.SUBMIT &&
+ <>
+
+
+
+ >
+ }
+ {requestModalType === REQUEST_TYPE.CANCEL &&
+
+ }
+ {requestModalType === REQUEST_TYPE.ACCEPT &&
+ <>
+
+
+ >
+ }
+ {requestModalType === REQUEST_TYPE.CREATE && (!isEventModal &&
+ <>
+
+
+ > ||
+ )
+ }
+
+
+
+
+ >
+ );
+};
+
+RequestModal.propTypes = {
+ request: PropTypes.object.isRequired,
+ requestModalType: PropTypes.oneOf(["create", "submit", "cancel", "accept"]).isRequired,
+ requestTypes: PropTypes.array,
+ isEventModal: PropTypes.bool,
+ triggerButton: PropTypes.element,
+};
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
new file mode 100644
index 00000000..77402780
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
@@ -0,0 +1,202 @@
+import React, { useState, useEffect, useContext } from "react";
+import PropTypes from "prop-types";
+
+import { i18next } from "@translations/oarepo_requests_ui/i18next";
+import { Dimmer, Loader, Segment, Modal, Button, Header, Icon, Grid, Input, List, Container, Form, Divider, Message, Comment } from "semantic-ui-react";
+import _isEmpty from "lodash/isEmpty";
+import _sortBy from "lodash/sortBy";
+import { useFormikContext } from "formik";
+import axios from "axios";
+
+import { CustomFields } from "react-invenio-forms";
+
+import { RequestModal } from ".";
+import { RequestContext } from "../contexts";
+import { REQUEST_TYPE } from "../utils/objects";
+import ReadOnlyCustomFields from "./common/ReadOnlyCustomFields";
+
+/**
+ * @typedef {import("../types").Request} Request
+ * @typedef {import("../types").RequestType} RequestType
+ * @typedef {import("../types").RequestTypeEnum} RequestTypeEnum
+ * @typedef {import("../types").Event} Event
+ */
+
+/** @param {{ request: Request, requestType: RequestType, isSidebar: boolean }} props */
+const RequestSideInfo = ({ request, requestType, isSidebar = false }) => {
+ return (
+
+
+
+ {i18next.t("Creator")}
+ {request.created_by?.link && {request.created_by.label} || request.created_by?.label}
+
+
+
+
+ {i18next.t("Receiver")}
+ {request.receiver?.link && {request.receiver?.label} || request.receiver?.label}
+
+
+
+
+ {i18next.t("Request type")}
+ {requestType.name}
+
+
+
+
+ {i18next.t("Created")}
+ {`${Math.ceil(Math.abs(new Date(request?.created) - new Date()) / 3.6e6)} hours ago`}
+
+
+
+ )
+};
+
+/** @param {{ request: Request, requestModalType: RequestTypeEnum, requestTypes: RequestType[] }} props */
+export const RequestModalContent = ({ request, requestTypes, requestModalType }) => {
+ /** @type {[Request[], (requests: Request[]) => void]} */
+ const [requests, setRequests] = useContext(RequestContext);
+
+ useEffect(() => {
+ axios
+ .get(request.links?.events, { headers: { 'Content-Type': 'application/json' } })
+ .then(response => {
+ setRequests(requests => requests.map(req => {
+ if (req.uuid === request.uuid) {
+ req.events = response.data;
+ }
+ return req;
+ }));
+ })
+ .catch(error => {
+ console.log(error);
+ });
+ }, []);
+
+ const actualRequest = requests.find(req => req.uuid === request.uuid);
+
+ const requestType = requestTypes.find(requestType => requestType.id === request.type);
+ const payloadUI = requestType?.payload_ui;
+ const eventTypes = requestType?.event_types;
+
+ /** @type {Event[]} */
+ let events = [];
+ if (!_isEmpty(request?.events)) {
+ events = _sortBy(request.events, ['updated']);
+ } else if (!_isEmpty(actualRequest?.events)) {
+ events = _sortBy(actualRequest.events, ['updated']);
+ }
+
+ const renderSubmitForm = requestModalType === REQUEST_TYPE.SUBMIT && payloadUI;
+ const renderReadOnlyData = (requestModalType === REQUEST_TYPE.ACCEPT || requestModalType === REQUEST_TYPE.CANCEL) && request?.payload;
+
+ const { isSubmitting, isValid, handleSubmit } = useFormikContext();
+
+ return (
+
+
+
+ {request.description}
+
+
+ {(renderSubmitForm || renderReadOnlyData) &&
+
+
+
+
+
+ {renderSubmitForm &&
+
+ }
+ {renderReadOnlyData &&
+ <>
+
+ {Object.keys(request.payload).map(key => (
+
+
+ {key}
+ import(`../components/common/${widget}.jsx`),
+ (widget) => import(`react-invenio-forms`)
+ ]}
+ />
+
+
+ ))}
+
+ {!_isEmpty(eventTypes) &&
+ <>
+ {i18next.t("Timeline")}
+ {!_isEmpty(events) &&
+
+ {events.map(event => {
+ const eventPayloadUI = eventTypes.filter(eventType => eventType.id === event.type_code)[0]?.payload_ui;
+ return (
+
+
+ {event.created_by.label}
+
+ {new Date(event?.created)?.toLocaleString("cs-CZ")}
+
+
+ import(`./${widget}.jsx`),
+ (widget) => import(`react-invenio-forms`)
+ ]}
+ // fieldPathPrefix="payload"
+ />
+
+
+
+ )
+ })}
+
+ }
+ {eventTypes.map(event => (
+ } />
+ ))}
+ >
+ }
+ >
+ }
+
+
+
+
+ ||
+
+
+
+
+
+ }
+
+ );
+}
+
+RequestModalContent.propTypes = {
+ request: PropTypes.object.isRequired,
+ requestTypes: PropTypes.array.isRequired,
+};
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/DefaultView.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/DefaultView.jsx
new file mode 100644
index 00000000..26e2ec47
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/DefaultView.jsx
@@ -0,0 +1,6 @@
+import React from "react";
+import PropTypes from "prop-types";
+
+export default function DefaultView({ props, value }) {
+ return {value}
+}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx
new file mode 100644
index 00000000..972f14b2
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx
@@ -0,0 +1,89 @@
+// This file is part of React-Invenio-Forms
+// Copyright (C) 2022 CERN.
+// Copyright (C) 2022 Northwestern University.
+//
+// React-Invenio-Forms is free software; you can redistribute it and/or modify it
+// under the terms of the MIT License; see LICENSE file for more details.
+
+import React, { useEffect, useState } from "react";
+import PropTypes from "prop-types";
+import { loadWidgetsFromConfig } from "../../utils/loader";
+import _has from "lodash/has";
+import _zip from "lodash/zip";
+
+const ReadOnlyCustomFields = ({
+ config,
+ data,
+ fieldPathPrefix,
+ templateLoaders,
+ includesPaths = (fields) => fields.map((field) => field.key)
+}) => {
+ const [sections, setSections] = useState([]);
+
+ const loadCustomFieldsWidgets = async () => {
+ const sections = [];
+ for (const sectionCfg of config) {
+ const usedFields = sectionCfg.fields.filter((field) => _has(data, field.field));
+ const Widgets = await loadWidgetsFromConfig({
+ templateLoaders: templateLoaders,
+ fieldPathPrefix: fieldPathPrefix,
+ fields: usedFields,
+ });
+ const widgetsWithConfig = _zip(Widgets, usedFields);
+ const filteredFieldsWithData = widgetsWithConfig
+ .map(([Widget, fieldConfig]) => {
+ const value = data[fieldConfig.field];
+ return ;
+ });
+ sections.push({ ...sectionCfg, fields: filteredFieldsWithData });
+ }
+ return sections;
+ };
+
+ useEffect(() => {
+ loadCustomFieldsWidgets()
+ .then((sections) => {
+ sections = sections.map((sectionCfg) => {
+ const paths = includesPaths(sectionCfg.fields, fieldPathPrefix);
+ return { ...sectionCfg, paths };
+ });
+ setSections(sections);
+ })
+ .catch((error) => {
+ console.error("Couldn't load custom fields widgets.", error);
+ });
+ }, [config, fieldPathPrefix, includesPaths, templateLoaders]);
+
+ return (
+ <>
+ {sections.map(({ section, fields, paths }) => (
+ {fields}
+ ))}
+ >
+ );
+};
+
+ReadOnlyCustomFields.propTypes = {
+ config: PropTypes.arrayOf(
+ PropTypes.shape({
+ section: PropTypes.string.isRequired,
+ fields: PropTypes.arrayOf(
+ PropTypes.shape({
+ field: PropTypes.string.isRequired,
+ view_widget: PropTypes.string,
+ view_widget_props: PropTypes.object,
+ })
+ ),
+ })
+ ),
+ data: PropTypes.object.isRequired, // { field1: value1, field2: value2, ...} just like Formik initialValues
+ templateLoaders: PropTypes.array.isRequired,
+ fieldPathPrefix: PropTypes.string,
+ includesPaths: PropTypes.func,
+};
+
+ReadOnlyCustomFields.defaultProps = {
+ includesPaths: (fields) => fields.map((field) => field.key),
+};
+
+export default ReadOnlyCustomFields;
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js
new file mode 100644
index 00000000..4e98fdd0
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js
@@ -0,0 +1,3 @@
+export { default as ReadOnlyCustomFields } from "./ReadOnlyCustomFields";
+export { default as DefaultView } from "./DefaultView";
+export { default as StaticText } from "./StaticText";
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js
new file mode 100644
index 00000000..0880c0d3
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js
@@ -0,0 +1,8 @@
+export { RequestListContainer } from "./RequestListContainer";
+export { CreateRequestButtonGroup } from "./CreateRequestButtonGroup";
+export { RequestModal } from "./RequestModal";
+export { TriggerButton } from "./TriggerButton";
+export { RecordRequests } from "./RecordRequests";
+export { RequestModalContent } from "./RequestModalContent";
+export { CreateRequestModalContent } from "./CreateRequestModalContent";
+export { RequestList } from "./RequestList";
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RequestContext.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RequestContext.jsx
new file mode 100644
index 00000000..ce71376f
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RequestContext.jsx
@@ -0,0 +1,11 @@
+import React, { createContext } from "react";
+
+export const RequestContext = createContext();
+
+export const RequestContextProvider = ({ children, requests }) => {
+ return (
+
+ {children}
+
+ );
+};
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js
new file mode 100644
index 00000000..abf50903
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js
@@ -0,0 +1 @@
+export { RequestContext, RequestContextProvider } from './RequestContext';
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
new file mode 100644
index 00000000..35bd673d
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
@@ -0,0 +1,607 @@
+export default {
+ "id": "36s8e-qwz66",
+ "created": "2024-01-08T09:37:15.726599+00:00",
+ "updated": "2024-01-08T09:37:15.761771+00:00",
+ "links": {
+ "files": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/files",
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66",
+ "self_html": "https://127.0.0.1:5000/theses/36s8e-qwz66"
+ },
+ "revision_id": 2,
+ "$schema": "local://uct_theses-1.0.0.json",
+ "metadata": {
+ "abstract": [
+ {
+ "lang": "cs",
+ "value": "Byla připravena série kvarterních flaviniových solí: 5-ethyl-3,7,8,10-\r\n-tetramethylisoalloxazinium-perchlorát (2a), 10-butyl-5-ethyl-3,7,8-\r\n-trimethylisoalloxazinium-perchlorát (2b), 5-ethyl-3,7,8-trimethyl-10-oktyl-isoalloxazinium-perchlorát (2c) a 10-dodecyl-5-ethyl-3,7,8-trimethylisoalloxazinium-\r\n-perchlorát (2d). Připravené isoalloxaziniové soli 2a-d byly studovány jako katalyzátory oxidace sulfidů na sulfoxidy peroxidem vodíku v různých typech micel: v anionických micelách dodecylsulfátu sodného (SDS), v kationických micelách hexadecyltrimethylamonium-chloridu (CTAC) a hexadecyltrimethylamonium-nitrátu (CTANO3) a v neionických micelách polyoxyethylen(23)(dodecyl)etheru (Brij 35). Pro porovnání byl ve vodě rozpustný derivát 2a testován také v homogenním prostředí (ve směsi methanol-voda 1 : 1). Ve všech micelárních prostředích byl studován vliv pH reakčního prostředí a lipofility isoalloxaziniových solí 2 na jejich katalytickou účinnost měřením rychlosti oxidace modelového substrátu, thioanisolu (9), v přítomnosti katalytického množství soli 2. V micelách SDS byla oxidace provedena také v semipreparativním měřítku."
+ },
+ {
+ "lang": "en",
+ "value": "Series of quaternary flavinium salts: 5-ethyl-3,7,8,10-tetramethylisoalloxazinium perchlorate (2a), 10-butyl-5-ethyl-3,7,8-trimethylisoalloxazinium perchlorate (2b), \r\n5-ethyl-3,7,8-trimethyl-10-oktyl-isoalloxazinium perchlorate (2c) and 10-dodecyl-5-\r\n-ethyl-3,7,8-trimethylisoalloxazinium perchlorate (2d) was prepared. Flavinium salts 2a-d were studied as catalysts for oxidation of sulfides to sulfoxides with hydrogen peroxide in several micellar systems: in anionic micelles of sodium dodecylsulfate (SDS), in cationic micelles of hexadecyltrimethylammonium chloride (CTAC) and hexadecyltrimethylammonium nitrate (CTANO3), and in non-ionic micelles formed by polyoxyethylene(23)dodecyl ether (Brij 35). For comparison, water-soluble derivative 2a was also tested in homogeneous solution (in the mixture methanol-water 1 : 1). In all micellar systems, the effect of pH of reaction medium and lipophilicity of isoalloxazinium salts on their catalytic efficiency was tested by measuring the rate of model substrate (thioanisole (9)) oxidation in the presence of a catalytic amount of flavinium salt 2. In SDS micelles, sulfoxidation was performed also in semipreparative scale."
+ }
+ ],
+ "accessRights": {
+ "id": "c_abf2",
+ "@v": "199a114b-2933-4905-8a76-015ee4cc7f06::1",
+ "title": {
+ "cs": "otevřený přístup",
+ "en": "open access"
+ }
+ },
+ "accessibility": [
+ {
+ "lang": "cs",
+ "value": "Text práce je k nahlédnutí na ústavu, kde byla práce vypracována. Další dokumenty jsou uloženy v archivu VŠCHT Praha."
+ },
+ {
+ "lang": "en",
+ "value": "The printed version of the thesis is available at the department where the thesis was produced. Defence protocol and reviews are available at UCT Prague archive."
+ }
+ ],
+ "additionalTitles": [
+ {
+ "title": {
+ "lang": "en",
+ "value": "Synthesis and investigation of amphiphilic flavinium salts as sulfoxidation catalysts//in micellar solutions"
+ },
+ "titleType": "translatedTitle"
+ }
+ ],
+ "contributors": [
+ {
+ "fullName": "prof. Ing. Radek Cibulka, Ph.D.",
+ "nameType": "Personal",
+ "role": {
+ "id": "advisor",
+ "@v": "42e623d6-f9f9-4ece-8db9-434a495d91c1::1",
+ "title": {
+ "cs": "vedoucí",
+ "en": "advisor"
+ }
+ }
+ },
+ {
+ "fullName": "prof. Ing. Jan Šmidrkal, CSc.",
+ "nameType": "Personal",
+ "role": {
+ "id": "referee",
+ "@v": "c5b87187-8d0b-4de8-aec9-ae19047e1bee::1",
+ "title": {
+ "cs": "oponent",
+ "en": "referee"
+ }
+ }
+ }
+ ],
+ "creators": [
+ {
+ "fullName": "Ing. Lenka Baxová",
+ "nameType": "Personal"
+ }
+ ],
+ "dateAvailable": "2007-10-11",
+ "dateModified": "2007-10-11",
+ "languages": [
+ {
+ "id": "cs",
+ "@v": "590f1c0e-d9c6-4179-bf3c-83b31b4b3803::1",
+ "title": {
+ "cs": "čeština",
+ "en": "Czech"
+ }
+ }
+ ],
+ "resourceType": {
+ "id": "master",
+ "@v": "b96ee94b-fef1-49c1-8840-841add31339b::1",
+ "title": {
+ "cs": "Diplomová práce",
+ "en": "Master thesis"
+ }
+ },
+ "systemIdentifiers": [
+ {
+ "scheme": "catalogueSysNo",
+ "identifier": "4701"
+ }
+ ],
+ "title": "Syntéza a studium amfifilních flaviniových solí jako katalyzátorů oxidace sulfidů//v micelárních roztocích",
+ "collection": "22310",
+ "thesis": {
+ "dateDefended": "2007-06-01",
+ "defended": true
+ },
+ "sis": {
+ "did": 4701,
+ "timestamp": "2007-10-11T15:11:24"
+ }
+ },
+ "files": {
+ "enabled": true
+ },
+ "requests": [
+ {
+ "name": "pridel doi",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "uuid": "ed181799-26c5-4269-b032-4a2a4624eb9d",
+ "type": "assign_doi",
+ "links": {
+ "actions": {
+ "submit": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/actions/submit",
+ "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/actions/cancel"
+ },
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d",
+ "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/html",
+ "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/events" // TODO: Shouldn't this be more specific event like "comments"?
+ },
+ "created_by": {
+ "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
+ "type": "user",
+ "label": "Ron",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ },
+ "receiver": {
+ "reference": {
+ "id": "f40d6c41-3aa1-42be-a185-f8a0a125c815"
+ },
+ "type": "community",
+ "label": "cesnet",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c815"
+ },
+ "topic": {
+ "reference": {
+ "id": "36s8e-qwz66"
+ },
+ "type": "record",
+ "label": "title recordu",
+ "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
+ },
+ "status_code": "draft",
+ "status": "Vytvořeno",
+ "created": "2024-01-08T09:37:15.726599+00:00",
+ "updated": "2024-01-08T09:37:15.761771+00:00",
+ "payload": {
+ "name": "pridel doi",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "request_text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam fringilla tortor nibh, sed sagittis lorem congue ac. Aliquam ante mauris, porttitor eu ornare ut, feugiat sit amet diam. Maecenas ut sem mi. Maecenas elementum, elit mollis vestibulum cursus, nisi ex commodo neque, id ultrices felis ligula eget massa. Integer vel justo et ligula dapibus ultrices. Nullam ultricies sed neque sed lacinia. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent sed lectus ut diam sollicitudin malesuada a quis nibh. In tempus nibh ex, tincidunt tempus enim rutrum id. Aliquam laoreet dictum enim in vestibulum. Nam sagittis, turpis at pretium maximus, odio nibh venenatis risus, eu tempus tortor nibh id ante. Vestibulum aliquam, quam ac gravida fringilla, risus leo fermentum nunc, in fringilla magna urna a turpis. Cras sed metus vel metus lacinia auctor. In sed maximus risus, at euismod urna. Donec mi velit, euismod non orci id, pharetra eleifend tortor."
+ }
+ },
+ {
+ "name": "pridel doi 2",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "uuid": "ed181799-26c5-4269-b032-4a2a4624eb9e",
+ "type": "assign_doi",
+ "links": {
+ "actions": {
+ "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4269-b032-4a2a4624eb9e/actions/cancel"
+ },
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9e",
+ "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9e/html",
+ "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9e/events"
+ },
+ "created_by": {
+ "reference": "6c3f6437-9197-490c-9584-d2daa5143dcg",
+ "type": "user",
+ "label": "Ron",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcg"
+ },
+ "receiver": {
+ "reference": {
+ "id": "f40d6c41-3aa1-42be-a185-f8a0a125c816"
+ },
+ "type": "community",
+ "label": "cesnet",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c816"
+ },
+ "topic": {
+ "reference": {
+ "id": "36s8e-qwz66"
+ },
+ "type": "record",
+ "label": "title recordu",
+ "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
+ },
+ "status_code": "submitted",
+ "status": "Zažádáno",
+ "created": "2024-01-09T09:37:15.726599+00:00",
+ "updated": "2024-01-09T09:37:15.761771+00:00"
+ },
+ {
+ "name": "pridel doi 3",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "uuid": "ed181799-26c5-po69-b032-4a2a4664eb9e",
+ "type": "assign_doi",
+ "links": {
+ "actions": {
+ "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-po69-b032-4a2a4664eb9e/actions/cancel"
+ },
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-po69-b032-4a2a4664eb9e",
+ "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-po69-b032-4a2a4664eb9e/html",
+ "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-po69-b032-4a2a4664eb9e/events"
+ },
+ "created_by": {
+ "reference": "6c3f6437-9197-490c-9584-d2daa5143dcg",
+ "type": "user",
+ "label": "Ron",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcg"
+ },
+ "receiver": {
+ "reference": {
+ "id": "f40d6c41-3aa1-42be-a185-f8a0a125c816"
+ },
+ "type": "community",
+ "label": "cesnet",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c816"
+ },
+ "topic": {
+ "reference": {
+ "id": "36s8e-qwz66"
+ },
+ "type": "record",
+ "label": "title recordu",
+ "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
+ },
+ "status_code": "submitted",
+ "status": "Zažádáno",
+ "created": "2024-01-09T09:37:15.726599+00:00",
+ "updated": "2024-01-09T09:37:15.761771+00:00"
+ },
+ {
+ "name": "pridel doi 4",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "uuid": "ed181799-26c5-4226-bsf32-4a2a4624eb9d",
+ "type": "assign_doi",
+ "links": {
+ "actions": {
+ "accept": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/actions/accept",
+ "decline": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/actions/decline"
+ },
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d",
+ "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/html",
+ "events": "https://9c2a4912-c1a0-48f8-9565-e772482c6e92.mock.pstmn.io/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/events"
+ },
+ "created_by": {
+ "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
+ "type": "user",
+ "label": "Ron",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ },
+ "receiver": {
+ "reference": {
+ "id": "f40d6c41-3aa1-42be-a185-f8a0a125c815"
+ },
+ "type": "community",
+ "label": "cesnet",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c815"
+ },
+ "topic": {
+ "reference": {
+ "id": "36s8e-qwz66"
+ },
+ "type": "record",
+ "label": "title recordu",
+ "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
+ },
+ "status_code": "submitted",
+ "status": "Zažádáno",
+ "created": "2024-01-08T09:37:15.726599+00:00",
+ "updated": "2024-01-08T09:37:15.761771+00:00",
+ "payload": {
+ "name": "pridel doi",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "request_text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam fringilla tortor nibh, sed sagittis lorem congue ac. Aliquam ante mauris, porttitor eu ornare ut, feugiat sit amet diam. Maecenas ut sem mi. Maecenas elementum, elit mollis vestibulum cursus, nisi ex commodo neque, id ultrices felis ligula eget massa. Integer vel justo et ligula dapibus ultrices. Nullam ultricies sed neque sed lacinia. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent sed lectus ut diam sollicitudin malesuada a quis nibh. In tempus nibh ex, tincidunt tempus enim rutrum id. Aliquam laoreet dictum enim in vestibulum. Nam sagittis, turpis at pretium maximus, odio nibh venenatis risus, eu tempus tortor nibh id ante. Vestibulum aliquam, quam ac gravida fringilla, risus leo fermentum nunc, in fringilla magna urna a turpis. Cras sed metus vel metus lacinia auctor. In sed maximus risus, at euismod urna. Donec mi velit, euismod non orci id, pharetra eleifend tortor."
+ },
+ // "events": [
+ // {
+ // "payload": {
+ // "comment": "hello world"
+ // },
+ // "created": "2024-01-08T09:37:15.726599+00:00",
+ // "created_by": {
+ // "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
+ // "type": "user",
+ // "label": "Ron",
+ // "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ // },
+ // "updated": "2024-01-08T09:37:15.726599+00:00",
+ // "revision_id": 1,
+ // "id": "53c6a7fd-6a07-41a7-8996-46852267elk0",
+ // "type_code": "C",
+ // "type": "Comment",
+ // "links": {
+ // "self": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ // },
+ // "permissions": {
+ // "can_update_comment": true,
+ // "can_delete_comment": true
+ // }
+ // },
+ // {
+ // "payload": {
+
+ // },
+ // "created": "2024-01-08T09:37:15.726599+00:00",
+ // "created_by": {
+ // "reference": "6c3f6437-9197-490c-9ki9-d2daa5143dcf",
+ // "type": "user",
+ // "label": "Ron",
+ // "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ // },
+ // "updated": "2024-01-08T09:37:15.726599+00:00",
+ // "revision_id": 1,
+ // "id": "53c6a7fd-6a07-41a7-8996-46852267e940",
+ // "type_code": "P",
+ // "type": "Znalecký posudek",
+ // "links": {
+ // "self": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ // },
+ // "permissions": {
+ // "can_update_comment": true,
+ // "can_delete_comment": true
+ // }
+ // }
+ // ]
+ },
+ {
+ "name": "pridel doi 6",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "uuid": "ed129799-26c5-4269-b032-4a2a4624lo9d",
+ "type": "assign_doi",
+ "links": {
+ "actions": {
+ "submit": "https://127.0.0.1:5000/api/uct-theses/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/actions/submit",
+ "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/actions/cancel"
+ },
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d", // PUT request: override existing record
+ "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/html",
+ "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/events"
+ },
+ "created_by": {
+ "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
+ "type": "user",
+ "label": "Ron",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
+ },
+ "receiver": {
+ "reference": {
+ "id": "f40d6c41-3aa1-42be-a185-f8a0a125c815"
+ },
+ "type": "community",
+ "label": "cesnet",
+ "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c815"
+ },
+ "topic": {
+ "reference": {
+ "id": "36s8e-qwz66"
+ },
+ "type": "record",
+ "label": "title recordu",
+ "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
+ },
+ "status_code": "draft",
+ "status": "Vytvořeno",
+ "created": "2024-01-08T09:37:15.726599+00:00",
+ "updated": "2024-01-08T09:37:15.761771+00:00"
+ }
+ ],
+ "request_types": [
+ {
+ "name": "pridel doi",
+ "description": "Pridel DOI k objektu 36s8e-qwz66",
+ "id": "assign_doi",
+ "links": {
+ "actions": {
+ "create": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/assign_doi/create"
+ }
+ },
+ "fast_approve": true,
+ "payload_ui": [
+ {
+ "section": "General info",
+ "fields": [
+ {
+ "field": "name",
+ "ui_widget": "Input",
+ // "editable": ["requestor"],
+ "props": {
+ "readonly": "true",
+ "label": "name",
+ "placeholder": "name",
+ "icon": "text cursor",
+ "required": true
+ },
+ "view_widget": "StaticText",
+ "view_widget_props": {
+ "label": "name",
+ "icon": "text cursor",
+ }
+ },
+ {
+ "field": "description",
+ "ui_widget": "RichInput",
+ "props": {
+ "label": "description",
+ "placeholder": "description",
+ "icon": "text height",
+ "required": true
+ },
+ "view_widget": "StaticText",
+ "view_widget_props": {
+ "label": "name",
+ "icon": "text cursor",
+ }
+ },
+ {
+ "field": "request_text",
+ "ui_widget": "RichInput",
+ "props": {
+ "label": "Request Text",
+ "placeholder": "request text",
+ "icon": "text height",
+ "required": true
+ },
+ "view_widget": "StaticText",
+ "view_widget_props": {
+ "label": "name",
+ "icon": "text cursor",
+ }
+ },
+ // {
+ // "field": "comment",
+ // "ui_widget": "RichInput",
+ // "editable": ["requestor", "approver"],
+ // "props": {
+ // "label": "description",
+ // "placeholder": "description",
+ // "icon": "text height",
+ // "required": true
+ // }
+ // },
+ // {
+ // "field": "internal_comment",
+ // "ui_widget": "RichInput",
+ // "visible": ["approver"],
+ // "editable": ["approver"],
+ // "props": {
+ // "label": "description",
+ // "placeholder": "description",
+ // "icon": "text height",
+ // "required": true
+ // }
+ // }
+ ]
+ }
+ ],
+ "event_types": [
+ {
+ "name": "Comment",
+ "description": "Comment on request",
+ "id": "C",
+ "links": {
+ "create": "https://127.0.0.1:5000/api/uct-theses/requests/assign_doi/comments"
+ }, // only if current user can create new event of this type
+ "payload_ui": [
+ {
+ "section": "Comment",
+ "fields": [
+ {
+ "field": "comment",
+ "ui_widget": "RichInput",
+ "props": {
+ "label": "description",
+ "placeholder": "description",
+ "icon": "text height",
+ "required": true
+ },
+ "view_widget": "StaticText",
+ "view_widget_props": {
+ "label": "name",
+ "icon": "text cursor",
+ }
+ },
+ ],
+ }
+ ]
+ },
+ {
+ "name": "Znalecký posudek",
+ "description": "Znalecký posudek na 36s8e-qwz66",
+ "id": "P",
+ "links": {
+ "create": "https://127.0.0.1:5000/api/uct-theses/requests/assign_doi/expert_opinion" // TODO: How to connect Event to specific request?
+ }, // only if current user can create new event of this type
+ "payload_ui": [
+ {
+ "section": "Informace o znaleckém posudku",
+ "fields": [
+ {
+ "field": "expert_opinion",
+ "ui_widget": "RichInput",
+ "props": {
+ "label": "description",
+ "placeholder": "description",
+ "icon": "text height",
+ "required": true
+ },
+ "view_widget": "FileViewWidget",
+ "view_widget_props": {
+ "label": "file",
+ "icon": "file",
+ }
+ },
+ ],
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "ask permission",
+ "description": "Ak permission for 36s8e-qwz66",
+ "id": "ask_permission",
+ "links": {
+ "actions": {
+ "create": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ask_permission/create"
+ }
+ },
+ "fast_approve": true,
+ "payload_ui": [
+ {
+ "section": "General info",
+ "fields": [
+ {
+ "field": "name",
+ "ui_widget": "Input",
+ "editable": ["requestor"],
+ "props": {
+ "readonly": "true",
+ "label": "name",
+ "placeholder": "name",
+ "icon": "text cursor",
+ "required": true
+ }
+ },
+ {
+ "field": "description",
+ "ui_widget": "RichInput",
+ "props": {
+ "label": "description",
+ "placeholder": "description",
+ "icon": "text height",
+ "required": true
+ }
+ },
+ ]
+ }
+ ],
+ "event_types": [
+ {
+ "name": "Comment",
+ "description": "Comment on request",
+ "id": "C",
+ "links": {
+ "create": "https://127.0.0.1:5000/api/uct-theses/requests/ask_permission/comments" // TODO: How to connect Event to specific request?
+ }, // only if current user can create new event of this type
+ "payload_ui": [
+ {
+ "section": "Comment",
+ "fields": [
+ {
+ "field": "comment",
+ "ui_widget": "RichInput",
+ "editable": ["requestor", "approver"],
+ "props": {
+ "label": "description",
+ "placeholder": "description",
+ "icon": "text height",
+ "required": true
+ }
+ },
+ ],
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
new file mode 100644
index 00000000..b5b73c1e
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
@@ -0,0 +1,17 @@
+import React from "react";
+import ReactDOM from "react-dom";
+
+import { RecordRequests } from "./components";
+
+import dummyRecord from "./dummy-record.js";
+
+const recordRequestsAppDiv = document.getElementById("record-requests");
+
+let record = JSON.parse(recordRequestsAppDiv.dataset.record)?.requests || dummyRecord;
+
+ReactDOM.render(
+ ,
+ recordRequestsAppDiv
+);
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/types.d.ts b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/types.d.ts
new file mode 100644
index 00000000..94dbd401
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/types.d.ts
@@ -0,0 +1,106 @@
+export interface Request {
+ name: string;
+ description: string;
+ uuid: string;
+ type: string;
+ links: Links;
+ created_by: Creator;
+ receiver: Receiver;
+ topic: Receiver;
+ created: string; // Datetime
+ updated: string; // Datetime
+ events?: Event[];
+}
+
+export interface Links {
+ actions?: RequestActions;
+ self: string;
+ self_html?: string;
+ events?: string;
+}
+
+export interface RequestActions {
+ create?: string;
+ submit?: string;
+ cancel?: string;
+ accept?: string;
+ decline?: string;
+ expire?: string;
+ delete?: string;
+}
+
+export interface Creator {
+ reference: string;
+ type: string;
+ label: string;
+ link: string;
+}
+
+export interface Receiver {
+ reference: Reference;
+ type: Type;
+ label: Label;
+ link: string;
+}
+
+export interface Reference {
+ id: string;
+}
+
+export interface RequestType {
+ name: string;
+ description: string;
+ id: string;
+ links: Links;
+ fast_approve?: boolean;
+ payload_ui?: PayloadUI[];
+ event_types?: EventType[];
+}
+
+export interface PayloadUI {
+ section: string;
+ fields: Field[];
+}
+
+export interface Field {
+ field: string;
+ ui_widget: "Input" | "NumberInput" | "MultiInput" | "RichInput" | "TextArea" | "Dropdown" | "AutocompleteDropdown" | "BooleanCheckbox";
+ visible: ("requestor" | "approver")[];
+ editable: ("requestor" | "approver")[];
+ props: React.ComponentProps;
+}
+
+export interface EventType {
+ name: string;
+ description: string;
+ id: string;
+ links: Links;
+ payload_ui?: PayloadUI[];
+}
+
+export interface Event {
+ payload: any;
+ created: string; // Datetime
+ created_by: Creator;
+ updated: string; // Datetime
+ revision_id: number;
+ id: string;
+ type_code: string;
+ type: string;
+ links: Links;
+ permissions: Permissions;
+}
+
+export interface Permissions {
+ can_update_comment: boolean;
+ can_delete_comment: boolean;
+}
+
+export enum RequestTypeEnum {
+ CREATE = "create",
+ SUBMIT = "submit",
+ CANCEL = "cancel",
+ ACCEPT = "accept",
+ DECLINE = "decline",
+ SAVE = "save",
+}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/loader.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/loader.js
new file mode 100644
index 00000000..8d827164
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/loader.js
@@ -0,0 +1,87 @@
+import React from "react";
+import DefaultView from "../components/common/DefaultView";
+
+/** Import function to load widget either from a specific path or local widgets
+ *
+ * The user defined path to import widget is of the format `@templates/`.
+ * Note that the `@template` alias should be a correctly resolving path and it's the
+ * user of this function that has to ensure that. The value is hardcoded here as the
+ * dynamic import cannot rely on purely a dynamic path i.e a variable.
+ */
+export async function importWidget(
+ templateLoaders,
+ { view_widget: UIWidget, fieldPath, view_widget_props: props }
+) {
+ let component = undefined;
+
+ // Try import widget from user's defined templateLoaders
+ for (const loader of templateLoaders) {
+ try {
+ const module = await loader(UIWidget);
+ component = module.default ?? module[UIWidget];
+ // Component was found, stop looking.
+ if (component) {
+ return component;
+ }
+ } catch (error) {
+ // If the component failed to load from a loader, try other loaders first.
+ continue;
+ }
+ }
+
+ return DefaultView;
+}
+
+/**
+ * @param config: Configuration to load widgets
+ *
+ * Example configuration
+ *
+ * {
+ * fieldPathPrefix: "mynamespace" or empty,
+ * templateLoader: UIWidget => import(`my_folder/${UIWidget}.js`),
+ * fields: [{
+ * ui_widget: "MyWidget",
+ * field: "field_id",
+ * props: {
+ * label: "My label"
+ * }
+ * }]
+ * }
+ *
+ * @returns array fields: resolved react components
+ *
+ * Example return
+ *
+ * [
+ * ,
+ * ...
+ * ]
+ *
+ */
+export async function loadWidgetsFromConfig({
+ templateLoaders,
+ fieldPathPrefix,
+ fields,
+}) {
+ const importWidgetsFromFolder = (templateFolder, fieldPathPrefix, fieldsConfig) => {
+ const tplPromises = [];
+ fieldsConfig.forEach((fieldCfg) => {
+ tplPromises.push(
+ importWidget(templateFolder, {
+ ...fieldCfg,
+ fieldPath: fieldPathPrefix
+ ? `${fieldPathPrefix}.${fieldCfg.field}`
+ : fieldCfg.field,
+ })
+ );
+ });
+ return Promise.all(tplPromises);
+ };
+ const _fields = await importWidgetsFromFolder(
+ templateLoaders,
+ fieldPathPrefix,
+ fields
+ );
+ return [..._fields];
+}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/objects.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/objects.js
new file mode 100644
index 00000000..512d0b08
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/objects.js
@@ -0,0 +1,8 @@
+export const REQUEST_TYPE = {
+ CREATE: 'create',
+ SUBMIT: 'submit',
+ CANCEL: 'cancel',
+ ACCEPT: 'accept',
+ DECLINE: 'decline',
+ SAVE: 'save',
+}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/custom-components.less b/oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/custom-components.less
new file mode 100644
index 00000000..525c082f
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/custom-components.less
@@ -0,0 +1,8 @@
+/*
+ * In this file you will import the less files for your component.
+
+ The file name of the component is sample.less, note that the extension is not written here.
+*/
+/*
+ & { @import "./definitions/sample"; }
+*/
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/definitions/sample.less b/oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/definitions/sample.less
new file mode 100644
index 00000000..02603740
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/less/oarepo_requests/definitions/sample.less
@@ -0,0 +1,50 @@
+/*******************************
+ Theme
+*******************************/
+
+/*
+ The type is the type of the component as defined in semantic-ui - element, collection, view, module
+ For simple component, 'element' is the correct type
+*/
+@type : 'element';
+
+/*
+ This is the name of the component - though not required, keep it the same as the filename
+*/
+@element : 'sample';
+
+/*******************************
+
+ DO NOT FORGET !!!
+
+Edit *theme.config* in your site
+and add (replace 'sample' with the
+name of the component from above)
+
+@sample : 'default';
+
+
+Edit *theme.less* in your site
+and add the imports for your component
+library there. See the commented out
+chunks for details.
+
+*******************************/
+
+
+@import (multiple) '../../theme.config';
+
+/*
+ This is the styling of your component. The class should start with .ui.
+
+ Note: use variables here, not the exact values. Placing the values to another file (sample.variables)
+ will allow users to override these values.
+ */
+.ui.sample {
+ color: @sampleColor;
+}
+
+/*
+ This will load the overrides, enabling the user of your component to override your css if required
+ */
+.loadUIOverrides();
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/webpack.py b/oarepo_requests/ui/theme/webpack.py
new file mode 100644
index 00000000..f4b964be
--- /dev/null
+++ b/oarepo_requests/ui/theme/webpack.py
@@ -0,0 +1,19 @@
+from invenio_assets.webpack import WebpackThemeBundle
+
+theme = WebpackThemeBundle(
+ __name__,
+ "assets",
+ default="semantic-ui",
+ themes={
+ "semantic-ui": dict(
+ entry={
+ "oarepo_requests_ui_record_requests": "./js/oarepo_requests_ui/record-requests/index.js",
+ },
+ dependencies={},
+ devDependencies={},
+ aliases={
+ "@translations/oarepo_requests_ui": "translations/oarepo_requests",
+ },
+ )
+ },
+)
diff --git a/setup.cfg b/setup.cfg
index 9a29f03f..cff0d0b9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -29,3 +29,6 @@ tests =
oarepo-model-builder-requests
oarepo-model-builder-drafts
+[options.entry_points]
+invenio_assets.webpack =
+ oarepo_requests_ui_theme = oarepo_requests.ui.theme.webpack:theme
From 5d1f5e1a9a07d4789953d7c062a46ab4e96f3933 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Thu, 1 Feb 2024 11:40:07 +0100
Subject: [PATCH 02/41] Update UI components
---
.gitignore | 2 +
.../oarepo_requests_ui/RecordRequests.jinja | 7 +-
.../components/CreateRequestModalContent.jsx | 2 +-
.../components/RecordRequests.jsx | 21 +++---
.../components/RequestList.jsx | 4 +-
.../components/RequestListContainer.jsx | 16 -----
.../components/RequestModal.jsx | 14 ++--
.../components/RequestModalContent.jsx | 9 ++-
.../common/ReadOnlyCustomFields.jsx | 7 --
.../components/common/index.js | 3 +-
.../record-requests/components/index.js | 1 -
.../contexts/RecordContext.jsx | 11 ++++
.../record-requests/contexts/index.js | 3 +-
.../record-requests/dummy-record.js | 65 +++----------------
.../record-requests/index.js | 2 +
15 files changed, 55 insertions(+), 112 deletions(-)
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RecordContext.jsx
diff --git a/.gitignore b/.gitignore
index 0287eb89..469934ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -91,3 +91,5 @@ dist/
.vscode
thesis
+
+**/ui/theme/**/todo.md
\ No newline at end of file
diff --git a/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja b/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja
index 2b8ecd8c..9f048a87 100644
--- a/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja
+++ b/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RecordRequests.jinja
@@ -2,9 +2,4 @@
{% set record = record | to_dict %}
-
-
-{%- block javascript %}
-{{ super() }}
-{{ webpack['oarepo_requests_ui_record_requests.js']}}
-{%- endblock %}
\ No newline at end of file
+
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
index 225a6599..3c0b4ae5 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
@@ -33,7 +33,7 @@ export const CreateRequestModalContent = ({ requestType, extraPreSubmitEvent })
}
{payloadUI &&
-
+
}
+ {/* Render read only data for Accept and Cancel modals */}
{renderReadOnlyData &&
<>
@@ -141,6 +142,7 @@ export const RequestModalContent = ({ request, requestTypes, requestModalType })
))}
+ {/* If events are enabled for this request type, you can see the timeline of events and create new events. */}
{!_isEmpty(eventTypes) &&
<>
{i18next.t("Timeline")}
@@ -186,6 +188,7 @@ export const RequestModalContent = ({ request, requestTypes, requestModalType })
||
+ /* No Submit Form (no PayloadUI for this request type) nor Payload (read only data) available for this Request */
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx
index 972f14b2..11cdd2b2 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/ReadOnlyCustomFields.jsx
@@ -1,10 +1,3 @@
-// This file is part of React-Invenio-Forms
-// Copyright (C) 2022 CERN.
-// Copyright (C) 2022 Northwestern University.
-//
-// React-Invenio-Forms is free software; you can redistribute it and/or modify it
-// under the terms of the MIT License; see LICENSE file for more details.
-
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import { loadWidgetsFromConfig } from "../../utils/loader";
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js
index 4e98fdd0..61bdc7f0 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/common/index.js
@@ -1,3 +1,2 @@
export { default as ReadOnlyCustomFields } from "./ReadOnlyCustomFields";
-export { default as DefaultView } from "./DefaultView";
-export { default as StaticText } from "./StaticText";
\ No newline at end of file
+export { default as DefaultView } from "./DefaultView";
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js
index 0880c0d3..6009c138 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/index.js
@@ -1,7 +1,6 @@
export { RequestListContainer } from "./RequestListContainer";
export { CreateRequestButtonGroup } from "./CreateRequestButtonGroup";
export { RequestModal } from "./RequestModal";
-export { TriggerButton } from "./TriggerButton";
export { RecordRequests } from "./RecordRequests";
export { RequestModalContent } from "./RequestModalContent";
export { CreateRequestModalContent } from "./CreateRequestModalContent";
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RecordContext.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RecordContext.jsx
new file mode 100644
index 00000000..46423b46
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/RecordContext.jsx
@@ -0,0 +1,11 @@
+import React, { createContext } from "react";
+
+export const RecordContext = createContext();
+
+export const RecordContextProvider = ({ children, record }) => {
+ return (
+
+ {children}
+
+ );
+};
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js
index abf50903..a055d8f3 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/contexts/index.js
@@ -1 +1,2 @@
-export { RequestContext, RequestContextProvider } from './RequestContext';
\ No newline at end of file
+export { RequestContext, RequestContextProvider } from './RequestContext';
+export { RecordContext, RecordContextProvider } from './RecordContext';
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
index 35bd673d..f6167ae4 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
@@ -5,7 +5,8 @@ export default {
"links": {
"files": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/files",
"self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66",
- "self_html": "https://127.0.0.1:5000/theses/36s8e-qwz66"
+ "self_html": "https://127.0.0.1:5000/theses/36s8e-qwz66",
+ "requests": "https://9c2a4912-c1a0-48f8-9565-e772482c6e92.mock.pstmn.io/api/uct-theses/36s8e-qwz66/requests"
},
"revision_id": 2,
"$schema": "local://uct_theses-1.0.0.json",
@@ -132,7 +133,7 @@ export default {
},
"self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d",
"self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/html",
- "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/events" // TODO: Shouldn't this be more specific event like "comments"?
+ "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/events"
},
"created_by": {
"reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
@@ -291,56 +292,6 @@ export default {
"description": "Pridel DOI k objektu 36s8e-qwz66",
"request_text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam fringilla tortor nibh, sed sagittis lorem congue ac. Aliquam ante mauris, porttitor eu ornare ut, feugiat sit amet diam. Maecenas ut sem mi. Maecenas elementum, elit mollis vestibulum cursus, nisi ex commodo neque, id ultrices felis ligula eget massa. Integer vel justo et ligula dapibus ultrices. Nullam ultricies sed neque sed lacinia. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent sed lectus ut diam sollicitudin malesuada a quis nibh. In tempus nibh ex, tincidunt tempus enim rutrum id. Aliquam laoreet dictum enim in vestibulum. Nam sagittis, turpis at pretium maximus, odio nibh venenatis risus, eu tempus tortor nibh id ante. Vestibulum aliquam, quam ac gravida fringilla, risus leo fermentum nunc, in fringilla magna urna a turpis. Cras sed metus vel metus lacinia auctor. In sed maximus risus, at euismod urna. Donec mi velit, euismod non orci id, pharetra eleifend tortor."
},
- // "events": [
- // {
- // "payload": {
- // "comment": "hello world"
- // },
- // "created": "2024-01-08T09:37:15.726599+00:00",
- // "created_by": {
- // "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
- // "type": "user",
- // "label": "Ron",
- // "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- // },
- // "updated": "2024-01-08T09:37:15.726599+00:00",
- // "revision_id": 1,
- // "id": "53c6a7fd-6a07-41a7-8996-46852267elk0",
- // "type_code": "C",
- // "type": "Comment",
- // "links": {
- // "self": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- // },
- // "permissions": {
- // "can_update_comment": true,
- // "can_delete_comment": true
- // }
- // },
- // {
- // "payload": {
-
- // },
- // "created": "2024-01-08T09:37:15.726599+00:00",
- // "created_by": {
- // "reference": "6c3f6437-9197-490c-9ki9-d2daa5143dcf",
- // "type": "user",
- // "label": "Ron",
- // "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- // },
- // "updated": "2024-01-08T09:37:15.726599+00:00",
- // "revision_id": 1,
- // "id": "53c6a7fd-6a07-41a7-8996-46852267e940",
- // "type_code": "P",
- // "type": "Znalecký posudek",
- // "links": {
- // "self": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- // },
- // "permissions": {
- // "can_update_comment": true,
- // "can_delete_comment": true
- // }
- // }
- // ]
},
{
"name": "pridel doi 6",
@@ -352,7 +303,7 @@ export default {
"submit": "https://127.0.0.1:5000/api/uct-theses/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/actions/submit",
"cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/actions/cancel"
},
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d", // PUT request: override existing record
+ "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d",
"self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/html",
"events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/events"
},
@@ -516,11 +467,11 @@ export default {
"fields": [
{
"field": "expert_opinion",
- "ui_widget": "RichInput",
+ "ui_widget": "Input",
"props": {
- "label": "description",
- "placeholder": "description",
- "icon": "text height",
+ "label": "name",
+ "placeholder": "File Name",
+ "icon": "file",
"required": true
},
"view_widget": "FileViewWidget",
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
index b5b73c1e..46b8b0c6 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
@@ -9,6 +9,8 @@ const recordRequestsAppDiv = document.getElementById("record-requests");
let record = JSON.parse(recordRequestsAppDiv.dataset.record)?.requests || dummyRecord;
+console.log(dummyRecord);
+
ReactDOM.render(
Date: Tue, 13 Feb 2024 10:02:21 +0100
Subject: [PATCH 03/41] Add oarepo_requests_ui blueprint, translations, entry
points
---
babel.ini | 24 +++++
oarepo.yaml | 10 ++
.../translations/cs/LC_MESSAGES/messages.po | 87 +++++++++++++++
.../translations/en/LC_MESSAGES/messages.po | 87 +++++++++++++++
oarepo_requests/translations/messages.pot | 102 ++++++++++++++++++
.../oarepo_requests_ui/i18next.js | 37 +++++++
.../messages/cs/LC_MESSAGES/translations.json | 1 +
.../messages/en/LC_MESSAGES/translations.json | 1 +
.../oarepo_requests_ui/messages/index.js | 7 ++
oarepo_requests/ui/theme/webpack.py | 3 +-
oarepo_requests/ui/views.py | 3 +
setup.cfg | 4 +
12 files changed, 365 insertions(+), 1 deletion(-)
create mode 100644 babel.ini
create mode 100644 oarepo.yaml
create mode 100644 oarepo_requests/translations/cs/LC_MESSAGES/messages.po
create mode 100644 oarepo_requests/translations/en/LC_MESSAGES/messages.po
create mode 100644 oarepo_requests/translations/messages.pot
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/i18next.js
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/index.js
create mode 100644 oarepo_requests/ui/views.py
diff --git a/babel.ini b/babel.ini
new file mode 100644
index 00000000..39e658cd
--- /dev/null
+++ b/babel.ini
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Invenio.
+# Copyright (C) 2015-2018 CERN.
+#
+# Invenio is free software; you can redistribute it and/or modify it
+# under the terms of the MIT License; see LICENSE file for more details.
+
+# Extraction from Python source files
+
+[python: **.py]
+encoding = utf-8
+
+# Extraction from Jinja2 templates
+
+[jinja2: **/templates/**.html]
+encoding = utf-8
+
+[jinja2: **/templates/**.jinja]
+encoding = utf-8
+
+# Special case for jinjax translation strings
+[jinja2: **/jinjax_messages.jinja]
+encoding = utf-8
diff --git a/oarepo.yaml b/oarepo.yaml
new file mode 100644
index 00000000..d5d36815
--- /dev/null
+++ b/oarepo.yaml
@@ -0,0 +1,10 @@
+i18n:
+ babel_output_translations: oarepo_requests/translations
+ babel_source_paths:
+ - oarepo_requests/
+ i18next_output_translations: oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui
+ i18next_source_paths:
+ - oarepo_requests/ui/theme/assets/semantic-ui/js
+ languages:
+ - cs
+ - en
\ No newline at end of file
diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
new file mode 100644
index 00000000..1e5ebce3
--- /dev/null
+++ b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
@@ -0,0 +1,87 @@
+#
+msgid ""
+msgstr ""
+
+msgid "Create Request"
+msgstr ""
+
+msgid "No status"
+msgstr ""
+
+msgid "Open dialog for request"
+msgstr ""
+
+msgid "My Requests"
+msgstr ""
+
+msgid "Requests to Approve"
+msgstr ""
+
+msgid "Are you sure?"
+msgstr ""
+
+msgid "Cancel"
+msgstr ""
+
+msgid "OK"
+msgstr ""
+
+msgid "Create request"
+msgstr ""
+
+msgid "Submit request"
+msgstr ""
+
+msgid "Delete request"
+msgstr ""
+
+msgid "Delete"
+msgstr ""
+
+msgid "Accept request"
+msgstr ""
+
+msgid "Accept"
+msgstr ""
+
+msgid "Decline request"
+msgstr ""
+
+msgid "Decline"
+msgstr ""
+
+msgid "Create and submit request"
+msgstr ""
+
+msgid "Create and submit"
+msgstr ""
+
+msgid "Error sending request"
+msgstr ""
+
+msgid "Submit"
+msgstr ""
+
+msgid "Save drafted request"
+msgstr ""
+
+msgid "Save"
+msgstr ""
+
+msgid "Create"
+msgstr ""
+
+msgid "Creator"
+msgstr ""
+
+msgid "Receiver"
+msgstr ""
+
+msgid "Request type"
+msgstr ""
+
+msgid "Created"
+msgstr ""
+
+msgid "Timeline"
+msgstr ""
diff --git a/oarepo_requests/translations/en/LC_MESSAGES/messages.po b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
new file mode 100644
index 00000000..1e5ebce3
--- /dev/null
+++ b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
@@ -0,0 +1,87 @@
+#
+msgid ""
+msgstr ""
+
+msgid "Create Request"
+msgstr ""
+
+msgid "No status"
+msgstr ""
+
+msgid "Open dialog for request"
+msgstr ""
+
+msgid "My Requests"
+msgstr ""
+
+msgid "Requests to Approve"
+msgstr ""
+
+msgid "Are you sure?"
+msgstr ""
+
+msgid "Cancel"
+msgstr ""
+
+msgid "OK"
+msgstr ""
+
+msgid "Create request"
+msgstr ""
+
+msgid "Submit request"
+msgstr ""
+
+msgid "Delete request"
+msgstr ""
+
+msgid "Delete"
+msgstr ""
+
+msgid "Accept request"
+msgstr ""
+
+msgid "Accept"
+msgstr ""
+
+msgid "Decline request"
+msgstr ""
+
+msgid "Decline"
+msgstr ""
+
+msgid "Create and submit request"
+msgstr ""
+
+msgid "Create and submit"
+msgstr ""
+
+msgid "Error sending request"
+msgstr ""
+
+msgid "Submit"
+msgstr ""
+
+msgid "Save drafted request"
+msgstr ""
+
+msgid "Save"
+msgstr ""
+
+msgid "Create"
+msgstr ""
+
+msgid "Creator"
+msgstr ""
+
+msgid "Receiver"
+msgstr ""
+
+msgid "Request type"
+msgstr ""
+
+msgid "Created"
+msgstr ""
+
+msgid "Timeline"
+msgstr ""
diff --git a/oarepo_requests/translations/messages.pot b/oarepo_requests/translations/messages.pot
new file mode 100644
index 00000000..fbadf637
--- /dev/null
+++ b/oarepo_requests/translations/messages.pot
@@ -0,0 +1,102 @@
+# Translations template for PROJECT.
+# Copyright (C) 2024 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR , 2024.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2024-01-31 13:19+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 2.14.0\n"
+
+msgid "Create Request"
+msgstr ""
+
+msgid "No status"
+msgstr ""
+
+msgid "Open dialog for request"
+msgstr ""
+
+msgid "My Requests"
+msgstr ""
+
+msgid "Requests to Approve"
+msgstr ""
+
+msgid "Are you sure?"
+msgstr ""
+
+msgid "Cancel"
+msgstr ""
+
+msgid "OK"
+msgstr ""
+
+msgid "Create request"
+msgstr ""
+
+msgid "Submit request"
+msgstr ""
+
+msgid "Delete request"
+msgstr ""
+
+msgid "Delete"
+msgstr ""
+
+msgid "Accept request"
+msgstr ""
+
+msgid "Accept"
+msgstr ""
+
+msgid "Decline request"
+msgstr ""
+
+msgid "Decline"
+msgstr ""
+
+msgid "Create and submit request"
+msgstr ""
+
+msgid "Create and submit"
+msgstr ""
+
+msgid "Error sending request"
+msgstr ""
+
+msgid "Submit"
+msgstr ""
+
+msgid "Save drafted request"
+msgstr ""
+
+msgid "Save"
+msgstr ""
+
+msgid "Create"
+msgstr ""
+
+msgid "Creator"
+msgstr ""
+
+msgid "Receiver"
+msgstr ""
+
+msgid "Request type"
+msgstr ""
+
+msgid "Created"
+msgstr ""
+
+msgid "Timeline"
+msgstr ""
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/i18next.js b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/i18next.js
new file mode 100644
index 00000000..d5dae7d2
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/i18next.js
@@ -0,0 +1,37 @@
+// This file is part of React-Invenio-Deposit
+// Copyright (C) 2021 Graz University of Technology.
+//
+// Invenio-app-rdm is free software; you can redistribute it and/or modify it
+// under the terms of the MIT License; see LICENSE file for more details.
+
+import i18n from "i18next";
+
+import LanguageDetector from "i18next-browser-languagedetector";
+import { translations } from "./messages";
+import { initReactI18next } from "react-i18next";
+
+const options = {
+ fallbackLng: "en", // fallback keys
+ returnEmptyString: false,
+ debug: process.env.NODE_ENV === "development",
+ resources: translations,
+ keySeparator: false,
+ nsSeparator: false,
+ // specify language detection order
+ detection: {
+ order: ["htmlTag"],
+ // cache user language off
+ caches: [],
+ },
+ react: {
+ // Set empty - to allow html tags convert to trans tags
+ // HTML TAG | Trans TAG
+ // | <1>
+ transKeepBasicHtmlNodesFor: [],
+ },
+};
+
+const i18next = i18n.createInstance();
+i18next.use(LanguageDetector).use(initReactI18next).init(options);
+
+export { i18next };
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
new file mode 100644
index 00000000..9e26dfee
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
new file mode 100644
index 00000000..9e26dfee
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/index.js
new file mode 100644
index 00000000..5a8c3f18
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/index.js
@@ -0,0 +1,7 @@
+// This file was autogenerated with oarepo-tools
+import TRANSLATE_CS from "./cs/LC_MESSAGES/translations.json"
+import TRANSLATE_EN from "./en/LC_MESSAGES/translations.json"
+export const translations = {
+ cs: { translation: TRANSLATE_CS },
+ en: { translation: TRANSLATE_EN },
+}
diff --git a/oarepo_requests/ui/theme/webpack.py b/oarepo_requests/ui/theme/webpack.py
index f4b964be..a598aa7c 100644
--- a/oarepo_requests/ui/theme/webpack.py
+++ b/oarepo_requests/ui/theme/webpack.py
@@ -12,7 +12,8 @@
dependencies={},
devDependencies={},
aliases={
- "@translations/oarepo_requests_ui": "translations/oarepo_requests",
+ "@translations/oarepo_requests_ui": "translations/oarepo_requests_ui",
+ "@js/oarepo_requests": "js/oarepo_requests_ui/record-requests",
},
)
},
diff --git a/oarepo_requests/ui/views.py b/oarepo_requests/ui/views.py
new file mode 100644
index 00000000..9c2a462b
--- /dev/null
+++ b/oarepo_requests/ui/views.py
@@ -0,0 +1,3 @@
+from flask import Blueprint
+
+blueprint = Blueprint("oarepo_requests_ui", __name__, template_folder="templates")
diff --git a/setup.cfg b/setup.cfg
index cff0d0b9..f736f773 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -30,5 +30,9 @@ tests =
oarepo-model-builder-drafts
[options.entry_points]
+invenio_base.blueprints =
+ oarepo_requests_ui = oarepo_requests.ui.views:blueprint
invenio_assets.webpack =
oarepo_requests_ui_theme = oarepo_requests.ui.theme.webpack:theme
+invenio_i18n.translations =
+ oarepo_requests_ui = oarepo_requests
From ea57b9009448f32310980a3c9eafda89b1d52a0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Tue, 13 Feb 2024 13:14:46 +0100
Subject: [PATCH 04/41] Add Czech translations for messages
---
messages.po | 100 ++++++++++++++++++
.../translations/cs/LC_MESSAGES/messages.po | 59 ++++++-----
.../translations/en/LC_MESSAGES/messages.po | 3 +
oarepo_requests/translations/messages.pot | 8 +-
.../messages/cs/LC_MESSAGES/translations.json | 2 +-
5 files changed, 139 insertions(+), 33 deletions(-)
create mode 100644 messages.po
diff --git a/messages.po b/messages.po
new file mode 100644
index 00000000..7fc342dd
--- /dev/null
+++ b/messages.po
@@ -0,0 +1,100 @@
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"Language: cs\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 3.4.2\n"
+
+msgid "Create Request"
+msgstr "Vytvořit Žádost"
+
+msgid "No status"
+msgstr "Neznámý stav"
+
+msgid "Open dialog for request"
+msgstr "Otevřít dialogové okno pro žádost"
+
+msgid "My Requests"
+msgstr "Moje Žádosti"
+
+msgid "Requests to Approve"
+msgstr "Žádosti ke schválení"
+
+msgid "Are you sure?"
+msgstr "Jste si jistí?"
+
+msgid "Cancel"
+msgstr "Zrušit"
+
+msgid "OK"
+msgstr "OK"
+
+msgid "Create request"
+msgstr "Vytvořit žádost"
+
+msgid "Submit request"
+msgstr "Odeslat žádost"
+
+msgid "Delete request"
+msgstr "Smazat žádost"
+
+msgid "Delete"
+msgstr "Smazat"
+
+msgid "Accept request"
+msgstr "Přijmout žádost"
+
+msgid "Accept"
+msgstr "Přijmout"
+
+msgid "Decline request"
+msgstr "Zamítnout žádost"
+
+msgid "Decline"
+msgstr "Zamítnout"
+
+msgid "Create and submit request"
+msgstr "Vytvořit a odeslat žádost"
+
+msgid "Create and submit"
+msgstr "Vytvořit a odeslat"
+
+msgid "Error sending request"
+msgstr "Chyba při odesílání žádosti"
+
+msgid "Submit"
+msgstr "Odeslat"
+
+msgid "Save drafted request"
+msgstr "Uložit koncept žádosti"
+
+msgid "Save"
+msgstr "Uložit"
+
+msgid "Create"
+msgstr "Vytvořit"
+
+msgid "Creator"
+msgstr "Tvůrce"
+
+msgid "Receiver"
+msgstr "Příjemce"
+
+msgid "Request type"
+msgstr "Typ žádosti"
+
+msgid "Created"
+msgstr "Vytvořeno"
+
+msgid "Timeline"
+msgstr "Časová osa"
+
+msgid "Submit event"
+msgstr "Odeslat událost"
diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
index 1e5ebce3..c67d1521 100644
--- a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
@@ -3,85 +3,88 @@ msgid ""
msgstr ""
msgid "Create Request"
-msgstr ""
+msgstr "Vytvořit Žádost"
msgid "No status"
-msgstr ""
+msgstr "Neznámý stav"
msgid "Open dialog for request"
-msgstr ""
+msgstr "Otevřít dialogové okno pro žádost"
msgid "My Requests"
-msgstr ""
+msgstr "Moje Žádosti"
msgid "Requests to Approve"
-msgstr ""
+msgstr "Žádosti ke schválení"
msgid "Are you sure?"
-msgstr ""
+msgstr "Jste si jistí?"
msgid "Cancel"
-msgstr ""
+msgstr "Zrušit"
msgid "OK"
-msgstr ""
+msgstr "OK"
msgid "Create request"
-msgstr ""
+msgstr "Vytvořit žádost"
msgid "Submit request"
-msgstr ""
+msgstr "Odeslat žádost"
msgid "Delete request"
-msgstr ""
+msgstr "Smazat žádost"
msgid "Delete"
-msgstr ""
+msgstr "Smazat"
msgid "Accept request"
-msgstr ""
+msgstr "Přijmout žádost"
msgid "Accept"
-msgstr ""
+msgstr "Přijmout"
msgid "Decline request"
-msgstr ""
+msgstr "Zamítnout žádost"
msgid "Decline"
-msgstr ""
+msgstr "Zamítnout"
msgid "Create and submit request"
-msgstr ""
+msgstr "Vytvořit a odeslat žádost"
msgid "Create and submit"
-msgstr ""
+msgstr "Vytvořit a odeslat"
msgid "Error sending request"
-msgstr ""
+msgstr "Chyba při odesílání žádosti"
msgid "Submit"
-msgstr ""
+msgstr "Odeslat"
msgid "Save drafted request"
-msgstr ""
+msgstr "Uložit koncept žádosti"
msgid "Save"
-msgstr ""
+msgstr "Uložit"
msgid "Create"
-msgstr ""
+msgstr "Vytvořit"
msgid "Creator"
-msgstr ""
+msgstr "Tvůrce"
msgid "Receiver"
-msgstr ""
+msgstr "Příjemce"
msgid "Request type"
-msgstr ""
+msgstr "Typ žádosti"
msgid "Created"
-msgstr ""
+msgstr "Vytvořeno"
msgid "Timeline"
-msgstr ""
+msgstr "Časová osa"
+
+msgid "Submit event"
+msgstr "Odeslat událost"
diff --git a/oarepo_requests/translations/en/LC_MESSAGES/messages.po b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
index 1e5ebce3..a96d920b 100644
--- a/oarepo_requests/translations/en/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
@@ -85,3 +85,6 @@ msgstr ""
msgid "Timeline"
msgstr ""
+
+msgid "Submit event"
+msgstr ""
diff --git a/oarepo_requests/translations/messages.pot b/oarepo_requests/translations/messages.pot
index fbadf637..71598377 100644
--- a/oarepo_requests/translations/messages.pot
+++ b/oarepo_requests/translations/messages.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2024-01-31 13:19+0100\n"
+"POT-Creation-Date: 2024-02-13 13:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -23,9 +23,6 @@ msgstr ""
msgid "No status"
msgstr ""
-msgid "Open dialog for request"
-msgstr ""
-
msgid "My Requests"
msgstr ""
@@ -41,6 +38,9 @@ msgstr ""
msgid "OK"
msgstr ""
+msgid "Submit event"
+msgstr ""
+
msgid "Create request"
msgstr ""
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
index 9e26dfee..7c41e41b 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
@@ -1 +1 @@
-{}
\ No newline at end of file
+{"Create Request":"Vytvořit Žádost","No status":"Neznámý stav","Open dialog for request":"Otevřít dialogové okno pro žádost","My Requests":"Moje Žádosti","Requests to Approve":"Žádosti ke schválení","Are you sure?":"Jste si jistí?","Cancel":"Zrušit","OK":"OK","Create request":"Vytvořit žádost","Submit request":"Odeslat žádost","Delete request":"Smazat žádost","Delete":"Smazat","Accept request":"Přijmout žádost","Accept":"Přijmout","Decline request":"Zamítnout žádost","Decline":"Zamítnout","Create and submit request":"Vytvořit a odeslat žádost","Create and submit":"Vytvořit a odeslat","Error sending request":"Chyba při odesílání žádosti","Submit":"Odeslat","Save drafted request":"Uložit koncept žádosti","Save":"Uložit","Create":"Vytvořit","Creator":"Tvůrce","Receiver":"Příjemce","Request type":"Typ žádosti","Created":"Vytvořeno","Timeline":"Časová osa","Submit event":"Odeslat událost"}
\ No newline at end of file
From 6c701991f9fce0a907bbcaaea87f17a0a6f1c755 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Wed, 14 Feb 2024 16:07:36 +0100
Subject: [PATCH 05/41] Refactor setup.cfg to include oarepo_requests blueprint
and remove unnecessary code
---
setup.cfg | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index 8bd689a1..f2ac03aa 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -28,20 +28,12 @@ invenio_base.api_apps =
oarepo_requests = oarepo_requests.ext:OARepoRequests
invenio_base.apps =
thesis = oarepo_requests.ext:OARepoRequests
-#invenio_base.blueprints =
-# oarepo_requests = oarepo_requests.views.api:create_oarepo_requests
invenio_base.blueprints =
+ oarepo_requests = oarepo_requests.views.app:create_app_blueprint
oarepo_requests_ui = oarepo_requests.ui.views:blueprint
invenio_assets.webpack =
oarepo_requests_ui_theme = oarepo_requests.ui.theme.webpack:theme
invenio_i18n.translations =
oarepo_requests_ui = oarepo_requests
-
invenio_base.api_blueprints =
oarepo_requests = oarepo_requests.views.api:create_oarepo_requests
-
-invenio_base.blueprints =
- oarepo_requests = oarepo_requests.views.app:create_app_blueprint
-
-
-
From 656d6bc090dca29bd5fedb87cc3ef020a85a9496 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Thu, 14 Mar 2024 11:01:47 +0100
Subject: [PATCH 06/41] Fix some issues
---
.../components/CreateRequestButtonGroup.jsx | 2 +-
.../components/CreateRequestModalContent.jsx | 13 +++----
.../components/RequestModal.jsx | 37 ++++++++++---------
.../components/RequestModalContent.jsx | 2 +-
.../record-requests/index.js | 6 +--
5 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
index dced49ee..3e2cc6f6 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
@@ -25,7 +25,7 @@ export const CreateRequestButtonGroup = ({ requestTypes }) => {
{createRequests.map((requestType) => (
}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
index 3c0b4ae5..b2229b41 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestModalContent.jsx
@@ -32,11 +32,10 @@ export const CreateRequestModalContent = ({ requestType, extraPreSubmitEvent })
{requestType.description}
}
- {payloadUI &&
-
-
-
- }
+
+ }
+
>
);
}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
index 5e186706..d8866e40 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
@@ -20,9 +20,9 @@ import { RecordContext, RequestContext } from "../contexts";
* @typedef {import("semantic-ui-react").ConfirmProps} ConfirmProps
*/
-function delay(t, val) {
- return new Promise(resolve => setTimeout(resolve, t, val));
-}
+// function delay(t, val) {
+// return new Promise(resolve => setTimeout(resolve, t, val));
+// }
const mapPayloadUiToInitialValues = (payloadUi) => {
const initialValues = { payload: {} };
@@ -58,7 +58,6 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
const formik = useFormik({
initialValues: !isEmpty(request?.payload) ? { payload: request.payload } : mapPayloadUiToInitialValues(request?.payload_ui),
onSubmit: (values) => {
- console.log(values);
if (requestModalType === REQUEST_TYPE.SUBMIT) {
confirmAction(REQUEST_TYPE.SUBMIT);
} else if (requestModalType === REQUEST_TYPE.CREATE) {
@@ -90,21 +89,22 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
const callApi = async (url, method, doNotHandleResolve = false) => {
if (doNotHandleResolve) {
- // return axios({
- // method: method,
- // url: url,
- // data: formik.values,
- // headers: { 'Content-Type': 'application/json' }
- // });
- return delay(1000)
+ return axios({
+ method: method,
+ url: url,
+ data: formik.values,
+ headers: { 'Content-Type': 'application/json' }
+ });
+ // return delay(1000)
}
- // axios({
- // method: method,
- // url: url,
- // data: formik.values,
- // headers: { 'Content-Type': 'application/json' }
- // })
- return delay(1000)
+
+ // return delay(1000)
+ return axios({
+ method: method,
+ url: url,
+ data: formik.values,
+ headers: { 'Content-Type': 'application/json' }
+ })
.then(response => {
console.log(response);
fetchUpdated(record.links?.requests, setRequests);
@@ -147,6 +147,7 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
}
const confirmAction = (requestType, createAndSubmit = false) => {
+ console.log("confirmAction", requestType, createAndSubmit);
/** @type {ConfirmProps} */
let newConfirmDialogProps = {
open: true,
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
index 22e1ebf7..1188c8e8 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
@@ -77,7 +77,7 @@ export const RequestModalContent = ({ request, requestTypes, requestModalType })
});
}, [actualRequest]);
- const requestType = requestTypes.find(requestType => requestType.id === request.type);
+ const requestType = requestTypes.find(requestType => requestType.type_id === request.type);
const payloadUI = requestType?.payload_ui;
const eventTypes = requestType?.event_types;
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
index 46b8b0c6..5719b1fe 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
@@ -3,13 +3,13 @@ import ReactDOM from "react-dom";
import { RecordRequests } from "./components";
-import dummyRecord from "./dummy-record.js";
+// import dummyRecord from "./dummy-record.js";
const recordRequestsAppDiv = document.getElementById("record-requests");
-let record = JSON.parse(recordRequestsAppDiv.dataset.record)?.requests || dummyRecord;
+let record = JSON.parse(recordRequestsAppDiv.dataset.record);
-console.log(dummyRecord);
+console.log(record);
ReactDOM.render(
Date: Thu, 14 Mar 2024 12:59:06 +0100
Subject: [PATCH 07/41] Fix issue with empty requests array
---
.../translations/cs/LC_MESSAGES/messages.po | 3 +
.../translations/en/LC_MESSAGES/messages.po | 3 +
oarepo_requests/translations/messages.pot | 3 +
.../components/RequestListContainer.jsx | 5 +-
.../components/RequestModal.jsx | 6 -
.../record-requests/dummy-record.js | 558 ------------------
.../record-requests/index.js | 4 -
.../messages/cs/LC_MESSAGES/translations.json | 2 +-
8 files changed, 13 insertions(+), 571 deletions(-)
delete mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
index c67d1521..1b944be0 100644
--- a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
@@ -88,3 +88,6 @@ msgstr "Časová osa"
msgid "Submit event"
msgstr "Odeslat událost"
+
+msgid "No requests to show"
+msgstr "Žádné žádosti k zobrazení"
diff --git a/oarepo_requests/translations/en/LC_MESSAGES/messages.po b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
index a96d920b..4dcd095c 100644
--- a/oarepo_requests/translations/en/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
@@ -88,3 +88,6 @@ msgstr ""
msgid "Submit event"
msgstr ""
+
+msgid "No requests to show"
+msgstr ""
diff --git a/oarepo_requests/translations/messages.pot b/oarepo_requests/translations/messages.pot
index 71598377..0bab877b 100644
--- a/oarepo_requests/translations/messages.pot
+++ b/oarepo_requests/translations/messages.pot
@@ -100,3 +100,6 @@ msgstr ""
msgid "Timeline"
msgstr ""
+
+msgid "No requests to show"
+msgstr ""
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
index 641ffe11..2b5d8911 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
import { i18next } from "@translations/oarepo_requests_ui/i18next";
import { List, Segment, SegmentGroup, Header, Button } from "semantic-ui-react";
+import _isEmpty from "lodash/isEmpty";
import { RequestList } from ".";
import { RequestContext } from "../contexts";
@@ -27,13 +28,13 @@ export const RequestListContainer = ({ requestTypes }) => {
}
}
- const SegmentGroupOrEmpty = requestsToApprove.length > 0 && otherRequests.length > 0 ? SegmentGroup : <>>;
+ const SegmentGroupOrEmpty = requestsToApprove.length > 0 && otherRequests.length > 0 ? SegmentGroup : React.Fragment;
return (
{i18next.t("My Requests")}
-
+ {!_isEmpty(otherRequests) ? : {i18next.t("No requests to show")}.
}
{requestsToApprove.length > 0 && (
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
index d8866e40..d279caf8 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
@@ -20,10 +20,6 @@ import { RecordContext, RequestContext } from "../contexts";
* @typedef {import("semantic-ui-react").ConfirmProps} ConfirmProps
*/
-// function delay(t, val) {
-// return new Promise(resolve => setTimeout(resolve, t, val));
-// }
-
const mapPayloadUiToInitialValues = (payloadUi) => {
const initialValues = { payload: {} };
payloadUi?.forEach(section => {
@@ -95,10 +91,8 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
data: formik.values,
headers: { 'Content-Type': 'application/json' }
});
- // return delay(1000)
}
- // return delay(1000)
return axios({
method: method,
url: url,
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
deleted file mode 100644
index f6167ae4..00000000
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/dummy-record.js
+++ /dev/null
@@ -1,558 +0,0 @@
-export default {
- "id": "36s8e-qwz66",
- "created": "2024-01-08T09:37:15.726599+00:00",
- "updated": "2024-01-08T09:37:15.761771+00:00",
- "links": {
- "files": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/files",
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66",
- "self_html": "https://127.0.0.1:5000/theses/36s8e-qwz66",
- "requests": "https://9c2a4912-c1a0-48f8-9565-e772482c6e92.mock.pstmn.io/api/uct-theses/36s8e-qwz66/requests"
- },
- "revision_id": 2,
- "$schema": "local://uct_theses-1.0.0.json",
- "metadata": {
- "abstract": [
- {
- "lang": "cs",
- "value": "Byla připravena série kvarterních flaviniových solí: 5-ethyl-3,7,8,10-\r\n-tetramethylisoalloxazinium-perchlorát (2a), 10-butyl-5-ethyl-3,7,8-\r\n-trimethylisoalloxazinium-perchlorát (2b), 5-ethyl-3,7,8-trimethyl-10-oktyl-isoalloxazinium-perchlorát (2c) a 10-dodecyl-5-ethyl-3,7,8-trimethylisoalloxazinium-\r\n-perchlorát (2d). Připravené isoalloxaziniové soli 2a-d byly studovány jako katalyzátory oxidace sulfidů na sulfoxidy peroxidem vodíku v různých typech micel: v anionických micelách dodecylsulfátu sodného (SDS), v kationických micelách hexadecyltrimethylamonium-chloridu (CTAC) a hexadecyltrimethylamonium-nitrátu (CTANO3) a v neionických micelách polyoxyethylen(23)(dodecyl)etheru (Brij 35). Pro porovnání byl ve vodě rozpustný derivát 2a testován také v homogenním prostředí (ve směsi methanol-voda 1 : 1). Ve všech micelárních prostředích byl studován vliv pH reakčního prostředí a lipofility isoalloxaziniových solí 2 na jejich katalytickou účinnost měřením rychlosti oxidace modelového substrátu, thioanisolu (9), v přítomnosti katalytického množství soli 2. V micelách SDS byla oxidace provedena také v semipreparativním měřítku."
- },
- {
- "lang": "en",
- "value": "Series of quaternary flavinium salts: 5-ethyl-3,7,8,10-tetramethylisoalloxazinium perchlorate (2a), 10-butyl-5-ethyl-3,7,8-trimethylisoalloxazinium perchlorate (2b), \r\n5-ethyl-3,7,8-trimethyl-10-oktyl-isoalloxazinium perchlorate (2c) and 10-dodecyl-5-\r\n-ethyl-3,7,8-trimethylisoalloxazinium perchlorate (2d) was prepared. Flavinium salts 2a-d were studied as catalysts for oxidation of sulfides to sulfoxides with hydrogen peroxide in several micellar systems: in anionic micelles of sodium dodecylsulfate (SDS), in cationic micelles of hexadecyltrimethylammonium chloride (CTAC) and hexadecyltrimethylammonium nitrate (CTANO3), and in non-ionic micelles formed by polyoxyethylene(23)dodecyl ether (Brij 35). For comparison, water-soluble derivative 2a was also tested in homogeneous solution (in the mixture methanol-water 1 : 1). In all micellar systems, the effect of pH of reaction medium and lipophilicity of isoalloxazinium salts on their catalytic efficiency was tested by measuring the rate of model substrate (thioanisole (9)) oxidation in the presence of a catalytic amount of flavinium salt 2. In SDS micelles, sulfoxidation was performed also in semipreparative scale."
- }
- ],
- "accessRights": {
- "id": "c_abf2",
- "@v": "199a114b-2933-4905-8a76-015ee4cc7f06::1",
- "title": {
- "cs": "otevřený přístup",
- "en": "open access"
- }
- },
- "accessibility": [
- {
- "lang": "cs",
- "value": "Text práce je k nahlédnutí na ústavu, kde byla práce vypracována. Další dokumenty jsou uloženy v archivu VŠCHT Praha."
- },
- {
- "lang": "en",
- "value": "The printed version of the thesis is available at the department where the thesis was produced. Defence protocol and reviews are available at UCT Prague archive."
- }
- ],
- "additionalTitles": [
- {
- "title": {
- "lang": "en",
- "value": "Synthesis and investigation of amphiphilic flavinium salts as sulfoxidation catalysts//in micellar solutions"
- },
- "titleType": "translatedTitle"
- }
- ],
- "contributors": [
- {
- "fullName": "prof. Ing. Radek Cibulka, Ph.D.",
- "nameType": "Personal",
- "role": {
- "id": "advisor",
- "@v": "42e623d6-f9f9-4ece-8db9-434a495d91c1::1",
- "title": {
- "cs": "vedoucí",
- "en": "advisor"
- }
- }
- },
- {
- "fullName": "prof. Ing. Jan Šmidrkal, CSc.",
- "nameType": "Personal",
- "role": {
- "id": "referee",
- "@v": "c5b87187-8d0b-4de8-aec9-ae19047e1bee::1",
- "title": {
- "cs": "oponent",
- "en": "referee"
- }
- }
- }
- ],
- "creators": [
- {
- "fullName": "Ing. Lenka Baxová",
- "nameType": "Personal"
- }
- ],
- "dateAvailable": "2007-10-11",
- "dateModified": "2007-10-11",
- "languages": [
- {
- "id": "cs",
- "@v": "590f1c0e-d9c6-4179-bf3c-83b31b4b3803::1",
- "title": {
- "cs": "čeština",
- "en": "Czech"
- }
- }
- ],
- "resourceType": {
- "id": "master",
- "@v": "b96ee94b-fef1-49c1-8840-841add31339b::1",
- "title": {
- "cs": "Diplomová práce",
- "en": "Master thesis"
- }
- },
- "systemIdentifiers": [
- {
- "scheme": "catalogueSysNo",
- "identifier": "4701"
- }
- ],
- "title": "Syntéza a studium amfifilních flaviniových solí jako katalyzátorů oxidace sulfidů//v micelárních roztocích",
- "collection": "22310",
- "thesis": {
- "dateDefended": "2007-06-01",
- "defended": true
- },
- "sis": {
- "did": 4701,
- "timestamp": "2007-10-11T15:11:24"
- }
- },
- "files": {
- "enabled": true
- },
- "requests": [
- {
- "name": "pridel doi",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "uuid": "ed181799-26c5-4269-b032-4a2a4624eb9d",
- "type": "assign_doi",
- "links": {
- "actions": {
- "submit": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/actions/submit",
- "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/actions/cancel"
- },
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d",
- "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/html",
- "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9d/events"
- },
- "created_by": {
- "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
- "type": "user",
- "label": "Ron",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- },
- "receiver": {
- "reference": {
- "id": "f40d6c41-3aa1-42be-a185-f8a0a125c815"
- },
- "type": "community",
- "label": "cesnet",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c815"
- },
- "topic": {
- "reference": {
- "id": "36s8e-qwz66"
- },
- "type": "record",
- "label": "title recordu",
- "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
- },
- "status_code": "draft",
- "status": "Vytvořeno",
- "created": "2024-01-08T09:37:15.726599+00:00",
- "updated": "2024-01-08T09:37:15.761771+00:00",
- "payload": {
- "name": "pridel doi",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "request_text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam fringilla tortor nibh, sed sagittis lorem congue ac. Aliquam ante mauris, porttitor eu ornare ut, feugiat sit amet diam. Maecenas ut sem mi. Maecenas elementum, elit mollis vestibulum cursus, nisi ex commodo neque, id ultrices felis ligula eget massa. Integer vel justo et ligula dapibus ultrices. Nullam ultricies sed neque sed lacinia. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent sed lectus ut diam sollicitudin malesuada a quis nibh. In tempus nibh ex, tincidunt tempus enim rutrum id. Aliquam laoreet dictum enim in vestibulum. Nam sagittis, turpis at pretium maximus, odio nibh venenatis risus, eu tempus tortor nibh id ante. Vestibulum aliquam, quam ac gravida fringilla, risus leo fermentum nunc, in fringilla magna urna a turpis. Cras sed metus vel metus lacinia auctor. In sed maximus risus, at euismod urna. Donec mi velit, euismod non orci id, pharetra eleifend tortor."
- }
- },
- {
- "name": "pridel doi 2",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "uuid": "ed181799-26c5-4269-b032-4a2a4624eb9e",
- "type": "assign_doi",
- "links": {
- "actions": {
- "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4269-b032-4a2a4624eb9e/actions/cancel"
- },
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9e",
- "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9e/html",
- "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4269-b032-4a2a4624eb9e/events"
- },
- "created_by": {
- "reference": "6c3f6437-9197-490c-9584-d2daa5143dcg",
- "type": "user",
- "label": "Ron",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcg"
- },
- "receiver": {
- "reference": {
- "id": "f40d6c41-3aa1-42be-a185-f8a0a125c816"
- },
- "type": "community",
- "label": "cesnet",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c816"
- },
- "topic": {
- "reference": {
- "id": "36s8e-qwz66"
- },
- "type": "record",
- "label": "title recordu",
- "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
- },
- "status_code": "submitted",
- "status": "Zažádáno",
- "created": "2024-01-09T09:37:15.726599+00:00",
- "updated": "2024-01-09T09:37:15.761771+00:00"
- },
- {
- "name": "pridel doi 3",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "uuid": "ed181799-26c5-po69-b032-4a2a4664eb9e",
- "type": "assign_doi",
- "links": {
- "actions": {
- "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-po69-b032-4a2a4664eb9e/actions/cancel"
- },
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-po69-b032-4a2a4664eb9e",
- "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-po69-b032-4a2a4664eb9e/html",
- "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-po69-b032-4a2a4664eb9e/events"
- },
- "created_by": {
- "reference": "6c3f6437-9197-490c-9584-d2daa5143dcg",
- "type": "user",
- "label": "Ron",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcg"
- },
- "receiver": {
- "reference": {
- "id": "f40d6c41-3aa1-42be-a185-f8a0a125c816"
- },
- "type": "community",
- "label": "cesnet",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c816"
- },
- "topic": {
- "reference": {
- "id": "36s8e-qwz66"
- },
- "type": "record",
- "label": "title recordu",
- "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
- },
- "status_code": "submitted",
- "status": "Zažádáno",
- "created": "2024-01-09T09:37:15.726599+00:00",
- "updated": "2024-01-09T09:37:15.761771+00:00"
- },
- {
- "name": "pridel doi 4",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "uuid": "ed181799-26c5-4226-bsf32-4a2a4624eb9d",
- "type": "assign_doi",
- "links": {
- "actions": {
- "accept": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/actions/accept",
- "decline": "https://127.0.0.1:5000/api/uct-theses/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/actions/decline"
- },
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d",
- "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/html",
- "events": "https://9c2a4912-c1a0-48f8-9565-e772482c6e92.mock.pstmn.io/api/uct-theses/36s8e-qwz66/requests/ed181799-26c5-4226-bsf32-4a2a4624eb9d/events"
- },
- "created_by": {
- "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
- "type": "user",
- "label": "Ron",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- },
- "receiver": {
- "reference": {
- "id": "f40d6c41-3aa1-42be-a185-f8a0a125c815"
- },
- "type": "community",
- "label": "cesnet",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c815"
- },
- "topic": {
- "reference": {
- "id": "36s8e-qwz66"
- },
- "type": "record",
- "label": "title recordu",
- "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
- },
- "status_code": "submitted",
- "status": "Zažádáno",
- "created": "2024-01-08T09:37:15.726599+00:00",
- "updated": "2024-01-08T09:37:15.761771+00:00",
- "payload": {
- "name": "pridel doi",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "request_text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam fringilla tortor nibh, sed sagittis lorem congue ac. Aliquam ante mauris, porttitor eu ornare ut, feugiat sit amet diam. Maecenas ut sem mi. Maecenas elementum, elit mollis vestibulum cursus, nisi ex commodo neque, id ultrices felis ligula eget massa. Integer vel justo et ligula dapibus ultrices. Nullam ultricies sed neque sed lacinia. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent sed lectus ut diam sollicitudin malesuada a quis nibh. In tempus nibh ex, tincidunt tempus enim rutrum id. Aliquam laoreet dictum enim in vestibulum. Nam sagittis, turpis at pretium maximus, odio nibh venenatis risus, eu tempus tortor nibh id ante. Vestibulum aliquam, quam ac gravida fringilla, risus leo fermentum nunc, in fringilla magna urna a turpis. Cras sed metus vel metus lacinia auctor. In sed maximus risus, at euismod urna. Donec mi velit, euismod non orci id, pharetra eleifend tortor."
- },
- },
- {
- "name": "pridel doi 6",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "uuid": "ed129799-26c5-4269-b032-4a2a4624lo9d",
- "type": "assign_doi",
- "links": {
- "actions": {
- "submit": "https://127.0.0.1:5000/api/uct-theses/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/actions/submit",
- "cancel": "https://127.0.0.1:5000/api/uct-theses/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/actions/cancel"
- },
- "self": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d",
- "self_html": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/html",
- "events": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ed129799-26c5-4269-b032-4a2a4624lo9d/events"
- },
- "created_by": {
- "reference": "6c3f6437-9197-490c-9584-d2daa5143dcf",
- "type": "user",
- "label": "Ron",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/6c3f6437-9197-490c-9584-d2daa5143dcf"
- },
- "receiver": {
- "reference": {
- "id": "f40d6c41-3aa1-42be-a185-f8a0a125c815"
- },
- "type": "community",
- "label": "cesnet",
- "link": "https://127.0.0.1:5000/api/uct-theses/users/f40d6c41-3aa1-42be-a185-f8a0a125c815"
- },
- "topic": {
- "reference": {
- "id": "36s8e-qwz66"
- },
- "type": "record",
- "label": "title recordu",
- "link": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66"
- },
- "status_code": "draft",
- "status": "Vytvořeno",
- "created": "2024-01-08T09:37:15.726599+00:00",
- "updated": "2024-01-08T09:37:15.761771+00:00"
- }
- ],
- "request_types": [
- {
- "name": "pridel doi",
- "description": "Pridel DOI k objektu 36s8e-qwz66",
- "id": "assign_doi",
- "links": {
- "actions": {
- "create": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/assign_doi/create"
- }
- },
- "fast_approve": true,
- "payload_ui": [
- {
- "section": "General info",
- "fields": [
- {
- "field": "name",
- "ui_widget": "Input",
- // "editable": ["requestor"],
- "props": {
- "readonly": "true",
- "label": "name",
- "placeholder": "name",
- "icon": "text cursor",
- "required": true
- },
- "view_widget": "StaticText",
- "view_widget_props": {
- "label": "name",
- "icon": "text cursor",
- }
- },
- {
- "field": "description",
- "ui_widget": "RichInput",
- "props": {
- "label": "description",
- "placeholder": "description",
- "icon": "text height",
- "required": true
- },
- "view_widget": "StaticText",
- "view_widget_props": {
- "label": "name",
- "icon": "text cursor",
- }
- },
- {
- "field": "request_text",
- "ui_widget": "RichInput",
- "props": {
- "label": "Request Text",
- "placeholder": "request text",
- "icon": "text height",
- "required": true
- },
- "view_widget": "StaticText",
- "view_widget_props": {
- "label": "name",
- "icon": "text cursor",
- }
- },
- // {
- // "field": "comment",
- // "ui_widget": "RichInput",
- // "editable": ["requestor", "approver"],
- // "props": {
- // "label": "description",
- // "placeholder": "description",
- // "icon": "text height",
- // "required": true
- // }
- // },
- // {
- // "field": "internal_comment",
- // "ui_widget": "RichInput",
- // "visible": ["approver"],
- // "editable": ["approver"],
- // "props": {
- // "label": "description",
- // "placeholder": "description",
- // "icon": "text height",
- // "required": true
- // }
- // }
- ]
- }
- ],
- "event_types": [
- {
- "name": "Comment",
- "description": "Comment on request",
- "id": "C",
- "links": {
- "create": "https://127.0.0.1:5000/api/uct-theses/requests/assign_doi/comments"
- }, // only if current user can create new event of this type
- "payload_ui": [
- {
- "section": "Comment",
- "fields": [
- {
- "field": "comment",
- "ui_widget": "RichInput",
- "props": {
- "label": "description",
- "placeholder": "description",
- "icon": "text height",
- "required": true
- },
- "view_widget": "StaticText",
- "view_widget_props": {
- "label": "name",
- "icon": "text cursor",
- }
- },
- ],
- }
- ]
- },
- {
- "name": "Znalecký posudek",
- "description": "Znalecký posudek na 36s8e-qwz66",
- "id": "P",
- "links": {
- "create": "https://127.0.0.1:5000/api/uct-theses/requests/assign_doi/expert_opinion" // TODO: How to connect Event to specific request?
- }, // only if current user can create new event of this type
- "payload_ui": [
- {
- "section": "Informace o znaleckém posudku",
- "fields": [
- {
- "field": "expert_opinion",
- "ui_widget": "Input",
- "props": {
- "label": "name",
- "placeholder": "File Name",
- "icon": "file",
- "required": true
- },
- "view_widget": "FileViewWidget",
- "view_widget_props": {
- "label": "file",
- "icon": "file",
- }
- },
- ],
- }
- ]
- }
- ]
- },
- {
- "name": "ask permission",
- "description": "Ak permission for 36s8e-qwz66",
- "id": "ask_permission",
- "links": {
- "actions": {
- "create": "https://127.0.0.1:5000/api/uct-theses/36s8e-qwz66/requests/ask_permission/create"
- }
- },
- "fast_approve": true,
- "payload_ui": [
- {
- "section": "General info",
- "fields": [
- {
- "field": "name",
- "ui_widget": "Input",
- "editable": ["requestor"],
- "props": {
- "readonly": "true",
- "label": "name",
- "placeholder": "name",
- "icon": "text cursor",
- "required": true
- }
- },
- {
- "field": "description",
- "ui_widget": "RichInput",
- "props": {
- "label": "description",
- "placeholder": "description",
- "icon": "text height",
- "required": true
- }
- },
- ]
- }
- ],
- "event_types": [
- {
- "name": "Comment",
- "description": "Comment on request",
- "id": "C",
- "links": {
- "create": "https://127.0.0.1:5000/api/uct-theses/requests/ask_permission/comments" // TODO: How to connect Event to specific request?
- }, // only if current user can create new event of this type
- "payload_ui": [
- {
- "section": "Comment",
- "fields": [
- {
- "field": "comment",
- "ui_widget": "RichInput",
- "editable": ["requestor", "approver"],
- "props": {
- "label": "description",
- "placeholder": "description",
- "icon": "text height",
- "required": true
- }
- },
- ],
- }
- ]
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
index 5719b1fe..4ad50c09 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
@@ -3,14 +3,10 @@ import ReactDOM from "react-dom";
import { RecordRequests } from "./components";
-// import dummyRecord from "./dummy-record.js";
-
const recordRequestsAppDiv = document.getElementById("record-requests");
let record = JSON.parse(recordRequestsAppDiv.dataset.record);
-console.log(record);
-
ReactDOM.render(
Date: Thu, 21 Mar 2024 16:13:44 +0100
Subject: [PATCH 08/41] Fix some issues with backend integration
---
.gitignore | 3 +-
.../components/RequestList.jsx | 4 +-
.../components/RequestModal.jsx | 45 ++++++++++++++-----
.../components/RequestModalContent.jsx | 11 +++--
.../record-requests/index.js | 2 +
.../record-requests/types.d.ts | 2 +-
6 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/.gitignore b/.gitignore
index ccacc3b9..6906d187 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,4 +93,5 @@ dist/
tests/thesis
thesis
-**/ui/theme/**/todo.md
\ No newline at end of file
+**/ui/theme/**/todo.md
+node_modules
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx
index 1e0e85f3..6c2c4877 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestList.jsx
@@ -26,10 +26,12 @@ export const RequestList = ({ requests, requestTypes, requestModalType }) => {
modalType = "submit";
} else if ("cancel" in request.links?.actions) {
modalType = "cancel";
+ } else {
+ modalType = "submit";
}
}
return (
-
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
index d279caf8..08ff4fab 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
@@ -21,7 +21,7 @@ import { RecordContext, RequestContext } from "../contexts";
*/
const mapPayloadUiToInitialValues = (payloadUi) => {
- const initialValues = { payload: {} };
+ const initialValues = { payload: { content: "hello world" } }; // TODO: is this correct?
payloadUi?.forEach(section => {
section.fields.forEach(field => {
initialValues.payload[field.field] = "";
@@ -76,27 +76,30 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
})
.then(response => {
console.log(response);
- setter(response.data);
+ setter(response.data?.hits?.hits);
})
.catch(error => {
console.log(error);
});
}
- const callApi = async (url, method, doNotHandleResolve = false) => {
+ const callApi = async (url, method, data = formik.values, doNotHandleResolve = false) => {
if (doNotHandleResolve) {
+ console.log("doNotHandleResolve", url, method, data);
return axios({
method: method,
url: url,
- data: formik.values,
+ data: data, // TODO: is this correct?
headers: { 'Content-Type': 'application/json' }
});
}
+
+ console.log(url, method);
return axios({
method: method,
url: url,
- data: formik.values,
+ data: data, // TODO: is this correct?
headers: { 'Content-Type': 'application/json' }
})
.then(response => {
@@ -115,9 +118,17 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
}
const createAndSubmitRequest = async () => {
+ let createPayload = formik.values;
+ if (isEmpty(formik.values?.payload?.content) && Object.keys(formik.values?.payload).length <= 1) {
+ createPayload = {};
+ }
+ console.log("createAndSubmitRequest", createPayload);
try {
- await callApi(request.links.actions?.create, 'post', true);
- await callApi(request.links.actions?.submit, 'post', true);
+ await callApi(request.links.actions?.create, 'post', createPayload, true);
+ console.log("created");
+ await callApi(request.links.actions?.submit, 'post', formik.values, true);
+ console.log("submitted");
+ fetchUpdated(record.links?.requests, setRequests);
setModalOpen(false);
formik.resetForm();
} catch (error) {
@@ -132,10 +143,18 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
formik.setSubmitting(true);
setError(null);
if (createAndSubmit) {
- return createAndSubmitRequest();
+ return await createAndSubmitRequest();
+ }
+
+ let customPayload = formik.values;
+ if (isEmpty(formik.values?.payload?.content) && formik.values?.payload?.content != "hello world" && Object.keys(formik.values?.payload).length <= 1) { // TODO: remove hardcoded value
+ customPayload = {};
}
+
if (requestType === REQUEST_TYPE.SAVE) {
- return callApi(request.links.self, 'put');
+ return callApi(request.links.self, 'put', {});
+ } else if (requestType === REQUEST_TYPE.CREATE) {
+ return callApi(request.links.actions?.create, 'post', customPayload);
}
return callApi(!isEventModal ? request.links.actions[requestType] : request.links[requestType], 'post');
}
@@ -206,6 +225,10 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
}
}
+ const requestType = requestTypes?.find(requestType => requestType.type_id === request.type) ?? {};
+ const formWillBeRendered = requestModalType === REQUEST_TYPE.SUBMIT && requestType?.payload_ui;
+ const submitButtonExtraProps = formWillBeRendered ? { type: "submit", form: "request-form" } : { onClick: () => confirmAction(REQUEST_TYPE.SUBMIT) };
+
return (
<>
{requestModalType === REQUEST_TYPE.CREATE &&
||
-
+
}
{requestModalType === REQUEST_TYPE.SUBMIT &&
<>
-
- confirmAction(REQUEST_TYPE.CANCEL)} negative icon labelPosition="left" floated="left">
+ confirmAction(REQUEST_TYPE.CANCEL)} negative icon labelPosition="left" floated="left">
- {i18next.t("Delete")}
+ {i18next.t("Cancel request")}
sendRequest(REQUEST_TYPE.SAVE)} color="grey" icon labelPosition="left" floated="right">
@@ -287,9 +288,9 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
>
}
{requestModalType === REQUEST_TYPE.CANCEL &&
- confirmAction(REQUEST_TYPE.CANCEL)} negative icon labelPosition="left" floated="left">
+ confirmAction(REQUEST_TYPE.CANCEL)} negative icon labelPosition="left" floated="left">
- {i18next.t("Delete")}
+ {i18next.t("Cancel request")}
}
{requestModalType === REQUEST_TYPE.ACCEPT &&
From 896f92f0301709d578b0bd18c1f772f055486553 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Wed, 27 Mar 2024 11:20:37 +0100
Subject: [PATCH 28/41] Update created timestamp display in
ModalContentSideInfo component
---
.../record-requests/components/ModalContentSideInfo.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/ModalContentSideInfo.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/ModalContentSideInfo.jsx
index ffb55894..2d09339a 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/ModalContentSideInfo.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/ModalContentSideInfo.jsx
@@ -33,7 +33,7 @@ export const ModalContentSideInfo = ({ request, requestType, isSidebar = false }
{i18next.t("Created")}
- {`${Math.ceil(Math.abs(new Date(request?.created) - new Date()) / 3.6e6)} hours ago`}
+ {request?.created}
From dc02851feb19771c1423e2c86884681a109d3aad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Wed, 27 Mar 2024 11:33:49 +0100
Subject: [PATCH 29/41] BE trans
---
oarepo_requests/translations/cs/LC_MESSAGES/messages.po | 8 ++++----
oarepo_requests/translations/en/LC_MESSAGES/messages.po | 2 +-
oarepo_requests/translations/messages.pot | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
index 6ce45da0..c7eb5265 100644
--- a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2024-03-27 09:01+0100\n"
+"POT-Creation-Date: 2024-03-27 11:31+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language: cs\n"
@@ -141,13 +141,13 @@ msgstr "API pro žádosti záznamu"
#: oarepo_requests/types/delete_record.py:14
msgid "Request deletion of published record"
-msgstr "Požádat o smazání zveřejněného záznamu"
+msgstr "Žádost o smazání zveřejněného záznamu"
#: oarepo_requests/types/edit_record.py:14
msgid "Request re-opening of published record"
-msgstr "Požádat o znovuotevření zveřejněného záznamu"
+msgstr "Žádost o znovuotevření zveřejněného záznamu"
#: oarepo_requests/types/publish_draft.py:14
msgid "Request publishing of a draft"
-msgstr "Požádat o kontrolu a zveřejnění konceptu"
+msgstr "Žádost o kontrolu a zveřejnění konceptu"
diff --git a/oarepo_requests/translations/en/LC_MESSAGES/messages.po b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
index a3d97b3e..0e701af4 100644
--- a/oarepo_requests/translations/en/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
@@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2024-03-27 09:01+0100\n"
+"POT-Creation-Date: 2024-03-27 11:31+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language: en\n"
diff --git a/oarepo_requests/translations/messages.pot b/oarepo_requests/translations/messages.pot
index cceb7088..18179dff 100644
--- a/oarepo_requests/translations/messages.pot
+++ b/oarepo_requests/translations/messages.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2024-03-27 09:01+0100\n"
+"POT-Creation-Date: 2024-03-27 11:31+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
From 0dc21ace2f0a558821f45dc62ac3fcf4e8a321dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Wed, 27 Mar 2024 14:08:43 +0100
Subject: [PATCH 30/41] Update translations
---
.../oarepo_requests_ui/.gitignore | 5 +++
.../messages/cs/LC_MESSAGES/translations.json | 9 +++---
.../messages/en/LC_MESSAGES/translations.json | 32 ++++++++++++++++++-
3 files changed, 40 insertions(+), 6 deletions(-)
create mode 100644 oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/.gitignore
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/.gitignore b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/.gitignore
new file mode 100644
index 00000000..064f1c87
--- /dev/null
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/.gitignore
@@ -0,0 +1,5 @@
+i18next-scanner.config.js
+scripts
+package.json
+package-lock.json
+translations.pot
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
index f6b869f3..7a67ef2d 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
@@ -1,7 +1,6 @@
{
"Create Request": "Vytvořit žádost",
"No status": "Neznámý stav",
- "Open dialog for request": "Otevřít dialogové okno pro žádost",
"My Requests": "Moje Žádosti",
"Requests to Approve": "Žádosti ke schválení",
"Are you sure?": "Jste si jistí?",
@@ -9,8 +8,6 @@
"OK": "OK",
"Create request": "Vytvořit žádost",
"Submit request": "Odeslat žádost",
- "Delete request": "Smazat žádost",
- "Delete": "Smazat",
"Accept request": "Přijmout žádost",
"Accept": "Přijmout",
"Decline request": "Zamítnout žádost",
@@ -28,5 +25,7 @@
"Created": "Vytvořeno",
"Timeline": "Časová osa",
"Submit event": "Odeslat událost",
- "No requests to show": "Žádné žádosti k zobrazení"
-}
\ No newline at end of file
+ "No requests to show": "Žádné žádosti k zobrazení",
+ "Cannot send request. Please try again later.": "Nelze odeslat žádost. Zkuste to prosím později.",
+ "Cancel request": "Zrušit žádost"
+}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
index 9e26dfee..4f672318 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
@@ -1 +1,31 @@
-{}
\ No newline at end of file
+{
+ "Create Request": "Create Request",
+ "Creator": "Creator",
+ "Receiver": "Receiver",
+ "Request type": "Request type",
+ "Created": "Created",
+ "No status": "No status",
+ "My Requests": "My Requests",
+ "No requests to show": "No requests to show",
+ "Requests to Approve": "Requests to Approve",
+ "Are you sure?": "Are you sure?",
+ "Cancel": "Cancel",
+ "OK": "OK",
+ "Cannot send request. Please try again later.": "Cannot send request. Please try again later.",
+ "Submit event": "Submit event",
+ "Create request": "Create request",
+ "Submit request": "Submit request",
+ "Cancel request": "Cancel request",
+ "Accept request": "Accept request",
+ "Accept": "Accept",
+ "Decline request": "Decline request",
+ "Decline": "Decline",
+ "Create and submit request": "Create and submit request",
+ "Create and submit": "Create and submit",
+ "Error sending request": "Error sending request",
+ "Submit": "Submit",
+ "Save drafted request": "Save drafted request",
+ "Save": "Save",
+ "Create": "Create",
+ "Timeline": "Timeline"
+}
From 34b2de0b0a9762c10bd8e13ab38efa210a73f226 Mon Sep 17 00:00:00 2001
From: Mirek Simek
Date: Wed, 27 Mar 2024 14:30:32 +0100
Subject: [PATCH 31/41] assigned=True and mine=true on requests api
---
oarepo_requests/services/search_options.py | 50 ++++++++++++++++++++++
oarepo_requests/views/api.py | 4 ++
2 files changed, 54 insertions(+)
create mode 100644 oarepo_requests/services/search_options.py
diff --git a/oarepo_requests/services/search_options.py b/oarepo_requests/services/search_options.py
new file mode 100644
index 00000000..cf72506f
--- /dev/null
+++ b/oarepo_requests/services/search_options.py
@@ -0,0 +1,50 @@
+from invenio_records_resources.services.records.params import FilterParam
+from invenio_requests.resources.requests.config import RequestSearchRequestArgsSchema, RequestsResourceConfig
+from invenio_requests.services.requests.config import RequestSearchOptions, RequestsServiceConfig
+from marshmallow import fields
+from opensearch_dsl.query import Bool, Term
+
+
+class RequestOwnerFilterParam(FilterParam):
+ def apply(self, identity, search, params):
+ value = params.pop(self.param_name, None)
+ if value is not None:
+ search = search.filter("term", **{self.field_name: identity.id})
+ return search
+
+
+class RequestReceiverFilterParam(FilterParam):
+ def apply(self, identity, search, params):
+ value = params.pop(self.param_name, None)
+ my_groups = [
+ n.value for n in identity.provides if n.method == 'role'
+ ]
+ if value is not None:
+ search = search.filter(Bool(should=[
+ # explicitly myself
+ Term(**{f"{self.field_name}.user": identity.id}),
+ # my roles
+ *[
+ Term(**{f"{self.field_name}.group": group_id}) for group_id in my_groups
+ ],
+ # TODO: add my communities where I have a role to accept requests
+ ], minimum_should_match=1))
+ return search
+
+
+class EnhancedRequestSearchOptions(RequestSearchOptions):
+ params_interpreters_cls = RequestSearchOptions.params_interpreters_cls + [
+ RequestOwnerFilterParam.factory("mine", "created_by.user"),
+ RequestReceiverFilterParam.factory("assigned", "receiver")
+ ]
+
+
+class ExtendedRequestSearchRequestArgsSchema(RequestSearchRequestArgsSchema):
+ mine = fields.Boolean()
+ assigned = fields.Boolean()
+
+
+def override_invenio_request_search_options(*args, **kwargs):
+ # this monkey patch should be done better
+ RequestsServiceConfig.search = EnhancedRequestSearchOptions
+ RequestsResourceConfig.request_search_args = ExtendedRequestSearchRequestArgsSchema
\ No newline at end of file
diff --git a/oarepo_requests/views/api.py b/oarepo_requests/views/api.py
index ea7df014..e5ce6206 100644
--- a/oarepo_requests/views/api.py
+++ b/oarepo_requests/views/api.py
@@ -2,6 +2,10 @@ def create_oarepo_requests(app):
"""Create requests blueprint."""
ext = app.extensions["oarepo-requests"]
blueprint = ext.requests_resource.as_blueprint()
+
+ from oarepo_requests.services.search_options import override_invenio_request_search_options
+ blueprint.record_once(override_invenio_request_search_options)
+
return blueprint
From e16d3893af400def483eb05b7cdf49ce937012af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Wed, 27 Mar 2024 14:55:40 +0100
Subject: [PATCH 32/41] Reload after accepted request
---
.../record-requests/components/RequestModal.jsx | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
index 51f959ba..c8972f0d 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
@@ -98,8 +98,6 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
});
}
- console.log(url, method);
-
return axios({
method: method,
url: url,
@@ -136,7 +134,7 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
}
}
- const sendRequest = (requestType, createAndSubmit = false) => {
+ const sendRequest = async (requestType, createAndSubmit = false) => {
formik.setSubmitting(true);
setError(null);
if (createAndSubmit) {
@@ -144,6 +142,10 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
}
if (requestType === REQUEST_TYPE.SAVE) {
return callApi(request.links.self, 'put');
+ } else if (requestType === REQUEST_TYPE.ACCEPT) { // Reload page after succesful "Accept" operation
+ await callApi(request.links.actions?.accept, 'post');
+ location.reload();
+ return;
}
const mappedData = !isDeepEmpty(formik.values) ? {} : formik.values;
const actionUrl = !isEventModal ? request.links.actions[requestType] : request.links[requestType];
From b48783922e96541368c51f71b60191ec228a002f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C4=8Corov=C4=8D=C3=A1k?=
Date: Wed, 27 Mar 2024 15:19:01 +0100
Subject: [PATCH 33/41] Fix CreateRequestButtonGroup rendering issue
---
.../record-requests/components/CreateRequestButtonGroup.jsx | 2 +-
.../record-requests/components/RecordRequests.jsx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
index 98c641dc..462f58e9 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/CreateRequestButtonGroup.jsx
@@ -20,7 +20,7 @@ export const CreateRequestButtonGroup = ({ requestTypes }) => {
return (
{i18next.t("Create Request")}
-
+
{createRequests.map((requestType) => (
{
{!_isEmpty(requestTypes) && (
)}
- {!_isEmpty(record?.requests) && (
+ {!_isEmpty(requestsState[0]) && (
)}
From 6e1cb13f86bea31ea39adf2b7fcdb6614d72b602 Mon Sep 17 00:00:00 2001
From: Miroslav Bauer
Date: Wed, 27 Mar 2024 17:58:48 +0100
Subject: [PATCH 34/41] style: make requests state code understandable
---
.../record-requests/components/RecordRequests.jsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
index dc6b466d..5c728df6 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
@@ -17,7 +17,7 @@ export const RecordRequests = ({ record }) => {
/** @type {RequestType[]} */
const requestTypes = record?.request_types ?? [];
- const requestsState = useState(sortByStatusCode(record?.requests ?? []) ?? []);
+ const [requests, setRequests] = useState(sortByStatusCode(record?.requests ?? []) ?? []);
useEffect(() => {
axios({
@@ -29,7 +29,7 @@ export const RecordRequests = ({ record }) => {
}
})
.then(response => {
- requestsState[1](sortByStatusCode(response.data?.hits?.hits));
+ setRequests(sortByStatusCode(response.data?.hits?.hits));
})
.catch(error => {
console.log(error);
@@ -42,7 +42,7 @@ export const RecordRequests = ({ record }) => {
{!_isEmpty(requestTypes) && (
)}
- {!_isEmpty(requestsState[0]) && (
+ {!_isEmpty(requests) && (
)}
From b303c6238780fc06d7a4d49d58a7e2524bedf760 Mon Sep 17 00:00:00 2001
From: Miroslav Bauer
Date: Wed, 27 Mar 2024 18:03:31 +0100
Subject: [PATCH 35/41] style: refactor requestContext usage
---
.../record-requests/components/RecordRequests.jsx | 2 +-
.../record-requests/components/RequestListContainer.jsx | 2 +-
.../record-requests/components/RequestModal.jsx | 2 +-
.../record-requests/components/RequestModalContent.jsx | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
index 5c728df6..2cbec03a 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
@@ -38,7 +38,7 @@ export const RecordRequests = ({ record }) => {
return (
-
+
{!_isEmpty(requestTypes) && (
)}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
index 919f957e..0ae1c914 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestListContainer.jsx
@@ -15,7 +15,7 @@ import { RequestContext } from "../contexts";
* @param {{ requests: Request[], requestTypes: RequestType[] }} props
*/
export const RequestListContainer = ({ requestTypes }) => {
- const [requests,] = useContext(RequestContext);
+ const { requests } = useContext(RequestContext);
let requestsToApprove = [];
let otherRequests = [];
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
index c8972f0d..69a15824 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModal.jsx
@@ -67,7 +67,7 @@ export const RequestModal = ({ request, requestTypes, requestModalType, isEventM
const errorMessageRef = useRef(null);
/** @type {[Request[], (requests: Request[]) => void]} */
- const [requests, setRequests] = useContext(RequestContext);
+ const { setRequests } = useContext(RequestContext);
const record = useContext(RecordContext);
const formik = useFormik({
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
index 16d57f81..2cc170f0 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
@@ -24,7 +24,7 @@ import ReadOnlyCustomFields from "./common/ReadOnlyCustomFields";
/** @param {{ request: Request, requestModalType: RequestTypeEnum, requestType: RequestType, fetchNewEvents: (url: string, setter: (events: Event[]) => void) => Promise, customSubmitHandler: (e) => void }} props */
export const RequestModalContent = ({ request, requestType, requestModalType, fetchNewEvents, customSubmitHandler }) => {
/** @type {[Request[], (requests: Request[]) => void]} */
- const [requests, setRequests] = useContext(RequestContext);
+ const { requests, setRequests } = useContext(RequestContext);
const actualRequest = requests.find(req => req.id === request.id);
From 3ff58dfabe17111115d1e9c427247face8784711 Mon Sep 17 00:00:00 2001
From: Mirek Simek
Date: Wed, 27 Mar 2024 18:08:38 +0100
Subject: [PATCH 36/41] Translations updated
---
babel.ini | 4 +
.../translations/cs/LC_MESSAGES/messages.po | 12 ++-
.../translations/en/LC_MESSAGES/messages.po | 11 ++-
oarepo_requests/translations/messages.pot | 78 ++++++++++---------
.../messages/cs/LC_MESSAGES/translations.json | 32 +-------
.../messages/en/LC_MESSAGES/translations.json | 32 +-------
6 files changed, 67 insertions(+), 102 deletions(-)
diff --git a/babel.ini b/babel.ini
index 39e658cd..5f06bab3 100644
--- a/babel.ini
+++ b/babel.ini
@@ -8,6 +8,9 @@
# Extraction from Python source files
+[extractors]
+jinja2 = jinja2.ext:babel_extract
+
[python: **.py]
encoding = utf-8
@@ -18,6 +21,7 @@ encoding = utf-8
[jinja2: **/templates/**.jinja]
encoding = utf-8
+extensions = jinjax.jinjax.JinjaX
# Special case for jinjax translation strings
[jinja2: **/jinjax_messages.jinja]
diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
index c7eb5265..10b6da1b 100644
--- a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po
@@ -6,12 +6,12 @@ msgstr ""
"POT-Creation-Date: 2024-03-27 11:31+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
-"Language: cs\n"
"Language-Team: cs \n"
-"Plural-Forms: nplurals=3; plural=((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);\n"
+"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);\n"
"Generated-By: Babel 2.14.0\n"
#: oarepo_requests/services/ui_schema.py:71
@@ -151,3 +151,11 @@ msgstr "Žádost o znovuotevření zveřejněného záznamu"
msgid "Request publishing of a draft"
msgstr "Žádost o kontrolu a zveřejnění konceptu"
+msgid "No status"
+msgstr "Beze stavu"
+
+msgid "Cannot send request. Please try again later."
+msgstr "Nemohu poslat žádost. Prosím, zkuste později."
+
+msgid "Cancel request"
+msgstr ""
diff --git a/oarepo_requests/translations/en/LC_MESSAGES/messages.po b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
index 0e701af4..7283ebc8 100644
--- a/oarepo_requests/translations/en/LC_MESSAGES/messages.po
+++ b/oarepo_requests/translations/en/LC_MESSAGES/messages.po
@@ -6,12 +6,12 @@ msgstr ""
"POT-Creation-Date: 2024-03-27 11:31+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
-"Language: en\n"
"Language-Team: en \n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Generated-By: Babel 2.14.0\n"
#: oarepo_requests/services/ui_schema.py:71
@@ -150,6 +150,11 @@ msgstr ""
msgid "Request publishing of a draft"
msgstr ""
+msgid "Cannot send request. Please try again later."
+msgstr ""
+
+msgid "Cancel request"
+msgstr ""
+
#~ msgid "No status"
#~ msgstr ""
-
diff --git a/oarepo_requests/translations/messages.pot b/oarepo_requests/translations/messages.pot
index 18179dff..d6fedfc2 100644
--- a/oarepo_requests/translations/messages.pot
+++ b/oarepo_requests/translations/messages.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2024-03-27 11:31+0100\n"
+"POT-Creation-Date: 2024-03-27 18:06+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -17,139 +17,147 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"
-#: oarepo_requests/services/ui_schema.py:71
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/services/ui_schema.py:71
msgid "status"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:3
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:3
msgid "Create Request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:4
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:4
msgid "Open dialog for request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:5
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:5
msgid "My Requests"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:6
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:6
msgid "Requests to Approve"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:7
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:7
msgid "Are you sure?"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:8
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:8
msgid "Cancel"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:9
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:9
msgid "OK"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:10
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:10
msgid "Create request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:11
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:11
msgid "Submit request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:12
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:12
msgid "Delete request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:13
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:13
msgid "Delete"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:14
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:14
msgid "Accept request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:15
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:15
msgid "Accept"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:16
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:16
msgid "Decline request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:17
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:17
msgid "Decline"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:18
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:18
msgid "Create and submit request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:19
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:19
msgid "Create and submit"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:20
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:20
msgid "Error sending request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:21
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:21
msgid "Submit"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:22
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:22
msgid "Save drafted request"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:23
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:23
msgid "Save"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:24
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:24
msgid "Create"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:25
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:25
msgid "Creator"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:26
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:26
msgid "Receiver"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:27
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:27
msgid "Request type"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:28
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:28
msgid "Created"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:29
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:29
msgid "Timeline"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:30
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:30
msgid "Submit event"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:31
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:31
msgid "No requests to show"
msgstr ""
-#: oarepo_requests/translations/_only_for_translations.py:32
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:32
msgid "api.requests"
msgstr ""
-#: oarepo_requests/types/delete_record.py:14
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/types/delete_record.py:14
msgid "Request deletion of published record"
msgstr ""
-#: oarepo_requests/types/edit_record.py:14
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/types/edit_record.py:16
msgid "Request re-opening of published record"
msgstr ""
-#: oarepo_requests/types/publish_draft.py:14
+#: /Users/m/w/cesnet/oarepo-requests/oarepo_requests/types/publish_draft.py:14
msgid "Request publishing of a draft"
msgstr ""
+msgid "No status"
+msgstr ""
+
+msgid "Cannot send request. Please try again later."
+msgstr ""
+
+msgid "Cancel request"
+msgstr ""
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
index 7a67ef2d..6fce8ad7 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/cs/LC_MESSAGES/translations.json
@@ -1,31 +1 @@
-{
- "Create Request": "Vytvořit žádost",
- "No status": "Neznámý stav",
- "My Requests": "Moje Žádosti",
- "Requests to Approve": "Žádosti ke schválení",
- "Are you sure?": "Jste si jistí?",
- "Cancel": "Zrušit",
- "OK": "OK",
- "Create request": "Vytvořit žádost",
- "Submit request": "Odeslat žádost",
- "Accept request": "Přijmout žádost",
- "Accept": "Přijmout",
- "Decline request": "Zamítnout žádost",
- "Decline": "Zamítnout",
- "Create and submit request": "Vytvořit a odeslat žádost",
- "Create and submit": "Vytvořit a odeslat",
- "Error sending request": "Chyba při odesílání žádosti",
- "Submit": "Odeslat",
- "Save drafted request": "Uložit koncept žádosti",
- "Save": "Uložit",
- "Create": "Vytvořit",
- "Creator": "Tvůrce",
- "Receiver": "Příjemce",
- "Request type": "Typ žádosti",
- "Created": "Vytvořeno",
- "Timeline": "Časová osa",
- "Submit event": "Odeslat událost",
- "No requests to show": "Žádné žádosti k zobrazení",
- "Cannot send request. Please try again later.": "Nelze odeslat žádost. Zkuste to prosím později.",
- "Cancel request": "Zrušit žádost"
-}
+{"Create Request":"Vytvořit žádost","Open dialog for request":"Otevřít dialogové okno pro žádost","My Requests":"Moje žádosti","Requests to Approve":"Žádosti ke schválení","Are you sure?":"Jste si jistí?","Cancel":"Zrušit","OK":"OK","Create request":"Vytvořit žádost","Submit request":"Odeslat žádost","Delete request":"Smazat žádost","Delete":"Smazat","Accept request":"Přijmout žádost","Accept":"Přijmout","Decline request":"Zamítnout žádost","Decline":"Zamítnout","Create and submit request":"Vytvořit a odeslat žádost","Create and submit":"Vytvořit a odeslat","Error sending request":"Chyba při odesílání žádosti","Submit":"Odeslat","Save drafted request":"Uložit koncept žádosti","Save":"Uložit","Create":"Vytvořit","Creator":"Tvůrce","Receiver":"Příjemce","Request type":"Typ žádosti","Created":"Vytvořeno","Timeline":"Časová osa","Submit event":"Odeslat událost","No requests to show":"Žádné žádosti k zobrazení","api.requests":"API pro žádosti záznamu","Request deletion of published record":"Žádost o smazání zveřejněného záznamu","Request re-opening of published record":"Žádost o znovuotevření zveřejněného záznamu","Request publishing of a draft":"Žádost o kontrolu a zveřejnění konceptu"}
\ No newline at end of file
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
index 4f672318..d6d48eee 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/translations/oarepo_requests_ui/messages/en/LC_MESSAGES/translations.json
@@ -1,31 +1 @@
-{
- "Create Request": "Create Request",
- "Creator": "Creator",
- "Receiver": "Receiver",
- "Request type": "Request type",
- "Created": "Created",
- "No status": "No status",
- "My Requests": "My Requests",
- "No requests to show": "No requests to show",
- "Requests to Approve": "Requests to Approve",
- "Are you sure?": "Are you sure?",
- "Cancel": "Cancel",
- "OK": "OK",
- "Cannot send request. Please try again later.": "Cannot send request. Please try again later.",
- "Submit event": "Submit event",
- "Create request": "Create request",
- "Submit request": "Submit request",
- "Cancel request": "Cancel request",
- "Accept request": "Accept request",
- "Accept": "Accept",
- "Decline request": "Decline request",
- "Decline": "Decline",
- "Create and submit request": "Create and submit request",
- "Create and submit": "Create and submit",
- "Error sending request": "Error sending request",
- "Submit": "Submit",
- "Save drafted request": "Save drafted request",
- "Save": "Save",
- "Create": "Create",
- "Timeline": "Timeline"
-}
+{"api.requests":"Requests API"}
\ No newline at end of file
From cf0db54e381708f7d6429e546054011dbee14526 Mon Sep 17 00:00:00 2001
From: Miroslav Bauer
Date: Wed, 27 Mar 2024 18:16:45 +0100
Subject: [PATCH 37/41] add setRequests to effect dependencies
---
.../record-requests/components/RecordRequests.jsx | 3 ++-
.../record-requests/components/RequestModalContent.jsx | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
index 2cbec03a..abf07302 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RecordRequests.jsx
@@ -18,6 +18,7 @@ export const RecordRequests = ({ record }) => {
const requestTypes = record?.request_types ?? [];
const [requests, setRequests] = useState(sortByStatusCode(record?.requests ?? []) ?? []);
+ const requestsSetter = React.useCallback(newRequests => setRequests(newRequests), [])
useEffect(() => {
axios({
@@ -38,7 +39,7 @@ export const RecordRequests = ({ record }) => {
return (
-
+
{!_isEmpty(requestTypes) && (
)}
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
index 2cc170f0..68b79b9a 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/components/RequestModalContent.jsx
@@ -39,7 +39,7 @@ export const RequestModalContent = ({ request, requestType, requestModalType, fe
}));
});
}
- }, [actualRequest]);
+ }, [actualRequest, setRequests]);
const { handleSubmit } = useFormikContext();
From d0ec2b369c27febe60fae3a926dd5d0eae095a69 Mon Sep 17 00:00:00 2001
From: Miroslav Bauer
Date: Wed, 27 Mar 2024 18:23:51 +0100
Subject: [PATCH 38/41] remove debug log
---
.../semantic-ui/js/oarepo_requests_ui/record-requests/index.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
index a9b8dbec..2861a95f 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/index.js
@@ -9,8 +9,6 @@ const recordRequestsAppDiv = document.getElementById("record-requests");
let record = JSON.parse(recordRequestsAppDiv.dataset.record);
-console.log("RecordRequests - Record", record);
-
if (!_isEmpty(record?.request_types) || !_isEmpty(record?.requests)) {
ReactDOM.render(
Date: Wed, 27 Mar 2024 18:29:27 +0100
Subject: [PATCH 39/41] add todo
---
.../js/oarepo_requests_ui/record-requests/utils/index.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/index.js b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/index.js
index 02c3ccea..2c00d407 100644
--- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/index.js
+++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/index.js
@@ -5,6 +5,8 @@ import _partition from "lodash/partition";
import _isEmpty from "lodash/isEmpty";
export function sortByStatusCode(requests) {
+ // TODO: why we are checking status_code of first request
+ // instead of just checking if requests array is empty
if (!_has(requests[0], "status_code")) {
return requests;
}
From 9a26a017755c62d1146e65c3b52068af2afd069c Mon Sep 17 00:00:00 2001
From: Mirek Simek
Date: Wed, 27 Mar 2024 18:34:39 +0100
Subject: [PATCH 40/41] removed obsolete translate command
---
translate.sh | 3 ---
1 file changed, 3 deletions(-)
delete mode 100755 translate.sh
diff --git a/translate.sh b/translate.sh
deleted file mode 100755
index 50a81905..00000000
--- a/translate.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-pybabel extract -o oarepo_requests/translations/messages.pot oarepo_requests
-pybabel update -i oarepo_requests/translations/messages.pot -d oarepo_requests/translations
-pybabel compile -d oarepo_requests/translations
\ No newline at end of file
From e3ca2681bdcbc34f5c887583204436f040192ee8 Mon Sep 17 00:00:00 2001
From: Mirek Simek
Date: Wed, 27 Mar 2024 18:35:10 +0100
Subject: [PATCH 41/41] Increased version
---
setup.cfg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.cfg b/setup.cfg
index d8023760..b8d93f4b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-requests
-version = 1.1.6
+version = 1.1.7
description =
authors = Ronald Krist
readme = README.md