merge: upstream
This commit is contained in:
commit
5db583a3eb
701 changed files with 50809 additions and 13660 deletions
|
|
@ -318,7 +318,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkRange>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.canSearchNotes, 'canSearchNotes'])">
|
||||
<template #label>{{ i18n.ts._role._options.canSearchNotes }}</template>
|
||||
<template #suffix>
|
||||
|
|
@ -571,13 +571,33 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkRange>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.avatarDecorationLimit, 'avatarDecorationLimit'])">
|
||||
<template #label>{{ i18n.ts._role._options.avatarDecorationLimit }}</template>
|
||||
<template #suffix>
|
||||
<span v-if="role.policies.avatarDecorationLimit.useDefault" :class="$style.useDefaultLabel">{{ i18n.ts._role.useBaseValue }}</span>
|
||||
<span v-else>{{ role.policies.avatarDecorationLimit.value }}</span>
|
||||
<span :class="$style.priorityIndicator"><i :class="getPriorityIcon(role.policies.avatarDecorationLimit)"></i></span>
|
||||
</template>
|
||||
<div class="_gaps">
|
||||
<MkSwitch v-model="role.policies.avatarDecorationLimit.useDefault" :readonly="readonly">
|
||||
<template #label>{{ i18n.ts._role.useBaseValue }}</template>
|
||||
</MkSwitch>
|
||||
<MkInput v-model="role.policies.avatarDecorationLimit.value" type="number" :min="0">
|
||||
<template #label>{{ i18n.ts._role._options.avatarDecorationLimit }}</template>
|
||||
</MkInput>
|
||||
<MkRange v-model="role.policies.avatarDecorationLimit.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''">
|
||||
<template #label>{{ i18n.ts._role.priority }}</template>
|
||||
</MkRange>
|
||||
</div>
|
||||
</MkFolder>
|
||||
</div>
|
||||
</FormSlot>
|
||||
</div>
|
||||
</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';
|
||||
|
|
@ -589,7 +609,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
|
|||
import MkRange from '@/components/MkRange.vue';
|
||||
import FormSlot from '@/components/form/slot.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { ROLE_POLICIES } from '@/const';
|
||||
import { ROLE_POLICIES } from '@/const.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { deepClone } from '@/scripts/clone.js';
|
||||
|
||||
|
|
@ -602,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],
|
||||
|
|
@ -615,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 'ph-arrow-up ph-bold ph-lg';
|
||||
|
|
@ -632,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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue