egirlskey/packages/frontend/src/ui/deck/role-timeline-column.vue

68 lines
1.5 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2023-04-12 02:40:08 +00:00
<template>
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="() => timeline.reloadTimeline()">
2023-04-12 02:40:08 +00:00
<template #header>
<i class="ph-seal-check ph-bold ph-lg"></i><span style="margin-left: 8px;">{{ column.name }}</span>
2023-04-12 02:40:08 +00:00
</template>
2023-05-29 08:24:46 +00:00
<MkTimeline v-if="column.roleId" ref="timeline" src="role" :role="column.roleId"/>
2023-04-12 02:40:08 +00:00
</XColumn>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import XColumn from './column.vue';
2023-09-19 07:37:43 +00:00
import { updateColumn, Column } from './deck-store.js';
2023-04-12 02:40:08 +00:00
import MkTimeline from '@/components/MkTimeline.vue';
2023-09-19 07:37:43 +00:00
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
2023-04-12 02:40:08 +00:00
const props = defineProps<{
column: Column;
isStacked: boolean;
}>();
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
onMounted(() => {
if (props.column.roleId == null) {
setRole();
}
});
async function setRole() {
const roles = (await os.api('roles/list')).filter(x => x.isExplorable);
2023-04-12 02:40:08 +00:00
const { canceled, result: role } = await os.select({
title: i18n.ts.role,
items: roles.map(x => ({
value: x, text: x.name,
})),
default: props.column.roleId,
});
if (canceled) return;
updateColumn(props.column.id, {
roleId: role.id,
});
}
const menu = [{
2023-09-30 19:53:52 +00:00
icon: 'ph-pencil ph-bold ph-lg',
2023-04-12 02:40:08 +00:00
text: i18n.ts.role,
action: setRole,
}];
/*
function focus() {
timeline.focus();
}
defineExpose({
focus,
});
*/
</script>