rsanchez
2017-06-23 7163fc28f700785424ec10601ce6aa58d6d05223
securis/src/main/webapp/src/app/forms/base.ts
....@@ -91,22 +91,30 @@
9191 }
9292
9393 protected prepareInitialData(idparam: string, default_values: any = {}, callback?: (data: any) => void) : void {
94
- this.form_title = this.$L.get('{} data', this.resourceName.capitalize());
95
- this.isNew = true;
94
+ super.setViewData(() => {
95
+ this.form_title = this.$L.get('{} data', this.resourceName.capitalize());
96
+ this.isNew = true;
97
+ });
9698 !!this.route && this.route.params.subscribe(params => {
9799 var eleId = params[idparam];
98100 if (!eleId) {
99
- this.data = {};
100
- Object.keys(default_values).forEach((k : string) => this.data[k] = default_values[k]);
101
- this.form_subtitle = this.$L.get('Create a new {}', this.resourceName) ;
102
- } else {
103
- this.isNew = false;
104
- this.resourceServices.get(eleId).subscribe(eleData => {
105
- this.data = eleData;
106
- Object.keys(default_values).forEach((k : string) => (this.data[k] === undefined) && (this.data[k] = default_values[k]));
107
- callback && callback(this.data);
101
+ super.setViewData(() => {
102
+ this.data = {};
103
+ Object.keys(default_values).forEach((k : string) => this.data[k] = default_values[k]);
104
+ this.form_subtitle = this.$L.get('Create a new {}', this.resourceName) ;
108105 });
109
- this.form_subtitle = this.$L.get('Modify the {} data', this.resourceName) ;
106
+ } else {
107
+ super.setViewData(() => {
108
+ this.isNew = false;
109
+ this.resourceServices.get(eleId).subscribe(eleData => {
110
+ super.setViewData(() => {
111
+ this.data = eleData;
112
+ Object.keys(default_values).forEach((k : string) => (this.data[k] === undefined) && (this.data[k] = default_values[k]));
113
+ callback && callback(this.data);
114
+ });
115
+ });
116
+ this.form_subtitle = this.$L.get('Modify the {} data', this.resourceName) ;
117
+ });
110118 }
111119 });
112120 }