diff --git a/apps/console/src/pages/organizations/documents/DocumentLayout.tsx b/apps/console/src/pages/organizations/documents/DocumentLayout.tsx index 1c166576d..d8760c2d9 100644 --- a/apps/console/src/pages/organizations/documents/DocumentLayout.tsx +++ b/apps/console/src/pages/organizations/documents/DocumentLayout.tsx @@ -67,6 +67,7 @@ export const documentLayoutQuery = graphql` ... on Document { id status + writeMode canPublish: permission(action: "core:document-version:publish") ...PublishDialog_documentFragment controlInfo: controls(first: 0) { @@ -146,6 +147,7 @@ export function DocumentLayout(props: { queryRef: PreloadedQuery )} > + {isGenerated && {__("Generated")}} @@ -239,6 +242,8 @@ export function DocumentLayout(props: { queryRef: PreloadedQuery diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentDetailsCard.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentDetailsCard.tsx index d795941f4..c5e0ce991 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentDetailsCard.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentDetailsCard.tsx @@ -124,9 +124,18 @@ export function DocumentDetailsCard(props: { documentFragmentRef: DocumentDetailsCard_documentFragment$key; versionFragmentRef: DocumentDetailsCard_versionFragment$key; isEditable: boolean; + isGenerated?: boolean; + isLatestVersion?: boolean; onDocumentUpdated: () => void; }) { - const { documentFragmentRef, versionFragmentRef, isEditable, onDocumentUpdated } = props; + const { + documentFragmentRef, + versionFragmentRef, + isEditable, + isGenerated = false, + isLatestVersion = true, + onDocumentUpdated, + } = props; const { __ } = useTranslate(); const organizationId = useOrganizationId(); @@ -140,6 +149,8 @@ export function DocumentDetailsCard(props: { const version = useFragment(versionFragment, versionFragmentRef); const canEdit = document.canUpdate && isEditable; + const canEditVersionFields = canEdit && !isGenerated; + const canEditApprovers = document.canUpdate && isLatestVersion; const { control, handleSubmit, reset } = useFormWithSchema( schema, @@ -272,59 +283,6 @@ export function DocumentDetailsCard(props: { return (
-
-
- {__("Approvers")} -
- {isEditingApprovers - ? ( -
-
- ({ - id: a.id, - fullName: a.fullName, - emailAddress: a.emailAddress, - }))} - placeholder={__("Add approvers...")} - /> -
-
- ) - : ( -
-
- {document.defaultApprovers.length > 0 - ? document.defaultApprovers.map(a => a.fullName).join(", ") - : __("None")} -
- {canEdit && ( -
- )} -
{__("Type")} @@ -362,7 +320,7 @@ export function DocumentDetailsCard(props: {
{getDocumentTypeLabel(__, version.documentType)}
- {canEdit && ( + {canEditVersionFields && (
- {canEdit && ( + {canEditVersionFields && (
+ {isLatestVersion && ( +
+
+ {__("Approvers")} +
+ {isEditingApprovers + ? ( +
+
+ ({ + id: a.id, + fullName: a.fullName, + emailAddress: a.emailAddress, + }))} + placeholder={__("Add approvers...")} + /> +
+
+ ) + : ( +
+
+ {document.defaultApprovers.length > 0 + ? document.defaultApprovers.map(a => a.fullName).join(", ") + : __("None")} +
+ {canEditApprovers && ( +
+ )} +
+ )}
diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx index 0d8866d64..df5ba7b82 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx @@ -12,7 +12,7 @@ // OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -import { documentClassifications, documentTypes, getDocumentClassificationLabel, getDocumentTypeLabel, sprintf } from "@probo/helpers"; +import { documentClassifications, documentTypes, documentWriteModes, getDocumentClassificationLabel, getDocumentTypeLabel, getDocumentWriteModeLabel, sprintf } from "@probo/helpers"; import { useList } from "@probo/hooks"; import { useTranslate } from "@probo/i18n"; import { Button, Card, Checkbox, IconArchive, IconArrowDown, IconCrossLargeX, IconSignature, IconTrashCan, IconUpload, Option, Select, Tbody, Th, Thead, Tr, useConfirm } from "@probo/ui"; @@ -23,7 +23,7 @@ import { ConnectionHandler, graphql } from "relay-runtime"; import type { DocumentListBulkArchiveMutation } from "#/__generated__/core/DocumentListBulkArchiveMutation.graphql"; import type { DocumentListBulkUnarchiveMutation } from "#/__generated__/core/DocumentListBulkUnarchiveMutation.graphql"; import type { DocumentListFragment$key } from "#/__generated__/core/DocumentListFragment.graphql"; -import type { DocumentClassification, DocumentOrderField, DocumentsListQuery, DocumentType } from "#/__generated__/core/DocumentsListQuery.graphql"; +import type { DocumentClassification, DocumentOrderField, DocumentsListQuery, DocumentType, DocumentWriteMode } from "#/__generated__/core/DocumentsListQuery.graphql"; import { BulkExportDialog, type BulkExportDialogRef } from "#/components/documents/BulkExportDialog"; import { type Order, SortableTable, SortableTh } from "#/components/SortableTable"; import { useBulkDeleteDocumentsMutation, useBulkExportDocumentsMutation } from "#/hooks/graph/DocumentGraph"; @@ -50,6 +50,7 @@ const fragment = graphql` status: { type: "[DocumentStatus!]", defaultValue: [ACTIVE] } documentTypes: { type: "[DocumentType!]", defaultValue: null } classifications: { type: "[DocumentClassification!]", defaultValue: null } + writeModes: { type: "[DocumentWriteMode!]", defaultValue: null } ) { documents( first: $first @@ -57,7 +58,7 @@ const fragment = graphql` last: $last before: $before orderBy: $order - filter: { status: $status documentTypes: $documentTypes classifications: $classifications } + filter: { status: $status documentTypes: $documentTypes classifications: $classifications writeModes: $writeModes } ) @connection(key: "DocumentsListQuery_documents" filters: ["orderBy", "filter"]) { __id edges { @@ -130,6 +131,7 @@ export function DocumentList(props: { const [documentTypeFilter, setDocumentTypeFilter] = useState(null); const [classificationFilter, setClassificationFilter] = useState(null); + const [writeModeFilter, setWriteModeFilter] = useState(null); const [isPending, startTransition] = useTransition(); const refetch = pagination.refetch; @@ -140,11 +142,12 @@ export function DocumentList(props: { status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null, classifications: classificationFilter ? [classificationFilter] : null, + writeModes: writeModeFilter ? [writeModeFilter] : null, }, { fetchPolicy: "store-and-network" }, ); }); - }, [tab, refetch, documentTypeFilter, classificationFilter]); + }, [tab, refetch, documentTypeFilter, classificationFilter, writeModeFilter]); const documents = pagination.data.documents.edges.map(({ node }) => node); const connectionId = pagination.data.documents.__id; @@ -194,6 +197,7 @@ export function DocumentList(props: { status: [tab], documentTypes: newType ? [newType] : null, classifications: classificationFilter ? [classificationFilter] : null, + writeModes: writeModeFilter ? [writeModeFilter] : null, }, }, ), @@ -214,6 +218,28 @@ export function DocumentList(props: { status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null, classifications: newClassification ? [newClassification] : null, + writeModes: writeModeFilter ? [writeModeFilter] : null, + }, + }, + ), + ); + }; + + const handleWriteModeFilterChange = (value: string) => { + const newWriteMode = value === "ALL" ? null : (value as DocumentWriteMode); + clear(); + setWriteModeFilter(newWriteMode); + onConnectionIdChange( + ConnectionHandler.getConnectionID( + organizationId, + "DocumentsListQuery_documents", + { + orderBy: { direction: "ASC", field: "TITLE" }, + filter: { + status: [tab], + documentTypes: documentTypeFilter ? [documentTypeFilter] : null, + classifications: classificationFilter ? [classificationFilter] : null, + writeModes: newWriteMode ? [newWriteMode] : null, }, }, ), @@ -297,6 +323,7 @@ export function DocumentList(props: { status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null, classifications: classificationFilter ? [classificationFilter] : null, + writeModes: writeModeFilter ? [writeModeFilter] : null, }, }, ), @@ -309,12 +336,24 @@ export function DocumentList(props: { status: [tab], documentTypes: documentTypeFilter ? [documentTypeFilter] : null, classifications: classificationFilter ? [classificationFilter] : null, + writeModes: writeModeFilter ? [writeModeFilter] : null, }); }; return (
+