rsanchez
2017-03-21 a6e1ace2b6bdba8c08a4acfa42433f3ac073b747
securis/src/main/webapp/src/app/forms/organization.form.component.ts
....@@ -9,6 +9,7 @@
99 import { TdMediaService } from '@covalent/core';
1010 import { FormBase, IComboOption } from './base';
1111 import { ActivatedRoute, Router } from '@angular/router';
12
+import { UsersService } from "../resources/users";
1213
1314 var app_example = {
1415 code: 'CICS',
....@@ -30,9 +31,13 @@
3031 })
3132 export class OrganizationFormComponent extends FormBase {
3233
34
+ parentOrganizations: any[];
35
+ usernames: string[] = [];
36
+
3337 constructor(private http: Http,
3438 private licenseTypes: LicenseTypesService,
3539 private organizations: OrganizationsService,
40
+ private users: UsersService,
3641 router: Router,
3742 toaster: ToastsManager,
3843 route: ActivatedRoute,
....@@ -41,15 +46,33 @@
4146 super($L, router, route, toaster, organizations, $L.get('organization'), dialogs);
4247 }
4348
44
-
49
+ loadCombos() : void {
50
+ this.organizations.get()
51
+ .map(list => list.map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
52
+ .subscribe(
53
+ data => this.parentOrganizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
54
+ err => console.error('Error loading organizations')
55
+ );
56
+ this.users.get()
57
+ .map(list => list
58
+ .filter((user : any) => user.username !== '_client')
59
+ .map((u : any) => u.username))
60
+ .subscribe(
61
+ data => this.usernames = (<string[]>data).sort((u1, u2) => u1.localeCompare(u2)),
62
+ err => console.error('Error loading users')
63
+ );
64
+ }
65
+
66
+
4567 goBack(): void {
4668 this.router.navigate([`organizations`]);
4769 }
4870
4971 init() : void {
72
+ this.loadCombos();
5073 super.setFirstFocus();
5174 super.reset();
52
- super.prepareInitialData('organizationId');
75
+ super.prepareInitialData('organizationId', {users_ids: []});
5376 }
5477
5578 ngAfterViewInit(): void {