@@ -24,25 +24,37 @@ export const getFormPermissions = (forms) => {
24
24
return output ;
25
25
} ;
26
26
27
- // Function adds `id` field to rows so they will be accepted by DataTable
28
- // "display" is prefered for display name if present, otherwise fall back on "name'"
29
- const prepareRowsForTable = ( rawFormData ) => {
30
- if ( rawFormData ) {
31
- return rawFormData ?. map ( ( form ) => ( {
32
- ...form ,
33
- id : form . uuid ,
34
- display : form . display || form . name ,
35
- } ) ) ;
36
- }
37
- return null ;
27
+ /**
28
+ * Prepares the raw form data to be used in a DataTable.
29
+ * Adds an `id` field based on the `uuid` property of the form.
30
+ * Sets the `display` field based on the `display` property if present, otherwise falls back to the `name` field.
31
+ * Also attaches the `disableGroupSession` flag from form categories config, if available.
32
+ *
33
+ * @param {Array } rawFormData
34
+ * @param {Array } formCategories
35
+ * @returns {Array }
36
+ */
37
+ const prepareRowsForTable = ( rawFormData = [ ] , formCategories = [ ] ) => {
38
+ const formCategoryMap = new Map (
39
+ formCategories . flatMap ( ( { forms } ) =>
40
+ forms . map ( ( { formUUID, disableGroupSession } ) => [ formUUID , disableGroupSession ] ) ,
41
+ ) ,
42
+ ) ;
43
+
44
+ return rawFormData . map ( ( form ) => ( {
45
+ ...form ,
46
+ id : form . uuid ,
47
+ display : form . display || form . name ,
48
+ disableGroupSession : formCategoryMap . get ( form . uuid ) ,
49
+ } ) ) ;
38
50
} ;
39
51
40
52
const FormsPage = ( ) => {
41
53
const config = useConfig ( ) ;
42
54
const { t } = useTranslation ( ) ;
43
55
const { formCategories, formCategoriesToShow } = config ;
44
56
const { forms, isLoading, error } = useGetAllForms ( ) ;
45
- const cleanRows = prepareRowsForTable ( forms ) ;
57
+ const cleanRows = prepareRowsForTable ( forms , formCategories ) ;
46
58
const { user } = useSession ( ) ;
47
59
const savedFormsData = localStorage . getItem ( fdeWorkflowStorageName + ':' + user ?. uuid ) ;
48
60
const savedGroupFormsData = localStorage . getItem ( fdeGroupWorkflowStorageName + ':' + user ?. uuid ) ;
0 commit comments