|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { t } from '@nextcloud/l10n' |
| 7 | + |
| 8 | +import DocMdpScalarRuleEditor from './DocMdpScalarRuleEditor.vue' |
| 9 | +import type { EffectivePolicyValue } from '../../../../../types/index' |
| 10 | +import type { RealPolicySettingDefinition } from '../realTypes' |
| 11 | + |
| 12 | +export function resolveDocMdpLevel(value: EffectivePolicyValue): number | null { |
| 13 | + if (typeof value === 'number' && value >= 0 && value <= 3) { |
| 14 | + return value |
| 15 | + } |
| 16 | + |
| 17 | + if (typeof value === 'string' && /^[0-3]$/.test(value)) { |
| 18 | + return Number(value) |
| 19 | + } |
| 20 | + |
| 21 | + return null |
| 22 | +} |
| 23 | + |
| 24 | +export const docMdpRealDefinition: RealPolicySettingDefinition = { |
| 25 | + key: 'docmdp', |
| 26 | + title: t('libresign', 'PDF certification'), |
| 27 | + context: t('libresign', 'DocMDP'), |
| 28 | + description: t('libresign', 'Control what changes are allowed after a document is signed.'), |
| 29 | + editor: DocMdpScalarRuleEditor, |
| 30 | + createEmptyValue: () => 0, |
| 31 | + summarizeValue: (value: EffectivePolicyValue) => { |
| 32 | + const level = resolveDocMdpLevel(value) |
| 33 | + switch (level) { |
| 34 | + case 0: |
| 35 | + return t('libresign', 'Disabled') |
| 36 | + case 1: |
| 37 | + return t('libresign', 'No changes allowed') |
| 38 | + case 2: |
| 39 | + return t('libresign', 'Form filling') |
| 40 | + case 3: |
| 41 | + return t('libresign', 'Form filling and annotations') |
| 42 | + default: |
| 43 | + return t('libresign', 'Not configured') |
| 44 | + } |
| 45 | + }, |
| 46 | + formatAllowOverride: (allowChildOverride: boolean) => |
| 47 | + allowChildOverride |
| 48 | + ? t('libresign', 'Groups and users can set their own rule') |
| 49 | + : t('libresign', 'Groups and users must follow this value'), |
| 50 | +} |
0 commit comments