Manual change detection for config list
Adds manual change detection to the config page. Behaves better regarding "changed after checked" errors
This commit is contained in:
parent
2fb372ead9
commit
557824f5f1
@ -325,14 +325,6 @@ export class ConfigFieldComponent extends BaseComponent implements OnInit, OnDes
|
||||
this.sendUpdate(ev.target.getContent());
|
||||
}
|
||||
});
|
||||
editor.on('Remove', ev => {
|
||||
// Do not save empty values on remove. This prevents losing the value on e.g.
|
||||
// fast navigation, when the editor is not fully loaded. Then the content is empty
|
||||
// and would trigger an update with empty data.
|
||||
if (ev.target.getContent() && ev.target.getContent() !== this.translatedValue) {
|
||||
this.sendUpdate(ev.target.getContent());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@ -31,7 +31,8 @@ export interface ConfigItem {
|
||||
@Component({
|
||||
selector: 'os-config-list',
|
||||
templateUrl: './config-list.component.html',
|
||||
styleUrls: ['./config-list.component.scss']
|
||||
styleUrls: ['./config-list.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ConfigListComponent extends BaseComponent implements CanComponentDeactivate, OnInit, OnDestroy {
|
||||
public configGroup: ConfigGroup;
|
||||
@ -51,6 +52,7 @@ export class ConfigListComponent extends BaseComponent implements CanComponentDe
|
||||
public constructor(
|
||||
protected titleService: Title,
|
||||
protected translate: TranslateService,
|
||||
private cd: ChangeDetectorRef,
|
||||
private repo: ConfigRepositoryService,
|
||||
private route: ActivatedRoute,
|
||||
private promptDialog: PromptService
|
||||
@ -70,6 +72,7 @@ export class ConfigListComponent extends BaseComponent implements CanComponentDe
|
||||
const groupName = this.translate.instant(configGroup.name);
|
||||
super.setTitle(`${settings} - ${groupName}`);
|
||||
this.configGroup = configGroup;
|
||||
this.cd.markForCheck();
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -89,16 +92,20 @@ export class ConfigListComponent extends BaseComponent implements CanComponentDe
|
||||
} else {
|
||||
this.configItems[index] = { key, value };
|
||||
}
|
||||
this.cd.markForCheck();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves every field in this config-group.
|
||||
*/
|
||||
public saveAll(): void {
|
||||
this.cd.detach();
|
||||
this.repo.bulkUpdate(this.configItems).then(result => {
|
||||
this.errors = result.errors;
|
||||
if (Object.keys(result.errors).length === 0) {
|
||||
this.configItems = [];
|
||||
this.cd.reattach();
|
||||
this.cd.markForCheck();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user