Etemplate: Fix nextmatch controller destroy() left some references

AJAX responses would then try to use them after the etemplate was destroyed, and fail.
This commit is contained in:
nathangray 2020-11-09 09:44:40 -07:00
parent 2f40337f81
commit 1ba23feb9c
4 changed files with 22 additions and 2 deletions

View File

@ -87,6 +87,7 @@ var et2_dataview_controller = /** @class */ (function () {
this._parentController = null; this._parentController = null;
} }
} }
this._grid = null;
}; };
/** /**
* @param value is an object implementing the et2_IDataProvider * @param value is an object implementing the et2_IDataProvider
@ -124,6 +125,10 @@ var et2_dataview_controller = /** @class */ (function () {
* Completely clears the grid and selection. * Completely clears the grid and selection.
*/ */
et2_dataview_controller.prototype.update = function (clear) { et2_dataview_controller.prototype.update = function (clear) {
// Avoid update after destroy
// Happens sometimes if AJAX response comes after etemplate unload
if (!this._grid)
return;
// --------- // ---------
// TODO: Actually stuff here should be done if the server responds that // TODO: Actually stuff here should be done if the server responds that
// there at all were some changes (needs implementation of "refresh") // there at all were some changes (needs implementation of "refresh")

View File

@ -131,6 +131,8 @@ export class et2_dataview_controller
this._parentController = null; this._parentController = null;
} }
} }
this._grid = null;
} }
/** /**
@ -186,6 +188,9 @@ export class et2_dataview_controller
*/ */
update( clear? : boolean) update( clear? : boolean)
{ {
// Avoid update after destroy
// Happens sometimes if AJAX response comes after etemplate unload
if(!this._grid) return;
// --------- // ---------

View File

@ -40,6 +40,8 @@ var __extends = (this && this.__extends) || (function () {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var et2_dataview_view_row_1 = require("./et2_dataview_view_row"); var et2_dataview_view_row_1 = require("./et2_dataview_view_row");
var et2_dataview_view_tile_1 = require("./et2_dataview_view_tile"); var et2_dataview_view_tile_1 = require("./et2_dataview_view_tile");
var et2_dataview_controller_1 = require("./et2_dataview_controller");
var et2_dataview_model_columns_1 = require("./et2_dataview_model_columns");
/** /**
* @augments et2_dataview_controller * @augments et2_dataview_controller
*/ */
@ -123,6 +125,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
this._objectManager.remove(); this._objectManager.remove();
this._actionManager.remove(); this._actionManager.remove();
} }
this._widget = null;
_super.prototype.destroy.call(this); _super.prototype.destroy.call(this);
}; };
/** /**
@ -535,7 +538,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
col_refresh = true; col_refresh = true;
nm.dataview.columnMgr.getColumnById('col_' + column_index) nm.dataview.columnMgr.getColumnById('col_' + column_index)
.set_visibility(nm.getArrayMgr('content').parseBoolExpression(nm.columns[column_index].disabled) ? .set_visibility(nm.getArrayMgr('content').parseBoolExpression(nm.columns[column_index].disabled) ?
et2_dataview_column.ET2_COL_VISIBILITY_DISABLED : et2_dataview_model_columns_1.et2_dataview_column.ET2_COL_VISIBILITY_DISABLED :
nm.columns[column_index].visible); nm.columns[column_index].visible);
} }
} }
@ -621,6 +624,6 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
et2_nextmatch_controller.VIEW_ROW = 'row'; et2_nextmatch_controller.VIEW_ROW = 'row';
et2_nextmatch_controller.VIEW_TILE = 'tile'; et2_nextmatch_controller.VIEW_TILE = 'tile';
return et2_nextmatch_controller; return et2_nextmatch_controller;
}(et2_dataview_controller)); }(et2_dataview_controller_1.et2_dataview_controller));
exports.et2_nextmatch_controller = et2_nextmatch_controller; exports.et2_nextmatch_controller = et2_nextmatch_controller;
//# sourceMappingURL=et2_extension_nextmatch_controller.js.map //# sourceMappingURL=et2_extension_nextmatch_controller.js.map

View File

@ -27,6 +27,9 @@
import {et2_IDataProvider} from "./et2_dataview_interfaces"; import {et2_IDataProvider} from "./et2_dataview_interfaces";
import {et2_dataview_row} from "./et2_dataview_view_row"; import {et2_dataview_row} from "./et2_dataview_view_row";
import {et2_dataview_tile} from "./et2_dataview_view_tile"; import {et2_dataview_tile} from "./et2_dataview_view_tile";
import {et2_nextmatch} from "./et2_extension_nextmatch";
import {et2_dataview_controller} from "./et2_dataview_controller";
import {et2_dataview_column} from "./et2_dataview_model_columns";
/** /**
* @augments et2_dataview_controller * @augments et2_dataview_controller
@ -37,6 +40,8 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
public static readonly VIEW_ROW : string = 'row'; public static readonly VIEW_ROW : string = 'row';
public static readonly VIEW_TILE: string = 'tile'; public static readonly VIEW_TILE: string = 'tile';
private _widget: et2_nextmatch;
/** /**
* Initializes the nextmatch controller. * Initializes the nextmatch controller.
* *
@ -139,6 +144,8 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
this._actionManager.remove(); this._actionManager.remove();
} }
this._widget = null;
super.destroy(); super.destroy();
} }