From 7a5a01af169b0fd6f58b7f2c8332b7e898e9ede8 Mon Sep 17 00:00:00 2001 From: Johnny Hausman Date: Tue, 17 Feb 2026 14:43:11 -0600 Subject: [PATCH] [wip] refactor ABApplication.viewNew() to follow style of .pageNew() and similar methods. --- ABApplicationCore.js | 8 +++++--- ABFactoryCore.js | 2 +- mobile/ABMobilePageCore.js | 2 +- mobile/ABMobileViewCore.js | 20 ++++++-------------- views/ABViewConditionalContainerCore.js | 2 -- views/ABViewCore.js | 21 ++++++--------------- views/ABViewLayoutCore.js | 1 - views/ABViewPageCore.js | 2 +- views/ABViewTabCore.js | 1 - 9 files changed, 20 insertions(+), 39 deletions(-) diff --git a/ABApplicationCore.js b/ABApplicationCore.js index 0afe5279..e05723ae 100644 --- a/ABApplicationCore.js +++ b/ABApplicationCore.js @@ -994,12 +994,14 @@ module.exports = class ABApplicationCore extends ABMLClass { /** * @method viewNew() * - * return an instance of a new (unsaved) ABView. + * return an instance of a new (unsaved) ABView tied to this ABApplication. * + * @param {object} values view definition/settings + * @param {ABView} [parent=null] parent view of the new view * @return {ABView} */ - viewNew(values, application, parent) { - return this.ViewManager.newView(values, application, parent); + viewNew(values, parent = null) { + return this.ViewManager.newView(values, this, parent); } /// diff --git a/ABFactoryCore.js b/ABFactoryCore.js index b91c598c..06bc7718 100644 --- a/ABFactoryCore.js +++ b/ABFactoryCore.js @@ -1076,7 +1076,7 @@ class ABFactory extends EventEmitter { if (!this._mockApp) { this._mockApp = this.applicationNew({}); } - return this._mockApp.viewNew(values, this._mockApp); + return this._mockApp.viewNew(values, null); } // diff --git a/mobile/ABMobilePageCore.js b/mobile/ABMobilePageCore.js index a73318d3..e9deb927 100644 --- a/mobile/ABMobilePageCore.js +++ b/mobile/ABMobilePageCore.js @@ -351,7 +351,7 @@ module.exports = class ABMobilePageCore extends ABMobileView { // NOTE: this returns a new ABView component. // when creating a new page, the 3rd param should be null, to signify // the top level component. - var page = this.application.viewNew(values, this.application, null); + var page = this.application.viewNew(values, null); page.parent = this; return page; } diff --git a/mobile/ABMobileViewCore.js b/mobile/ABMobileViewCore.js index 045d52fe..bafc8d4f 100644 --- a/mobile/ABMobileViewCore.js +++ b/mobile/ABMobileViewCore.js @@ -67,11 +67,7 @@ module.exports = class ABMobileViewCore extends ABMLClass { */ static newInstance(application, parent) { // return a new instance from ABViewManager: - return application.viewNew( - { key: this.common().key }, - application, - parent - ); + return application.viewNew({ key: this.common().key }, parent); } viewKey() { @@ -210,7 +206,7 @@ module.exports = class ABMobileViewCore extends ABMLClass { (values.viewIDs || []).forEach((id) => { var def = this.AB.definitionByID(id); if (def) { - views.push(this.application.viewNew(def, this.application, this)); + views.push(this.application.viewNew(def, this)); } else { this.__missingViews.push(id); } @@ -552,12 +548,8 @@ module.exports = class ABMobileViewCore extends ABMLClass { * @method viewNew() * @return {ABView} */ - viewNew(values, application, parent) { - return this.application.viewNew( - values, - application || this.application, - parent || this - ); + viewNew(values, parent) { + return this.application.viewNew(values, parent || this); } /** @@ -811,7 +803,7 @@ module.exports = class ABMobileViewCore extends ABMLClass { } // copy from settings - let result = this.viewNew(config, this.application, parent); + let result = this.viewNew(config, parent); // change id if (parent == null) { @@ -885,7 +877,7 @@ module.exports = class ABMobileViewCore extends ABMLClass { } // copy from settings - let result = this.application.viewNew(config, this.application, parent); + let result = this.application.viewNew(config, parent); // keep the parent result.parent = parent || this.parent; diff --git a/views/ABViewConditionalContainerCore.js b/views/ABViewConditionalContainerCore.js index 80d256bd..a3f41f05 100644 --- a/views/ABViewConditionalContainerCore.js +++ b/views/ABViewConditionalContainerCore.js @@ -31,7 +31,6 @@ module.exports = class ABViewConditionalContainerCore extends ABViewContainer { removable: false, }, }, - application, this ); @@ -47,7 +46,6 @@ module.exports = class ABViewConditionalContainerCore extends ABViewContainer { removable: false, }, }, - application, this ); diff --git a/views/ABViewCore.js b/views/ABViewCore.js index f6e082c0..1578736d 100644 --- a/views/ABViewCore.js +++ b/views/ABViewCore.js @@ -67,11 +67,7 @@ module.exports = class ABViewCore extends ABMLClass { */ static newInstance(application, parent) { // return a new instance from ABViewManager: - return application.viewNew( - { key: this.common().key }, - application, - parent - ); + return application.viewNew({ key: this.common().key }, parent); } viewKey() { @@ -214,7 +210,7 @@ module.exports = class ABViewCore extends ABMLClass { (values.viewIDs || []).forEach((id) => { var def = this.AB.definitionByID(id); if (def) { - views.push(this.application.viewNew(def, this.application, this)); + views.push(this.application.viewNew(def, this)); } else { this.__missingViews.push(id); } @@ -555,15 +551,10 @@ module.exports = class ABViewCore extends ABMLClass { /** * @method viewNew() * - * * @return {ABView} */ - viewNew(values, application, parent) { - return this.application.viewNew( - values, - application || this.application, - parent || this - ); + viewNew(values, parent) { + return this.application.viewNew(values, parent || this); } /** @@ -805,7 +796,7 @@ module.exports = class ABViewCore extends ABMLClass { } // copy from settings - let result = this.viewNew(config, this.application, parent); + let result = this.viewNew(config, parent); // change id if (parent == null) { @@ -879,7 +870,7 @@ module.exports = class ABViewCore extends ABMLClass { } // copy from settings - let result = this.application.viewNew(config, this.application, parent); + let result = this.application.viewNew(config, parent); // keep the parent result.parent = parent || this.parent; diff --git a/views/ABViewLayoutCore.js b/views/ABViewLayoutCore.js index 8ae09298..b68848ed 100644 --- a/views/ABViewLayoutCore.js +++ b/views/ABViewLayoutCore.js @@ -41,7 +41,6 @@ module.exports = class ABViewLayoutCore extends ABViewWidget { { key: ABViewContainer.common().key, }, - this.application, this ) ); diff --git a/views/ABViewPageCore.js b/views/ABViewPageCore.js index 75e8bc99..73ab1fbe 100644 --- a/views/ABViewPageCore.js +++ b/views/ABViewPageCore.js @@ -322,7 +322,7 @@ module.exports = class ABViewPageCore extends ABViewContainer { // NOTE: this returns a new ABView component. // when creating a new page, the 3rd param should be null, to signify // the top level component. - var page = this.application.viewNew(values, this.application, null); + var page = this.application.viewNew(values, null); page.parent = this; return page; } diff --git a/views/ABViewTabCore.js b/views/ABViewTabCore.js index 2907c93f..57378210 100644 --- a/views/ABViewTabCore.js +++ b/views/ABViewTabCore.js @@ -67,7 +67,6 @@ module.exports = class ABViewTabCore extends ABViewWidget { label: tabName, tabicon: tabIcon, }, - this.application, this ) .save();