55<template >
66 <NcSettingsSection
77 :name =" t('libresign', 'Identification documents')"
8- :description =" t('libresign', 'The flow of identification documents will make it mandatory for anyone who must sign a file, to send their identification documents, this, in order for them to be approved by some member of the approval group. The user can only create the certificate after these are approved .')" >
9- <NcCheckboxRadioSwitch type = " switch "
10- v-model = " identificationDocumentsFlowEnabled "
11- @update:modelValue = " saveIdentificationDocumentsStatus " >
12- {{ t('libresign', 'Enable identification documents flow') }}
13- </ NcCheckboxRadioSwitch >
14- <p v-if = " identificationDocumentsFlowEnabled " >
15- {{ t('libresign', 'Select authorized groups that can request to sign documents. Admin group is the default group and doesn\'t need to be defined.') }}
16- < br >
17- < NcSelect :key = " idApprovalGroupsKey "
18- v-model = " approvalGroups "
19- label = " displayname "
20- :no-wrap =" false"
21- :aria-label-combobox = " description "
22- :close-on-select = " false "
23- :disabled = " loadingGroups "
24- :loading = " loadingGroups "
25- :multiple =" true"
26- : options =" groups "
27- :searchable = " true "
28- :show-no-options = " false "
29- @search-change = " searchGroup "
30- @update:modelValue = " saveApprovalGroups " />
8+ :description =" t('libresign', 'Configure which groups can approve submitted identification documents. Admin group members can always approve .')" >
9+ <p >
10+ {{ t('libresign', 'The Identification documents flow itself is managed in Policies.') }}
11+ </ p >
12+ < p >
13+ {{ t('libresign', 'Approval groups are used only when the effective policy enables this flow.') }}
14+ </ p >
15+ < NcSelect :key = " idApprovalGroupsKey "
16+ v-model = " approvalGroups "
17+ label = " displayname "
18+ :no-wrap = " false "
19+ :aria- label-combobox = " description "
20+ :close-on-select =" false"
21+ :disabled = " loadingGroups || !identificationDocumentsFlowEnabled "
22+ :loading = " loadingGroups "
23+ :multiple = " true "
24+ :options = " groups "
25+ :searchable =" true"
26+ :show-no- options =" false "
27+ @search-change = " searchGroup "
28+ @update:modelValue = " saveApprovalGroups " />
29+ < p v-if = " !identificationDocumentsFlowEnabled " class = " identification-documents-content__hint " >
30+ {{ t('libresign', 'This list is disabled because the effective policy currently disables identification documents flow.') }}
3131 </p >
3232 </NcSettingsSection >
3333</template >
@@ -38,7 +38,6 @@ import { generateOcsUrl } from '@nextcloud/router'
3838import { t } from ' @nextcloud/l10n'
3939import { computed , onMounted , ref } from ' vue'
4040
41- import NcCheckboxRadioSwitch from ' @nextcloud/vue/components/NcCheckboxRadioSwitch'
4241import NcSelect from ' @nextcloud/vue/components/NcSelect'
4342import NcSettingsSection from ' @nextcloud/vue/components/NcSettingsSection'
4443
@@ -54,8 +53,26 @@ type Group = {
5453}
5554
5655const approvalGroupState = loadState (' libresign' , ' approval_group' , [' admin' ])
57- const identificationDocumentsState = loadState <unknown >(' libresign' , ' identification_documents' , false )
58- const identificationDocumentsFlowEnabled = ref (identificationDocumentsState === true || identificationDocumentsState === ' 1' )
56+ const effectivePoliciesState = loadState <{ policies? : Record <string , { effectiveValue? : unknown }> }>(' libresign' , ' effective_policies' , { policies: {} })
57+
58+ function resolveEnabledValue(value : unknown ): boolean {
59+ if (typeof value === ' boolean' ) {
60+ return value
61+ }
62+
63+ if (typeof value === ' number' ) {
64+ return value !== 0
65+ }
66+
67+ if (typeof value === ' string' ) {
68+ return [' 1' , ' true' , ' yes' , ' on' ].includes (value .trim ().toLowerCase ())
69+ }
70+
71+ return false
72+ }
73+
74+ const effectivePolicies = effectivePoliciesState ?.policies ?? {}
75+ const identificationDocumentsFlowEnabled = ref (resolveEnabledValue (effectivePolicies .identification_documents ?.effectiveValue ))
5976const approvalGroupIds = ref <string []>(Array .isArray (approvalGroupState ) ? approvalGroupState : [' admin' ])
6077const approvalGroups = ref <Array <Group | string >>([])
6178const groups = ref <Group []>([])
@@ -68,10 +85,6 @@ function syncApprovalGroupsFromState() {
6885 approvalGroups .value = groups .value .filter ((group ) => approvalGroupIds .value .indexOf (group .id ) !== - 1 )
6986}
7087
71- function saveIdentificationDocumentsStatus() {
72- OCP .AppConfig .setValue (' libresign' , ' identification_documents' , identificationDocumentsFlowEnabled .value ? ' 1' : ' 0' )
73- }
74-
7588function saveApprovalGroups() {
7689 const listOfInputGroupsSelected = JSON .stringify (approvalGroups .value .map ((group ) => {
7790 if (typeof group === ' object' ) {
@@ -106,7 +119,7 @@ onMounted(async () => {
106119})
107120 </script >
108121<style scoped>
109- .identification-documents-content {
122+ .identification-documents-content {
110123 display : flex ;
111124 flex-direction : column ;
112125}
0 commit comments