Fix: widget is not removed from dashboard, only after page refresh

This commit is contained in:
Levko Kravets 2018-02-13 21:53:21 +02:00
parent 17f3b1e92d
commit 8ec0cda10b
2 changed files with 7 additions and 2 deletions

View File

@ -71,7 +71,8 @@ function DashboardWidgetCtrl($location, $uibModal, $window, Events, currentUser)
Events.record('delete', 'widget', this.widget.id);
this.widget.$delete((response) => {
this.dashboard.widgets = this.dashboard.widgets.filter(widget => widget.id !== undefined);
this.dashboard.widgets = this.dashboard.widgets
.filter(widget => (widget.id !== undefined) && (widget.id !== this.widget.id));
this.dashboard.version = response.version;
if (this.deleted) {
this.deleted({});

View File

@ -317,7 +317,11 @@ function DashboardCtrl(
this.removeWidget = () => {
this.extractGlobalParameters();
if (!this.layoutEditing) {
// We need to wait a bit for `angular-gridster` before it updates widgets,
// and only then save new layout
$timeout(() => {
saveDashboardLayout();
}, 50);
}
};