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