Skip to content

Commit

Permalink
[OGUI-1583] Reset status of this.item if there is an error saving aft…
Browse files Browse the repository at this point in the history
…er updating (#2671)

* Fixes error managing when trying to save a layout with no tabs
* Resets value of the layout to previous state before saving after edit if there is an error saving
  • Loading branch information
mariscalromeroalejandro authored Nov 25, 2024
1 parent da13305 commit 5e9be6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion QualityControl/public/layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export default class Layout extends Observable {
if (result.isSuccess()) {
this.model.notification.show(`Layout "${this.item.name}" has been saved successfully.`, 'success');
} else {
this.item = this.editOriginalClone;
this.model.notification.show(result.payload, 'danger');
}
this.notify();
Expand Down Expand Up @@ -730,7 +731,9 @@ export default class Layout extends Observable {
* @returns {undefined}
*/
setTabInterval(time) {
if (time >= 10) {
if (!this.tabs || this.tabs.length === 0) {
clearInterval(this.tabInterval);
} else if (time >= 10) {
this.tabInterval = setInterval(() => {
this._tabIndex = this._tabIndex + 1 >= this.item.tabs.length ? 0 : this._tabIndex + 1;
this.selectTab(this._tabIndex);
Expand Down Expand Up @@ -803,6 +806,7 @@ export default class Layout extends Observable {
* @returns {undefined}
*/
initializeEditViaJson() {
this.editOriginalClone = JSON.parse(JSON.stringify(this.item));
this.model.services.layout.update = RemoteData.success();
this.updatedJSON = LayoutUtils.toSkeleton(this.item);
this.model.isUpdateVisible = true;
Expand Down

0 comments on commit 5e9be6a

Please sign in to comment.