From f11e78dacb3bbf45988a5002bed3bf8e7f97d043 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 17 Apr 2017 15:36:47 +0000
Subject: [PATCH] #3529 fix - Fixed cancel an delete commands on licenses

---
 securis/src/main/webapp/src/app/forms/license.form.component.ts |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/securis/src/main/webapp/src/app/forms/license.form.component.ts b/securis/src/main/webapp/src/app/forms/license.form.component.ts
index 2f3c71b..ee052b9 100644
--- a/securis/src/main/webapp/src/app/forms/license.form.component.ts
+++ b/securis/src/main/webapp/src/app/forms/license.form.component.ts
@@ -53,15 +53,36 @@
 
 
   licenseAction(action: string) {
-    return this.licenses[action](this.data.id).subscribe(
-      (actionResponse : any) => {
-        this.toaster.success(this.$L.get('Action "{}" executed successfully', action));
-        this.init();
-      },
-      (err : any) => this.toaster.error(this.$L.get('Action "{}" failed', action))
-    );
+    if (action === 'cancel') {      
+      this.dialogs.openPrompt({
+        message: this.$L.get('Please, specify the reason to cancel the current license'),
+        title: this.$L.get('License cancelation'), //OPTIONAL, hides if not provided
+        value: '', 
+        cancelButton: this.$L.get('Close'), 
+        acceptButton: this.$L.get('Cancel license'), //OPTIONAL, defaults to 'ACCEPT'
+      }).afterClosed().subscribe((reason: string) => {
+        if (reason) {
+          this.licenses.cancel(this.data.id, reason).subscribe(
+            (actionResponse : any) => {
+              this.toaster.success(this.$L.get('License cancelled sucessfully'));
+              this.init();
+            },
+            (err : any) => this.toaster.error(err.message, this.$L.get('Action "{}" failed', action) )
+          );
+        }
+      });
+    } else {
+      return this.licenses[action](this.data.id).subscribe(
+        (actionResponse : any) => {
+          this.toaster.success(this.$L.get('Action "{}" executed successfully', action));
+          this.init();
+        },
+        (err : any) => this.toaster.error(err.message, this.$L.get('Action "{}" failed', action) )
+      );
+    }
   }
 
+
   
   canBeDeleted() : boolean {
     return !this.isNew && this.licenses.isActionAvailable('delete', this.data);

--
Gitblit v1.3.2