Added state selector for world
This commit is contained in:
26
components/global/input/ContentState.vue
Normal file
26
components/global/input/ContentState.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { contentStates, type ContentState } from "~/models/Entity";
|
||||||
|
|
||||||
|
const model = defineModel<ContentState>({ default: "draft" });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UiSelect v-model="model">
|
||||||
|
<UiSelectTrigger>
|
||||||
|
<UiSelectValue
|
||||||
|
:placeholder="$t('ui.contentState.selectOne')"
|
||||||
|
/>
|
||||||
|
</UiSelectTrigger>
|
||||||
|
<UiSelectContent position="popper">
|
||||||
|
<UiSelectGroup>
|
||||||
|
<UiSelectItem
|
||||||
|
v-for="state in contentStates"
|
||||||
|
:key="state"
|
||||||
|
:value="state"
|
||||||
|
>
|
||||||
|
{{ $t(`ui.contentState.${state}`) }}
|
||||||
|
</UiSelectItem>
|
||||||
|
</UiSelectGroup>
|
||||||
|
</UiSelectContent>
|
||||||
|
</UiSelect>
|
||||||
|
</template>
|
||||||
@@ -83,10 +83,6 @@ function handleFormCancel() {
|
|||||||
@input="handleNameChange"
|
@input="handleNameChange"
|
||||||
>
|
>
|
||||||
|
|
||||||
<div class="-mx-1 mb-4">
|
|
||||||
<InputColor v-model="worldSkeleton.color" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
id="new-world-description"
|
id="new-world-description"
|
||||||
v-model="worldSkeleton.description"
|
v-model="worldSkeleton.description"
|
||||||
@@ -94,6 +90,14 @@ function handleFormCancel() {
|
|||||||
:placeholder="$t('entity.addDescription')"
|
:placeholder="$t('entity.addDescription')"
|
||||||
class="w-full -my-1 py-1 -mx-1 px-1 min-h-24 max-h-36 text-sm border-b-[1px] bg-transparent focus-visible:outline-none focus-visible:border-blue-600"
|
class="w-full -my-1 py-1 -mx-1 px-1 min-h-24 max-h-36 text-sm border-b-[1px] bg-transparent focus-visible:outline-none focus-visible:border-blue-600"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div class="-mx-1 mb-4">
|
||||||
|
<InputColor v-model="worldSkeleton.color" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="-mx-1 mb-4">
|
||||||
|
<InputContentState v-model="worldSkeleton.state" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="flex justify-end gap-2 mt-6">
|
<footer class="flex justify-end gap-2 mt-6">
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ export default defineI18nConfig(() => ({
|
|||||||
black: "Black",
|
black: "Black",
|
||||||
white: "White",
|
white: "White",
|
||||||
},
|
},
|
||||||
|
contentState: {
|
||||||
|
selectOne: "Select a publication state",
|
||||||
|
published: "Published",
|
||||||
|
draft: "Draft",
|
||||||
|
archived: "Archived",
|
||||||
|
},
|
||||||
greeting: "Connected as {user}",
|
greeting: "Connected as {user}",
|
||||||
anonymousGreeting: "Preferences",
|
anonymousGreeting: "Preferences",
|
||||||
backToProfile: "Back to profile",
|
backToProfile: "Back to profile",
|
||||||
@@ -293,6 +299,12 @@ export default defineI18nConfig(() => ({
|
|||||||
black: "Noir",
|
black: "Noir",
|
||||||
white: "Blanc",
|
white: "Blanc",
|
||||||
},
|
},
|
||||||
|
contentState: {
|
||||||
|
selectOne: "Modify l'état de publication",
|
||||||
|
published: "Publié",
|
||||||
|
draft: "Brouillon",
|
||||||
|
archived: "Archivé",
|
||||||
|
},
|
||||||
greeting: "Connecté en tant que {user}",
|
greeting: "Connecté en tant que {user}",
|
||||||
anonymousGreeting: "Préférences",
|
anonymousGreeting: "Préférences",
|
||||||
backToProfile: "Retour au profil",
|
backToProfile: "Retour au profil",
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import type { CalendarEvent } from "./CalendarEvent"
|
|||||||
import { calendarMonthSchema, type CalendarMonth } from "./CalendarMonth"
|
import { calendarMonthSchema, type CalendarMonth } from "./CalendarMonth"
|
||||||
import { dateSchema, type RPGDate } from "./Date"
|
import { dateSchema, type RPGDate } from "./Date"
|
||||||
import type { World } from "./World"
|
import type { World } from "./World"
|
||||||
|
import type { ContentState } from "./Entity"
|
||||||
|
|
||||||
export type CalendarState = "published" | "draft" | "archived"
|
|
||||||
|
|
||||||
export interface CalendarConfig {
|
export interface CalendarConfig {
|
||||||
months: CalendarMonth[]
|
months: CalendarMonth[]
|
||||||
@@ -17,7 +17,7 @@ export interface Calendar extends CalendarConfig {
|
|||||||
name: string
|
name: string
|
||||||
events: CalendarEvent[]
|
events: CalendarEvent[]
|
||||||
eventNb?: Array<{ count: number }>
|
eventNb?: Array<{ count: number }>
|
||||||
state: CalendarState
|
state: ContentState
|
||||||
color?: string
|
color?: string
|
||||||
world?: World
|
world?: World
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
|
|||||||
2
models/Entity.ts
Normal file
2
models/Entity.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const contentStates = ["published", "draft", "archived"] as const
|
||||||
|
export type ContentState = typeof contentStates[number]
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import type { Calendar } from "./CalendarConfig"
|
import type { Calendar } from "./CalendarConfig"
|
||||||
import { rpgColorSchema, type RPGColor } from "./Color"
|
import { rpgColorSchema, type RPGColor } from "./Color"
|
||||||
|
import type { ContentState } from "./Entity"
|
||||||
export type WorldState = "published" | "draft" | "archived"
|
|
||||||
|
|
||||||
export interface World {
|
export interface World {
|
||||||
id?: number
|
id?: number
|
||||||
@@ -11,7 +10,7 @@ export interface World {
|
|||||||
color?: RPGColor
|
color?: RPGColor
|
||||||
calendars?: Calendar[]
|
calendars?: Calendar[]
|
||||||
gmId?: string
|
gmId?: string
|
||||||
state?: WorldState
|
state?: ContentState
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
updatedAt?: string
|
updatedAt?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
color,
|
color,
|
||||||
|
state,
|
||||||
createdAt:created_at,
|
createdAt:created_at,
|
||||||
updatedAt:updated_at,
|
updatedAt:updated_at,
|
||||||
gmId:gm_id,
|
gmId:gm_id,
|
||||||
@@ -35,6 +36,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
color,
|
color,
|
||||||
|
state,
|
||||||
createdAt:created_at,
|
createdAt:created_at,
|
||||||
updatedAt:updated_at,
|
updatedAt:updated_at,
|
||||||
calendars (
|
calendars (
|
||||||
|
|||||||
Reference in New Issue
Block a user