Skip to content

Commit

Permalink
Added filter to enquiry column
Browse files Browse the repository at this point in the history
  • Loading branch information
achouk committed Sep 20, 2024
1 parent e162a2d commit 80486fd
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 19 deletions.
25 changes: 9 additions & 16 deletions libs/upd/views/overview/src/lib/+state/overview/overview.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ export class OverviewFacade {

dateRangeLabel$ = combineLatest([this.overviewData$, this.currentLang$]).pipe(
map(
([data, lang]) =>
this.getDateRangeLabel(data.dateRange, lang) as string,
([data, lang]) => this.getDateRangeLabel(data.dateRange, lang) as string,
),
);

Expand Down Expand Up @@ -666,12 +665,17 @@ export class OverviewFacade {
map((data) => data.copsTestsCompletedSince2018),
);

calldriverTopics$ = this.overviewData$.pipe(
map((data) =>
calldriverTopics$ = combineLatest([
this.overviewData$,
this.currentLang$,
]).pipe(
map(([data, lang]) =>
data.calldriverTopics.map((topicData) => ({
topic: topicData.topic || '',
tpc_id: topicData.tpc_id || '',
enquiry_line: topicData.enquiry_line || '',
enquiry_line:
this.i18n.service.translate(`d3-${topicData.enquiry_line}`, lang) ||
'',
subtopic: topicData.subtopic || '',
sub_subtopic: topicData.sub_subtopic || '',
tasks: topicData.tasks,
Expand All @@ -681,17 +685,6 @@ export class OverviewFacade {
),
);

calldriverTopicsConfig$ = createColConfigWithI18n(this.i18n.service, [
{ field: 'tpc_id', header: 'tpc_id' },
{ field: 'enquiry_line', header: 'enquiry_line', translate: true },
{ field: 'topic', header: 'topic', translate: true },
{ field: 'subtopic', header: 'sub-topic', translate: true },
{ field: 'sub_subtopic', header: 'sub-subtopic', translate: true },
{ field: 'tasks', header: 'tasks', translate: true },
{ field: 'calls', header: 'calls', pipe: 'number' },
{ field: 'change', header: 'comparison', pipe: 'percent' },
]);

gcTasksTable$ = this.overviewData$.pipe(
map((data) =>
data?.dateRangeData?.gcTasksData.map((d) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<div class="col">
<upd-data-table-card
[data]="(calldriverTopics$ | async) || []"
[cols]="(calldriverTopicsConfig$ | async) || []"
[cols]="calldriverTopicsCols"
[filter]="true"
[pagination]="true"
[sort]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { I18nFacade } from '@dua-upd/upd/state';
import type { LocaleId } from '@dua-upd/upd/i18n';
import type { ColumnConfig } from '@dua-upd/types-common';
import { OverviewFacade } from '../+state/overview/overview.facade';
import type { GetTableProps } from '@dua-upd/utils-common';
import { createCategoryConfig } from '@dua-upd/upd/utils';

type callDriversColTypes = GetTableProps<
OverviewCalldriversComponent,
'calldriverTopics$'
>;

@Component({
selector: 'upd-overview-calldrivers',
Expand Down Expand Up @@ -35,7 +42,7 @@ export class OverviewCalldriversComponent implements OnInit {
}>[] = [];

calldriverTopics$ = this.overviewService.calldriverTopics$;
calldriverTopicsConfig$ = this.overviewService.calldriverTopicsConfig$;
calldriverTopicsCols: ColumnConfig<callDriversColTypes>[] = [];

top5IncreasedCalldriverTopics$ =
this.overviewService.top5IncreasedCalldriverTopics$;
Expand All @@ -58,7 +65,8 @@ export class OverviewCalldriversComponent implements OnInit {
this.currentLang$,
this.dateRangeLabel$,
this.comparisonDateRangeLabel$,
]).subscribe(([lang, dateRange, comparisonDateRange]) => {
this.calldriverTopics$,
]).subscribe(([lang, dateRange, comparisonDateRange, data]) => {
this.calldriversCols = [
{
field: 'name',
Expand All @@ -75,6 +83,55 @@ export class OverviewCalldriversComponent implements OnInit {
pipe: 'number',
},
];

this.calldriverTopicsCols = [
{
field: 'tpc_id',
header: 'tpc_id',
},
{
field: 'enquiry_line',
header: 'enquiry_line',
filterConfig: {
type: 'category',
categories: createCategoryConfig({
i18n: this.i18n.service,
data,
field: 'enquiry_line',
}),
},
},
{
field: 'topic',
header: 'topic',
translate: true,
},
{
field: 'subtopic',
header: 'sub-topic',
translate: true,
},
{
field: 'sub_subtopic',
header: 'sub-subtopic',
translate: true,
},
{
field: 'tasks',
header: 'tasks',
translate: true,
},
{
field: 'calls',
header: 'calls',
pipe: 'number',
},
{
field: 'change',
header: 'comparison',
pipe: 'percent',
},
];
});
}
}

0 comments on commit 80486fd

Please sign in to comment.