| .. | .. |
|---|
| 53 | 53 | |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | licenseAction(action: string) { |
|---|
| 56 | | - return this.licenses[action](this.data.id).subscribe( |
|---|
| 57 | | - (actionResponse : any) => { |
|---|
| 58 | | - this.toaster.success(this.$L.get('Action "{}" executed successfully', action)); |
|---|
| 59 | | - this.init(); |
|---|
| 60 | | - }, |
|---|
| 61 | | - (err : any) => this.toaster.error(this.$L.get('Action "{}" failed', action)) |
|---|
| 62 | | - ); |
|---|
| 56 | + if (action === 'cancel') { |
|---|
| 57 | + this.dialogs.openPrompt({ |
|---|
| 58 | + message: this.$L.get('Please, specify the reason to cancel the current license'), |
|---|
| 59 | + title: this.$L.get('License cancelation'), //OPTIONAL, hides if not provided |
|---|
| 60 | + value: '', |
|---|
| 61 | + cancelButton: this.$L.get('Close'), |
|---|
| 62 | + acceptButton: this.$L.get('Cancel license'), //OPTIONAL, defaults to 'ACCEPT' |
|---|
| 63 | + }).afterClosed().subscribe((reason: string) => { |
|---|
| 64 | + if (reason) { |
|---|
| 65 | + this.licenses.cancel(this.data.id, reason).subscribe( |
|---|
| 66 | + (actionResponse : any) => { |
|---|
| 67 | + this.toaster.success(this.$L.get('License cancelled sucessfully')); |
|---|
| 68 | + this.init(); |
|---|
| 69 | + }, |
|---|
| 70 | + (err : any) => this.toaster.error(err.message, this.$L.get('Action "{}" failed', action) ) |
|---|
| 71 | + ); |
|---|
| 72 | + } |
|---|
| 73 | + }); |
|---|
| 74 | + } else { |
|---|
| 75 | + return this.licenses[action](this.data.id).subscribe( |
|---|
| 76 | + (actionResponse : any) => { |
|---|
| 77 | + this.toaster.success(this.$L.get('Action "{}" executed successfully', action)); |
|---|
| 78 | + this.init(); |
|---|
| 79 | + }, |
|---|
| 80 | + (err : any) => this.toaster.error(err.message, this.$L.get('Action "{}" failed', action) ) |
|---|
| 81 | + ); |
|---|
| 82 | + } |
|---|
| 63 | 83 | } |
|---|
| 64 | 84 | |
|---|
| 85 | + |
|---|
| 65 | 86 | |
|---|
| 66 | 87 | canBeDeleted() : boolean { |
|---|
| 67 | 88 | return !this.isNew && this.licenses.isActionAvailable('delete', this.data); |
|---|