Skip to content

Commit

Permalink
Merge pull request #6482 from ever-co/bug/#6406-remove-actions-buttons
Browse files Browse the repository at this point in the history
Bug/#6406 remove actions buttons
  • Loading branch information
evereq authored Jul 6, 2023
2 parents 8692ffd + 0a00450 commit c4310d2
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,6 @@ <h4>
</form>
<div *ngIf="shouldLoadTable">
<div class="table-scroll-container custom-table">
<ng-container>
<div class="btn-action">
<ng-template
[ngTemplateOutlet]="actionButtons"
></ng-template>
</div>
</ng-container>
<ng2-smart-table
class="table"
[settings]="settingsSmartTable"
Expand All @@ -590,6 +583,20 @@ <h4>
#invoiceItemTable
></ng2-smart-table>
</div>
<div
class="pagination-container"
>
<ng-container *ngIf="pagination.totalItems > minItemPerPage">
<ga-pagination
(selectedOption)="onUpdateOption($event)"
(selectedPage)="onPageChange($event)"
[doEmit]="false"
[totalItems]="pagination?.totalItems"
[itemsPerPage]="pagination?.itemsPerPage"
[activePage]="pagination?.activePage"
></ga-pagination>
</ng-container>
</div>

<div class="total d-flex">
<div class="total-item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -48,14 +47,15 @@ import {
InvoiceProjectsSelectorComponent,
InvoiceTasksSelectorComponent
} from '../table-components';
import { IPaginationBase, PaginationFilterBaseComponent } from '../../../@shared/pagination/pagination-filter-base.component';

@UntilDestroy({ checkProperties: true })
@Component({
selector: 'ga-invoice-add',
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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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: '<i class="nb-plus"></i>',
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,6 @@ <h4>
</form>
<div *ngIf="shouldLoadTable">
<div class="table-scroll-container custom-table">
<ng-container>
<div class="btn-action">
<ngx-gauzy-button-action
[buttonTemplateVisible]="visible"
[isDisable]="!selectedItem?.isSelected"
[buttonTemplate]="actionButtons"
[hasLayoutSelector]="false"
></ngx-gauzy-button-action>
</div>
</ng-container>
<ng2-smart-table
class="table"
[settings]="settingsSmartTable"
Expand All @@ -389,6 +379,20 @@ <h4>
#invoiceItemTable
></ng2-smart-table>
</div>
<div
class="pagination-container"
>
<ng-container *ngIf="pagination.totalItems > minItemPerPage">
<ga-pagination
(selectedOption)="onUpdateOption($event)"
(selectedPage)="onPageChange($event)"
[doEmit]="false"
[totalItems]="pagination?.totalItems"
[itemsPerPage]="pagination?.itemsPerPage"
[activePage]="pagination?.activePage"
></ga-pagination>
</ng-container>
</div>
<div class="total d-flex">
<div class="d-flex">
<div class="total-item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ div.button-action {
flex-direction: column;
background-color: var(--gauzy-card-2);
padding: 12px;
.table {
margin: 0;
}
div.btn-action {
align-self: flex-end;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -38,14 +37,15 @@ import {
InvoiceTasksSelectorComponent
} from '../table-components';
import { any } from 'underscore';
import { IPaginationBase, PaginationFilterBaseComponent } from '../../../@shared/pagination/pagination-filter-base.component';

@UntilDestroy({ checkProperties: true })
@Component({
selector: 'ga-invoice-edit',
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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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: '<i class="nb-plus"></i>',
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c4310d2

Please sign in to comment.