From 280daa7f3f858ecfef9c91ffd5dea1007f021048 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Sun, 19 Mar 2017 11:29:37 +0000
Subject: [PATCH] #3527 fix - Added applications and some minor refactoring

---
 securis/src/main/webapp/src/app/forms/pack.form.component.ts |   40 +++++++++++++++++-----------------------
 1 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/securis/src/main/webapp/src/app/forms/pack.form.component.ts b/securis/src/main/webapp/src/app/forms/pack.form.component.ts
index 49b41ec..e798be4 100644
--- a/securis/src/main/webapp/src/app/forms/pack.form.component.ts
+++ b/securis/src/main/webapp/src/app/forms/pack.form.component.ts
@@ -8,7 +8,8 @@
 import { IPageChangeEvent } from '@covalent/core';
 import { Component, AfterViewInit } from '@angular/core';
 import { TdMediaService } from '@covalent/core';
-import { IComboOption } from './base';
+import { IComboOption, FormBase } from './base';
+import { ActivatedRoute, Router } from '@angular/router';
 
 
 
@@ -16,10 +17,8 @@
   selector: 'pack-form',
   templateUrl: 'src/app/forms/pack.form.html'
 })
-export class PackFormComponent implements AfterViewInit {
+export class PackFormComponent extends FormBase implements AfterViewInit {
 
-  form_title: string = 'Title';
-  form_subtitle: string = '';
   organizations : IComboOption[];
   licensetypes : IComboOption[];
   data: any = {};
@@ -44,18 +43,20 @@
     'value': '',
   }
   constructor(private http: Http,
-              private toaster: ToastsManager,
+              toaster: ToastsManager,
               private licenseTypes: LicenseTypesService,
+              route: ActivatedRoute,
+              private router: Router,
               private packs: PacksService,
-              private $L: LocaleService) {
-      Object.keys(this.fields).forEach(k => this.fields[k] = $L.get(`field.${k}`));
+              $L: LocaleService) {
+    super($L, route, toaster, packs, $L.get('pack'));
   }
 
   public getFieldName(fieldId: string) : string {
     return this.fields[fieldId];
   }
 
-  private loadCombos(): void {
+  loadCombos(): void {
       this.http.get('organization')
         .map(response => response.json().map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
         .subscribe(
@@ -70,15 +71,9 @@
         );
   }
 
-  save() {
-      var command = this.isNew ? this.packs.create(this.data) : this.packs.modify(this.data.id, this.data);
-      command.subscribe(
-          data => this.toaster.success(this.$L.get('Pack saved sucessfully')),
-          err => {
-            console.error(err);
-            this.toaster.success(this.$L.get('Error saving pack'));
-          }
-        );
+
+  goBack(): void {
+    this.router.navigate([`packs`]);
   }
 
   changeLicType(event: any) {
@@ -99,16 +94,15 @@
   } 
   
   ngOnInit(): void {
-    this.loadCombos();
-    if (this.isNew) {
-      this.data.status = PACK_STATUS.CREATED;
-    }
-    this.form_title = this.$L.get('Pack data');
-    this.form_subtitle = this.$L.get(this.isNew ? 'Create a new licenses pack': 'Modify the licenses pack data') ;
+
   }
 
 
   ngAfterViewInit(): void {
+    this.loadCombos();
+    super.prepareData('packId', {
+      status: PACK_STATUS.CREATED
+    });
   }
 }
 

--
Gitblit v1.3.2