| .. | .. |
|---|
| 90 | 90 | }); |
|---|
| 91 | 91 | } |
|---|
| 92 | 92 | |
|---|
| 93 | | - protected prepareInitialData(idparam: string, default_values: any = {}) : void { |
|---|
| 93 | + protected prepareInitialData(idparam: string, default_values: any = {}, callback?: (data: any) => void) : void { |
|---|
| 94 | 94 | this.form_title = this.$L.get('{} data', this.resourceName.capitalize()); |
|---|
| 95 | 95 | this.isNew = true; |
|---|
| 96 | 96 | !!this.route && this.route.params.subscribe(params => { |
|---|
| .. | .. |
|---|
| 101 | 101 | this.form_subtitle = this.$L.get('Create a new {}', this.resourceName) ; |
|---|
| 102 | 102 | } else { |
|---|
| 103 | 103 | 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 | + }); |
|---|
| 105 | 109 | this.form_subtitle = this.$L.get('Modify the {} data', this.resourceName) ; |
|---|
| 106 | 110 | } |
|---|
| 107 | 111 | }); |
|---|