-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Dismiss Dialog for duplicate expenses #3175
Changes from 2 commits
5403558
93803e7
85bf696
9cdadc3
7e6f760
e9a682a
3318b35
0d19e36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="dismiss-dialog"> | ||
<ion-content> | ||
<ion-grid class="dismiss-dialog--grid"> | ||
<ion-row> | ||
<ion-col> | ||
<div class="dismiss-dialog--header">Dismiss duplicate expenses</div> | ||
</ion-col> | ||
</ion-row> | ||
<ion-row> | ||
<ion-col> | ||
<div class="dismiss-dialog--body">Are you sure you want to take this action?</div> | ||
</ion-col> | ||
</ion-row> | ||
<ion-row class="dismiss-dialog--cta-container"> | ||
<ion-col size="6"> | ||
<div | ||
[ngClass]="{ 'dismiss-dialog--cancel__disabled': dismissCallInProgress }" | ||
class="dismiss-dialog--cancel" | ||
(click)="cancel()" | ||
> | ||
No, go back | ||
</div> | ||
</ion-col> | ||
<ion-col size="6"> | ||
<div class="dismiss-dialog--dismiss" (click)="dismiss()" appFormButtonValidation>Yes, Dismiss</div> | ||
</ion-col> | ||
</ion-row> | ||
</ion-grid> | ||
</ion-content> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@import '../../../../../theme/colors.scss'; | ||
|
||
.dismiss-dialog { | ||
&--header { | ||
font-size: 16px; | ||
line-height: 20.48px; | ||
color: $black; | ||
font-weight: 500; | ||
} | ||
|
||
&--body { | ||
font-size: 14px; | ||
line-height: 18px; | ||
color: $blue-black; | ||
font-weight: 400; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be there by default, check if it's not required There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, actually that is for different dialog, for this dismiss dialog we need to add this class styling since the |
||
margin-top: 16px; | ||
} | ||
|
||
&--cta-container { | ||
margin-top: 16px; | ||
} | ||
|
||
&--dismiss { | ||
display: flex; | ||
padding: 12px 16px; | ||
justify-content: center; | ||
color: #fff; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the color variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
align-items: center; | ||
border-radius: 4px; | ||
background: $brand-gradient; | ||
} | ||
|
||
&--cancel { | ||
display: flex; | ||
padding: 12px 16px; | ||
justify-content: center; | ||
align-items: center; | ||
color: $blue-black; | ||
&__disabled { | ||
opacity: 0.2; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { DismissDialogComponent } from './dismiss-dialog.component'; | ||
|
||
describe('DismissDialogComponent', () => { | ||
let component: DismissDialogComponent; | ||
let fixture: ComponentFixture<DismissDialogComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [DismissDialogComponent], | ||
imports: [IonicModule.forRoot()], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DismissDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs/internal/Observable'; | ||
import { PopoverController } from '@ionic/angular'; | ||
import { catchError, finalize, map } from 'rxjs/operators'; | ||
import { of } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-dismiss-dialog', | ||
templateUrl: './dismiss-dialog.component.html', | ||
styleUrls: ['./dismiss-dialog.component.scss'], | ||
}) | ||
export class DismissDialogComponent implements OnInit { | ||
// eslint-disable-next-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why have we added this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed this by adding the observable type |
||
@Input() dismissMethod: () => Observable<any>; | ||
|
||
dismissCallInProgress: boolean; | ||
|
||
constructor(private popoverController: PopoverController) {} | ||
|
||
ngOnInit(): void { | ||
this.dismissCallInProgress = false; | ||
} | ||
|
||
cancel(): void { | ||
if (!this.dismissCallInProgress) { | ||
this.popoverController.dismiss(); | ||
} | ||
} | ||
|
||
dismiss(): void { | ||
this.dismissCallInProgress = true; | ||
this.dismissMethod() | ||
.pipe( | ||
map(() => ({ status: 'success' })), | ||
catchError(() => | ||
of({ | ||
status: 'error', | ||
}) | ||
), | ||
finalize(() => (this.dismissCallInProgress = false)) | ||
) | ||
.subscribe((res) => { | ||
this.popoverController.dismiss(res); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,11 @@ import { SnackbarPropertiesService } from 'src/app/core/services/snackbar-proper | |
import { TrackingService } from 'src/app/core/services/tracking.service'; | ||
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service'; | ||
import { ToastMessageComponent } from 'src/app/shared/components/toast-message/toast-message.component'; | ||
import { DismissDialogComponent } from '../dashboard/tasks/dismiss-dialog/dismiss-dialog.component'; | ||
import { PopoverController } from '@ionic/angular'; | ||
import { OverlayResponse } from 'src/app/core/models/overlay-response.modal'; | ||
|
||
// eslint-disable-next-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint throwing error here, else need to create new modal for it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed this by creating new type in model file |
||
type Expenses = Expense[]; | ||
|
||
@Component({ | ||
|
@@ -34,7 +38,8 @@ export class PotentialDuplicatesPage { | |
private router: Router, | ||
private snackbarProperties: SnackbarPropertiesService, | ||
private matSnackBar: MatSnackBar, | ||
private trackingService: TrackingService | ||
private trackingService: TrackingService, | ||
private popoverController: PopoverController | ||
) {} | ||
|
||
ionViewWillEnter(): void { | ||
|
@@ -106,11 +111,24 @@ export class PotentialDuplicatesPage { | |
return this.expensesService.dismissDuplicates(duplicateExpenseIds, targetExpenseIds); | ||
} | ||
|
||
dismiss(expense: Expense): void { | ||
const transactionIds = [expense.id]; | ||
const duplicateTxnIds = this.duplicateSetData[this.selectedSet]; | ||
async dismiss(expense: Expense): Promise<void> { | ||
const targetExpenseIds = [expense.id]; | ||
const duplicateExpenseIds = this.duplicateSetData[this.selectedSet]; | ||
|
||
const popover = await this.popoverController.create({ | ||
component: DismissDialogComponent, | ||
cssClass: 'dismiss-dialog', | ||
backdropDismiss: false, | ||
componentProps: { | ||
dismissMethod: () => this.dismissDuplicates(duplicateExpenseIds, targetExpenseIds), | ||
}, | ||
}); | ||
|
||
await popover.present(); | ||
|
||
const popoverResponse = (await popover.onDidDismiss()) as OverlayResponse<{ status: string }>; | ||
|
||
this.dismissDuplicates(duplicateTxnIds, transactionIds).subscribe(() => { | ||
if (popoverResponse.data?.status === 'success') { | ||
this.trackingService.dismissedIndividualExpenses(); | ||
this.showDismissedSuccessToast(); | ||
this.duplicateSetData[this.selectedSet] = this.duplicateSetData[this.selectedSet].filter( | ||
|
@@ -119,12 +137,26 @@ export class PotentialDuplicatesPage { | |
this.duplicateExpenses[this.selectedSet] = this.duplicateExpenses[this.selectedSet].filter( | ||
(exp) => exp.id !== expense.id | ||
); | ||
}); | ||
} | ||
} | ||
|
||
dismissAll(): void { | ||
const txnIds = this.duplicateSetData[this.selectedSet]; | ||
this.dismissDuplicates(txnIds, txnIds).subscribe(() => { | ||
async dismissAll(): Promise<void> { | ||
const expenseIds = this.duplicateSetData[this.selectedSet]; | ||
|
||
const popover = await this.popoverController.create({ | ||
component: DismissDialogComponent, | ||
cssClass: 'dismiss-dialog', | ||
backdropDismiss: false, | ||
componentProps: { | ||
dismissMethod: () => this.dismissDuplicates(expenseIds, expenseIds), | ||
}, | ||
}); | ||
|
||
await popover.present(); | ||
|
||
const popoverResponse = (await popover.onDidDismiss()) as OverlayResponse<{ status: string }>; | ||
|
||
if (popoverResponse.data?.status === 'success') { | ||
if (this.selectedSet !== 0) { | ||
this.selectedSet--; | ||
} | ||
|
@@ -134,7 +166,7 @@ export class PotentialDuplicatesPage { | |
this.duplicateSets$.subscribe((duplicateExpenses) => { | ||
this.duplicateExpenses = duplicateExpenses; | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
mergeExpense(): void { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -952,6 +952,17 @@ ion-modal.flag-unflag-modal { | |
padding-top: 0 !important; | ||
} | ||
|
||
ion-popover.dismiss-dialog { | ||
--width: 298px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check this in different resolutions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have checked this, seems to working fine |
||
|
||
&::part(content) { | ||
border-radius: 8px; | ||
padding: 24px; | ||
} | ||
|
||
background: rgba(0, 0, 0, 0.6); | ||
} | ||
|
||
ion-popover.delete-dialog { | ||
--width: 296px; | ||
--max-height: 346px; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ $shadow-lg: rgba(44, 48, 78, 0.1); | |
|
||
$brand-primary: #ff3366 !default; | ||
$brand-primary-light: #fe5196 !default; | ||
$brand-gradient: linear-gradient(162deg, #f36 3.01%, #fe5196 111.5%); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not required, we already have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh right, will fix this |
||
|
||
$pink: #fe4c8e !default; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
20px
work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep