diff --git a/src/components/PlaceBlock.vue b/src/components/PlaceBlock.vue index ce78ce9..02a3d20 100644 --- a/src/components/PlaceBlock.vue +++ b/src/components/PlaceBlock.vue @@ -7,9 +7,17 @@ import { Key24Regular } from '@vicons/fluent' import type { Application, Door, Key, Place } from '@/api/generated/crabs/evening_detective_server' const props = defineProps({ + newPlaceCode: { + type: String, + }, + newPlaceName: { + type: String, + }, + newPlaceText: { + type: String, + }, place: { type: Object as PropType, - required: true, }, mode: { type: String, @@ -17,9 +25,22 @@ const props = defineProps({ }, }) -const emit = defineEmits<{ 'update:mode': [value: string] }>() +const emit = defineEmits<{ + 'update:newPlaceCode': [value: string], + 'update:newPlaceName': [value: string], + 'update:newPlaceText': [value: string], + 'update:mode': [value: string] +}>() +const updateCode = (code: string) => { + emit('update:newPlaceCode', code) +} +const updateName = (name: string) => { + emit('update:newPlaceName', name) +} +const updateText = (text: string) => { + emit('update:newPlaceText', text) +} const updateMode = (mode: string) => { - console.log(mode) emit('update:mode', mode) } @@ -53,9 +74,13 @@ function onCreateKey(): Key {
- - + + +
diff --git a/src/components/ScenariosEditorPage.vue b/src/components/ScenariosEditorPage.vue index b51b863..da3051e 100644 --- a/src/components/ScenariosEditorPage.vue +++ b/src/components/ScenariosEditorPage.vue @@ -33,18 +33,6 @@ const scenario = ref({ publishedAt: undefined, }) -const newPlace = ref({ - code: undefined, - name: undefined, - text: undefined, - image: undefined, - hidden: undefined, - applications: undefined, - doors: undefined, - keys: undefined, - mode: 'mini-add', -}) - async function getScenario(id: number) { const res = await client.GetScenario({ id: id }) if (res.error != '') { @@ -106,10 +94,25 @@ function uint8ToBase64(uint8Array: Uint8Array) { return btoa(binaryString) } +const code = ref('') +const name = ref('') +const text = ref('') +const mode = ref('mini-add') + + async function addPlace() { const res = await client.AddScenarioPlace({ id: scenario.value.id, - place: newPlace.value, + place: { + code: code.value, + name: name.value, + text: text.value, + image: undefined, + hidden: undefined, + applications: undefined, + doors: undefined, + keys: undefined, + }, }) if (res.error != '') { message.error(res.error!) @@ -117,17 +120,10 @@ async function addPlace() { } await getScenario(Number(scenarioId)) - newPlace.value = { - code: undefined, - name: undefined, - text: undefined, - image: undefined, - hidden: undefined, - applications: undefined, - doors: undefined, - keys: undefined, - mode: 'add' - } + code.value = '' + name.value = '' + text.value = '' + mode.value = 'add' } async function addNotFoundDoors(scenario: Scenario, place: Place) { @@ -208,10 +204,14 @@ async function deletePlace(place: Place) { - + {{ code }} + {{ name }} + {{ text }} + - Отмена - Добавить точку + Отмена + Добавить точку