Browse Source

Add apply filters button

pull/2971/head
Thomas Kaul 2 years ago
parent
commit
e02034ecc3
  1. 4
      apps/client/src/app/components/header/header.component.html
  2. 4
      apps/client/src/app/components/header/header.component.scss
  3. 4
      apps/client/src/styles.scss
  4. 40
      libs/ui/src/lib/assistant/assistant.component.ts
  5. 16
      libs/ui/src/lib/assistant/assistant.html

4
apps/client/src/app/components/header/header.component.html

@ -10,7 +10,7 @@
<gf-logo class="px-2" [label]="pageTitle" /> <gf-logo class="px-2" [label]="pageTitle" />
</a> </a>
</div> </div>
<span class="spacer"></span> <span class="gf-spacer"></span>
<ul class="alig-items-center d-flex list-inline m-0 px-2"> <ul class="alig-items-center d-flex list-inline m-0 px-2">
<li class="list-inline-item"> <li class="list-inline-item">
<a <a
@ -324,7 +324,7 @@
/> />
</a> </a>
</div> </div>
<span class="spacer"></span> <span class="gf-spacer"></span>
<ul class="alig-items-center d-flex list-inline m-0 px-2"> <ul class="alig-items-center d-flex list-inline m-0 px-2">
<li class="list-inline-item"> <li class="list-inline-item">
<a <a

4
apps/client/src/app/components/header/header.component.scss

@ -38,10 +38,6 @@
} }
} }
} }
.spacer {
flex: 1 1 auto;
}
} }
} }

4
apps/client/src/styles.scss

@ -379,6 +379,10 @@ ngx-skeleton-loader {
cursor: pointer; cursor: pointer;
} }
.gf-spacer {
flex: 1 1 auto;
}
.gf-table { .gf-table {
@include gf-table; @include gf-table;
} }

40
libs/ui/src/lib/assistant/assistant.component.ts

@ -22,7 +22,7 @@ import { DataService } from '@ghostfolio/client/services/data.service';
import { Filter, User } from '@ghostfolio/common/interfaces'; import { Filter, User } from '@ghostfolio/common/interfaces';
import { DateRange } from '@ghostfolio/common/types'; import { DateRange } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n'; import { translate } from '@ghostfolio/ui/i18n';
import { Account, AssetClass, Tag } from '@prisma/client'; import { Account, AssetClass } from '@prisma/client';
import { EMPTY, Observable, Subject, lastValueFrom } from 'rxjs'; import { EMPTY, Observable, Subject, lastValueFrom } from 'rxjs';
import { import {
catchError, catchError,
@ -158,25 +158,6 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit {
}; };
}); });
this.filterForm.valueChanges
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ account, assetClass, tag }) => {
this.filtersChanged.emit([
{
id: account,
type: 'ACCOUNT'
},
{
id: assetClass,
type: 'ASSET_CLASS'
},
{
id: tag,
type: 'TAG'
}
]);
});
this.searchFormControl.valueChanges this.searchFormControl.valueChanges
.pipe( .pipe(
map((searchTerm) => { map((searchTerm) => {
@ -260,6 +241,25 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
public onApplyFilters() {
this.filtersChanged.emit([
{
id: this.filterForm.get('account').value,
type: 'ACCOUNT'
},
{
id: this.filterForm.get('assetClass').value,
type: 'ASSET_CLASS'
},
{
id: this.filterForm.get('tag').value,
type: 'TAG'
}
]);
this.onCloseAssistant();
}
public onChangeDateRange(dateRangeString: string) { public onChangeDateRange(dateRangeString: string) {
this.dateRangeChanged.emit(dateRangeString as DateRange); this.dateRangeChanged.emit(dateRangeString as DateRange);
} }

16
libs/ui/src/lib/assistant/assistant.html

@ -148,17 +148,25 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div class="d-flex w-100">
<button <button
class="w-100"
color="primary"
i18n i18n
mat-flat-button mat-button
[disabled]="!hasFilter(filterForm.value)" [disabled]="!hasFilter(filterForm.value)"
(click)="onResetFilters()" (click)="onResetFilters()"
> >
Reset Filters Reset Filters
</button> </button>
<span class="gf-spacer"></span>
<button
color="primary"
i18n
mat-flat-button
[disabled]="!filterForm.dirty"
(click)="onApplyFilters()"
>
Apply Filters
</button>
</div> </div>
</div> </div>
</form> </form>

Loading…
Cancel
Save