2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2023-04-08 09:01:42 +09:00
|
|
|
<MkContainer
|
|
|
|
:style="`height: ${widgetProps.height}px;`"
|
|
|
|
:show-header="widgetProps.showHeader"
|
|
|
|
:scrollable="true"
|
|
|
|
class="mkw-notifications"
|
|
|
|
>
|
|
|
|
<template #header
|
|
|
|
><i class="ph-bell ph-bold ph-lg"></i
|
|
|
|
>{{ i18n.ts.notifications }}</template
|
|
|
|
>
|
|
|
|
<template #func
|
|
|
|
><button
|
|
|
|
class="_button"
|
|
|
|
@click="os.apiWithDialog('notifications/mark-all-as-read')"
|
|
|
|
>
|
|
|
|
<i class="ph-check ph-bold ph-lg"></i></button
|
|
|
|
><button class="_button" @click="configureNotification()">
|
|
|
|
<i class="ph-gear-six ph-bold ph-lg"></i></button
|
|
|
|
></template>
|
|
|
|
<div>
|
|
|
|
<XNotifications :include-types="widgetProps.includingTypes" />
|
|
|
|
</div>
|
|
|
|
</MkContainer>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 09:01:42 +09:00
|
|
|
import { defineAsyncComponent } from "vue";
|
|
|
|
import {
|
|
|
|
useWidgetPropsManager,
|
|
|
|
Widget,
|
|
|
|
WidgetComponentEmits,
|
|
|
|
WidgetComponentExpose,
|
|
|
|
WidgetComponentProps,
|
|
|
|
} from "./widget";
|
|
|
|
import { GetFormResultType } from "@/scripts/form";
|
|
|
|
import MkContainer from "@/components/MkContainer.vue";
|
|
|
|
import XNotifications from "@/components/MkNotifications.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { i18n } from "@/i18n";
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const name = "notifications";
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
const widgetPropsDef = {
|
|
|
|
showHeader: {
|
2023-04-08 09:01:42 +09:00
|
|
|
type: "boolean" as const,
|
2022-01-08 20:30:01 +09:00
|
|
|
default: true,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2022-01-08 20:30:01 +09:00
|
|
|
height: {
|
2023-04-08 09:01:42 +09:00
|
|
|
type: "number" as const,
|
2022-01-08 20:30:01 +09:00
|
|
|
default: 300,
|
|
|
|
},
|
|
|
|
includingTypes: {
|
2023-04-08 09:01:42 +09:00
|
|
|
type: "array" as const,
|
2022-01-08 20:30:01 +09:00
|
|
|
hidden: true,
|
|
|
|
default: null,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2022-01-08 20:30:01 +09:00
|
|
|
};
|
2020-08-22 10:06:17 +09:00
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
|
|
|
|
|
|
|
|
// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
|
|
|
|
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
|
|
|
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
2023-04-08 09:01:42 +09:00
|
|
|
const props = defineProps<{ widget?: Widget<WidgetProps> }>();
|
|
|
|
const emit = defineEmits<{ (ev: "updateProps", props: WidgetProps) }>();
|
2022-01-08 20:30:01 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const { widgetProps, configure, save } = useWidgetPropsManager(
|
|
|
|
name,
|
2022-01-08 20:30:01 +09:00
|
|
|
widgetPropsDef,
|
|
|
|
props,
|
2023-04-08 09:01:42 +09:00
|
|
|
emit
|
2022-01-08 20:30:01 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
const configureNotification = () => {
|
2023-04-08 09:01:42 +09:00
|
|
|
os.popup(
|
|
|
|
defineAsyncComponent(
|
|
|
|
() => import("@/components/MkNotificationSettingWindow.vue")
|
|
|
|
),
|
|
|
|
{
|
|
|
|
includingTypes: widgetProps.includingTypes,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
done: async (res) => {
|
|
|
|
const { includingTypes } = res;
|
|
|
|
widgetProps.includingTypes = includingTypes;
|
|
|
|
save();
|
|
|
|
},
|
2022-07-20 22:24:26 +09:00
|
|
|
},
|
2023-04-08 09:01:42 +09:00
|
|
|
"closed"
|
|
|
|
);
|
2022-01-08 20:30:01 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
defineExpose<WidgetComponentExpose>({
|
|
|
|
name,
|
|
|
|
configure,
|
|
|
|
id: props.widget ? props.widget.id : null,
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|