fix MkRoleSelectDialog.vue
This commit is contained in:
parent
87ff8e8d94
commit
5e64974539
|
@ -1,15 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<MkWindow
|
<MkModalWindow
|
||||||
ref="windowEl"
|
ref="windowEl"
|
||||||
:initialWidth="400"
|
:withOkButton="false"
|
||||||
:initialHeight="500"
|
:okButtonDisabled="false"
|
||||||
:canResize="false"
|
:width="400"
|
||||||
@close="windowEl?.close()"
|
:height="500"
|
||||||
@closed="$emit('closed')"
|
@close="onCloseModalWindow"
|
||||||
|
@closed="console.log('MkRoleSelectDialog: closed') ; $emit('dispose')"
|
||||||
>
|
>
|
||||||
<template #header>{{ title }}</template>
|
<template #header>{{ title }}</template>
|
||||||
<MkSpacer :marginMin="20" :marginMax="28">
|
<MkSpacer :marginMin="20" :marginMax="28">
|
||||||
<div class="_gaps">
|
<MkLoading v-if="fetching"/>
|
||||||
|
<div v-else class="_gaps">
|
||||||
<div :class="$style.header">
|
<div :class="$style.header">
|
||||||
<MkButton rounded @click="addRole"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
<MkButton rounded @click="addRole"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,7 +37,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkWindow>
|
</MkModalWindow>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
@ -46,14 +48,15 @@ import MkButton from '@/components/MkButton.vue';
|
||||||
import MkInfo from '@/components/MkInfo.vue';
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
import MkRolePreview from '@/components/MkRolePreview.vue';
|
import MkRolePreview from '@/components/MkRolePreview.vue';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import Section from '@/components/form/section.vue';
|
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import MkWindow from '@/components/MkWindow.vue';
|
|
||||||
import MkSpacer from '@/components/global/MkSpacer.vue';
|
import MkSpacer from '@/components/global/MkSpacer.vue';
|
||||||
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
||||||
|
import MkLoading from '@/components/global/MkLoading.vue';
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(ev: 'done', value: Misskey.entities.Role[]),
|
(ev: 'done', value: Misskey.entities.Role[]),
|
||||||
(ev: 'closed'),
|
(ev: 'close'),
|
||||||
|
(ev: 'dispose'),
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
|
@ -70,9 +73,10 @@ const props = withDefaults(defineProps<{
|
||||||
|
|
||||||
const { initialRoleIds, infoMessage, title, publicOnly } = toRefs(props);
|
const { initialRoleIds, infoMessage, title, publicOnly } = toRefs(props);
|
||||||
|
|
||||||
const windowEl = ref<InstanceType<typeof MkWindow>>();
|
const windowEl = ref<InstanceType<typeof MkModalWindow>>();
|
||||||
const roles = ref<Misskey.entities.Role[]>([]);
|
const roles = ref<Misskey.entities.Role[]>([]);
|
||||||
const selectedRoleIds = ref<string[]>(initialRoleIds.value ?? []);
|
const selectedRoleIds = ref<string[]>(initialRoleIds.value ?? []);
|
||||||
|
const fetching = ref(false);
|
||||||
|
|
||||||
const selectedRoles = computed(() => {
|
const selectedRoles = computed(() => {
|
||||||
const r = roles.value.filter(role => selectedRoleIds.value.includes(role.id));
|
const r = roles.value.filter(role => selectedRoleIds.value.includes(role.id));
|
||||||
|
@ -87,8 +91,10 @@ const selectedRoles = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetchRoles() {
|
async function fetchRoles() {
|
||||||
|
fetching.value = true;
|
||||||
const result = await misskeyApi('admin/roles/list', {});
|
const result = await misskeyApi('admin/roles/list', {});
|
||||||
roles.value = result.filter(it => publicOnly.value ? it.isPublic : true);
|
roles.value = result.filter(it => publicOnly.value ? it.isPublic : true);
|
||||||
|
fetching.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addRole() {
|
async function addRole() {
|
||||||
|
@ -115,7 +121,13 @@ function onOkClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCancelClicked() {
|
function onCancelClicked() {
|
||||||
emit('closed');
|
emit('close');
|
||||||
|
windowEl.value?.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCloseModalWindow() {
|
||||||
|
emit('close');
|
||||||
|
windowEl.value?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchRoles();
|
fetchRoles();
|
||||||
|
|
|
@ -489,10 +489,10 @@ export async function selectRole(params: {
|
||||||
done: roles => {
|
done: roles => {
|
||||||
resolve({ canceled: false, result: roles });
|
resolve({ canceled: false, result: roles });
|
||||||
},
|
},
|
||||||
closed: () => {
|
close: () => {
|
||||||
resolve({ canceled: true, result: undefined });
|
resolve({ canceled: true, result: undefined });
|
||||||
},
|
},
|
||||||
}, 'closed');
|
}, 'dispose');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,9 +275,9 @@ function setupGrid(): GridSetting {
|
||||||
},
|
},
|
||||||
customValueEditor: async (row) => {
|
customValueEditor: async (row) => {
|
||||||
// ID直記入は体験的に最悪なのでモーダルを使って入力する
|
// ID直記入は体験的に最悪なのでモーダルを使って入力する
|
||||||
const current = gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction.map(it => it.id);
|
const current = gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction;
|
||||||
const result = await os.selectRole({
|
const result = await os.selectRole({
|
||||||
initialRoleIds: current,
|
initialRoleIds: current.map(it => it.id),
|
||||||
title: i18n.ts.rolesThatCanBeUsedThisEmojiAsReaction,
|
title: i18n.ts.rolesThatCanBeUsedThisEmojiAsReaction,
|
||||||
infoMessage: i18n.ts.rolesThatCanBeUsedThisEmojiAsReactionEmptyDescription,
|
infoMessage: i18n.ts.rolesThatCanBeUsedThisEmojiAsReactionEmptyDescription,
|
||||||
publicOnly: true,
|
publicOnly: true,
|
||||||
|
|
|
@ -169,9 +169,9 @@ function setupGrid(): GridSetting {
|
||||||
},
|
},
|
||||||
customValueEditor: async (row) => {
|
customValueEditor: async (row) => {
|
||||||
// ID直記入は体験的に最悪なのでモーダルを使って入力する
|
// ID直記入は体験的に最悪なのでモーダルを使って入力する
|
||||||
const current = gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction.map(it => it.id);
|
const current = gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction;
|
||||||
const result = await os.selectRole({
|
const result = await os.selectRole({
|
||||||
initialRoleIds: current,
|
initialRoleIds: current.map(it => it.id),
|
||||||
title: i18n.ts.rolesThatCanBeUsedThisEmojiAsReaction,
|
title: i18n.ts.rolesThatCanBeUsedThisEmojiAsReaction,
|
||||||
infoMessage: i18n.ts.rolesThatCanBeUsedThisEmojiAsReactionEmptyDescription,
|
infoMessage: i18n.ts.rolesThatCanBeUsedThisEmojiAsReactionEmptyDescription,
|
||||||
publicOnly: true,
|
publicOnly: true,
|
||||||
|
|
Loading…
Reference in New Issue