From 08e725754836fd4b98d7aabbb6488764a0f2469a Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 26 Jun 2017 15:30:42 +0000
Subject: [PATCH] Merge branch 'angular2' of https://git.curisit.net/gitblit/git/common/securis into angular2
---
securis/src/main/webapp/src/app/common/utils.ts | 5 +++++
securis/src/main/webapp/src/app/forms/licensetype.form.component.ts | 6 +++---
securis/src/main/webapp/src/app/forms/base.ts | 32 ++++++++++++++++++++------------
securis/src/main/webapp/src/app/forms/pack.form.component.ts | 11 ++++++-----
securis/src/main/webapp/src/app/forms/license.form.component.ts | 3 +++
5 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/securis/src/main/webapp/src/app/common/utils.ts b/securis/src/main/webapp/src/app/common/utils.ts
index 6e63b6a..ecc46de 100644
--- a/securis/src/main/webapp/src/app/common/utils.ts
+++ b/securis/src/main/webapp/src/app/common/utils.ts
@@ -1,5 +1,6 @@
import { Component, Injectable, Input } from '@angular/core';
+import { Response } from '@angular/http';
import { LocaleService } from './i18n';
import { Observable } from 'rxjs/Observable';
@@ -42,6 +43,10 @@
constructor(protected $L: LocaleService) { }
+ public setViewData(callback: any) {
+ setTimeout(callback, 0);
+ }
+
public processErrorResponse(errorResponse: Response) {
// In a real world app, we might use a remote logging infrastructure
var error: IError = <IError>{};
diff --git a/securis/src/main/webapp/src/app/forms/base.ts b/securis/src/main/webapp/src/app/forms/base.ts
index 1fc2ca1..45d773b 100644
--- a/securis/src/main/webapp/src/app/forms/base.ts
+++ b/securis/src/main/webapp/src/app/forms/base.ts
@@ -91,22 +91,30 @@
}
protected prepareInitialData(idparam: string, default_values: any = {}, callback?: (data: any) => void) : void {
- this.form_title = this.$L.get('{} data', this.resourceName.capitalize());
- this.isNew = true;
+ super.setViewData(() => {
+ this.form_title = this.$L.get('{} data', this.resourceName.capitalize());
+ this.isNew = true;
+ });
!!this.route && this.route.params.subscribe(params => {
var eleId = params[idparam];
if (!eleId) {
- this.data = {};
- Object.keys(default_values).forEach((k : string) => this.data[k] = default_values[k]);
- this.form_subtitle = this.$L.get('Create a new {}', this.resourceName) ;
- } else {
- this.isNew = false;
- this.resourceServices.get(eleId).subscribe(eleData => {
- this.data = eleData;
- Object.keys(default_values).forEach((k : string) => (this.data[k] === undefined) && (this.data[k] = default_values[k]));
- callback && callback(this.data);
+ super.setViewData(() => {
+ this.data = {};
+ Object.keys(default_values).forEach((k : string) => this.data[k] = default_values[k]);
+ this.form_subtitle = this.$L.get('Create a new {}', this.resourceName) ;
});
- this.form_subtitle = this.$L.get('Modify the {} data', this.resourceName) ;
+ } else {
+ super.setViewData(() => {
+ this.isNew = false;
+ this.resourceServices.get(eleId).subscribe(eleData => {
+ super.setViewData(() => {
+ this.data = eleData;
+ Object.keys(default_values).forEach((k : string) => (this.data[k] === undefined) && (this.data[k] = default_values[k]));
+ callback && callback(this.data);
+ });
+ });
+ this.form_subtitle = this.$L.get('Modify the {} data', this.resourceName) ;
+ });
}
});
}
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 f6bf27c..8f16bb7 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
@@ -130,6 +130,9 @@
this.packs.get(packId).subscribe(
packData => {
this.pack = packData;
+ if (this.isNew) {
+ this.data.metadata = packData.metadata;
+ }
},
err => console.error(err)
);
diff --git a/securis/src/main/webapp/src/app/forms/licensetype.form.component.ts b/securis/src/main/webapp/src/app/forms/licensetype.form.component.ts
index 2a459cd..a60e426 100644
--- a/securis/src/main/webapp/src/app/forms/licensetype.form.component.ts
+++ b/securis/src/main/webapp/src/app/forms/licensetype.form.component.ts
@@ -54,7 +54,7 @@
this.applications.get(this.data.application_id)
.map(app_data => this._prepareMetadata(app_data.metadata))
.subscribe(
- metadata => this.data.metadata = metadata,
+ metadata => super.setViewData(() => this.data.metadata = metadata),
err => console.error('Error loading application metadata')
);
}
@@ -65,7 +65,7 @@
this.applications.get()
.map(list => list.map((app : any) => <IComboOption>{id: app.id, label: `(${app.code}) ${app.name}`}))
.subscribe(
- data => this.allApplications = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
+ data => super.setViewData(() => this.allApplications = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label))),
err => console.error('Error loading applications')
);
}
@@ -80,7 +80,7 @@
super.reset();
super.prepareInitialData('licensetypeId', {
metadata: []
- }, (data) => this._prepareMetadata(data.metadata));
+ }, (data) => super.setViewData(() => this._prepareMetadata(data.metadata)));
}
ngAfterViewInit(): void {
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 866e81f..2ee2cc9 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
@@ -27,7 +27,7 @@
private packs: PacksService,
router: Router,
toaster: ToastsManager,
- route: ActivatedRoute,
+ route: ActivatedRoute,
$L: LocaleService,
dialogs: TdDialogService) {
super($L, router, route, toaster, packs, $L.get('pack'), dialogs);
@@ -37,13 +37,13 @@
this.http.get('organization')
.map(response => response.json().map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
.subscribe(
- data => this.organizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
+ data => super.setViewData(() => this.organizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label))),
err => console.error('Error loading orgs')
);
this.licenseTypes.get()
.map(list => list.map((lt : any) => <IComboOption>{id: lt.id, label: `(${lt.code}) ${lt.name}`}))
.subscribe(
- data => this.licensetypes = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
+ data => super.setViewData(() => this.licensetypes = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label))),
err => console.error('Error loading license types')
);
}
@@ -57,7 +57,7 @@
this.licenseTypes.get(this.data.license_type_id)
.map(lt_data => lt_data.metadata)
.subscribe(
- metadata => this.data.metadata = metadata,
+ metadata => super.setViewData(() => this.data.metadata = metadata),
err => {
console.error('Error loading license type metadata');
console.error(err);
@@ -94,7 +94,8 @@
init(): void {
this.loadCombos();
super.prepareInitialData('packId', {
- status: PACK_STATUS.CREATED
+ status: PACK_STATUS.CREATED,
+ frozen: false
});
}
}
--
Gitblit v1.3.2