generated from VLADIMIR/template_frontend
add change status buttons
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { Settings } from '@vicons/carbon'
|
||||
import { Icon } from '@vicons/utils'
|
||||
import { NButton, type UploadFileInfo, useMessage } from 'naive-ui'
|
||||
import { NCard, NFlex, NInput, NModal, NSpace, NText, NUpload, NUploadDragger } from 'naive-ui'
|
||||
import { NCard, NFlex, NInput, NModal, NSpace, NText, NUpload, NUploadDragger, NAlert } from 'naive-ui'
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
@@ -17,6 +17,7 @@ const route = useRoute()
|
||||
const scenarioId = route.params.id
|
||||
|
||||
const showSettingsScenarioModal = ref(false)
|
||||
const statusScenarioName = ref('')
|
||||
const deletedScenarioName = ref('')
|
||||
|
||||
const message = useMessage()
|
||||
@@ -56,6 +57,30 @@ async function deleteScenario(id: number) {
|
||||
router.push('/scenarios')
|
||||
}
|
||||
|
||||
async function publicScenario(id: number) {
|
||||
const res = await client.PublicScenario({ id: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
statusScenarioName.value = ''
|
||||
showSettingsScenarioModal.value = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function draftScenario(id: number) {
|
||||
const res = await client.DraftScenario({ id: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
statusScenarioName.value = ''
|
||||
showSettingsScenarioModal.value = false
|
||||
}
|
||||
|
||||
async function uploadFile(file: File | null, filename: string): Promise<string> {
|
||||
if (!file) {
|
||||
return ''
|
||||
@@ -152,7 +177,7 @@ async function cancelAddPlace() {
|
||||
|
||||
async function addNotFoundDoors(scenario: Scenario, place: Place) {
|
||||
for (const door of place.doors || []) {
|
||||
let place = scenario.story?.places?.find((place) => {
|
||||
const place = scenario.story?.places?.find((place) => {
|
||||
return place.code == door.code
|
||||
})
|
||||
if (place == undefined) {
|
||||
@@ -227,6 +252,11 @@ async function deletePlace(place: Place) {
|
||||
<template>
|
||||
<div class="center-block-custom-big">
|
||||
<div class="places-container">
|
||||
<n-alert v-if="scenario.status == 'public'" title="Сценарий опубликован" type="warning"
|
||||
style="margin-bottom: 20px;">
|
||||
Не рекомендуется редактировать сценарий когда он опубликован.
|
||||
</n-alert>
|
||||
|
||||
<div class="settings-block">
|
||||
Точек: {{ scenario.story?.places?.length }}
|
||||
<n-button quaternary @click="showSettingsScenarioModal = true" class="settings-button">
|
||||
@@ -282,6 +312,25 @@ async function deletePlace(place: Place) {
|
||||
|
||||
<n-button @click="updateScenario()" ghost> Сохранить изменения </n-button>
|
||||
|
||||
<hr class="settings-hr" />
|
||||
<p>Публикация</p>
|
||||
<p>Статус:
|
||||
<span v-if="scenario.status == 'public'">опубликовано</span>
|
||||
<span v-if="scenario.status == 'draft'">в разработке</span>
|
||||
</p>
|
||||
<p>
|
||||
Введите название сценария <n-text class="name-text" strong>{{ scenario.name }}</n-text>
|
||||
</p>
|
||||
<n-input v-model:value="statusScenarioName" type="text" placeholder='Дело №0 "Следствие ведут овечки"' />
|
||||
<n-button v-if="scenario.status != 'public'" @click="publicScenario(scenario.id!)" ghost
|
||||
:disabled="statusScenarioName != scenario.name">
|
||||
Опубликовать сценарий
|
||||
</n-button>
|
||||
<n-button v-if="scenario.status != 'draft'" @click="draftScenario(scenario.id!)" ghost
|
||||
:disabled="statusScenarioName != scenario.name">
|
||||
Снять сценарий с публикации
|
||||
</n-button>
|
||||
|
||||
<hr class="settings-hr" />
|
||||
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user