@@ -5,6 +5,8 @@ import { html } from "lit";
55import { customElement , property } from "lit/decorators.js" ;
66import { ifDefined } from "lit/directives/if-defined.js" ;
77import { when } from "lit/directives/when.js" ;
8+ import mapValues from "lodash/fp/mapValues" ;
9+ import uniq from "lodash/fp/uniq" ;
810import type { PartialDeep } from "type-fest" ;
911
1012import {
@@ -26,6 +28,15 @@ import {
2628 type FormState as WorkflowFormState ,
2729} from "@/utils/workflow" ;
2830
31+ // Make array values unique since mergeDeep will concatenate arrays
32+ const makeArrUniq = mapValues ( ( val : unknown ) => {
33+ if ( Array . isArray ( val ) ) {
34+ return uniq ( val ) as unknown [ ] ;
35+ }
36+
37+ return val ;
38+ } ) ;
39+
2940/**
3041 * Usage:
3142 * ```ts
@@ -126,7 +137,7 @@ export class WorkflowsNew extends BtrixElement {
126137 </ sl-button >
127138 </ header >
128139 ${ when ( this . org , ( org ) => {
129- const initialWorkflow = mergeDeep (
140+ const mergedWorkflow = mergeDeep (
130141 this . defaultNewWorkflow ,
131142 {
132143 profileid : org . crawlingDefaults ?. profileid ,
@@ -153,6 +164,11 @@ export class WorkflowsNew extends BtrixElement {
153164 this . initialWorkflow || { } ,
154165 ) ;
155166
167+ const initialWorkflow = makeArrUniq ( {
168+ ...mergedWorkflow ,
169+ config : makeArrUniq ( mergedWorkflow . config ) ,
170+ } ) as WorkflowParams ;
171+
156172 const scopeType = this . scopeType || initialWorkflow . config . scopeType ;
157173
158174 return html `
0 commit comments