feat(voiceover): add draft status to voice scripts and hide drafts from users
This commit is contained in:
parent
dcaa8c9bbe
commit
6fe7dd62bd
6 changed files with 24519 additions and 6 deletions
|
|
@ -63,13 +63,15 @@ export const VoiceScripts: CollectionConfig = {
|
||||||
name: "status",
|
name: "status",
|
||||||
type: "select",
|
type: "select",
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: "open",
|
defaultValue: "draft",
|
||||||
options: [
|
options: [
|
||||||
|
{ label: "Draft", value: "draft" },
|
||||||
{ label: "Open", value: "open" },
|
{ label: "Open", value: "open" },
|
||||||
{ label: "Closed", value: "closed" },
|
{ label: "Closed", value: "closed" },
|
||||||
],
|
],
|
||||||
admin: {
|
admin: {
|
||||||
description: "Closed scripts reject new submissions",
|
description:
|
||||||
|
"Draft scripts are hidden from the frontend. Open scripts accept submissions; closed scripts reject new ones.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ export async function listScriptsForUser(
|
||||||
const [scriptsRes, submissionsRes] = await Promise.all([
|
const [scriptsRes, submissionsRes] = await Promise.all([
|
||||||
payload.find({
|
payload.find({
|
||||||
collection: "voice-scripts",
|
collection: "voice-scripts",
|
||||||
|
where: { status: { not_equals: "draft" } },
|
||||||
sort: "-createdAt",
|
sort: "-createdAt",
|
||||||
limit: 0,
|
limit: 0,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
|
|
@ -121,7 +122,7 @@ export async function getScriptForUser(
|
||||||
overrideAccess: true,
|
overrideAccess: true,
|
||||||
})
|
})
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
if (!script) return null;
|
if (!script || script.status === "draft") return null;
|
||||||
|
|
||||||
const submissionsRes = await payload.find({
|
const submissionsRes = await payload.find({
|
||||||
collection: "voice-submissions",
|
collection: "voice-submissions",
|
||||||
|
|
|
||||||
24488
src/migrations/20260909_223955_add_voice_script_draft_status.json
Normal file
24488
src/migrations/20260909_223955_add_voice_script_draft_status.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrateUpArgs, MigrateDownArgs, sql } from "@payloadcms/db-postgres";
|
||||||
|
|
||||||
|
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TYPE "public"."enum_voice_scripts_status" ADD VALUE IF NOT EXISTS 'draft' BEFORE 'open';`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "voice_scripts" ALTER COLUMN "status" SET DATA TYPE text;
|
||||||
|
ALTER TABLE "voice_scripts" ALTER COLUMN "status" SET DEFAULT 'open'::text;
|
||||||
|
DROP TYPE "public"."enum_voice_scripts_status";
|
||||||
|
CREATE TYPE "public"."enum_voice_scripts_status" AS ENUM('open', 'closed');
|
||||||
|
ALTER TABLE "voice_scripts" ALTER COLUMN "status" SET DEFAULT 'open'::"public"."enum_voice_scripts_status";
|
||||||
|
ALTER TABLE "voice_scripts" ALTER COLUMN "status" SET DATA TYPE "public"."enum_voice_scripts_status" USING "status"::"public"."enum_voice_scripts_status";`);
|
||||||
|
}
|
||||||
|
|
@ -49,6 +49,7 @@ import * as migration_20260908_172241_add_custom_minigame_collections from './20
|
||||||
import * as migration_20260908_193107_add_creator_xp_bank_field from './20260908_193107_add_creator_xp_bank_field';
|
import * as migration_20260908_193107_add_creator_xp_bank_field from './20260908_193107_add_creator_xp_bank_field';
|
||||||
import * as migration_20260908_194435_add_expose_edge_mines_field from './20260908_194435_add_expose_edge_mines_field';
|
import * as migration_20260908_194435_add_expose_edge_mines_field from './20260908_194435_add_expose_edge_mines_field';
|
||||||
import * as migration_20260909_153427_add_opord_recall_best_times from './20260909_153427_add_opord_recall_best_times';
|
import * as migration_20260909_153427_add_opord_recall_best_times from './20260909_153427_add_opord_recall_best_times';
|
||||||
|
import * as migration_20260909_223955_add_voice_script_draft_status from './20260909_223955_add_voice_script_draft_status';
|
||||||
|
|
||||||
export const migrations = [
|
export const migrations = [
|
||||||
{
|
{
|
||||||
|
|
@ -304,6 +305,11 @@ export const migrations = [
|
||||||
{
|
{
|
||||||
up: migration_20260909_153427_add_opord_recall_best_times.up,
|
up: migration_20260909_153427_add_opord_recall_best_times.up,
|
||||||
down: migration_20260909_153427_add_opord_recall_best_times.down,
|
down: migration_20260909_153427_add_opord_recall_best_times.down,
|
||||||
name: '20260909_153427_add_opord_recall_best_times'
|
name: '20260909_153427_add_opord_recall_best_times',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
up: migration_20260909_223955_add_voice_script_draft_status.up,
|
||||||
|
down: migration_20260909_223955_add_voice_script_draft_status.down,
|
||||||
|
name: '20260909_223955_add_voice_script_draft_status'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -3157,9 +3157,9 @@ export interface VoiceScript {
|
||||||
*/
|
*/
|
||||||
spoiler?: boolean | null;
|
spoiler?: boolean | null;
|
||||||
/**
|
/**
|
||||||
* Closed scripts reject new submissions
|
* Draft scripts are hidden from the frontend. Open scripts accept submissions; closed scripts reject new ones.
|
||||||
*/
|
*/
|
||||||
status: 'open' | 'closed';
|
status: 'draft' | 'open' | 'closed';
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue