revert document types
This commit is contained in:
@@ -56,29 +56,6 @@ const resolveCorrespondents = (doc) => {
|
||||
return results;
|
||||
};
|
||||
|
||||
const resolveDocumentType = (doc) => {
|
||||
if (!doc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const type = doc.document_type;
|
||||
const fallbackId = doc.document_type_id ?? null;
|
||||
|
||||
if (!type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && typeof type.name === 'string') {
|
||||
const name = type.name.trim();
|
||||
if (!name) {
|
||||
return null;
|
||||
}
|
||||
return { id: type.id ?? fallbackId, name };
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
// Detects when an element becomes visible within a scroll container.
|
||||
const useLazyVisibility = (rootRef, resetKey) => {
|
||||
const targetRef = useRef(null);
|
||||
@@ -254,8 +231,6 @@ const DocumentsTable = ({
|
||||
getDownloadHref,
|
||||
onTagClick,
|
||||
onCorrespondentClick,
|
||||
activeDocumentTypeIds = [],
|
||||
onDocumentTypeClick,
|
||||
isSearchLoading = false,
|
||||
onDocumentTagDrop,
|
||||
viewMode = 'list',
|
||||
@@ -282,10 +257,6 @@ const DocumentsTable = ({
|
||||
() => new Set(activeCorrespondentIds || []),
|
||||
[activeCorrespondentIds],
|
||||
);
|
||||
const activeDocumentTypeIdSet = useMemo(
|
||||
() => new Set(activeDocumentTypeIds || []),
|
||||
[activeDocumentTypeIds],
|
||||
);
|
||||
const scrollRef = useRef(null);
|
||||
const suppressDocumentClickRef = useRef(false);
|
||||
const [, forceVisibilityTick] = useState(0);
|
||||
@@ -657,43 +628,10 @@ const DocumentsTable = ({
|
||||
const visibleTags = tagList.slice(0, 3);
|
||||
const remainingTagCount = tagList.length > 3 ? tagList.length - 3 : 0;
|
||||
const correspondents = resolveCorrespondents(doc);
|
||||
const documentType = resolveDocumentType(doc);
|
||||
const isDocumentTypeActive =
|
||||
documentType?.id != null && activeDocumentTypeIdSet.has(documentType.id);
|
||||
const canToggleDocumentType =
|
||||
documentType?.id != null && typeof onDocumentTypeClick === 'function';
|
||||
const cardClasses = ['document-card', 'document'];
|
||||
if (isSelected) cardClasses.push('selected');
|
||||
if (isDraggingDoc) cardClasses.push('is-dragging');
|
||||
const titleText = doc.title || doc.original_name;
|
||||
const documentTypeNode = documentType
|
||||
? (
|
||||
<span
|
||||
className={`doc-type-inline${
|
||||
isDocumentTypeActive ? ' active' : ''
|
||||
}`}
|
||||
role={canToggleDocumentType ? 'button' : undefined}
|
||||
tabIndex={canToggleDocumentType ? 0 : undefined}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
if (canToggleDocumentType) {
|
||||
onDocumentTypeClick?.(documentType.id, documentType);
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (canToggleDocumentType) {
|
||||
onDocumentTypeClick?.(documentType.id, documentType);
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
({documentType.name})
|
||||
</span>
|
||||
)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -733,12 +671,6 @@ const DocumentsTable = ({
|
||||
</span>
|
||||
) : null}
|
||||
<span className="doc-name__primary">{titleText}</span>
|
||||
{documentTypeNode ? (
|
||||
<>
|
||||
{' '}
|
||||
{documentTypeNode}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
{visibleTags.length > 0 && (
|
||||
<div className="document-card__tags">
|
||||
@@ -924,38 +856,7 @@ const DocumentsTable = ({
|
||||
if (isDraggingDoc) rowClasses.push('is-dragging');
|
||||
const downloadHref = getDownloadHref?.(doc) || null;
|
||||
const correspondents = resolveCorrespondents(doc);
|
||||
const documentType = resolveDocumentType(doc);
|
||||
const isRowDocumentTypeActive = documentType?.id != null && activeDocumentTypeIdSet.has(documentType.id);
|
||||
const canToggleRowDocumentType = documentType?.id != null && typeof onDocumentTypeClick === 'function';
|
||||
const titleText = doc.title || doc.original_name;
|
||||
const documentTypeNode = documentType
|
||||
? (
|
||||
<span
|
||||
className={`doc-type-inline${
|
||||
isRowDocumentTypeActive ? ' active' : ''
|
||||
}`}
|
||||
role={canToggleRowDocumentType ? 'button' : undefined}
|
||||
tabIndex={canToggleRowDocumentType ? 0 : undefined}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
if (canToggleRowDocumentType) {
|
||||
onDocumentTypeClick?.(documentType.id, documentType);
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (canToggleRowDocumentType) {
|
||||
onDocumentTypeClick?.(documentType.id, documentType);
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
({documentType.name})
|
||||
</span>
|
||||
)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<tr
|
||||
@@ -991,12 +892,6 @@ const DocumentsTable = ({
|
||||
</span>
|
||||
) : null}
|
||||
<span className="doc-name__primary">{titleText}</span>
|
||||
{documentTypeNode ? (
|
||||
<>
|
||||
{' '}
|
||||
{documentTypeNode}
|
||||
</>
|
||||
) : null}
|
||||
</span>
|
||||
</div>
|
||||
{(doc.tags || []).length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user