mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-23 10:05:01 +02:00
UBERF-12299: Fix gmail integration selection (#9505)
* UBERF-12299: Fix gmail integration selection Signed-off-by: Artem Savchenko <armisav@gmail.com> * UBERF-12299: Use original social id Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
export let justify: 'left' | 'center' = 'center'
|
||||
export let width: string | undefined = undefined
|
||||
export let readonly = false
|
||||
export let mapToPrimarySocialId = true
|
||||
|
||||
$: docQuery =
|
||||
include.length === 0
|
||||
@@ -41,6 +42,17 @@
|
||||
}
|
||||
}
|
||||
$: selectedEmp = value != null ? $employeeByPersonIdStore.get(value)?._id : value
|
||||
let employeeToPersonIdMap = new Map<Ref<Employee>, PersonId>()
|
||||
$: employeeToPersonIdMap = mapToPrimarySocialId
|
||||
? employeeToPersonIdMap
|
||||
: new Map(
|
||||
include
|
||||
.map((personId) => {
|
||||
const employee = $employeeByPersonIdStore.get(personId)
|
||||
return employee !== undefined ? ([employee._id, personId] as const) : null
|
||||
})
|
||||
.filter(notEmpty)
|
||||
)
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
@@ -48,7 +60,17 @@
|
||||
if (e.detail === null) {
|
||||
dispatch('change', null)
|
||||
} else {
|
||||
const socialString = $primarySocialIdByEmployeeRefStore.get(e.detail)
|
||||
let socialString: PersonId | undefined
|
||||
|
||||
if (mapToPrimarySocialId) {
|
||||
socialString = $primarySocialIdByEmployeeRefStore.get(e.detail)
|
||||
} else {
|
||||
socialString = employeeToPersonIdMap.get(e.detail)
|
||||
if (socialString === undefined) {
|
||||
socialString = $primarySocialIdByEmployeeRefStore.get(e.detail)
|
||||
console.warn('PersonId not found in provided social id list, falling back to primary social ID:', e.detail)
|
||||
}
|
||||
}
|
||||
if (socialString === undefined) {
|
||||
console.error('Social id not found for person', e.detail)
|
||||
return
|
||||
|
||||
@@ -25,13 +25,16 @@
|
||||
|
||||
$: ids = Array.from(new Set(integrations.map((p) => p.createdBy))).filter(notEmpty)
|
||||
|
||||
function change (e: CustomEvent<PersonId | null>) {
|
||||
function change (e: CustomEvent<PersonId | null>): void {
|
||||
if (e.detail === null) {
|
||||
selected = undefined
|
||||
} else {
|
||||
selected = integrations.find((p) => p.createdBy === e.detail)
|
||||
if (selected === undefined) {
|
||||
console.warn('Integration not found for selected person', e.detail)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<AccountBox value={selected?.modifiedBy} {kind} {size} include={ids} on:change={change} />
|
||||
<AccountBox value={selected?.createdBy} {kind} {size} include={ids} on:change={change} mapToPrimarySocialId={false} />
|
||||
|
||||
Reference in New Issue
Block a user