2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2023-05-19 16:20:53 +09:00
|
|
|
<MkContainer :style="`height: ${widgetProps.height}px;`" :showHeader="widgetProps.showHeader" :scrollable="true" data-cy-mkw-notifications class="mkw-notifications">
|
2023-01-15 08:30:29 +09:00
|
|
|
<template #icon><i class="ti ti-bell"></i></template>
|
|
|
|
<template #header>{{ i18n.ts.notifications }}</template>
|
|
|
|
<template #func="{ buttonStyleClass }"><button class="_button" :class="buttonStyleClass" @click="configureNotification()"><i class="ti ti-settings"></i></button></template>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
<div>
|
2023-05-19 16:20:53 +09:00
|
|
|
<XNotifications :includeTypes="widgetProps.includingTypes"/>
|
2020-07-11 10:13:11 +09:00
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkContainer>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
<script lang="ts" setup>
|
2022-07-20 22:24:26 +09:00
|
|
|
import { defineAsyncComponent } from 'vue';
|
2023-05-19 16:20:53 +09:00
|
|
|
import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
|
2022-07-20 22:24:26 +09:00
|
|
|
import { GetFormResultType } from '@/scripts/form';
|
2022-09-06 18:21:49 +09:00
|
|
|
import MkContainer from '@/components/MkContainer.vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import XNotifications from '@/components/MkNotifications.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-07-20 22:24:26 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
const name = 'notifications';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
const widgetPropsDef = {
|
|
|
|
showHeader: {
|
|
|
|
type: 'boolean' as const,
|
|
|
|
default: true,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2022-01-08 20:30:01 +09:00
|
|
|
height: {
|
|
|
|
type: 'number' as const,
|
|
|
|
default: 300,
|
|
|
|
},
|
|
|
|
includingTypes: {
|
|
|
|
type: 'array' as const,
|
|
|
|
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>;
|
|
|
|
|
2023-05-19 16:20:53 +09:00
|
|
|
const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
|
|
|
const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
2023-07-08 07:08:16 +09:00
|
|
|
|
2022-01-08 20:30:01 +09:00
|
|
|
const { widgetProps, configure, save } = useWidgetPropsManager(name,
|
|
|
|
widgetPropsDef,
|
|
|
|
props,
|
|
|
|
emit,
|
|
|
|
);
|
|
|
|
|
|
|
|
const configureNotification = () => {
|
2022-08-31 00:24:33 +09:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkNotificationSettingWindow.vue')), {
|
2022-01-08 20:30:01 +09:00
|
|
|
includingTypes: widgetProps.includingTypes,
|
|
|
|
}, {
|
|
|
|
done: async (res) => {
|
|
|
|
const { includingTypes } = res;
|
|
|
|
widgetProps.includingTypes = includingTypes;
|
|
|
|
save();
|
2022-07-20 22:24:26 +09:00
|
|
|
},
|
2022-01-08 20:30:01 +09:00
|
|
|
}, 'closed');
|
|
|
|
};
|
|
|
|
|
|
|
|
defineExpose<WidgetComponentExpose>({
|
|
|
|
name,
|
|
|
|
configure,
|
|
|
|
id: props.widget ? props.widget.id : null,
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|