Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jul 23, 2024
1 parent 6cd0709 commit 997f134
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ export class CardContainerComponent implements OnInit, OnChanges {
distinctUntilChanged((a, b) => a.card_id === b.card_id),
debounceTime(this.platform.browser() ? 3000 : 0),
tap((card) => {
this.platform.browser(() => {
this.platform.browser(() => {
const li = this.route.snapshot.queryParams['li'];
let index = 0;
if (li) {
index = parseInt(li, 10);
}
const from = this.route.snapshot.queryParams['from'];
if (from || li) {
this.router.navigate([], {relativeTo: this.route, queryParams: {from: null}, queryParamsHandling: 'merge', replaceUrl: true, preserveFragment: true});
this.router.navigate([], {relativeTo: this.route, queryParams: {from: null, li: null}, queryParamsHandling: 'merge', replaceUrl: true, preserveFragment: true});
}
this.analytics.cardEvent(card, this.searchParams, index, false, from);
});
Expand Down
2 changes: 1 addition & 1 deletion projects/srm/src/app/card/card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h2>השירות ניתן ע״י:</h2>
<app-card-action-email [card]='card' [org]='true' [compact]='true'></app-card-action-email>
</div>
<div class='org-branches' *ngIf='card.organization_branch_count > 1'>
<a (activated)='showAllBranches($event)' [href]='"/s/" + card.organization_id' clickOnReturn aria-label="הצגת כל סניפי הארגון">{{card.organization_branch_count}} סניפים בארץ ←</a>
<a (activated)='showAllBranches($event)' [href]='"/s/" + card.organization_id + "?from=card-show-branches"' clickOnReturn aria-label="הצגת כל סניפי הארגון">{{card.organization_branch_count}} סניפים בארץ ←</a>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion projects/srm/src/app/card/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class CardComponent implements OnInit, OnChanges, AfterViewInit {

}
this.zoomout.emit(bounds);
this.router.navigate(['/s', this.card.organization_id]);
this.router.navigate(['/s', this.card.organization_id], { queryParams: { from: 'card-all-branches' } });
});
}

Expand Down
2 changes: 2 additions & 0 deletions projects/srm/src/app/homepage/homepage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ <h3>
<div class='homepage-group-items'>
@for (item of group.items; track item.query) {
<a class='homepage-group-item' [routerLink]='["/s", item.query]'
[queryParams]="{from: 'homepage-group-item'}"
interactionEvent='homepage-link' interactionEventWhere='homepage' [interactionEventContent]='item.title'
clickOnReturn>{{item.title}}</a>
}
</div>
@if (!!group.query && !!group.group_link) {
<a [routerLink]='["/s", group.query]'
[queryParams]="{from: 'homepage-group-more'}"
class='homepage-group-more'
interactionEvent='homepage-link-group' interactionEventWhere='homepage' [interactionEventContent]='group.title'
clickOnReturn>
Expand Down
2 changes: 1 addition & 1 deletion projects/srm/src/app/homepage/homepage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class HomepageComponent implements AfterViewInit{
this.searchConfig.focus();
} else {
this.analytics.interactionEvent('homepage-searchbar', 'homepage');
this.searchSvc.search(query);
this.searchSvc.search(query);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<ng-container class='content'>
<h2>מענים</h2>
@for (response of responses; track response.id) {
<a [href]='"/s/" + response.id'>{{response.response_name}}</a>
<a [href]='"/s/" + response.id + "?from=catalog-response"'>{{response.response_name}}</a>
}
<h2>מצבים</h2>
@for (situation of situations; track situation.id) {
<a [href]='"/s/" + situation.id'>{{situation.situation_name}}</a>
<a [href]='"/s/" + situation.id + "?from=catalog-situation"'>{{situation.situation_name}}</a>
}
</ng-container>
</app-menu-popup>
3 changes: 2 additions & 1 deletion projects/srm/src/app/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ export class PageComponent implements OnInit, AfterViewInit, OnDestroy {
fr: searchParams.filter_responses?.map(x => x.slice('human_services:'.length)).join('|') || null,
frc: searchParams.filter_response_categories?.map(x => x.slice('human_services:'.length)).join('|') || null,
},
queryParamsHandling: 'merge',
replaceUrl: true,
preserveFragment: true
});
Expand Down Expand Up @@ -692,7 +693,7 @@ export class PageComponent implements OnInit, AfterViewInit, OnDestroy {
if (visible && this.point && this.platform.browser()) {
timer(0).pipe(
switchMap(() =>
from(this.router.navigate(['/s', this.searchParams.ac_query], {queryParamsHandling: 'preserve'}))),
from(this.router.navigate(['/s', this.searchParams.ac_query], {queryParamsHandling: 'preserve', queryParams: {from: 'point-open-filters'}}))),
filter((x) => !!x),
delay(100),
).subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[style.background-color]='bgColor'
[style.border-color]='borderColor'
(activated)='doSearch($event)'
[href]='"/s/" + responseQuery'
[href]='"/s/" + responseQuery + "?from=tag-response"'
[class.small]='small'
[attr.aria-label]='response.name + " - לחצו לחיפוש באתר"'
(mouseover)='hover = true' (mouseleave)='hover = false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ResponseLinkyComponent extends ResponseBase implements OnChanges {
this.searchSvc.search(this.response.name);
}
} else {
this.router.navigate(['/s', this.responseQuery], { queryParamsHandling: 'merge' });
this.router.navigate(['/s', this.responseQuery], { queryParamsHandling: 'merge', queryParams: { from: 'tag-response' } });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div *ngIf='didYouMean' class='did-you-mean'>
<span>האם התכוונת&nbsp;</span>
<a [routerLink]='["/s", didYouMean.link]' [attr.aria-label]='"שינוי החיפוש לחיפוש מובנה של " + didYouMean.display'>
<a [routerLink]='["/s", didYouMean.link]' [queryParams]='{from: "did-you-mean"}' clickOnReturn
[attr.aria-label]='"שינוי החיפוש לחיפוש מובנה של " + didYouMean.display'>
{{didYouMean.display}}
</a><span>?</span>
</div>
Expand Down
32 changes: 22 additions & 10 deletions projects/srm/src/app/search-results/search-results.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Card, SearchParams, ViewPort } from '../consts';
import { PlatformService } from '../platform.service';
import { AnalyticsService } from '../analytics.service';
import { SearchState } from './search-state';
import { ActivatedRoute, Router } from '@angular/router';


export type SearchParamsOffset = {
Expand Down Expand Up @@ -64,9 +65,11 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit
totalNationalCount = 0;
loading: boolean = true;
viewport: ViewPort;
source = 'external';

constructor(private api: ApiService, private el: ElementRef, private platform: PlatformService,
private seo: SeoSocialShareService, private analytics: AnalyticsService) {
private seo: SeoSocialShareService, private analytics: AnalyticsService,
private route: ActivatedRoute, private router: Router) {
}

ngOnInit(): void {
Expand Down Expand Up @@ -165,15 +168,24 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit
});
this.fetch();
});
this.resultsParamsQueue.pipe(
untilDestroyed(this),
distinctUntilChanged((a, b) => {
return a.params.original_query === b.params.original_query && a.params.ac_query === b.params.ac_query && a.offset === b.offset;
}),
tap((item) => {
this.analytics.searchEvent(item.params, item.totalCount, item.items, item.offset);
})
).subscribe();
this.platform.browser(() => {
this.resultsParamsQueue.pipe(
untilDestroyed(this),
distinctUntilChanged((a, b) => {
return a.params.original_query === b.params.original_query && a.params.ac_query === b.params.ac_query && a.offset === b.offset;
}),
tap((item) => {
const from = this.route.snapshot.queryParams['from'] || this.source;
this.source = 'internal';
console.log('GTAG-DBG FROM', from);
this.analytics.interactionEvent('search', from);
if (from) {
this.router.navigate([], {relativeTo: this.route, queryParams: {from: null}, queryParamsHandling: 'merge', replaceUrl: true, preserveFragment: true});
}
this.analytics.searchEvent(item.params, item.totalCount, item.items, item.offset);
})
).subscribe();
});
}

