Revert "feat: お知らせの優先順位機能 (#118)"

This reverts commit fe0f7a91a3.
This commit is contained in:
まっちゃとーにゅ 2023-08-15 16:44:54 +09:00
parent eeef3965b7
commit 04fefb2056
No known key found for this signature in database
GPG key ID: 6AFBBF529601C1DB
12 changed files with 69 additions and 131 deletions

View file

@ -24,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</MkFolder>
</MkFolder>
<section v-for="announcement in announcements" :key="announcement.id">
<section v-for="announcement in announcements" class="">
<div class="_panel _gaps_m" style="padding: 24px;">
<MkInput ref="announceTitleEl" v-model="announcement.title" :large="false">
<template #label>{{ i18n.ts.title }}&nbsp;<button v-tooltip="i18n.ts.emoji" :class="['_button']" @click="insertEmoji"><i class="ti ti-mood-happy"></i></button></template>
@ -35,9 +35,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="announcement.imageUrl">
<template #label>{{ i18n.ts.imageUrl }}</template>
</MkInput>
<MkInput v-model="announcement.displayOrder" type="number">
<template #label>{{ i18n.ts.displayOrder }}</template>
</MkInput>
<MkInput v-model="announcement.closeDuration" type="number">
<template #label>{{ i18n.ts.dialogCloseDuration }}</template>
<template #suffix>{{ i18n.ts._time.second }}</template>
@ -51,7 +48,6 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</div>
</section>
<MkButton v-if="hasMore" :class="$style.more" :disabled="!hasMore" primary rounded @click="fetch()">{{ i18n.ts.loadMore }}</MkButton>
</div>
</MkSpacer>
</MkStickyContainer>
@ -70,31 +66,33 @@ import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
const announceTitleEl = $shallowRef<HTMLInputElement | null>(null);
const user = ref<UserLite | null>(null);
const offset = ref(0);
const hasMore = ref(false);
let announcements: any[] = $ref([]);
function insertEmoji(ev: MouseEvent): void {
os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, announceTitleEl);
}
const user = ref<UserLite>(null);
const announceTitleEl = $shallowRef<HTMLInputElement | null>(null);
function selectUserFilter(): void {
function selectUserFilter() {
os.selectUser().then(_user => {
user.value = _user;
});
}
function editUser(announcement): void {
function editUser(an) {
os.selectUser().then(_user => {
announcement.userId = _user.id;
announcement.user = _user;
an.userId = _user.id;
an.user = _user;
});
}
function add(): void {
async function insertEmoji(ev: MouseEvent) {
os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, announceTitleEl);
}
os.api('admin/announcements/list').then(announcementResponse => {
announcements = announcementResponse;
});
function add() {
announcements.unshift({
id: null,
title: '',
@ -102,12 +100,11 @@ function add(): void {
imageUrl: null,
userId: null,
user: null,
displayOrder: 0,
closeDuration: 10,
});
}
function remove(announcement): void {
function remove(announcement) {
os.confirm({
type: 'warning',
text: i18n.t('removeAreYouSure', { x: announcement.title }),
@ -118,14 +115,14 @@ function remove(announcement): void {
});
}
function save(announcement): void {
function save(announcement) {
if (announcement.id == null) {
os.api('admin/announcements/create', announcement).then(() => {
os.alert({
type: 'success',
text: i18n.ts.saved,
});
fetch(true);
refresh();
}).catch(err => {
os.alert({
type: 'error',
@ -147,26 +144,15 @@ function save(announcement): void {
}
}
function fetch(resetOffset = false): void {
if (resetOffset) {
announcements = [];
offset.value = 0;
}
os.api('admin/announcements/list', {
offsetMode: true,
offset: offset.value,
limit: 10,
userId: user.value?.id,
}).then(announcementResponse => {
announcements = announcements.concat(announcementResponse);
hasMore.value = announcementResponse?.length === 10;
offset.value += announcements.length;
function refresh() {
os.api('admin/announcements/list', { userId: user.value?.id }).then(announcementResponse => {
announcements = announcementResponse;
});
}
watch(user, () => fetch(true));
fetch();
watch(user, refresh);
refresh();
const headerActions = $computed(() => [{
asFullButton: true,
@ -182,10 +168,3 @@ definePageMetadata({
icon: 'ti ti-speakerphone',
});
</script>
<style lang="scss" module>
.more {
margin-left: auto;
margin-right: auto;
}
</style>