rsanchez
2017-03-21 a6e1ace2b6bdba8c08a4acfa42433f3ac073b747
securis/src/main/webapp/src/app/forms/base.ts
....@@ -90,7 +90,7 @@
9090 });
9191 }
9292
93
- protected prepareInitialData(idparam: string, default_values: any = {}) : void {
93
+ protected prepareInitialData(idparam: string, default_values: any = {}, callback?: (data: any) => void) : void {
9494 this.form_title = this.$L.get('{} data', this.resourceName.capitalize());
9595 this.isNew = true;
9696 !!this.route && this.route.params.subscribe(params => {
....@@ -101,7 +101,11 @@
101101 this.form_subtitle = this.$L.get('Create a new {}', this.resourceName) ;
102102 } else {
103103 this.isNew = false;
104
- this.resourceServices.get(eleId).subscribe(eleData => this.data = eleData);
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);
108
+ });
105109 this.form_subtitle = this.$L.get('Modify the {} data', this.resourceName) ;
106110 }
107111 });