Merge tag '2023.12.0-beta.3' into merge-upstream

This commit is contained in:
riku6460 2023-12-10 08:58:57 +09:00
commit e77ddfce91
No known key found for this signature in database
GPG key ID: 27414FA27DB94CF6
423 changed files with 42868 additions and 10814 deletions

View file

@ -597,7 +597,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { watch } from 'vue';
import { watch, ref, computed } from 'vue';
import { throttle } from 'throttle-debounce';
import RolesEditorFormula from './RolesEditorFormula.vue';
import MkInput from '@/components/MkInput.vue';
@ -622,12 +622,12 @@ const props = defineProps<{
readonly?: boolean;
}>();
let role = $ref(deepClone(props.modelValue));
const role = ref(deepClone(props.modelValue));
// fill missing policy
for (const ROLE_POLICY of ROLE_POLICIES) {
if (role.policies[ROLE_POLICY] == null) {
role.policies[ROLE_POLICY] = {
if (role.value.policies[ROLE_POLICY] == null) {
role.value.policies[ROLE_POLICY] = {
useDefault: true,
priority: 0,
value: instance.policies[ROLE_POLICY],
@ -635,15 +635,15 @@ for (const ROLE_POLICY of ROLE_POLICIES) {
}
}
let rolePermission = $computed({
get: () => role.isAdministrator ? 'administrator' : role.isModerator ? 'moderator' : 'normal',
const rolePermission = computed({
get: () => role.value.isAdministrator ? 'administrator' : role.value.isModerator ? 'moderator' : 'normal',
set: (val) => {
role.isAdministrator = val === 'administrator';
role.isModerator = val === 'moderator';
role.value.isAdministrator = val === 'administrator';
role.value.isModerator = val === 'moderator';
},
});
let q = $ref('');
const q = ref('');
function getPriorityIcon(option) {
if (option.priority === 2) return 'ti ti-arrows-up';
@ -652,32 +652,32 @@ function getPriorityIcon(option) {
}
function matchQuery(keywords: string[]): boolean {
if (q.trim().length === 0) return true;
return keywords.some(keyword => keyword.toLowerCase().includes(q.toLowerCase()));
if (q.value.trim().length === 0) return true;
return keywords.some(keyword => keyword.toLowerCase().includes(q.value.toLowerCase()));
}
const save = throttle(100, () => {
const data = {
name: role.name,
description: role.description,
color: role.color === '' ? null : role.color,
iconUrl: role.iconUrl === '' ? null : role.iconUrl,
displayOrder: role.displayOrder,
target: role.target,
condFormula: role.condFormula,
isAdministrator: role.isAdministrator,
isModerator: role.isModerator,
isPublic: role.isPublic,
isExplorable: role.isExplorable,
asBadge: role.asBadge,
canEditMembersByModerator: role.canEditMembersByModerator,
policies: role.policies,
name: role.value.name,
description: role.value.description,
color: role.value.color === '' ? null : role.value.color,
iconUrl: role.value.iconUrl === '' ? null : role.value.iconUrl,
displayOrder: role.value.displayOrder,
target: role.value.target,
condFormula: role.value.condFormula,
isAdministrator: role.value.isAdministrator,
isModerator: role.value.isModerator,
isPublic: role.value.isPublic,
isExplorable: role.value.isExplorable,
asBadge: role.value.asBadge,
canEditMembersByModerator: role.value.canEditMembersByModerator,
policies: role.value.policies,
};
emit('update:modelValue', data);
});
watch($$(role), save, { deep: true });
watch(role, save, { deep: true });
</script>
<style lang="scss" module>