Skip to content

Commit

Permalink
Filter patterns by name
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaslin committed Jun 30, 2024
1 parent 872934a commit cc8da12
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d2-checklist",
"version": "24.2.2",
"version": "24.2.3",
"manifest": "226342.24.06.19.1730-2-bnet.56014",
"license": "MIT",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ <h4 class="triumph-score">{{title$|async}}
</mat-checkbox>
</ng-container>
<ng-container *ngIf="o.showCrafted">

<mat-form-field class="margin-left-10">
<mat-label>Filter</mat-label>
<mat-select [(ngModel)]="craftedFilter">
Expand All @@ -19,6 +20,10 @@ <h4 class="triumph-score">{{title$|async}}

</mat-select>
</mat-form-field>
<mat-form-field class="margin-left-10">
<mat-label>Search Patterns By Name</mat-label>
<input matInput [(ngModel)]="craftedWildCardFilter" placeholder="Search Patterns By Name">
</mat-form-field>
</ng-container>
</h4>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class SpecialTriumphListComponent extends ChildComponent {
public rows$: BehaviorSubject<TriumphRecordNode[]> = new BehaviorSubject([]);
public showCrafted$: BehaviorSubject<boolean> = new BehaviorSubject(false);
public craftedFilter = 'TODO';
public craftedWildCardFilter = '';
public craftedFilterChoices = [
{
name: 'Todo (Not Crafted + Incomplete)',
Expand Down Expand Up @@ -115,31 +116,38 @@ export class SpecialTriumphListComponent extends ChildComponent {
this.sort$.next(this.sort$.getValue());
}

private filterPatternName(t: TriumphRecordNode): boolean {
if (this.craftedWildCardFilter == '') {
return true;
}
return t.name.toLowerCase().includes(this.craftedWildCardFilter.toLowerCase());
}

public shouldShow(t: TriumphRecordNode): boolean {
if (this.showCrafted$.getValue()) {
if (this.craftedFilter=='TODO') {
if (!t.complete || (t.complete && t.crafted?.length==0)) {
return true;
return this.filterPatternName(t);
}
} else if (this.craftedFilter=='INCOMPLETE') {
if (!t.complete) {
return true;
return this.filterPatternName(t);
}
} else if (this.craftedFilter=='NOT_CRAFTED') {
if (t.complete && t.crafted.length==0) {
return true;
return this.filterPatternName(t);
}
} else if (this.craftedFilter=='CRAFTED') {
if (t.complete && t.crafted.length>0) {
return true;
return this.filterPatternName(t);
}
} else if (this.craftedFilter=='ATTUNE_TO_CRAFT') {
if (!t.complete && t.redborder.length>0) {
return true;
return this.filterPatternName(t);
}
}
else if (this.craftedFilter=='ALL') {
return true;
return this.filterPatternName(t);
}
return false;
} else {
Expand Down

0 comments on commit cc8da12

Please sign in to comment.