2020-11-03 02:27:00 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<XModalWindow
|
|
|
|
ref="dialog"
|
|
|
|
:width="800"
|
|
|
|
:height="500"
|
|
|
|
:with-ok-button="true"
|
|
|
|
:ok-button-disabled="type === 'file' && selected.length === 0"
|
|
|
|
@click="cancel()"
|
|
|
|
@close="cancel()"
|
|
|
|
@ok="ok()"
|
|
|
|
@closed="emit('closed')"
|
|
|
|
>
|
|
|
|
<template #header>
|
|
|
|
{{
|
|
|
|
multiple
|
|
|
|
? type === "file"
|
|
|
|
? i18n.ts.selectFiles
|
|
|
|
: i18n.ts.selectFolders
|
|
|
|
: type === "file"
|
|
|
|
? i18n.ts.selectFile
|
|
|
|
: i18n.ts.selectFolder
|
|
|
|
}}
|
|
|
|
<span
|
|
|
|
v-if="selected.length > 0"
|
|
|
|
style="margin-left: 8px; opacity: 0.5"
|
|
|
|
>({{ number(selected.length) }})</span
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
<XDrive
|
|
|
|
:multiple="multiple"
|
|
|
|
:select="type"
|
|
|
|
@changeSelection="onChangeSelection"
|
|
|
|
@selected="ok()"
|
|
|
|
/>
|
|
|
|
</XModalWindow>
|
2020-11-03 02:27:00 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { ref } from "vue";
|
|
|
|
import * as Misskey from "calckey-js";
|
|
|
|
import XDrive from "@/components/MkDrive.vue";
|
|
|
|
import XModalWindow from "@/components/MkModalWindow.vue";
|
|
|
|
import number from "@/filters/number";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
|
|
|
|
withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
type?: "file" | "folder";
|
|
|
|
multiple: boolean;
|
|
|
|
}>(),
|
|
|
|
{
|
|
|
|
type: "file",
|
|
|
|
}
|
|
|
|
);
|
2020-11-03 02:27:00 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "done", r?: Misskey.entities.DriveFile[]): void;
|
|
|
|
(ev: "closed"): void;
|
2022-01-18 15:06:16 +01:00
|
|
|
}>();
|
2020-11-03 02:27:00 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const dialog = ref<InstanceType<typeof XModalWindow>>();
|
2020-11-03 02:27:00 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const selected = ref<Misskey.entities.DriveFile[]>([]);
|
2020-11-03 02:27:00 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
function ok() {
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("done", selected.value);
|
2022-01-18 15:06:16 +01:00
|
|
|
dialog.value?.close();
|
|
|
|
}
|
2020-11-03 02:27:00 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
function cancel() {
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("done");
|
2022-01-18 15:06:16 +01:00
|
|
|
dialog.value?.close();
|
|
|
|
}
|
2020-11-03 02:27:00 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
function onChangeSelection(files: Misskey.entities.DriveFile[]) {
|
|
|
|
selected.value = files;
|
|
|
|
}
|
2020-11-03 02:27:00 +01:00
|
|
|
</script>
|