Skip to content

Commit 852ca8a

Browse files
committed
Fix identities management
1 parent 0b011d1 commit 852ca8a

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

frontend/src/modules/organization/components/form/organization-form-identities.vue

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/>
2929
</el-form-item>
3030
<template v-for="(identity, ii) of model.identities" :key="`${identity}${ii}`">
31-
<div v-if="value.enabled && identity.platform === key">
31+
<div v-if="value.enabled && identity.platform === key && identity.url">
3232
<div
3333
class="flex flex-grow gap-2 mt-1 pb-3 last:!mb-6 last:pb-0"
3434
>
@@ -132,7 +132,7 @@ const identitiesForm = reactive({
132132
github: {
133133
label: 'GitHub',
134134
enabled:
135-
props.modelValue.identities?.some((el) => el.platform === 'github')
135+
props.modelValue.identities?.some((el) => el.platform === 'github' && el.url)
136136
|| false,
137137
urlPrefix: 'github.com/',
138138
imgContainerClass:
@@ -141,7 +141,7 @@ const identitiesForm = reactive({
141141
linkedin: {
142142
label: 'LinkedIn',
143143
enabled:
144-
props.modelValue.identities?.some((el) => el.platform === 'linkedin')
144+
props.modelValue.identities?.some((el) => el.platform === 'linkedin' && el.url)
145145
|| false,
146146
urlPrefix: 'linkedin.com/company/',
147147
imgContainerClass:
@@ -150,7 +150,7 @@ const identitiesForm = reactive({
150150
twitter: {
151151
label: 'Twitter',
152152
enabled:
153-
props.modelValue.identities?.some((el) => el.platform === 'twitter')
153+
props.modelValue.identities?.some((el) => el.platform === 'twitter' && el.url)
154154
|| false,
155155
urlPrefix: 'twitter.com/',
156156
imgContainerClass:
@@ -159,7 +159,7 @@ const identitiesForm = reactive({
159159
crunchbase: {
160160
label: 'Crunchbase',
161161
enabled:
162-
props.modelValue.identities?.some((el) => el.platform === 'crunchbase')
162+
props.modelValue.identities?.some((el) => el.platform === 'crunchbase' && el.url)
163163
|| false,
164164
urlPrefix: 'crunchbase.com/organization/',
165165
imgContainerClass:
@@ -172,15 +172,10 @@ function findPlatform(platform) {
172172
}
173173
174174
function onInputChange(newValue, key, value, index) {
175-
if (index === 0) {
176-
model.value.attributes = {
177-
...props.modelValue.attributes,
178-
url: {
179-
...props.modelValue.attributes?.url,
180-
[key]: `https://${value.urlPrefix}${newValue}`,
181-
},
182-
};
183-
}
175+
model.value.identities[index] = {
176+
...props.modelValue.identities[index],
177+
url: `https://${value.urlPrefix}${newValue}`,
178+
};
184179
}
185180
186181
function platformInIdentities(platform) {

frontend/src/modules/organization/pages/organization-form-page.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ function getInitialModel(record) {
215215
identities: record ? [...record.identities.map((i) => ({
216216
platform: i.platform,
217217
name: i.name,
218+
username: i.url ? i.url.split('/').at(-1) : i.name,
219+
url: i.url,
218220
}))] : [],
219221
revenueRange: record ? record.revenueRange : {},
220222
emails:
@@ -386,6 +388,11 @@ async function onSubmit() {
386388
}
387389
return acc;
388390
}, []),
391+
identities: formModel.value.identities.map((i) => ({
392+
platform: i.platform,
393+
url: i.url,
394+
name: i.name ?? i.username,
395+
})),
389396
phoneNumbers: formModel.value.phoneNumbers.reduce(
390397
(acc, item) => {
391398
if (item !== '') {

0 commit comments

Comments
 (0)