From 6a9420a17f02a37c3ce2db83e2d0f91ca39cd629 Mon Sep 17 00:00:00 2001 From: Claudio Guglielmo Date: Tue, 4 Feb 2025 15:30:17 +0100 Subject: [PATCH] Form: make withBusyHandling public Sometimes the busy indicator needs to be enabled outside the form. --- eclipse-scout-core/src/form/Form.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/eclipse-scout-core/src/form/Form.ts b/eclipse-scout-core/src/form/Form.ts index 71f73f79815..b683f787e42 100644 --- a/eclipse-scout-core/src/form/Form.ts +++ b/eclipse-scout-core/src/form/Form.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2024 BSI Business Systems Integration AG + * Copyright (c) 2010, 2025 BSI Business Systems Integration AG * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -385,16 +385,19 @@ export class Form extends Widget implements FormModel, DisplayParent { return $.resolvedPromise(); } try { - return this._withBusyHandling(() => this.lifecycle.load()) - .catch(error => { - return this._handleLoadErrorInternal(error); - }); + return this.withBusyHandling(() => this.lifecycle.load()) + .catch(error => this._handleLoadErrorInternal(error)); } catch (error) { return this._handleLoadErrorInternal(error); } } - protected _withBusyHandling(action: () => JQuery.Promise): JQuery.Promise { + /** + * Enables the {@link BusyIndicator} while the given action runs. + * + * @see setBusy + */ + withBusyHandling(action: () => JQuery.Promise): JQuery.Promise { this.setBusy(true); try { return action() @@ -405,6 +408,13 @@ export class Form extends Widget implements FormModel, DisplayParent { } } + /** + * @deprecated use {@link withBusyHandling}. + */ + protected _withBusyHandling(action: () => JQuery.Promise): JQuery.Promise { + return this.withBusyHandling(action); + } + /** * @returns promise which is resolved when the form is loaded, respectively when the 'load' event is triggered. */ @@ -555,7 +565,7 @@ export class Form extends Widget implements FormModel, DisplayParent { protected _onLifecycleSave(): JQuery.Promise { try { - return this._withBusyHandling(() => { + return this.withBusyHandling(() => { let data = this.exportData(); return this._save(data) .then(() => { @@ -563,9 +573,7 @@ export class Form extends Widget implements FormModel, DisplayParent { this.setData(data); this.trigger('save'); }); - }).catch(error => { - return this._handleSaveErrorInternal(error); - }); + }).catch(error => this._handleSaveErrorInternal(error)); } catch (error) { return this._handleSaveErrorInternal(error); }