Skip to content

Commit

Permalink
closes #104
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Jun 27, 2024
1 parent f26f5ce commit 87e9c1d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
32 changes: 32 additions & 0 deletions src/app/advanced/advanced.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,38 @@
</ion-col>
</ion-row>

<!-- faq -->
<ion-row>
<ion-col class="criteria" [sizeXs]="12" [sizeMd]="2" [offsetMd]="2">

@if(metaService.getSiteConfigProperty('icons.advanced.FAQ')) {
<ion-icon [name]="metaService.getSiteConfigProperty('icons.advanced.FAQ')" color="primary"></ion-icon>
}

<span>{{ 'Pages.AdvancedSearch.FAQLabel' | translate }}</span>
</ion-col>

<ion-col class="search" [sizeXs]="12" [sizeMd]="6">
<ion-checkbox [(ngModel)]="searchQuery.hasFAQ"></ion-checkbox>
</ion-col>
</ion-row>

<!-- errata -->
<ion-row>
<ion-col class="criteria" [sizeXs]="12" [sizeMd]="2" [offsetMd]="2">

@if(metaService.getSiteConfigProperty('icons.advanced.Errata')) {
<ion-icon [name]="metaService.getSiteConfigProperty('icons.advanced.Errata')" color="primary"></ion-icon>
}

<span>{{ 'Pages.AdvancedSearch.ErrataLabel' | translate }}</span>
</ion-col>

<ion-col class="search" [sizeXs]="12" [sizeMd]="6">
<ion-checkbox [(ngModel)]="searchQuery.hasErrata"></ion-checkbox>
</ion-col>
</ion-row>

<!-- tags -->
<ion-row>
<ion-col class="criteria" [sizeXs]="12" [sizeMd]="2" [offsetMd]="2">
Expand Down
24 changes: 8 additions & 16 deletions src/app/advanced/advanced.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ export class AdvancedPage implements OnInit {
if (this.searchQuery.meta[filter.prop]) return;

if (filter.type === 'number') {
if (['FAQ', 'Errata'].includes(filter.name)) {
this.searchQuery.meta[filter.prop] = {
operator: '>',
value: undefined,
};

return;
}

this.searchQuery.meta[filter.prop] = {
operator: '=',
value: undefined,
Expand Down Expand Up @@ -174,13 +165,6 @@ export class AdvancedPage implements OnInit {
this.visibleFilters = this.metaService.getFiltersByProductId(product);
this.visibleTags = this.tagsByProduct[product];
}

this.visibleFilters.unshift(
...([
{ name: 'FAQ', prop: 'faq', type: 'number' },
{ name: 'Errata', prop: 'errata', type: 'number' },
] as IProductFilter[])
);
}

getSearchQuery() {
Expand All @@ -205,6 +189,14 @@ export class AdvancedPage implements OnInit {
queryAttributes.push(`product:"${exactExpansions.join(',')}"`);
}

if (this.searchQuery.hasFAQ) {
queryAttributes.push(`faq:>0`);
}

if (this.searchQuery.hasErrata) {
queryAttributes.push(`errata:>0`);
}

if (this.searchQuery.tags.length > 0) {
queryAttributes.push(`tag:"${this.searchQuery.tags.join(',')}"`);
}
Expand Down

0 comments on commit 87e9c1d

Please sign in to comment.