merge: upstream
This commit is contained in:
commit
5db583a3eb
701 changed files with 50809 additions and 13660 deletions
|
|
@ -15,9 +15,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #label>{{ i18n.ts._play.summary }}</template>
|
||||
</MkTextarea>
|
||||
<MkButton primary @click="selectPreset">{{ i18n.ts.selectFromPresets }}<i class="ph-caret-down ph-bold ph-lg"></i></MkButton>
|
||||
<MkTextarea v-model="script" class="_monospace" tall spellcheck="false">
|
||||
<MkCodeEditor v-model="script" lang="is">
|
||||
<template #label>{{ i18n.ts._play.script }}</template>
|
||||
</MkTextarea>
|
||||
</MkCodeEditor>
|
||||
<div class="_buttons">
|
||||
<MkButton primary @click="save"><i class="ph-check ph-bold ph-lg"></i> {{ i18n.ts.save }}</MkButton>
|
||||
<MkButton @click="show"><i class="ph-eye ph-bold ph-lg"></i> {{ i18n.ts.show }}</MkButton>
|
||||
|
|
@ -34,12 +34,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import * as os from '@/os.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import MkTextarea from '@/components/MkTextarea.vue';
|
||||
import MkCodeEditor from '@/components/MkCodeEditor.vue';
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
import MkSelect from '@/components/MkSelect.vue';
|
||||
import { useRouter } from '@/router.js';
|
||||
|
|
@ -363,79 +364,79 @@ const props = defineProps<{
|
|||
id?: string;
|
||||
}>();
|
||||
|
||||
let flash = $ref(null);
|
||||
let visibility = $ref('public');
|
||||
const flash = ref(null);
|
||||
const visibility = ref('public');
|
||||
|
||||
if (props.id) {
|
||||
flash = await os.api('flash/show', {
|
||||
flash.value = await os.api('flash/show', {
|
||||
flashId: props.id,
|
||||
});
|
||||
}
|
||||
|
||||
let title = $ref(flash?.title ?? 'New Play');
|
||||
let summary = $ref(flash?.summary ?? '');
|
||||
let permissions = $ref(flash?.permissions ?? []);
|
||||
let script = $ref(flash?.script ?? PRESET_DEFAULT);
|
||||
const title = ref(flash.value?.title ?? 'New Play');
|
||||
const summary = ref(flash.value?.summary ?? '');
|
||||
const permissions = ref(flash.value?.permissions ?? []);
|
||||
const script = ref(flash.value?.script ?? PRESET_DEFAULT);
|
||||
|
||||
function selectPreset(ev: MouseEvent) {
|
||||
os.popupMenu([{
|
||||
text: 'Omikuji',
|
||||
action: () => {
|
||||
script = PRESET_OMIKUJI;
|
||||
script.value = PRESET_OMIKUJI;
|
||||
},
|
||||
}, {
|
||||
text: 'Shuffle',
|
||||
action: () => {
|
||||
script = PRESET_SHUFFLE;
|
||||
script.value = PRESET_SHUFFLE;
|
||||
},
|
||||
}, {
|
||||
text: 'Quiz',
|
||||
action: () => {
|
||||
script = PRESET_QUIZ;
|
||||
script.value = PRESET_QUIZ;
|
||||
},
|
||||
}, {
|
||||
text: 'Timeline viewer',
|
||||
action: () => {
|
||||
script = PRESET_TIMELINE;
|
||||
script.value = PRESET_TIMELINE;
|
||||
},
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (flash) {
|
||||
if (flash.value) {
|
||||
os.apiWithDialog('flash/update', {
|
||||
flashId: props.id,
|
||||
title,
|
||||
summary,
|
||||
permissions,
|
||||
script,
|
||||
visibility,
|
||||
title: title.value,
|
||||
summary: summary.value,
|
||||
permissions: permissions.value,
|
||||
script: script.value,
|
||||
visibility: visibility.value,
|
||||
});
|
||||
} else {
|
||||
const created = await os.apiWithDialog('flash/create', {
|
||||
title,
|
||||
summary,
|
||||
permissions,
|
||||
script,
|
||||
title: title.value,
|
||||
summary: summary.value,
|
||||
permissions: permissions.value,
|
||||
script: script.value,
|
||||
});
|
||||
router.push('/play/' + created.id + '/edit');
|
||||
}
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (flash == null) {
|
||||
if (flash.value == null) {
|
||||
os.alert({
|
||||
text: 'Please save',
|
||||
});
|
||||
} else {
|
||||
os.pageWindow(`/play/${flash.id}`);
|
||||
os.pageWindow(`/play/${flash.value.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function del() {
|
||||
const { canceled } = await os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.t('deleteAreYouSure', { x: flash.title }),
|
||||
text: i18n.t('deleteAreYouSure', { x: flash.value.title }),
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
|
|
@ -445,12 +446,12 @@ async function del() {
|
|||
router.push('/play');
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => []);
|
||||
const headerActions = computed(() => []);
|
||||
|
||||
const headerTabs = $computed(() => []);
|
||||
const headerTabs = computed(() => []);
|
||||
|
||||
definePageMetadata(computed(() => flash ? {
|
||||
title: i18n.ts._play.edit + ': ' + flash.title,
|
||||
definePageMetadata(computed(() => flash.value ? {
|
||||
title: i18n.ts._play.edit + ': ' + flash.value.title,
|
||||
} : {
|
||||
title: i18n.ts._play.new,
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue