Skip to content

Commit

Permalink
Form: make withBusyHandling public
Browse files Browse the repository at this point in the history
Sometimes the busy indicator needs to be enabled outside the form.
  • Loading branch information
cguglielmo committed Feb 6, 2025
1 parent 9111f92 commit 6a9420a
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions eclipse-scout-core/src/form/Form.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<T>(action: () => JQuery.Promise<T>): JQuery.Promise<T> {
/**
* Enables the {@link BusyIndicator} while the given action runs.
*
* @see setBusy
*/
withBusyHandling<T>(action: () => JQuery.Promise<T>): JQuery.Promise<T> {
this.setBusy(true);
try {
return action()
Expand All @@ -405,6 +408,13 @@ export class Form extends Widget implements FormModel, DisplayParent {
}
}

/**
* @deprecated use {@link withBusyHandling}.
*/
protected _withBusyHandling<T>(action: () => JQuery.Promise<T>): JQuery.Promise<T> {
return this.withBusyHandling(action);
}

/**
* @returns promise which is resolved when the form is loaded, respectively when the 'load' event is triggered.
*/
Expand Down Expand Up @@ -555,17 +565,15 @@ export class Form extends Widget implements FormModel, DisplayParent {

protected _onLifecycleSave(): JQuery.Promise<void> {
try {
return this._withBusyHandling(() => {
return this.withBusyHandling(() => {
let data = this.exportData();
return this._save(data)
.then(() => {
this.formSaved = true;
this.setData(data);
this.trigger('save');
});
}).catch(error => {
return this._handleSaveErrorInternal(error);
});
}).catch(error => this._handleSaveErrorInternal(error));
} catch (error) {
return this._handleSaveErrorInternal(error);
}
Expand Down

0 comments on commit 6a9420a

Please sign in to comment.