diff --git a/apps/gauzy/src/app/pages/invoices/invoice-add/invoice-add.component.ts b/apps/gauzy/src/app/pages/invoices/invoice-add/invoice-add.component.ts
index da8cf2dbcb3..8c0458329ef 100644
--- a/apps/gauzy/src/app/pages/invoices/invoice-add/invoice-add.component.ts
+++ b/apps/gauzy/src/app/pages/invoices/invoice-add/invoice-add.component.ts
@@ -19,14 +19,13 @@ import {
ExpenseStatusesEnum
} from '@gauzy/contracts';
import { filter, tap } from 'rxjs/operators';
-import { compareDate, isEmpty, isNotEmpty } from '@gauzy/common-angular';
+import { compareDate, distinctUntilChange, isEmpty, isNotEmpty } from '@gauzy/common-angular';
import { LocalDataSource, Ng2SmartTableComponent } from 'ng2-smart-table';
import { Observable, firstValueFrom } from 'rxjs';
import { Router } from '@angular/router';
import { NbDialogService } from '@nebular/theme';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import * as moment from 'moment';
-import { TranslationBaseComponent } from '../../../@shared/language-base';
import {
ExpensesService,
InvoiceEstimateHistoryService,
@@ -48,6 +47,7 @@ import {
InvoiceProjectsSelectorComponent,
InvoiceTasksSelectorComponent
} from '../table-components';
+import { IPaginationBase, PaginationFilterBaseComponent } from '../../../@shared/pagination/pagination-filter-base.component';
@UntilDestroy({ checkProperties: true })
@Component({
@@ -55,7 +55,7 @@ import {
templateUrl: './invoice-add.component.html',
styleUrls: ['./invoice-add.component.scss']
})
-export class InvoiceAddComponent extends TranslationBaseComponent
+export class InvoiceAddComponent extends PaginationFilterBaseComponent
implements OnInit, OnDestroy {
settingsSmartTable: object;
@@ -101,7 +101,7 @@ export class InvoiceAddComponent extends TranslationBaseComponent
return this.form.get('currency');
}
- private _isEstimate: boolean = false;
+ private _isEstimate = false;
@Input() set isEstimate(val: boolean) {
this._isEstimate = val;
}
@@ -169,6 +169,26 @@ export class InvoiceAddComponent extends TranslationBaseComponent
.subscribe((languageEvent) => {
this.selectedLanguage = languageEvent.lang;
});
+ this.subject$
+ .pipe(
+ tap(() => {
+ const { activePage, itemsPerPage } = this.getPagination();
+ this.smartTableSource.setPaging(
+ activePage,
+ itemsPerPage,
+ false
+ );
+ this.smartTableSource.refresh();
+ })
+ )
+ .subscribe();
+ this.pagination$
+ .pipe(
+ distinctUntilChange(),
+ tap(() => this.subject$.next(true)),
+ untilDestroyed(this)
+ )
+ .subscribe();
}
initializeForm() {
@@ -214,10 +234,11 @@ export class InvoiceAddComponent extends TranslationBaseComponent
}
loadSmartTable() {
+ const pagination: IPaginationBase = this.getPagination();
this.settingsSmartTable = {
pager: {
- display: true,
- perPage: 5
+ display: false,
+ perPage: pagination ? pagination.itemsPerPage : 10
},
add: {
addButtonContent: '
',
@@ -1094,6 +1115,11 @@ export class InvoiceAddComponent extends TranslationBaseComponent
if (this.total < 0) {
this.total = 0;
}
+ this.setPagination({
+ ...this.getPagination(),
+ totalItems: this.smartTableSource.count()
+ });
+ this.refreshPagination();
}
async applyDiscountAfterTax($event) {
@@ -1190,7 +1216,7 @@ export class InvoiceAddComponent extends TranslationBaseComponent
}
getNextMonth() {
- var date = new Date();
+ const date = new Date();
if (this.organization.daysUntilDue !== null) {
date.setDate(date.getDate() + this.organization.daysUntilDue);
} else {
From 0a00450ebe4abe8a70a22579d3a1ee096b6c5817 Mon Sep 17 00:00:00 2001
From: Adolphe Kifungo <45813955+adkif@users.noreply.github.com>
Date: Thu, 6 Jul 2023 22:34:02 +0200
Subject: [PATCH 3/3] fix: remove action buttons and add custom pagination
invoice edit
---
.../invoice-edit/invoice-edit.component.html | 24 +++++++------
.../invoice-edit/invoice-edit.component.ts | 36 ++++++++++++++++---
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.html b/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.html
index 31efed2c04a..c0ef20cb153 100644
--- a/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.html
+++ b/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.html
@@ -367,16 +367,6 @@
+
diff --git a/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.ts b/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.ts
index 7e48640cf25..9ca44c9ebae 100644
--- a/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.ts
+++ b/apps/gauzy/src/app/pages/invoices/invoice-edit/invoice-edit.component.ts
@@ -1,5 +1,4 @@
import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
-import { TranslationBaseComponent } from '../../../@shared/language-base/translation-base.component';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import {
@@ -38,6 +37,7 @@ import {
InvoiceTasksSelectorComponent
} from '../table-components';
import { any } from 'underscore';
+import { IPaginationBase, PaginationFilterBaseComponent } from '../../../@shared/pagination/pagination-filter-base.component';
@UntilDestroy({ checkProperties: true })
@Component({
@@ -45,7 +45,7 @@ import { any } from 'underscore';
templateUrl: './invoice-edit.component.html',
styleUrls: ['./invoice-edit.component.scss']
})
-export class InvoiceEditComponent extends TranslationBaseComponent
+export class InvoiceEditComponent extends PaginationFilterBaseComponent
implements OnInit, OnDestroy {
shouldLoadTable = false;
@@ -77,7 +77,7 @@ export class InvoiceEditComponent extends TranslationBaseComponent
return this.form.get('currency');
}
- private _isEstimate: boolean = false;
+ private _isEstimate = false;
@Input() set isEstimate(val: boolean) {
this._isEstimate = val;
}
@@ -148,6 +148,26 @@ export class InvoiceEditComponent extends TranslationBaseComponent
untilDestroyed(this)
)
.subscribe();
+ this.subject$
+ .pipe(
+ tap(() => {
+ const { activePage, itemsPerPage } = this.getPagination();
+ this.smartTableSource.setPaging(
+ activePage,
+ itemsPerPage,
+ false
+ );
+ this.smartTableSource.refresh();
+ })
+ )
+ .subscribe();
+ this.pagination$
+ .pipe(
+ distinctUntilChange(),
+ tap(() => this.subject$.next(true)),
+ untilDestroyed(this)
+ )
+ .subscribe();
}
getInvoiceById() {
@@ -241,10 +261,11 @@ export class InvoiceEditComponent extends TranslationBaseComponent
}
async loadSmartTable() {
+ const pagination: IPaginationBase = this.getPagination();
this.settingsSmartTable = {
pager: {
- display: true,
- perPage: 5
+ display: false,
+ perPage: pagination ? pagination.itemsPerPage : 10
},
add: {
addButtonContent: '',
@@ -911,6 +932,11 @@ export class InvoiceEditComponent extends TranslationBaseComponent
this.alreadyPaid = +this.invoice.alreadyPaid;
this.amountDue = +this.total - +this.alreadyPaid;
+ this.setPagination({
+ ...this.getPagination(),
+ totalItems: this.smartTableSource.count()
+ });
+ this.refreshPagination();
}
async onCurrencyChange($event) {