Skip to content

Commit

Permalink
fix: tab hasChanged update error
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Aug 12, 2022
1 parent 9836b14 commit 7440327
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/workbench/browser/src/app/pages/api/api-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,39 @@ export class ApiTabService {
`EO_ERROR:Child componentRef[${this.componentRef.constructor.name}] need has isFormChange function check model change`
);
}
let currentHasChanged=false;
switch (inData.when) {
case 'editing': {
// Saved APIs do not need to verify changes
if (!currentTab.params.uuid || currentTab.params.uuid.includes('history')) {
replaceTab.hasChanged = this.componentRef.isFormChange();
if (
currentTab.pathname !== '/home/api/test' ||
!currentTab.params.uuid ||
currentTab.params.uuid.includes('history')
) {
currentHasChanged = this.componentRef.isFormChange();
}
break;
}
case 'saved': {
replaceTab.hasChanged = false;
currentHasChanged = false;
}
}
//* Share change status within all content page
replaceTab.extends.hasChanged = currentTab.extends?.hasChanged || {};
replaceTab.extends.hasChanged[contentID] = replaceTab.hasChanged;
replaceTab.hasChanged =
currentTab.extends?.hasChanged?.[contentID === 'edit' ? 'test' : 'edit'] || replaceTab.hasChanged;

replaceTab.extends.hasChanged[contentID] = currentHasChanged;
// Editiable tab share hasChanged data
if (!currentHasChanged) {
const otherEditableTabs = [];
for (const key in this.BASIC_TBAS) {
if (this.BASIC_TBAS[key].type === 'edit' && key !== contentID) {
otherEditableTabs.push(key);
}
}
if (currentTab.extends?.hasChanged) {
currentHasChanged = otherEditableTabs.some((module) => currentTab.extends?.hasChanged[module]);
}
}
replaceTab.hasChanged=currentHasChanged;
// Set storage
//Set baseContent
if (['init', 'saved'].includes(inData.when)) {
Expand Down

0 comments on commit 7440327

Please sign in to comment.