fix(deals): колонка «Конкурент» показывает только бренд до первой запятой
Имя конкурента хранится как «Бренд, описание» — в колонке «Конкурент» показываем часть до первой запятой, полное имя — в title при наведении. Применено к десктопной таблице и мобильной карточке. +тест на обрезку. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,14 @@ function hasSource(deal: MockDeal): boolean {
|
||||
return Boolean(deal.sourceIdentifier || deal.sourceProjectId);
|
||||
}
|
||||
|
||||
// «Конкурент» — только бренд, без описания: имя конкурента хранится как
|
||||
// «Бренд, описание…», в колонке показываем часть до первой запятой.
|
||||
function competitorShort(name: string | null | undefined): string {
|
||||
if (!name) return '';
|
||||
const i = name.indexOf(',');
|
||||
return (i === -1 ? name : name.slice(0, i)).trim();
|
||||
}
|
||||
|
||||
function formatDateTime(iso: string | null | undefined): string {
|
||||
if (!iso) return '—';
|
||||
const d = new Date(iso);
|
||||
@@ -103,9 +111,10 @@ function toggleSelect(id: number): void {
|
||||
<router-link
|
||||
v-if="item.competitorId"
|
||||
class="cell-link"
|
||||
:title="item.competitorName ?? undefined"
|
||||
:to="{ name: 'autopodbor', query: { competitor: String(item.competitorId) } }"
|
||||
@click.stop
|
||||
>{{ item.competitorName }}</router-link
|
||||
>{{ competitorShort(item.competitorName) }}</router-link
|
||||
>
|
||||
<span v-else class="text-medium-emphasis">—</span>
|
||||
</template>
|
||||
@@ -199,9 +208,10 @@ function toggleSelect(id: number): void {
|
||||
<router-link
|
||||
v-if="deal.competitorId"
|
||||
class="deal-card__competitor"
|
||||
:title="deal.competitorName ?? undefined"
|
||||
:to="{ name: 'autopodbor', query: { competitor: String(deal.competitorId) } }"
|
||||
@click.stop
|
||||
>{{ deal.competitorName }}</router-link
|
||||
>{{ competitorShort(deal.competitorName) }}</router-link
|
||||
>
|
||||
<span v-else class="deal-card__project">{{ stripChannelPrefix(deal.project) }}</span>
|
||||
<span v-if="!hasSource(deal) && signalLabel(deal.signalType)" class="deal-card__signal">{{
|
||||
|
||||
@@ -128,6 +128,29 @@ describe('DealsTable', () => {
|
||||
expect(links[1].props('to')).toMatchObject({ name: 'autopodbor', query: { competitor: '3', project: '5' } });
|
||||
});
|
||||
|
||||
it('«Конкурент» — только бренд до первой запятой, без описания', () => {
|
||||
const deal: MockDeal = {
|
||||
id: 12,
|
||||
name: '79000000002',
|
||||
phone: '79000000002',
|
||||
statusSlug: 'new',
|
||||
project: 'X',
|
||||
manager: { initials: '—', name: '—' },
|
||||
cost: 0,
|
||||
receivedMinutesAgo: 1,
|
||||
competitorId: 4,
|
||||
competitorName: 'AutoMoney, микрокредитная компания',
|
||||
sourceIdentifier: '79135396546',
|
||||
sourceSignalType: 'call',
|
||||
sourceProjectId: 5,
|
||||
sourceIsActive: true,
|
||||
sourceExtraCount: 0,
|
||||
};
|
||||
const w = mountTable([deal]);
|
||||
expect(w.text()).toContain('AutoMoney');
|
||||
expect(w.text()).not.toContain('микрокредитная');
|
||||
});
|
||||
|
||||
it('показывает « · +N» при нескольких источниках проекта', () => {
|
||||
const deal: MockDeal = {
|
||||
id: 11,
|
||||
|
||||
Reference in New Issue
Block a user