feat: 为文档库添加文档类型显示功能
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m10s
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m10s
- 功能添加:在文档列表中,当未指定文档类型时,在标题右侧显示文档类型 - 查询更改:产品查询添加文档类型查询方法 - mapper更改:productDocumentView添加文档类型
This commit is contained in:
@ -51,6 +51,13 @@ query GetProduct($id: ID!, $locale: String!) {
|
||||
id
|
||||
product_documents_id(filter: { status: { _eq: "published" } }) {
|
||||
id
|
||||
type {
|
||||
id
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
file {
|
||||
id
|
||||
filesize
|
||||
|
||||
@ -347,6 +347,15 @@ describe('toProductDocumentView', () => {
|
||||
filesize: 1000,
|
||||
filename_download: 'doc1.pdf',
|
||||
},
|
||||
type: {
|
||||
id: 1,
|
||||
translations: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'manual',
|
||||
},
|
||||
],
|
||||
},
|
||||
translations: [
|
||||
{
|
||||
id: 1,
|
||||
@ -363,6 +372,10 @@ describe('toProductDocumentView', () => {
|
||||
fileId: 'rand-om__-uuid-1234',
|
||||
filename: 'doc1.pdf',
|
||||
title: 'Document Title 1',
|
||||
type: {
|
||||
id: '1',
|
||||
name: 'manual',
|
||||
},
|
||||
size: 1000,
|
||||
url: '/api/assets/rand-om__-uuid-1234',
|
||||
},
|
||||
@ -391,6 +404,10 @@ describe('toProductDocumentView', () => {
|
||||
fileId: 'rand-om__-uuid-1234',
|
||||
filename: 'doc1.pdf',
|
||||
title: '',
|
||||
type: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
},
|
||||
size: 1000,
|
||||
url: '/api/assets/rand-om__-uuid-1234',
|
||||
},
|
||||
@ -413,6 +430,10 @@ describe('toProductDocumentView', () => {
|
||||
filename: '',
|
||||
title: '',
|
||||
size: 0,
|
||||
type: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
},
|
||||
url: '',
|
||||
},
|
||||
{
|
||||
@ -421,6 +442,10 @@ describe('toProductDocumentView', () => {
|
||||
filename: '',
|
||||
title: '',
|
||||
size: 0,
|
||||
type: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
},
|
||||
url: '',
|
||||
},
|
||||
]);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { isObject } from '../../server/utils/object';
|
||||
import { toDocumentTypeView } from './documentMapper';
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 ProductImage 数据转换为 ProductImageView 视图模型
|
||||
@ -161,6 +162,10 @@ export function toProductDocumentView(
|
||||
size: 0,
|
||||
title: '',
|
||||
url: '',
|
||||
type: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
},
|
||||
} satisfies ProductDocumentView;
|
||||
}
|
||||
|
||||
@ -173,6 +178,10 @@ export function toProductDocumentView(
|
||||
size: 0,
|
||||
title: '',
|
||||
url: '',
|
||||
type: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
},
|
||||
} satisfies ProductDocumentView;
|
||||
}
|
||||
|
||||
@ -184,6 +193,8 @@ export function toProductDocumentView(
|
||||
|
||||
const trans = document.translations?.[0];
|
||||
|
||||
const typeView = toDocumentTypeView(document.type ?? null);
|
||||
|
||||
return {
|
||||
id: item.id.toString(),
|
||||
fileId: file?.id ?? '',
|
||||
@ -191,6 +202,7 @@ export function toProductDocumentView(
|
||||
size: file?.filesize ?? 0,
|
||||
title: trans?.title ?? '',
|
||||
url: url,
|
||||
type: typeView,
|
||||
} satisfies ProductDocumentView;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user