From a6e1ace2b6bdba8c08a4acfa42433f3ac073b747 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Tue, 21 Mar 2017 10:16:22 +0000
Subject: [PATCH] #3527 feature - Added all catalogs and working fine

---
 securis/src/main/webapp/src/app/forms/organization.form.component.ts |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/securis/src/main/webapp/src/app/forms/organization.form.component.ts b/securis/src/main/webapp/src/app/forms/organization.form.component.ts
index 4d2caec..d5b4708 100644
--- a/securis/src/main/webapp/src/app/forms/organization.form.component.ts
+++ b/securis/src/main/webapp/src/app/forms/organization.form.component.ts
@@ -9,6 +9,7 @@
 import { TdMediaService } from '@covalent/core';
 import { FormBase, IComboOption } from './base';
 import { ActivatedRoute, Router } from '@angular/router';
+import { UsersService } from "../resources/users";
 
 var app_example = { 
 	code: 'CICS',
@@ -30,9 +31,13 @@
 })
 export class OrganizationFormComponent extends FormBase {
 
+  parentOrganizations: any[];
+  usernames: string[] = [];
+  
   constructor(private http: Http,
               private licenseTypes: LicenseTypesService,
               private organizations: OrganizationsService,
+              private users: UsersService,
               router: Router,
               toaster: ToastsManager,
               route: ActivatedRoute,              
@@ -41,15 +46,33 @@
     super($L, router, route, toaster, organizations, $L.get('organization'), dialogs);
   }
 
- 
+  loadCombos() : void {
+      this.organizations.get()
+        .map(list => list.map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
+        .subscribe(
+          data => this.parentOrganizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
+          err => console.error('Error loading organizations')
+        );
+      this.users.get()
+        .map(list => list
+                      .filter((user : any) => user.username !== '_client')
+                      .map((u : any) => u.username))
+        .subscribe(
+          data => this.usernames = (<string[]>data).sort((u1, u2) => u1.localeCompare(u2)),
+          err => console.error('Error loading users')
+        );
+  }
+
+
   goBack(): void {
     this.router.navigate([`organizations`]);
   }
 
   init() : void {
+    this.loadCombos();
     super.setFirstFocus();
     super.reset();
-    super.prepareInitialData('organizationId');
+    super.prepareInitialData('organizationId', {users_ids: []});
   }
  
   ngAfterViewInit(): void {

--
Gitblit v1.3.2