ngOnChanges(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
input:hover {
border: 2px solid @color-blue-4;
background-color: @color-blue-8;
background-image: url(../../../assets/img/icon-search-blue-2.svg);
&.desktopStyle {
background-image: url(../../../assets/img/icon-search-blue-2.svg);
}
}
}
7 changes: 5 additions & 2 deletions projects/srm/src/app/search/search-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ export class SearchConfig {
console.table(presets);
this.presets = [{
link: ['/s', 'שירותים_למצב_החירום'],
linkParams: {q: prepareQuery(this.query), from: 'search-presets'},
display: '<span class="emergency">שירותים למצב החירום המלחמתי</span>',
query: 'שירותים למצב החירום',
direct: false,
}, ...presets.map((preset) => {
return {
link: ['/s', prepareQuery(preset.title)],
linkParams: {q: prepareQuery(this.query), from: 'search-presets'},
display: `<em>${preset.title}</em>`,
query: preset.title,
direct: false,
Expand All @@ -62,6 +64,7 @@ export class SearchConfig {
this.autoCompleteResults = results.map((result) => {
return {
link: ['/s', result.id],
linkParams: {q: prepareQuery(this.query), from: 'search-autocomplete-result'},
display: _h(result, 'query'),
query: result.query,
direct: false,
Expand Down Expand Up @@ -140,7 +143,7 @@ export class SearchConfig {
}
if (!found) {
this.closeSearch();
this.router.navigate(['/s', '_'], {queryParams: {q: prepareQuery(this.query)}});
this.router.navigate(['/s', '_'], {queryParams: {q: prepareQuery(this.query), from: 'search-autocomplete-fulltext'}});
}
}
}
Expand All @@ -164,7 +167,7 @@ export class SearchConfig {
if (this.noResults && this.query?.length > 0) {
this.results_.push({
link: ['/s', '_'],
linkParams: {q: prepareQuery(this.query)},
linkParams: {q: prepareQuery(this.query), from: 'search-autocomplete-fulltext'},
display: `<em>${this.query}</em>`,
query: null,
direct: true,
Expand Down
2 changes: 1 addition & 1 deletion projects/srm/src/app/situation/situation.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<a class='situation linkable' [class.small]='small' *ngIf='!selected && link'
(activated)='doSearch($event)'
[href]='"/s/" + querySituation'
[href]='"/s/" + querySituation + "?from=tag-situation"'
[class.small]='smaller'
[attr.aria-label]='situation.name + " - לחצו לחיפוש באתר"'
clickOnReturn
Expand Down

0 comments on commit 997f134

Please sign in to comment.