Skip to content

Commit

Permalink
Organization enrichment frontend (#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
joanagmaia authored May 16, 2023
1 parent 789faf8 commit d3bc417
Show file tree
Hide file tree
Showing 15 changed files with 713 additions and 25 deletions.
4 changes: 4 additions & 0 deletions frontend/src/assets/scss/badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
}
}

&--border {
@apply text-gray-900 gap-1.5 border px-1.5 rounded-md h-6 truncate block;
}

&--interactive {
@apply text-gray-900 hover:text-brand-500 transition text-ellipsis truncate flex items-center hover:cursor-pointer gap-1.5 border px-1.5 rounded-md h-6;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div class="grid gap-x-12 grid-cols-3 mb-16">
<div v-if="showHeader">
<h6>Attributes</h6>
<p class="text-gray-500 text-2xs leading-normal mt-1">
Data points to enhance the organization profile
</p>
</div>
<div :class="showHeader ? 'col-span-2' : 'col-span-3'">
<div class="flex gap-3 border-b h-8 items-center">
<span
class="uppercase text-gray-400 text-2xs font-semibold tracking-wide w-1/3"
>Name</span>
<span
class="uppercase text-gray-400 text-2xs font-semibold tracking-wide grow"
>Value</span>
</div>
<div
class="custom-attributes-form flex mt-4 mb-2 flex-col gap-4"
>
<app-organization-form-item
v-for="attribute in visibleAttributes"
:key="attribute.name"
:type="attribute.type"
:label="attribute.label"
:is-enrichment-field="true"
>
<app-autocomplete-many-input
v-if="attribute.type === attributesTypes.multiSelect"
v-model="model[attribute.name]"
disabled
input-class="w-full multi-select-field"
placeholder=" "
:collapse-tags="true"
/>
<el-input
v-else
v-model="model[attribute.name]"
:type="attribute.type"
disabled
clearable
/><template #error>
<div class="el-form-item__error">
Value is required
</div>
</template>
</app-organization-form-item>
</div>
</div>
</div>
</template>

<script setup>
import { computed } from 'vue';
import enrichmentAttributes, { attributesTypes } from '@/modules/organization/config/organization-enrichment-attributes';
import AppOrganizationFormItem from './organization-form-item.vue';
const props = defineProps({
showHeader: {
type: Boolean,
default: true,
},
modelValue: {
type: Object,
default: () => {},
},
organization: {
type: Object,
default: () => {},
},
});
const model = computed(() => props.modelValue);
const visibleAttributes = computed(() => enrichmentAttributes.filter((a) => a.showInForm));
</script>

<script>
export default {
name: 'AppOrganizationFormAttributes',
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div class="flex gap-3">
<div
class="w-1/3 flex flex-col gap-1 justify-start mt-0.5"
>
<div class="flex items-center leading-tight">
<div
class="text-gray-900 text-xs font-medium mr-2"
>
{{ label }}
</div>
<el-tooltip
v-if="isEnrichmentField"
content="Organization enrichment"
placement="top"
>
<div class="form-enrichment-badge">
<app-svg name="enrichment" />
</div>
</el-tooltip>
</div>
<span
class="text-2xs text-gray-500 leading-none"
>{{ type }}</span>
</div>
<el-form-item class="grow">
<slot />
</el-form-item>
</div>
</template>

<script setup>
import AppSvg from '@/shared/svg/svg.vue';
defineProps({
label: {
type: String,
default: null,
},
type: {
type: String,
default: null,
},
isEnrichmentField: {
type: Boolean,
default: false,
},
});
</script>

<script>
export default {
name: 'AppOrganizationFormItem',
};
</script>

<style lang="scss">
.form-enrichment-badge {
@apply w-5 h-5 bg-gray-100 rounded-full flex items-center justify-center;
svg {
@apply h-4 w-4 overflow-visible flex items-center justify-center leading-none;
}
}
.multi-select-field .el-select__tags {
@apply h-7;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,24 @@
</template>
</el-table-column>

<!-- Number of employees
TODO: Uncomment when we support enrichment
<!-- Number of employees -->
<el-table-column
label="# Employees"
width="150"
prop="employees"
sortable
><template #default="scope">
<div class="text-gray-900 text-sm">
{{
formatNumberToRange(
scope.row.employees
)
}}
</div></template
></el-table-column
>
-->
<template #default="scope">
<div class="text-sm h-full flex items-center">
<span v-if="scope.row.employees" class="text-gray-900">
{{
formatNumber(scope.row.employees)
}}
</span>
<span v-else class="text-gray-500">-</span>
</div>
</template>
</el-table-column>

<!-- Number of activities -->
<el-table-column
Expand Down Expand Up @@ -331,6 +331,161 @@
</template>
</el-table-column>

<!-- Location -->
<el-table-column
label="Location"
width="150"
prop="location"
sortable
>
<template #default="scope">
<router-link
:to="{
name: 'organizationView',
params: { id: scope.row.id },
}"
class="block"
>
<div
class="text-sm h-full flex items-center"
>
<span v-if="scope.row.location" class="text-gray-900">
{{
scope.row.location
}}
</span>
<span v-else class="text-gray-500">-</span>
</div>
</router-link>
</template>
</el-table-column>

<!-- Industry -->
<el-table-column
label="Industry"
width="150"
prop="industry"
sortable
>
<template #default="scope">
<router-link
:to="{
name: 'organizationView',
params: { id: scope.row.id },
}"
class="block"
>
<div
class="text-sm h-full flex items-center"
>
<span v-if="scope.row.industry" class="text-gray-900">
{{
toSentenceCase(scope.row.industry)
}}
</span>
<span v-else class="text-gray-500">-</span>
</div>
</router-link>
</template>
</el-table-column>

<!-- Size -->
<el-table-column
label="Size"
width="150"
prop="size"
sortable
>
<template #default="scope">
<router-link
:to="{
name: 'organizationView',
params: { id: scope.row.id },
}"
class="block"
>
<div
class="text-sm h-full flex items-center"
>
<span v-if="scope.row.size" class="text-gray-900">
{{
scope.row.size
}}
</span>
<span v-else class="text-gray-500">-</span>
</div>
</router-link>
</template>
</el-table-column>

