chore: feedback changes
This commit is contained in:
@@ -38,7 +38,6 @@ export const queryDrafts: QueryDrafts = async function queryDrafts(
|
||||
|
||||
for (let i = 0; i < result.docs.length; i++) {
|
||||
const id = result.docs[i].parent
|
||||
console.log(result.docs[i])
|
||||
const localeStatus = result.docs[i].localeStatus || {}
|
||||
if (locale && localeStatus[locale]) {
|
||||
result.docs[i].status = localeStatus[locale]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @ts-strict-ignore
|
||||
import type { SanitizedConfig } from '../config/types.js'
|
||||
import type { CheckboxField, Field, Option } from '../fields/config/types.js'
|
||||
|
||||
export const statuses: Option[] = [
|
||||
@@ -43,3 +44,23 @@ export const versionSnapshotField: CheckboxField = {
|
||||
},
|
||||
index: true,
|
||||
}
|
||||
|
||||
export function buildLocaleStatusField(config: SanitizedConfig): Field[] {
|
||||
if (!config.localization || !config.localization.locales) {
|
||||
throw new Error('localeStatusFields called without localization config.')
|
||||
}
|
||||
|
||||
return config.localization.locales.map((locale) => {
|
||||
const code = typeof locale === 'string' ? locale : locale.code
|
||||
|
||||
return {
|
||||
name: code,
|
||||
type: 'select',
|
||||
index: true,
|
||||
options: [
|
||||
{ label: ({ t }) => t('version:draft'), value: 'draft' },
|
||||
{ label: ({ t }) => t('version:published'), value: 'published' },
|
||||
],
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { SanitizedCollectionConfig } from '../collections/config/types.js'
|
||||
import type { SanitizedConfig } from '../config/types.js'
|
||||
import type { Field, FlattenedField } from '../fields/config/types.js'
|
||||
|
||||
import { versionSnapshotField } from './baseFields.js'
|
||||
import { buildLocaleStatusField, versionSnapshotField } from './baseFields.js'
|
||||
|
||||
export const buildVersionCollectionFields = <T extends boolean = false>(
|
||||
config: SanitizedConfig,
|
||||
@@ -64,18 +64,7 @@ export const buildVersionCollectionFields = <T extends boolean = false>(
|
||||
})
|
||||
|
||||
if (config.localization.enableStatusLocalization) {
|
||||
const localeStatusFields: Field[] = config.localization.locales.map((locale) => {
|
||||
const code = typeof locale === 'string' ? locale : locale.code
|
||||
|
||||
return {
|
||||
name: code,
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: 'Draft', value: 'draft' },
|
||||
{ label: 'Published', value: 'published' },
|
||||
],
|
||||
}
|
||||
})
|
||||
const localeStatusFields = buildLocaleStatusField(config)
|
||||
|
||||
fields.push({
|
||||
name: 'localeStatus',
|
||||
@@ -85,7 +74,6 @@ export const buildVersionCollectionFields = <T extends boolean = false>(
|
||||
disabled: true,
|
||||
},
|
||||
fields: localeStatusFields,
|
||||
index: true,
|
||||
...(flatten && {
|
||||
flattenedFields: localeStatusFields as FlattenedField[],
|
||||
})!,
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { SanitizedConfig } from '../config/types.js'
|
||||
import type { Field, FlattenedField } from '../fields/config/types.js'
|
||||
import type { SanitizedGlobalConfig } from '../globals/config/types.js'
|
||||
|
||||
import { versionSnapshotField } from './baseFields.js'
|
||||
import { buildLocaleStatusField, versionSnapshotField } from './baseFields.js'
|
||||
|
||||
export const buildVersionGlobalFields = <T extends boolean = false>(
|
||||
config: SanitizedConfig,
|
||||
@@ -58,18 +58,7 @@ export const buildVersionGlobalFields = <T extends boolean = false>(
|
||||
})
|
||||
|
||||
if (config.localization.enableStatusLocalization) {
|
||||
const localeStatusFields: Field[] = config.localization.locales.map((locale) => {
|
||||
const code = typeof locale === 'string' ? locale : locale.code
|
||||
|
||||
return {
|
||||
name: code,
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: 'Draft', value: 'draft' },
|
||||
{ label: 'Published', value: 'published' },
|
||||
],
|
||||
}
|
||||
})
|
||||
const localeStatusFields = buildLocaleStatusField(config)
|
||||
|
||||
fields.push({
|
||||
name: 'localeStatus',
|
||||
@@ -79,7 +68,6 @@ export const buildVersionGlobalFields = <T extends boolean = false>(
|
||||
disabled: true,
|
||||
},
|
||||
fields: localeStatusFields,
|
||||
index: true,
|
||||
...(flatten && {
|
||||
flattenedFields: localeStatusFields as FlattenedField[],
|
||||
})!,
|
||||
|
||||
Reference in New Issue
Block a user