(apps/contacts) Added confirmation to the "Delete contact" action using FuseConfirmationService

(apps/ecommerce/inventory) Added confirmation to the "Delete product" action using FuseConfirmationService
(apps/scrumboard) Added confirmation to the "Delete list" action using FuseConfirmationService
(apps/tasks) Added confirmation to the "Delete task" action using FuseConfirmationService
This commit is contained in:
sercan 2021-07-16 12:28:43 +03:00
parent 8b977c0eeb
commit 961b86c8cb
5 changed files with 159 additions and 71 deletions

View File

@ -6,6 +6,7 @@ import { Overlay, OverlayRef } from '@angular/cdk/overlay';
import { MatDrawerToggleResult } from '@angular/material/sidenav'; import { MatDrawerToggleResult } from '@angular/material/sidenav';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators'; import { debounceTime, takeUntil } from 'rxjs/operators';
import { FuseConfirmationService } from '@fuse/services/confirmation';
import { Contact, Country, Tag } from 'app/modules/admin/apps/contacts/contacts.types'; import { Contact, Country, Tag } from 'app/modules/admin/apps/contacts/contacts.types';
import { ContactsListComponent } from 'app/modules/admin/apps/contacts/list/list.component'; import { ContactsListComponent } from 'app/modules/admin/apps/contacts/list/list.component';
import { ContactsService } from 'app/modules/admin/apps/contacts/contacts.service'; import { ContactsService } from 'app/modules/admin/apps/contacts/contacts.service';
@ -42,6 +43,7 @@ export class ContactsDetailsComponent implements OnInit, OnDestroy
private _contactsListComponent: ContactsListComponent, private _contactsListComponent: ContactsListComponent,
private _contactsService: ContactsService, private _contactsService: ContactsService,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _fuseConfirmationService: FuseConfirmationService,
private _renderer2: Renderer2, private _renderer2: Renderer2,
private _router: Router, private _router: Router,
private _overlay: Overlay, private _overlay: Overlay,
@ -275,6 +277,23 @@ export class ContactsDetailsComponent implements OnInit, OnDestroy
* Delete the contact * Delete the contact
*/ */
deleteContact(): void deleteContact(): void
{
// Open the confirmation dialog
const confirmation = this._fuseConfirmationService.open({
title : 'Delete contact',
message: 'Are you sure you want to delete this contact? This action cannot be undone!',
actions: {
confirm: {
label: 'Delete'
}
}
});
// Subscribe to the confirmation dialog closed action
confirmation.afterClosed().subscribe((result) => {
// If the confirm button pressed...
if ( result === 'confirmed' )
{ {
// Get the current contact's id // Get the current contact's id
const id = this.contact.id; const id = this.contact.id;
@ -312,6 +331,9 @@ export class ContactsDetailsComponent implements OnInit, OnDestroy
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
} }
});
}
/** /**
* Upload avatar * Upload avatar

View File

@ -6,6 +6,7 @@ import { MatSort } from '@angular/material/sort';
import { merge, Observable, Subject } from 'rxjs'; import { merge, Observable, Subject } from 'rxjs';
import { debounceTime, map, switchMap, takeUntil } from 'rxjs/operators'; import { debounceTime, map, switchMap, takeUntil } from 'rxjs/operators';
import { fuseAnimations } from '@fuse/animations'; import { fuseAnimations } from '@fuse/animations';
import { FuseConfirmationService } from '@fuse/services/confirmation';
import { InventoryBrand, InventoryCategory, InventoryPagination, InventoryProduct, InventoryTag, InventoryVendor } from 'app/modules/admin/apps/ecommerce/inventory/inventory.types'; import { InventoryBrand, InventoryCategory, InventoryPagination, InventoryProduct, InventoryTag, InventoryVendor } from 'app/modules/admin/apps/ecommerce/inventory/inventory.types';
import { InventoryService } from 'app/modules/admin/apps/ecommerce/inventory/inventory.service'; import { InventoryService } from 'app/modules/admin/apps/ecommerce/inventory/inventory.service';
@ -62,6 +63,7 @@ export class InventoryListComponent implements OnInit, AfterViewInit, OnDestroy
*/ */
constructor( constructor(
private _changeDetectorRef: ChangeDetectorRef, private _changeDetectorRef: ChangeDetectorRef,
private _fuseConfirmationService: FuseConfirmationService,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _inventoryService: InventoryService private _inventoryService: InventoryService
) )
@ -525,6 +527,24 @@ export class InventoryListComponent implements OnInit, AfterViewInit, OnDestroy
*/ */
deleteSelectedProduct(): void deleteSelectedProduct(): void
{ {
// Open the confirmation dialog
const confirmation = this._fuseConfirmationService.open({
title : 'Delete product',
message: 'Are you sure you want to remove this product? This action cannot be undone!',
actions: {
confirm: {
label: 'Delete'
}
}
});
// Subscribe to the confirmation dialog closed action
confirmation.afterClosed().subscribe((result) => {
// If the confirm button pressed...
if ( result === 'confirmed' )
{
// Get the product object // Get the product object
const product = this.selectedProductForm.getRawValue(); const product = this.selectedProductForm.getRawValue();
@ -535,6 +555,8 @@ export class InventoryListComponent implements OnInit, AfterViewInit, OnDestroy
this.closeDetails(); this.closeDetails();
}); });
} }
});
}
/** /**
* Show flash message * Show flash message

View File

@ -85,7 +85,7 @@
<mat-icon <mat-icon
class="icon-size-5" class="icon-size-5"
[svgIcon]="'heroicons_solid:pencil-alt'"></mat-icon> [svgIcon]="'heroicons_solid:pencil-alt'"></mat-icon>
Rename List Rename list
</button> </button>
<button <button
mat-menu-item mat-menu-item
@ -93,7 +93,7 @@
<mat-icon <mat-icon
class="icon-size-5" class="icon-size-5"
[svgIcon]="'heroicons_solid:trash'"></mat-icon> [svgIcon]="'heroicons_solid:trash'"></mat-icon>
Delete List Delete list
</button> </button>
</mat-menu> </mat-menu>
</div> </div>

View File

@ -3,9 +3,10 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import * as moment from 'moment';
import { FuseConfirmationService } from '@fuse/services/confirmation';
import { ScrumboardService } from 'app/modules/admin/apps/scrumboard/scrumboard.service'; import { ScrumboardService } from 'app/modules/admin/apps/scrumboard/scrumboard.service';
import { Board, Card, List } from 'app/modules/admin/apps/scrumboard/scrumboard.models'; import { Board, Card, List } from 'app/modules/admin/apps/scrumboard/scrumboard.models';
import * as moment from 'moment';
@Component({ @Component({
selector : 'scrumboard-board', selector : 'scrumboard-board',
@ -31,6 +32,7 @@ export class ScrumboardBoardComponent implements OnInit, OnDestroy
constructor( constructor(
private _changeDetectorRef: ChangeDetectorRef, private _changeDetectorRef: ChangeDetectorRef,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _fuseConfirmationService: FuseConfirmationService,
private _scrumboardService: ScrumboardService private _scrumboardService: ScrumboardService
) )
{ {
@ -148,9 +150,29 @@ export class ScrumboardBoardComponent implements OnInit, OnDestroy
*/ */
deleteList(id): void deleteList(id): void
{ {
// Open the confirmation dialog
const confirmation = this._fuseConfirmationService.open({
title : 'Delete list',
message: 'Are you sure you want to delete this list and its cards? This action cannot be undone!',
actions: {
confirm: {
label: 'Delete'
}
}
});
// Subscribe to the confirmation dialog closed action
confirmation.afterClosed().subscribe((result) => {
// If the confirm button pressed...
if ( result === 'confirmed' )
{
// Delete the list // Delete the list
this._scrumboardService.deleteList(id).subscribe(); this._scrumboardService.deleteList(id).subscribe();
} }
});
}
/** /**
* Add new card * Add new card

View File

@ -4,6 +4,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { TemplatePortal } from '@angular/cdk/portal'; import { TemplatePortal } from '@angular/cdk/portal';
import { Overlay, OverlayRef } from '@angular/cdk/overlay'; import { Overlay, OverlayRef } from '@angular/cdk/overlay';
import { MatDrawerToggleResult } from '@angular/material/sidenav'; import { MatDrawerToggleResult } from '@angular/material/sidenav';
import { FuseConfirmationService } from '@fuse/services/confirmation';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { debounceTime, filter, takeUntil, tap } from 'rxjs/operators'; import { debounceTime, filter, takeUntil, tap } from 'rxjs/operators';
import { assign } from 'lodash-es'; import { assign } from 'lodash-es';
@ -40,6 +41,7 @@ export class TasksDetailsComponent implements OnInit, AfterViewInit, OnDestroy
private _activatedRoute: ActivatedRoute, private _activatedRoute: ActivatedRoute,
private _changeDetectorRef: ChangeDetectorRef, private _changeDetectorRef: ChangeDetectorRef,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _fuseConfirmationService: FuseConfirmationService,
private _renderer2: Renderer2, private _renderer2: Renderer2,
private _router: Router, private _router: Router,
private _tasksListComponent: TasksListComponent, private _tasksListComponent: TasksListComponent,
@ -472,6 +474,24 @@ export class TasksDetailsComponent implements OnInit, AfterViewInit, OnDestroy
*/ */
deleteTask(): void deleteTask(): void
{ {
// Open the confirmation dialog
const confirmation = this._fuseConfirmationService.open({
title : 'Delete task',
message: 'Are you sure you want to delete this task? This action cannot be undone!',
actions: {
confirm: {
label: 'Delete'
}
}
});
// Subscribe to the confirmation dialog closed action
confirmation.afterClosed().subscribe((result) => {
// If the confirm button pressed...
if ( result === 'confirmed' )
{
// Get the current task's id // Get the current task's id
const id = this.task.id; const id = this.task.id;
@ -505,6 +525,8 @@ export class TasksDetailsComponent implements OnInit, AfterViewInit, OnDestroy
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
} }
});
}
/** /**
* Track by function for ngFor loops * Track by function for ngFor loops