-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from oarepo/corovcam/fe-150-ux-for-requests-bu…
…ttons-in-various-dialogues UX for request buttons in various dialogues + Refactor RequestModal.jsx
- Loading branch information
Showing
10 changed files
with
168 additions
and
102 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,16 @@ msgstr "" | |
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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 <EMAIL@ADDRESS>\n" | ||
"PO-Revision-Date: 2024-06-19 14:40+0200\n" | ||
"Last-Translator: \n" | ||
"Language-Team: cs <[email protected]>\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" | ||
"X-Generator: Poedit 3.4.4\n" | ||
|
||
#: oarepo_requests/services/ui_schema.py:71 | ||
msgid "status" | ||
|
@@ -204,3 +205,18 @@ msgstr "Chyba při načítání žádostí" | |
|
||
msgid "Loading requests" | ||
msgstr "Načítám žádosti" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/delete_record.py:12 | ||
msgid "Delete record" | ||
msgstr "Smazat záznam" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/edit_record.py:13 | ||
msgid "Edit record" | ||
msgstr "Upravit záznam" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/publish_draft.py:12 | ||
msgid "Publish draft" | ||
msgstr "Publikovat" | ||
|
||
msgid "Close" | ||
msgstr "Zavřít" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,40 +8,40 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
"POT-Creation-Date: 2024-04-08 13:55+0200\n" | ||
"POT-Creation-Date: 2024-06-19 14:40+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\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" | ||
"Generated-By: Babel 2.15.0\n" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:92 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:94 | ||
msgid "Submitted" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:93 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:95 | ||
msgid "Expired" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:94 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:96 | ||
msgid "Accepted" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:95 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:97 | ||
msgid "Declined" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:96 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:98 | ||
msgid "Cancelled" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:98 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:100 | ||
msgid "Status" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:104 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/invenio_patches.py:106 | ||
msgid "Type" | ||
msgstr "" | ||
|
||
|
@@ -169,15 +169,27 @@ msgstr "" | |
msgid "api.requests" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/delete_record.py:14 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/delete_record.py:12 | ||
msgid "Delete record" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/delete_record.py:18 | ||
msgid "Request deletion of published record" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/edit_record.py:16 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/edit_record.py:13 | ||
msgid "Edit record" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/edit_record.py:20 | ||
msgid "Request re-opening of published record" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/publish_draft.py:14 | ||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/publish_draft.py:12 | ||
msgid "Publish draft" | ||
msgstr "" | ||
|
||
#: /Users/miroslavbauer/Code/github.com/oarepo/oarepo-requests/oarepo_requests/types/publish_draft.py:18 | ||
msgid "Request publishing of a draft" | ||
msgstr "" | ||
|
||
|
@@ -207,3 +219,6 @@ msgstr "" | |
|
||
msgid "Cancel request" | ||
msgstr "" | ||
|
||
msgid "Close" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/hooks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useState } from "react"; | ||
|
||
import { i18next } from "@translations/oarepo_requests_ui/i18next"; | ||
import { Button } from "semantic-ui-react"; | ||
|
||
import { REQUEST_TYPE } from "./objects"; | ||
|
||
/** | ||
* @typedef {import("semantic-ui-react").ConfirmProps} ConfirmProps | ||
*/ | ||
|
||
export const useConfirmDialog = (formik, sendRequest, isEventModal) => { | ||
/** @type {[ConfirmProps, (props: ConfirmProps) => void]} */ | ||
const [confirmDialogProps, setConfirmDialogProps] = useState({ | ||
open: false, | ||
content: i18next.t("Are you sure?"), | ||
cancelButton: i18next.t("Close"), | ||
confirmButton: i18next.t("OK"), | ||
onCancel: () => setConfirmDialogProps(props => ({ ...props, open: false })), | ||
onConfirm: () => setConfirmDialogProps(props => ({ ...props, open: false })) | ||
}); | ||
|
||
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 = isEventModal ? i18next.t("Submit event") : i18next.t("Create request"); | ||
break; | ||
case REQUEST_TYPE.SUBMIT: | ||
newConfirmDialogProps.header = i18next.t("Submit request"); | ||
newConfirmDialogProps.confirmButton = i18next.t("OK"); | ||
break; | ||
case REQUEST_TYPE.CANCEL: | ||
newConfirmDialogProps.header = i18next.t("Cancel request"); | ||
newConfirmDialogProps.confirmButton = <Button negative>{i18next.t("Cancel request")}</Button>; | ||
break; | ||
case REQUEST_TYPE.ACCEPT: | ||
newConfirmDialogProps.header = i18next.t("Accept request"); | ||
newConfirmDialogProps.confirmButton = <Button positive>{i18next.t("Accept")}</Button>; | ||
break; | ||
case REQUEST_TYPE.DECLINE: | ||
newConfirmDialogProps.header = i18next.t("Decline request"); | ||
newConfirmDialogProps.confirmButton = <Button negative>{i18next.t("Decline")}</Button>; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
if (createAndSubmit) { | ||
newConfirmDialogProps = { | ||
...newConfirmDialogProps, | ||
header: i18next.t("Create and submit request"), | ||
confirmButton: <Button positive>{i18next.t("Create and submit")}</Button>, | ||
onConfirm: () => { | ||
setConfirmDialogProps(props => ({ ...props, open: false })); | ||
sendRequest(REQUEST_TYPE.CREATE, createAndSubmit); | ||
} | ||
} | ||
} | ||
|
||
setConfirmDialogProps(props => ({ ...props, ...newConfirmDialogProps })); | ||
}; | ||
|
||
return { confirmDialogProps, confirmAction }; | ||
} |
Oops, something went wrong.