rsanchez
2017-04-17 f11e78dacb3bbf45988a5002bed3bf8e7f97d043
securis/src/main/webapp/src/app/forms/license.form.component.ts
....@@ -53,15 +53,36 @@
5353
5454
5555 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
+ }
6383 }
6484
85
+
6586
6687 canBeDeleted() : boolean {
6788 return !this.isNew && this.licenses.isActionAvailable('delete', this.data);