| .. | .. |
|---|
| 1 | 1 | import { ActivatedRoute, Router } from '@angular/router'; |
|---|
| 2 | 2 | import { MdDialog, MdDialogConfig } from '@angular/material'; |
|---|
| 3 | | -import { TdDataTableService, TdPagingBarComponent, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 3 | +import { TdDialogService, TdDataTableService, TdPagingBarComponent, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 4 | 4 | import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 5 | 5 | import { Component, AfterViewInit, ViewChild } from '@angular/core'; |
|---|
| 6 | 6 | import { TdMediaService } from '@covalent/core'; |
|---|
| .. | .. |
|---|
| 48 | 48 | license_menu_options = LICENSE_ACTIONS; |
|---|
| 49 | 49 | |
|---|
| 50 | 50 | licenseAction(action: string, license: any) { |
|---|
| 51 | | - return this.licenses[action](license.id).subscribe( |
|---|
| 52 | | - (actionResponse : any) => { |
|---|
| 53 | | - this.toaster.success(this.$L.get('Action "{}" executed successfully', action)); |
|---|
| 54 | | - this.reload(this.pack.id); |
|---|
| 55 | | - }, |
|---|
| 56 | | - (err : any) => this.toaster.error(this.$L.get('Action "{}" failed', action)) |
|---|
| 57 | | - ); |
|---|
| 51 | + if (action === 'cancel') { |
|---|
| 52 | + this.dialogs.openPrompt({ |
|---|
| 53 | + message: this.$L.get('Please, specify the reason to cancel the current license'), |
|---|
| 54 | + title: this.$L.get('License cancelation'), //OPTIONAL, hides if not provided |
|---|
| 55 | + value: '', |
|---|
| 56 | + cancelButton: this.$L.get('Close'), |
|---|
| 57 | + acceptButton: this.$L.get('Cancel license'), //OPTIONAL, defaults to 'ACCEPT' |
|---|
| 58 | + }).afterClosed().subscribe((reason: string) => { |
|---|
| 59 | + if (reason) { |
|---|
| 60 | + this.licenses.cancel(license.id, reason).subscribe( |
|---|
| 61 | + (actionResponse : any) => { |
|---|
| 62 | + this.toaster.success(this.$L.get('License cancelled sucessfully')); |
|---|
| 63 | + this.reload(this.pack.id); |
|---|
| 64 | + }, |
|---|
| 65 | + (err : any) => this.toaster.error(err.message, this.$L.get('Action "{}" failed', action) ) |
|---|
| 66 | + ); |
|---|
| 67 | + } |
|---|
| 68 | + }); |
|---|
| 69 | + } else { |
|---|
| 70 | + return this.licenses[action](license.id).subscribe( |
|---|
| 71 | + (actionResponse : any) => { |
|---|
| 72 | + this.toaster.success(this.$L.get('Action "{}" executed successfully', action)); |
|---|
| 73 | + this.reload(this.pack.id); |
|---|
| 74 | + }, |
|---|
| 75 | + (err : any) => this.toaster.error(err.message, this.$L.get('Action "{}" failed', action)) |
|---|
| 76 | + ); |
|---|
| 77 | + } |
|---|
| 58 | 78 | } |
|---|
| 59 | 79 | |
|---|
| 60 | 80 | reload(packId: number) : void { |
|---|
| .. | .. |
|---|
| 73 | 93 | |
|---|
| 74 | 94 | constructor( _dataTableService: TdDataTableService, |
|---|
| 75 | 95 | private media: TdMediaService, |
|---|
| 96 | + private dialogs: TdDialogService, |
|---|
| 76 | 97 | private $L: LocaleService, |
|---|
| 77 | 98 | private router: Router, |
|---|
| 78 | 99 | private location: Location, |
|---|