@talxis/base-controls 1.2507.2 → 1.2508.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -94,24 +94,50 @@ const Lookup = (props) => {
|
|
|
94
94
|
const isComponentActive = () => {
|
|
95
95
|
return mouseOver || isFocused;
|
|
96
96
|
};
|
|
97
|
-
const getSecondaryName = (result
|
|
97
|
+
const getSecondaryName = async (result) => {
|
|
98
|
+
const metadata = await entities.find(x => x.entityName === result.entityType)?.metadata;
|
|
99
|
+
const attribute = result.layout?.Rows?.[0]?.Cells?.[1]?.Name;
|
|
98
100
|
//polymorphic, selected all
|
|
99
101
|
if (!entities.find(x => x.selected)) {
|
|
100
102
|
return metadata?.DisplayName;
|
|
101
103
|
}
|
|
102
|
-
else {
|
|
103
|
-
let
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
else if (metadata?.LogicalName && attribute) {
|
|
105
|
+
let targetEntityName = metadata.LogicalName;
|
|
106
|
+
let targetAttribute = attribute;
|
|
107
|
+
//checking for attributes pointing to related entity attribute, given by convention of using dot as separator
|
|
108
|
+
if (attribute.includes(".")) {
|
|
109
|
+
targetEntityName = result.layout.Rows.find(x => x.Cells.find(y => y.Name === attribute))?.Cells?.find(y => y.Name === attribute)?.RelatedEntityName || metadata.LogicalName;
|
|
110
|
+
targetAttribute = attribute.split(".")[1];
|
|
109
111
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
const entityMetadata = await props.context.utils.getEntityMetadata(targetEntityName, [targetAttribute]);
|
|
113
|
+
const attributetype = entityMetadata.Attributes.get(targetAttribute).AttributeTypeName;
|
|
114
|
+
let primaryName;
|
|
115
|
+
switch (attributetype) {
|
|
116
|
+
case "lookup":
|
|
117
|
+
case "partylist":
|
|
118
|
+
case "owner":
|
|
119
|
+
case "customer":
|
|
120
|
+
primaryName = result.entityData[`_${targetAttribute}_value@OData.Community.Display.V1.FormattedValue`];
|
|
121
|
+
break;
|
|
122
|
+
case "optionset":
|
|
123
|
+
case "picklist":
|
|
124
|
+
case "state":
|
|
125
|
+
case "status":
|
|
126
|
+
case "boolean":
|
|
127
|
+
case "integer":
|
|
128
|
+
case "bigint":
|
|
129
|
+
case "decimal":
|
|
130
|
+
case "money":
|
|
131
|
+
//TODO: Introduce user formatting, this approach takes format from application user setting
|
|
132
|
+
primaryName = result.entityData[`${targetAttribute}@OData.Community.Display.V1.FormattedValue`];
|
|
133
|
+
break;
|
|
134
|
+
case "datetime":
|
|
135
|
+
primaryName = props.context.formatting.formatTime(dayjs(result.entityData[attribute]).toDate(), 1);
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
primaryName = result.entityData[attribute];
|
|
113
139
|
}
|
|
114
|
-
return
|
|
140
|
+
return primaryName;
|
|
115
141
|
}
|
|
116
142
|
};
|
|
117
143
|
const onResolveSuggestions = async (filter, selectedItems) => {
|
|
@@ -122,11 +148,10 @@ const Lookup = (props) => {
|
|
|
122
148
|
if (selectedItems?.find(x => x.key === result.id)) {
|
|
123
149
|
continue;
|
|
124
150
|
}
|
|
125
|
-
const metadata = await entities.find(x => x.entityName === result.entityType)?.metadata;
|
|
126
151
|
suggestions.push({
|
|
127
152
|
key: result.id,
|
|
128
153
|
text: result.name,
|
|
129
|
-
secondaryText: getSecondaryName(result
|
|
154
|
+
secondaryText: await getSecondaryName(result),
|
|
130
155
|
'data-entity': result.entityType
|
|
131
156
|
});
|
|
132
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lookup.js","sources":["../../../src/components/Lookup/Lookup.tsx"],"sourcesContent":["\nimport { ILayout, ILookup, IMetadata } from \"./interfaces\";\nimport { useLookup } from \"./hooks/useLookup\";\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { ThemeProvider } from \"@fluentui/react\";\nimport { IItemProps, TagPicker } from \"@talxis/react-components\";\nimport { TargetSelector } from \"./components/TargetSelector\";\nimport { useMouseOver } from \"../../hooks/useMouseOver\";\nimport { getLookupStyles, getSuggestionsCalloutStyles } from \"./styles\";\nimport { IBasePicker } from \"@fluentui/react/lib/components/pickers/BasePicker.types\";\nimport { ITag } from \"@fluentui/react/lib/components/pickers/TagPicker/TagPicker.types\";\nimport { RecordCreator } from \"./components/RecordCreator\";\nimport { useFocusIn } from \"../../hooks/useFocusIn\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const Lookup = (props: ILookup) => {\n const context = props.context;\n const ref = useRef<HTMLDivElement>(null);\n const componentRef = useRef<IBasePicker<ITag>>(null);\n const itemLimit = props.parameters.MultipleEnabled?.raw === true ? Infinity : 1\n const { height } = useControlSizing(props.context.mode);\n const [value, entities, labels, records, selectEntity, getSearchResults, theme] = useLookup(props);\n const styles = getLookupStyles(theme, itemLimit === 1, height);\n const suggestionsCalloutTheme = props.context.fluentDesignLanguage?.applicationTheme ?? theme;\n const suggestionsCalloutStyles = useMemo(() => getSuggestionsCalloutStyles(suggestionsCalloutTheme), [suggestionsCalloutTheme])\n const mouseOver = useMouseOver(ref);\n const isFocused = useFocusIn(ref, 100);\n const firstRenderRef = useRef(true);\n const shouldFocusRef = useRef(false);\n const [placeholder, setPlaceholder] = useState('---');\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n\n useEffect(() => {\n if (firstRenderRef.current) {\n firstRenderRef.current = false;\n return;\n }\n //@ts-ignore\n if (componentRef.current.state.suggestionsVisible) {\n //if the suggestions callout is open and the selected target changes, refresh the results\n forceSearch();\n }\n }, [entities])\n\n useEffect(() => {\n const onKeyPress = (ev: KeyboardEvent) => {\n if (context.mode.isControlDisabled) {\n return;\n }\n if (ev.key === 'Backspace') {\n const picker = ref.current?.querySelector('[class*=\"TALXIS__tag-picker__root\"]');\n if ((document.activeElement === picker) && value.length === 1) {\n records.select(undefined);\n setTimeout(() => {\n componentRef.current?.focusInput()\n }, 200)\n }\n }\n }\n document.addEventListener('keydown', onKeyPress)\n return () => {\n document.removeEventListener('keydown', onKeyPress);\n }\n }, [value]);\n\n useEffect(() => {\n if (props.parameters.AutoFocus?.raw === true) {\n focus();\n }\n }, []);\n\n const focus = () => {\n if (componentRef.current?.items?.length === itemLimit) {\n const el = ref.current?.querySelector(':scope>div') as HTMLDivElement;\n el?.click();\n el?.focus();\n return;\n }\n componentRef.current?.focusInput();\n }\n\n const forceSearch = async () => {\n //@ts-ignore - We need to use internal methods to show and fill the suggestions on entity change\n componentRef.current.suggestionStore.updateSuggestions([]);\n //@ts-ignore - ^^same as above\n componentRef.current.setState({\n suggestionsVisible: true,\n suggestionsLoading: true,\n });\n //@ts-ignore - ^^same as above\n const results = await onResolveSuggestions(componentRef.current.input.current.value)\n //@ts-ignore - ^^same as above\n componentRef.current.updateSuggestionsList(results);\n //@ts-ignore - ^^same above\n componentRef.current.setState({\n isMostRecentlyUsedVisible: false,\n suggestionsVisible: true,\n moreSuggestionsAvailable: false,\n });\n }\n\n const isComponentActive = () => {\n return mouseOver || isFocused;\n }\n\n const getSecondaryName = (result: ComponentFramework.LookupValue & {\n entityData: {\n [key: string]: any;\n };\n layout: ILayout;\n }, metadata?: IMetadata) => {\n //polymorphic, selected all\n if (!entities.find(x => x.selected)) {\n return metadata?.DisplayName;\n }\n else {\n let text: string | undefined = result.entityData[result.layout?.Rows?.[0]?.Cells?.[1]?.Name];\n //TODO: use metadata to know if the attribute is a lookup and datetime\n //metadata are laaded prior to the search result, so we don't know what attribute to ask for when fetching metadata\n if(!text){\n //if the attribute is not found, try to get the formatted value of lookup\n text = result.entityData[\"_\"+result.layout?.Rows?.[0]?.Cells?.[1]?.Name+\"_value@OData.Community.Display.V1.FormattedValue\"]\n }\n const dateRegex = /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z/;\n if (typeof text === 'string' && text.match(dateRegex)) {\n text = props.context.formatting.formatTime(dayjs(text).toDate(), 1);\n }\n return text;\n }\n }\n\n const onResolveSuggestions = async (filter: string, selectedItems?: IItemProps[] | undefined): Promise<IItemProps[]> => {\n //TODO: onResolveSuggestions gets called when the record gets selected resulting in unnecessary call\n const results = await getSearchResults(filter);\n const suggestions: IItemProps[] = [];\n for (const result of results) {\n if (selectedItems?.find(x => x.key === result.id)) {\n continue;\n }\n const metadata = await entities.find(x => x.entityName === result.entityType)?.metadata;\n suggestions.push({\n key: result.id,\n text: result.name,\n secondaryText: getSecondaryName(result, metadata),\n 'data-entity': result.entityType\n })\n }\n return suggestions;\n }\n\n const componentProps = onOverrideComponentProps({\n ref: componentRef,\n readOnly: context.mode.isControlDisabled,\n resolveDelay: 200,\n stackItems: itemLimit === 1,\n errorMessage: props.parameters.value.errorMessage,\n hideErrorMessage: !props.parameters.ShowErrorMessage?.raw,\n pickerCalloutProps: {\n layerProps: {\n eventBubblingEnabled: true\n },\n className: suggestionsCalloutStyles.suggestionsCallout,\n theme: suggestionsCalloutTheme,\n },\n inputProps: {\n placeholder: placeholder,\n onMouseEnter: () => {\n if (context.mode.isControlDisabled) {\n return;\n }\n setPlaceholder(`${labels.placeholder()} ${props.parameters.value.attributes.DisplayName}`);\n },\n onMouseLeave: () => {\n setPlaceholder(\"---\");\n }\n\n },\n pickerSuggestionsProps: {\n loadingText: labels.searching(),\n theme: suggestionsCalloutTheme,\n noResultsFoundText: labels.noRecordsFound(),\n className: suggestionsCalloutStyles.suggestionsContainer,\n // @ts-ignore\n suggestionsHeaderText: (\n <>\n {props.parameters.IsInlineNewEnabled?.raw !== false && (\n <RecordCreator labels={labels} entities={entities} onCreateRecord={records.create} />\n )}\n {props.parameters.value.attributes.Targets.length > 1 && (\n <TargetSelector\n labels={labels}\n entities={entities}\n onEntitySelected={(entityName) => {\n selectEntity(entityName);\n }}\n />\n )}\n </>\n )\n },\n transparent: itemLimit === 1,\n onChange: (items) => {\n records.select(\n items?.map((item) => {\n return {\n entityType: item['data-entity'],\n id: item.key,\n name: item.text\n };\n })\n );\n },\n searchBtnProps: {\n key: 'search',\n iconProps: {\n iconName: 'Search'\n },\n showOnlyOnHover: true\n },\n selectedItems: value.map((lookup) => {\n return {\n key: lookup.id,\n text: lookup.name || labels.noName(),\n 'data-entity': lookup.entityType,\n 'data-navigation-enabled': props.parameters.EnableNavigation?.raw !== false,\n onClick: () => {\n if (props.parameters.EnableNavigation?.raw === false) {\n return;\n }\n context.navigation.openForm({\n entityName: lookup.entityType,\n entityId: lookup.id\n });\n },\n deleteButtonProps:\n isComponentActive() || itemLimit > 1\n ? {\n key: 'delete',\n iconProps: {\n iconName: 'Cancel',\n },\n onClick: () => {\n shouldFocusRef.current = false;\n records.deselect(lookup);\n setTimeout(() => {\n focus();\n }, 200);\n }\n }\n : undefined\n };\n }),\n itemLimit: itemLimit,\n onEmptyResolveSuggestions: !context.mode.isControlDisabled ? (selectedItems) => onResolveSuggestions(\"\", selectedItems as IItemProps[]) as any : undefined,\n onResolveSuggestions: onResolveSuggestions,\n });\n\n return (\n <ThemeProvider applyTo=\"none\" theme={theme} className={`talxis__lookupControl ${styles.root}`} ref={ref}>\n <TagPicker {...componentProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AAgBa,MAAA,MAAM,GAAG,CAAC,KAAc,KAAI;AACrC,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACzC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;AACrD,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,KAAK,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAA;AAC/E,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,EA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.js","sources":["../../../src/components/Lookup/Lookup.tsx"],"sourcesContent":["\nimport { ILayout, ILookup, IMetadata } from \"./interfaces\";\nimport { useLookup } from \"./hooks/useLookup\";\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { ThemeProvider } from \"@fluentui/react\";\nimport { IItemProps, TagPicker } from \"@talxis/react-components\";\nimport { TargetSelector } from \"./components/TargetSelector\";\nimport { useMouseOver } from \"../../hooks/useMouseOver\";\nimport { getLookupStyles, getSuggestionsCalloutStyles } from \"./styles\";\nimport { IBasePicker } from \"@fluentui/react/lib/components/pickers/BasePicker.types\";\nimport { ITag } from \"@fluentui/react/lib/components/pickers/TagPicker/TagPicker.types\";\nimport { RecordCreator } from \"./components/RecordCreator\";\nimport { useFocusIn } from \"../../hooks/useFocusIn\";\nimport { useControlSizing } from \"../../hooks/useControlSizing\";\nimport dayjs from \"dayjs\";\n\nexport const Lookup = (props: ILookup) => {\n const context = props.context;\n const ref = useRef<HTMLDivElement>(null);\n const componentRef = useRef<IBasePicker<ITag>>(null);\n const itemLimit = props.parameters.MultipleEnabled?.raw === true ? Infinity : 1\n const { height } = useControlSizing(props.context.mode);\n const [value, entities, labels, records, selectEntity, getSearchResults, theme] = useLookup(props);\n const styles = getLookupStyles(theme, itemLimit === 1, height);\n const suggestionsCalloutTheme = props.context.fluentDesignLanguage?.applicationTheme ?? theme;\n const suggestionsCalloutStyles = useMemo(() => getSuggestionsCalloutStyles(suggestionsCalloutTheme), [suggestionsCalloutTheme])\n const mouseOver = useMouseOver(ref);\n const isFocused = useFocusIn(ref, 100);\n const firstRenderRef = useRef(true);\n const shouldFocusRef = useRef(false);\n const [placeholder, setPlaceholder] = useState('---');\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n\n useEffect(() => {\n if (firstRenderRef.current) {\n firstRenderRef.current = false;\n return;\n }\n //@ts-ignore\n if (componentRef.current.state.suggestionsVisible) {\n //if the suggestions callout is open and the selected target changes, refresh the results\n forceSearch();\n }\n }, [entities])\n\n useEffect(() => {\n const onKeyPress = (ev: KeyboardEvent) => {\n if (context.mode.isControlDisabled) {\n return;\n }\n if (ev.key === 'Backspace') {\n const picker = ref.current?.querySelector('[class*=\"TALXIS__tag-picker__root\"]');\n if ((document.activeElement === picker) && value.length === 1) {\n records.select(undefined);\n setTimeout(() => {\n componentRef.current?.focusInput()\n }, 200)\n }\n }\n }\n document.addEventListener('keydown', onKeyPress)\n return () => {\n document.removeEventListener('keydown', onKeyPress);\n }\n }, [value]);\n\n useEffect(() => {\n if (props.parameters.AutoFocus?.raw === true) {\n focus();\n }\n }, []);\n\n const focus = () => {\n if (componentRef.current?.items?.length === itemLimit) {\n const el = ref.current?.querySelector(':scope>div') as HTMLDivElement;\n el?.click();\n el?.focus();\n return;\n }\n componentRef.current?.focusInput();\n }\n\n const forceSearch = async () => {\n //@ts-ignore - We need to use internal methods to show and fill the suggestions on entity change\n componentRef.current.suggestionStore.updateSuggestions([]);\n //@ts-ignore - ^^same as above\n componentRef.current.setState({\n suggestionsVisible: true,\n suggestionsLoading: true,\n });\n //@ts-ignore - ^^same as above\n const results = await onResolveSuggestions(componentRef.current.input.current.value)\n //@ts-ignore - ^^same as above\n componentRef.current.updateSuggestionsList(results);\n //@ts-ignore - ^^same above\n componentRef.current.setState({\n isMostRecentlyUsedVisible: false,\n suggestionsVisible: true,\n moreSuggestionsAvailable: false,\n });\n }\n\n const isComponentActive = () => {\n return mouseOver || isFocused;\n }\n\n const getSecondaryName = async (result: ComponentFramework.LookupValue & {\n entityData: {\n [key: string]: any;\n };\n layout: ILayout;\n }): Promise<string | undefined> => {\n const metadata = await entities.find(x => x.entityName === result.entityType)?.metadata;\n const attribute: string | undefined = result.layout?.Rows?.[0]?.Cells?.[1]?.Name;\n //polymorphic, selected all\n if (!entities.find(x => x.selected)) {\n return metadata?.DisplayName;\n }\n else if (metadata?.LogicalName && attribute) {\n let targetEntityName = metadata.LogicalName;\n let targetAttribute = attribute;\n //checking for attributes pointing to related entity attribute, given by convention of using dot as separator\n if (attribute.includes(\".\")) {\n targetEntityName = result.layout.Rows.find(x => x.Cells.find(y => y.Name === attribute))?.Cells?.find(y => y.Name === attribute)?.RelatedEntityName || metadata.LogicalName;\n targetAttribute = attribute.split(\".\")[1]\n }\n const entityMetadata: ComponentFramework.PropertyHelper.EntityMetadata = await props.context.utils.getEntityMetadata(targetEntityName, [targetAttribute]);\n const attributetype: string = entityMetadata.Attributes.get(targetAttribute).AttributeTypeName;\n let primaryName: string;\n switch (attributetype) {\n case \"lookup\":\n case \"partylist\":\n case \"owner\":\n case \"customer\":\n primaryName = result.entityData[`_${targetAttribute}_value@OData.Community.Display.V1.FormattedValue`];\n break;\n case \"optionset\":\n case \"picklist\":\n case \"state\":\n case \"status\":\n case \"boolean\":\n case \"integer\":\n case \"bigint\":\n case \"decimal\":\n case \"money\":\n //TODO: Introduce user formatting, this approach takes format from application user setting\n primaryName = result.entityData[`${targetAttribute}@OData.Community.Display.V1.FormattedValue`];\n break;\n case \"datetime\":\n primaryName = props.context.formatting.formatTime(dayjs(result.entityData[attribute]).toDate(), 1);\n break;\n default:\n primaryName = result.entityData[attribute];\n };\n return primaryName;\n }\n }\n\n const onResolveSuggestions = async (filter: string, selectedItems?: IItemProps[] | undefined): Promise<IItemProps[]> => {\n //TODO: onResolveSuggestions gets called when the record gets selected resulting in unnecessary call\n const results = await getSearchResults(filter);\n const suggestions: IItemProps[] = [];\n for (const result of results) {\n if (selectedItems?.find(x => x.key === result.id)) {\n continue;\n }\n suggestions.push({\n key: result.id,\n text: result.name,\n secondaryText: await getSecondaryName(result),\n 'data-entity': result.entityType\n })\n }\n return suggestions;\n }\n\n const componentProps = onOverrideComponentProps({\n ref: componentRef,\n readOnly: context.mode.isControlDisabled,\n resolveDelay: 200,\n stackItems: itemLimit === 1,\n errorMessage: props.parameters.value.errorMessage,\n hideErrorMessage: !props.parameters.ShowErrorMessage?.raw,\n pickerCalloutProps: {\n layerProps: {\n eventBubblingEnabled: true\n },\n className: suggestionsCalloutStyles.suggestionsCallout,\n theme: suggestionsCalloutTheme,\n },\n inputProps: {\n placeholder: placeholder,\n onMouseEnter: () => {\n if (context.mode.isControlDisabled) {\n return;\n }\n setPlaceholder(`${labels.placeholder()} ${props.parameters.value.attributes.DisplayName}`);\n },\n onMouseLeave: () => {\n setPlaceholder(\"---\");\n }\n\n },\n pickerSuggestionsProps: {\n loadingText: labels.searching(),\n theme: suggestionsCalloutTheme,\n noResultsFoundText: labels.noRecordsFound(),\n className: suggestionsCalloutStyles.suggestionsContainer,\n // @ts-ignore\n suggestionsHeaderText: (\n <>\n {props.parameters.IsInlineNewEnabled?.raw !== false && (\n <RecordCreator labels={labels} entities={entities} onCreateRecord={records.create} />\n )}\n {props.parameters.value.attributes.Targets.length > 1 && (\n <TargetSelector\n labels={labels}\n entities={entities}\n onEntitySelected={(entityName) => {\n selectEntity(entityName);\n }}\n />\n )}\n </>\n )\n },\n transparent: itemLimit === 1,\n onChange: (items) => {\n records.select(\n items?.map((item) => {\n return {\n entityType: item['data-entity'],\n id: item.key,\n name: item.text\n };\n })\n );\n },\n searchBtnProps: {\n key: 'search',\n iconProps: {\n iconName: 'Search'\n },\n showOnlyOnHover: true\n },\n selectedItems: value.map((lookup) => {\n return {\n key: lookup.id,\n text: lookup.name || labels.noName(),\n 'data-entity': lookup.entityType,\n 'data-navigation-enabled': props.parameters.EnableNavigation?.raw !== false,\n onClick: () => {\n if (props.parameters.EnableNavigation?.raw === false) {\n return;\n }\n context.navigation.openForm({\n entityName: lookup.entityType,\n entityId: lookup.id\n });\n },\n deleteButtonProps:\n isComponentActive() || itemLimit > 1\n ? {\n key: 'delete',\n iconProps: {\n iconName: 'Cancel',\n },\n onClick: () => {\n shouldFocusRef.current = false;\n records.deselect(lookup);\n setTimeout(() => {\n focus();\n }, 200);\n }\n }\n : undefined\n };\n }),\n itemLimit: itemLimit,\n onEmptyResolveSuggestions: !context.mode.isControlDisabled ? (selectedItems) => onResolveSuggestions(\"\", selectedItems as IItemProps[]) as any : undefined,\n onResolveSuggestions: onResolveSuggestions,\n });\n\n return (\n <ThemeProvider applyTo=\"none\" theme={theme} className={`talxis__lookupControl ${styles.root}`} ref={ref}>\n <TagPicker {...componentProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AAgBa,MAAA,MAAM,GAAG,CAAC,KAAc,KAAI;AACrC,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACzC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;AACrD,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,KAAK,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAA;AAC/E,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACnG,IAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,uBAAuB,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,gBAAgB,IAAI,KAAK,CAAC;AAC9F,IAAA,MAAM,wBAAwB,GAAG,OAAO,CAAC,MAAM,2BAA2B,CAAC,uBAAuB,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAA;AAC/H,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,IAA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U,CAAC,MAAK;AACZ,gCAAA,KAAK,EAAE,CAAC;6BACX,EAAE,GAAG,CAAC,CAAC;yBACX;AACJ,qBAAA;AACD,sBAAE,SAAS;aACtB,CAAC;AACN,SAAC,CAAC;AACF,QAAA,SAAS,EAAE,SAAS;QACpB,yBAAyB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,GAAG,CAAC,aAAa,KAAK,oBAAoB,CAAC,EAAE,EAAE,aAA6B,CAAQ,GAAG,SAAS;AAC1J,QAAA,oBAAoB,EAAE,oBAAoB;AAC7C,KAAA,CAAC,CAAC;AAEH,IAAA,QACIA,GAAA,CAAC,aAAa,EAAA,EAAC,OAAO,EAAC,MAAM,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA,sBAAA,EAAyB,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,EAAE,GAAG,EAAA,QAAA,EACnGA,GAAC,CAAA,SAAS,EAAK,EAAA,GAAA,cAAc,EAAI,CAAA,EAAA,CACrB,EAClB;AACN;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { lookupTranslations } from '../translations.js';
|
|
3
3
|
import { useFetchXml } from './useFetchXml.js';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
4
5
|
import { useControl } from '../../../hooks/useControl.js';
|
|
5
6
|
|
|
6
7
|
const useLookup = (props) => {
|
|
@@ -61,19 +62,44 @@ const useLookup = (props) => {
|
|
|
61
62
|
}
|
|
62
63
|
await Promise.all(fetchXmlMap.values());
|
|
63
64
|
const responsePromiseMap = new Map();
|
|
65
|
+
const aliasEntityMap = [];
|
|
66
|
+
const domParser = new DOMParser();
|
|
64
67
|
for (const [entityName, fetchXml] of fetchXmlMap) {
|
|
65
|
-
|
|
68
|
+
const fetchXMLresult = await fetchXml;
|
|
69
|
+
responsePromiseMap.set(entityName, context.webAPI.retrieveMultipleRecords(entityName, `?$top=25&fetchXml=${encodeURIComponent((fetchXMLresult))}`));
|
|
70
|
+
//parsing of link entities from fetchXML
|
|
71
|
+
const xml = domParser.parseFromString(fetchXMLresult, "application/xml");
|
|
72
|
+
const linkEntities = xml.querySelectorAll(`link-entity`);
|
|
73
|
+
for (const linkEntity of linkEntities) {
|
|
74
|
+
const aliasAttribute = linkEntity.getAttribute('alias');
|
|
75
|
+
const entityAttribute = linkEntity.getAttribute('name');
|
|
76
|
+
if (entityAttribute) {
|
|
77
|
+
aliasEntityMap.push({ aliasAttribute: aliasAttribute ?? entityAttribute, entityAttribute: entityAttribute });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw Error("Link-entity without name property is not supported. Offedning query: " + fetchXMLresult);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
66
83
|
}
|
|
67
84
|
await Promise.all(responsePromiseMap.values());
|
|
68
85
|
const result = [];
|
|
69
86
|
for (const [entityName, response] of responsePromiseMap) {
|
|
70
87
|
const layout = JSON.parse((await getFetchXml(entityViewIdMap.get(entityName))).layoutjson ?? "{}");
|
|
88
|
+
//Mapping link-entities' logical names to layout's Cell
|
|
89
|
+
if (layout.Rows.some(x => x.Cells.some(x => x.Name.includes(".")))) {
|
|
90
|
+
const cellsToModify = layout.Rows.flatMap(row => row.Cells)
|
|
91
|
+
.filter(cell => cell.Name.includes("."));
|
|
92
|
+
cellsToModify.forEach(cell => {
|
|
93
|
+
const alias = cell.Name.split(".")[0];
|
|
94
|
+
cell.RelatedEntityName = aliasEntityMap.find(x => x.aliasAttribute === alias)?.entityAttribute ?? "";
|
|
95
|
+
});
|
|
96
|
+
}
|
|
71
97
|
for (const entity of (await response).entities) {
|
|
72
98
|
const entityMetadata = await entities.find(x => x.entityName === entityName).metadata;
|
|
73
99
|
result.push({
|
|
74
100
|
entityType: entityName,
|
|
75
101
|
id: entity[entityMetadata.PrimaryIdAttribute],
|
|
76
|
-
name: entity
|
|
102
|
+
name: await getPrimaryName(entity, entityName, layout.Rows?.[0]?.Cells?.[0]?.Name, layout),
|
|
77
103
|
entityData: entity,
|
|
78
104
|
layout: layout
|
|
79
105
|
});
|
|
@@ -81,6 +107,46 @@ const useLookup = (props) => {
|
|
|
81
107
|
}
|
|
82
108
|
return result;
|
|
83
109
|
};
|
|
110
|
+
const getPrimaryName = async (entity, entityName, attribute, layout) => {
|
|
111
|
+
let targetEntityName = entityName;
|
|
112
|
+
let targetAttribute = attribute;
|
|
113
|
+
//checking for attributes pointing to related entity attribute, given by convention of using dot as separator
|
|
114
|
+
if (attribute.includes(".")) {
|
|
115
|
+
targetEntityName = layout.Rows.find(x => x.Cells)?.Cells?.find(y => y.Name === attribute)?.RelatedEntityName || entityName;
|
|
116
|
+
targetAttribute = attribute.split(".")[1];
|
|
117
|
+
}
|
|
118
|
+
const entityMetadata = await props.context.utils.getEntityMetadata(targetEntityName, [targetAttribute]);
|
|
119
|
+
const attributetype = entityMetadata.Attributes.get(targetAttribute).AttributeTypeName;
|
|
120
|
+
let primaryName;
|
|
121
|
+
switch (attributetype.toLowerCase()) {
|
|
122
|
+
case "lookup":
|
|
123
|
+
case "partylist":
|
|
124
|
+
case "owner":
|
|
125
|
+
case "customer":
|
|
126
|
+
primaryName = entity[`_${targetAttribute}_value@OData.Community.Display.V1.FormattedValue`];
|
|
127
|
+
break;
|
|
128
|
+
case "optionset":
|
|
129
|
+
case "picklist":
|
|
130
|
+
case "state":
|
|
131
|
+
case "status":
|
|
132
|
+
case "boolean":
|
|
133
|
+
case "integer":
|
|
134
|
+
case "bigint":
|
|
135
|
+
case "decimal":
|
|
136
|
+
case "money":
|
|
137
|
+
//TODO: Introduce user formatting, this approach takes format from application user setting
|
|
138
|
+
primaryName = entity[`${targetAttribute}@OData.Community.Display.V1.FormattedValue`];
|
|
139
|
+
break;
|
|
140
|
+
case "datetime":
|
|
141
|
+
primaryName = props.context.formatting.formatTime(dayjs(entity[targetAttribute]).toDate(), 1);
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
primaryName = entity[targetAttribute];
|
|
145
|
+
}
|
|
146
|
+
return (primaryName ??
|
|
147
|
+
entity[entityMetadata.PrimaryNameAttribute] ??
|
|
148
|
+
labels.noName());
|
|
149
|
+
};
|
|
84
150
|
const createRecord = async (entityName) => {
|
|
85
151
|
const formParameters = props.onGetOnCreateFormParameters?.(entityName);
|
|
86
152
|
const result = await context.navigation.openForm({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLookup.js","sources":["../../../../src/components/Lookup/hooks/useLookup.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { ITranslation, useControl } from \"../../../hooks\";\nimport { IEntity, ILayout, ILookup } from \"../interfaces\";\nimport { lookupTranslations } from \"../translations\";\nimport { useFetchXml } from \"./useFetchXml\";\nimport { ITheme } from \"@talxis/react-components\";\n\nexport const useLookup = (props: ILookup): [\n ComponentFramework.LookupValue[],\n IEntity[],\n ITranslation<Required<ILookup>['translations']>,\n {\n create: (entityName: string) => void,\n select: (record: ComponentFramework.LookupValue[] | undefined) => void,\n deselect: (record: ComponentFramework.LookupValue) => void,\n },\n (entityName: string | null) => void,\n (query: string) => Promise<(ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[]>,\n ITheme\n] => {\n\n const targets = props.parameters.value.attributes.Targets;\n const boundValue = props.parameters.value.raw;\n const context = props.context;\n const { labels, theme, onNotifyOutputChanged } = useControl('Lookup', props, lookupTranslations);\n const [getFetchXml, applyLookupQuery] = useFetchXml(context);\n\n const [entities, setEntities] = useState<IEntity[]>(() => {\n return targets.map(target => {\n return {\n entityName: target,\n selected: targets.length === 1 ? true : false,\n metadata: props.context.utils.getEntityMetadata(target, []) as any,\n }\n })\n });\n\n const selectedEntity = entities.find(x => x.selected);\n\n const selectEntity = (entityName: string | null) => {\n setEntities([...entities as IEntity[]].map(entity => {\n return {\n entityName: entity.entityName,\n metadata: entity.metadata,\n selected: entity.entityName === entityName\n }\n }))\n }\n\n const selectRecords = (records: ComponentFramework.LookupValue[] | undefined) => {\n onNotifyOutputChanged({\n value: records\n })\n }\n const getSearchFetchXml = async (entityName: string, query: string, viewIdCallBack: (id: string) => void): Promise<string> => {\n const response = (await props.parameters.value.getAllViews(entityName)).find(x => x.isDefault);\n if (!response?.viewId) {\n throw new Error(`Entity ${entityName} does not have a default view id!`);\n }\n viewIdCallBack(response.viewId);\n let fetchXml = response?.fetchXml\n if (!fetchXml) {\n fetchXml = (await getFetchXml(response.viewId)).fetchxml;\n }\n return applyLookupQuery(entities.find(x => x.entityName === entityName)!, fetchXml, query);\n\n }\n const getSearchResults = async (query: string): Promise<(ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[]> => {\n if (props.onSearch) {\n return props.onSearch(selectedEntity ? [selectedEntity?.entityName] : targets, query) as any;\n }\n const fetchXmlMap = new Map<string, Promise<string>>();\n const entityViewIdMap = new Map<string, string>();\n if (selectedEntity) {\n fetchXmlMap.set(selectedEntity.entityName, getSearchFetchXml(selectedEntity.entityName, query, (viewId) => entityViewIdMap.set(selectedEntity.entityName, viewId)))\n }\n else {\n for (const entity of targets) {\n fetchXmlMap.set(entity, getSearchFetchXml(entity, query, (viewId) => entityViewIdMap.set(entity, viewId)))\n }\n }\n await Promise.all(fetchXmlMap.values());\n const responsePromiseMap = new Map<string, Promise<ComponentFramework.WebApi.RetrieveMultipleResponse>>()\n for (const [entityName, fetchXml] of fetchXmlMap) {\n responsePromiseMap.set(entityName, context.webAPI.retrieveMultipleRecords(entityName, `?$top=25&fetchXml=${encodeURIComponent((await fetchXml))}`))\n }\n await Promise.all(responsePromiseMap.values());\n const result: (ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[] = [];\n for (const [entityName, response] of responsePromiseMap) {\n const layout: ILayout = JSON.parse((await getFetchXml(entityViewIdMap.get(entityName)!)).layoutjson ?? \"{}\");\n for (const entity of (await response).entities) {\n const entityMetadata = await entities.find(x => x.entityName === entityName)!.metadata;\n result.push({\n entityType: entityName,\n id: entity[entityMetadata.PrimaryIdAttribute],\n name: entity[layout.Rows?.[0]?.Cells?.[0]?.Name] ?? entity[entityMetadata.PrimaryNameAttribute] ?? labels.noName(),\n entityData: entity,\n layout: layout\n });\n }\n }\n return result;\n }\n\n const createRecord = async (entityName: string) => {\n const formParameters = props.onGetOnCreateFormParameters?.(entityName)\n const result = await context.navigation.openForm({\n entityName: entityName,\n useQuickCreateForm: true\n }, formParameters);\n if (!result.savedEntityReference) {\n return;\n }\n onNotifyOutputChanged({\n value: [\n ...boundValue,\n ...result.savedEntityReference\n ]\n });\n }\n\n const deselectRecord = (record: ComponentFramework.LookupValue) => {\n const map = new Map<string, ComponentFramework.LookupValue>(boundValue.map(value => [value.id, value]));\n map.delete(record.id);\n onNotifyOutputChanged({\n value: [...map.values()]\n })\n }\n\n return [\n boundValue, entities, labels, {\n create: createRecord,\n deselect: deselectRecord,\n select: selectRecords\n },\n selectEntity,\n getSearchResults,\n theme\n ];\n};"],"names":[],"mappings":";;;;;AAOa,MAAA,SAAS,GAAG,CAAC,KAAc,KAYpC;IAEA,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IAC1D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjG,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAE7D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAY,MAAK;AACrD,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,IAAG;YACxB,OAAO;AACH,gBAAA,UAAU,EAAE,MAAM;AAClB,gBAA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;;;"}
|
|
1
|
+
{"version":3,"file":"useLookup.js","sources":["../../../../src/components/Lookup/hooks/useLookup.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { ITranslation, useControl } from \"../../../hooks\";\nimport { IEntity, ILayout, ILookup, IMetadata } from \"../interfaces\";\nimport { lookupTranslations } from \"../translations\";\nimport { useFetchXml } from \"./useFetchXml\";\nimport { ITheme } from \"@talxis/react-components\";\nimport dayjs from \"dayjs\";\n\nexport const useLookup = (props: ILookup): [\n ComponentFramework.LookupValue[],\n IEntity[],\n ITranslation<Required<ILookup>['translations']>,\n {\n create: (entityName: string) => void,\n select: (record: ComponentFramework.LookupValue[] | undefined) => void,\n deselect: (record: ComponentFramework.LookupValue) => void,\n },\n (entityName: string | null) => void,\n (query: string) => Promise<(ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[]>,\n ITheme\n] => {\n\n const targets = props.parameters.value.attributes.Targets;\n const boundValue = props.parameters.value.raw;\n const context = props.context;\n const { labels, theme, onNotifyOutputChanged } = useControl('Lookup', props, lookupTranslations);\n const [getFetchXml, applyLookupQuery] = useFetchXml(context);\n\n const [entities, setEntities] = useState<IEntity[]>(() => {\n return targets.map(target => {\n return {\n entityName: target,\n selected: targets.length === 1 ? true : false,\n metadata: props.context.utils.getEntityMetadata(target, []) as any,\n }\n })\n });\n\n const selectedEntity = entities.find(x => x.selected);\n\n const selectEntity = (entityName: string | null) => {\n setEntities([...entities as IEntity[]].map(entity => {\n return {\n entityName: entity.entityName,\n metadata: entity.metadata,\n selected: entity.entityName === entityName\n }\n }))\n }\n\n const selectRecords = (records: ComponentFramework.LookupValue[] | undefined) => {\n onNotifyOutputChanged({\n value: records\n })\n }\n const getSearchFetchXml = async (entityName: string, query: string, viewIdCallBack: (id: string) => void): Promise<string> => {\n const response = (await props.parameters.value.getAllViews(entityName)).find(x => x.isDefault);\n if (!response?.viewId) {\n throw new Error(`Entity ${entityName} does not have a default view id!`);\n }\n viewIdCallBack(response.viewId);\n let fetchXml = response?.fetchXml\n if (!fetchXml) {\n fetchXml = (await getFetchXml(response.viewId)).fetchxml;\n }\n return applyLookupQuery(entities.find(x => x.entityName === entityName)!, fetchXml, query);\n\n }\n const getSearchResults = async (query: string): Promise<(ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[]> => {\n if (props.onSearch) {\n return props.onSearch(selectedEntity ? [selectedEntity?.entityName] : targets, query) as any;\n }\n const fetchXmlMap = new Map<string, Promise<string>>();\n const entityViewIdMap = new Map<string, string>();\n if (selectedEntity) {\n fetchXmlMap.set(selectedEntity.entityName, getSearchFetchXml(selectedEntity.entityName, query, (viewId) => entityViewIdMap.set(selectedEntity.entityName, viewId)))\n }\n else {\n for (const entity of targets) {\n fetchXmlMap.set(entity, getSearchFetchXml(entity, query, (viewId) => entityViewIdMap.set(entity, viewId)))\n }\n }\n await Promise.all(fetchXmlMap.values());\n const responsePromiseMap = new Map<string, Promise<ComponentFramework.WebApi.RetrieveMultipleResponse>>()\n const aliasEntityMap: { aliasAttribute: string, entityAttribute: string }[] = [];\n const domParser = new DOMParser();\n for (const [entityName, fetchXml] of fetchXmlMap) {\n const fetchXMLresult = await fetchXml;\n responsePromiseMap.set(entityName, context.webAPI.retrieveMultipleRecords(entityName, `?$top=25&fetchXml=${encodeURIComponent((fetchXMLresult))}`))\n //parsing of link entities from fetchXML\n const xml = domParser.parseFromString(fetchXMLresult, \"application/xml\");\n const linkEntities = xml.querySelectorAll(`link-entity`);\n for (const linkEntity of linkEntities) {\n const aliasAttribute = linkEntity.getAttribute('alias');\n const entityAttribute = linkEntity.getAttribute('name');\n if (entityAttribute) {\n aliasEntityMap.push({ aliasAttribute: aliasAttribute ?? entityAttribute, entityAttribute: entityAttribute })\n }\n else {\n throw Error(\"Link-entity without name property is not supported. Offedning query: \" + fetchXMLresult);\n }\n }\n }\n await Promise.all(responsePromiseMap.values());\n const result: (ComponentFramework.LookupValue & { entityData: { [key: string]: any }, layout: ILayout })[] = [];\n for (const [entityName, response] of responsePromiseMap) {\n const layout: ILayout = JSON.parse((await getFetchXml(entityViewIdMap.get(entityName)!)).layoutjson ?? \"{}\");\n //Mapping link-entities' logical names to layout's Cell \n if (layout.Rows.some(x => x.Cells.some(x => x.Name.includes(\".\")))) {\n const cellsToModify = layout.Rows.flatMap(row => row.Cells)\n .filter(cell => cell.Name.includes(\".\"));\n\n cellsToModify.forEach(cell => {\n const alias = cell.Name.split(\".\")[0]\n cell.RelatedEntityName = aliasEntityMap.find(x => x.aliasAttribute === alias)?.entityAttribute ?? \"\";\n });\n }\n for (const entity of (await response).entities) {\n const entityMetadata = await entities.find(x => x.entityName === entityName)!.metadata;\n result.push({\n entityType: entityName,\n id: entity[entityMetadata.PrimaryIdAttribute],\n name: await getPrimaryName(entity, entityName, layout.Rows?.[0]?.Cells?.[0]?.Name, layout),\n entityData: entity,\n layout: layout\n });\n }\n }\n return result;\n }\n\n const getPrimaryName = async (\n entity: ComponentFramework.WebApi.Entity,\n entityName: string,\n attribute: string,\n layout: ILayout\n ): Promise<string> => {\n let targetEntityName = entityName;\n let targetAttribute = attribute;\n //checking for attributes pointing to related entity attribute, given by convention of using dot as separator\n if (attribute.includes(\".\")) {\n targetEntityName = layout.Rows.find(x => x.Cells)?.Cells?.find(y => y.Name === attribute)?.RelatedEntityName || entityName;\n targetAttribute = attribute.split(\".\")[1]\n }\n const entityMetadata: ComponentFramework.PropertyHelper.EntityMetadata = await props.context.utils.getEntityMetadata(targetEntityName, [targetAttribute]);\n const attributetype: string = entityMetadata.Attributes.get(targetAttribute).AttributeTypeName;\n let primaryName: string;\n switch (attributetype.toLowerCase()) {\n case \"lookup\":\n case \"partylist\":\n case \"owner\":\n case \"customer\":\n primaryName = entity[`_${targetAttribute}_value@OData.Community.Display.V1.FormattedValue`];\n break;\n case \"optionset\":\n case \"picklist\":\n case \"state\":\n case \"status\":\n case \"boolean\":\n case \"integer\":\n case \"bigint\":\n case \"decimal\":\n case \"money\":\n //TODO: Introduce user formatting, this approach takes format from application user setting\n primaryName = entity[`${targetAttribute}@OData.Community.Display.V1.FormattedValue`];\n break;\n case \"datetime\":\n primaryName = props.context.formatting.formatTime(dayjs(entity[targetAttribute]).toDate(), 1);\n break\n default:\n primaryName = entity[targetAttribute];\n };\n return (\n primaryName ??\n entity[entityMetadata.PrimaryNameAttribute] ??\n labels.noName()\n );\n };\n\n const createRecord = async (entityName: string) => {\n const formParameters = props.onGetOnCreateFormParameters?.(entityName)\n const result = await context.navigation.openForm({\n entityName: entityName,\n useQuickCreateForm: true\n }, formParameters);\n if (!result.savedEntityReference) {\n return;\n }\n onNotifyOutputChanged({\n value: [\n ...boundValue,\n ...result.savedEntityReference\n ]\n });\n }\n\n const deselectRecord = (record: ComponentFramework.LookupValue) => {\n const map = new Map<string, ComponentFramework.LookupValue>(boundValue.map(value => [value.id, value]));\n map.delete(record.id);\n onNotifyOutputChanged({\n value: [...map.values()]\n })\n }\n\n return [\n boundValue, entities, labels, {\n create: createRecord,\n deselect: deselectRecord,\n select: selectRecords\n },\n selectEntity,\n getSearchResults,\n theme\n ];\n};"],"names":[],"mappings":";;;;;;AAQa,MAAA,SAAS,GAAG,CAAC,KAAc,KAYpC;IAEA,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IAC1D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACjG,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAE7D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAY,MAAK;AACrD,QAAA,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