mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-11-15 11:46:56 +01:00
406b4bdbe7
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
78 lines
2.1 KiB
Vue
78 lines
2.1 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<MkModalWindow
|
|
ref="dialog"
|
|
:width="400"
|
|
:height="450"
|
|
:withOkButton="true"
|
|
:okButtonDisabled="false"
|
|
@ok="ok()"
|
|
@close="dialog?.close()"
|
|
@closed="emit('closed')"
|
|
>
|
|
<template #header>{{ i18n.ts.notificationSetting }}</template>
|
|
|
|
<MkSpacer :marginMin="20" :marginMax="28">
|
|
<div class="_gaps_m">
|
|
<MkInfo>{{ i18n.ts.notificationSettingDesc }}</MkInfo>
|
|
<div class="_buttons">
|
|
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
|
|
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
|
|
</div>
|
|
<MkSwitch v-for="ntype in notificationTypes" :key="ntype" v-model="typesMap[ntype].value">{{ i18n.t(`_notification._types.${ntype}`) }}</MkSwitch>
|
|
</div>
|
|
</MkSpacer>
|
|
</MkModalWindow>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref, Ref, shallowRef } from 'vue';
|
|
import MkSwitch from './MkSwitch.vue';
|
|
import MkInfo from './MkInfo.vue';
|
|
import MkButton from './MkButton.vue';
|
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
|
import { notificationTypes } from '@/const.js';
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
type TypesMap = Record<typeof notificationTypes[number], Ref<boolean>>
|
|
|
|
const emit = defineEmits<{
|
|
(ev: 'done', v: { excludeTypes: string[] }): void,
|
|
(ev: 'closed'): void,
|
|
}>();
|
|
|
|
const props = withDefaults(defineProps<{
|
|
excludeTypes?: typeof notificationTypes[number][];
|
|
}>(), {
|
|
excludeTypes: () => [],
|
|
});
|
|
|
|
const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();
|
|
|
|
const typesMap: TypesMap = notificationTypes.reduce((p, t) => ({ ...p, [t]: ref<boolean>(!props.excludeTypes.includes(t)) }), {} as any);
|
|
|
|
function ok() {
|
|
emit('done', {
|
|
excludeTypes: (Object.keys(typesMap) as typeof notificationTypes[number][])
|
|
.filter(type => !typesMap[type].value),
|
|
});
|
|
|
|
if (dialog.value) dialog.value.close();
|
|
}
|
|
|
|
function disableAll() {
|
|
for (const type of notificationTypes) {
|
|
typesMap[type].value = false;
|
|
}
|
|
}
|
|
|
|
function enableAll() {
|
|
for (const type of notificationTypes) {
|
|
typesMap[type].value = true;
|
|
}
|
|
}
|
|
</script>
|