| .. | .. |
|---|
| 91 | 91 | } |
|---|
| 92 | 92 | |
|---|
| 93 | 93 | 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 | + }); |
|---|
| 96 | 98 | !!this.route && this.route.params.subscribe(params => { |
|---|
| 97 | 99 | var eleId = params[idparam]; |
|---|
| 98 | 100 | 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) ; |
|---|
| 108 | 105 | }); |
|---|
| 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 | + }); |
|---|
| 110 | 118 | } |
|---|
| 111 | 119 | }); |
|---|
| 112 | 120 | } |
|---|