<!-- Founded -->
<el-table-column
label="Founded"
width="150"
prop="founded"
sortable
>
<template #default="scope">
<router-link
:to="{
name: 'organizationView',
params: { id: scope.row.id },
}"
class="block"
>
<div
class="text-sm h-full flex items-center"
>
<span v-if="scope.row.founded" class="text-gray-900">
{{
scope.row.founded
}}
</span>
<span v-else class="text-gray-500">-</span>
</div>
</router-link>
</template>
</el-table-column>

<!-- Profiles -->
<el-table-column
label="Profiles"
:width="profilesColumnWidth"
>
<template #default="scope">
<router-link
:to="{
name: 'organizationView',
params: { id: scope.row.id },
}"
class="block"
>
<div
v-if="scope.row.profiles?.length && scope.row.profiles?.some((e) => !!e)"
class="text-sm cursor-auto flex flex-wrap gap-1"
>
<app-tags
:tags="scope.row.profiles"
:interactive="true"
:collapse-tags="true"
:collapse-tags-tooltip="true"
>
<template #tagTooltipContent>
<span>Open profile
<i
class="ri-external-link-line text-gray-400"
/></span>
</template>
</app-tags>
</div>
<span
v-else
class="text-gray-500"
>-</span>
</router-link>
</template>
</el-table-column>

<!-- Actions -->
<el-table-column fixed="right">
<template #default="scope">
Expand Down Expand Up @@ -388,8 +543,9 @@ import {
mapActions,
} from '@/shared/vuex/vuex.helpers';
import { formatDateToTimeAgo } from '@/utils/date';
import { formatNumberToCompact } from '@/utils/number';
import { withHttp } from '@/utils/string';
import { formatNumberToCompact, formatNumber } from '@/utils/number';
import { withHttp, toSentenceCase } from '@/utils/string';
import AppTags from '@/shared/tags/tags.vue';
import AppOrganizationIdentities from '../organization-identities.vue';
import AppOrganizationListToolbar from './organization-list-toolbar.vue';
import AppOrganizationName from '../organization-name.vue';
Expand Down Expand Up @@ -515,6 +671,22 @@ const emailsColumnWidth = computed(() => {
return maxTabWidth;
});
const profilesColumnWidth = computed(() => {
let maxTabWidth = 150;
rows.value.forEach((row) => {
const tabWidth = row.profiles
?.map((profile) => (profile ? profile.length * 12 : 0))
.reduce((a, b) => a + b, 0);
if (tabWidth > maxTabWidth) {
maxTabWidth = tabWidth > 400 ? 400 : tabWidth;
}
});
return maxTabWidth;
});
const trackEmailClick = () => {
window.analytics.track('Click Organization Contact', {
channel: 'Email',
Expand Down
Loading

0 comments on commit d3bc417

Please sign in to comment.