UI: Fixed empty delete dialog in javascript library panel
This commit is contained in:
parent
122dea9feb
commit
dfbb753d5e
@ -16,4 +16,5 @@
|
|||||||
|
|
||||||
export interface IEntityDetailsPageComponent {
|
export interface IEntityDetailsPageComponent {
|
||||||
reload(): void;
|
reload(): void;
|
||||||
|
goBack(): void;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,10 +26,10 @@ import { Router } from '@angular/router';
|
|||||||
import {
|
import {
|
||||||
Resource,
|
Resource,
|
||||||
ResourceInfo,
|
ResourceInfo,
|
||||||
|
ResourceInfoWithReferences,
|
||||||
ResourceSubType,
|
ResourceSubType,
|
||||||
ResourceSubTypeTranslationMap,
|
ResourceSubTypeTranslationMap,
|
||||||
ResourceType,
|
ResourceType,
|
||||||
ResourceInfoWithReferences,
|
|
||||||
toResourceDeleteResult
|
toResourceDeleteResult
|
||||||
} from '@shared/models/resource.models';
|
} from '@shared/models/resource.models';
|
||||||
import { EntityType, entityTypeResources } from '@shared/models/entity-type.models';
|
import { EntityType, entityTypeResources } from '@shared/models/entity-type.models';
|
||||||
@ -57,7 +57,6 @@ import {
|
|||||||
ResourcesInUseDialogData
|
ResourcesInUseDialogData
|
||||||
} from "@shared/components/resource/resources-in-use-dialog.component";
|
} from "@shared/components/resource/resources-in-use-dialog.component";
|
||||||
import { ResourcesDatasource } from "@home/pages/admin/resource/resources-datasource";
|
import { ResourcesDatasource } from "@home/pages/admin/resource/resources-datasource";
|
||||||
import { AuthUser } from '@shared/models/user.model';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JsLibraryTableConfigResolver {
|
export class JsLibraryTableConfigResolver {
|
||||||
@ -166,6 +165,8 @@ export class JsLibraryTableConfigResolver {
|
|||||||
case 'downloadResource':
|
case 'downloadResource':
|
||||||
this.downloadResource(action.event, action.entity);
|
this.downloadResource(action.event, action.entity);
|
||||||
return true;
|
return true;
|
||||||
|
case 'deleteLibrary':
|
||||||
|
this.deleteResource(action.event, action.entity);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -200,7 +201,11 @@ export class JsLibraryTableConfigResolver {
|
|||||||
).subscribe(
|
).subscribe(
|
||||||
(deleteResult) => {
|
(deleteResult) => {
|
||||||
if (deleteResult.success) {
|
if (deleteResult.success) {
|
||||||
this.config.updateData();
|
if (this.config.getEntityDetailsPage()) {
|
||||||
|
this.config.getEntityDetailsPage().goBack();
|
||||||
|
} else {
|
||||||
|
this.config.updateData(true);
|
||||||
|
}
|
||||||
} else if (deleteResult.resourceIsReferencedError) {
|
} else if (deleteResult.resourceIsReferencedError) {
|
||||||
const resources: ResourceInfoWithReferences[] = [{...resource, ...{references: deleteResult.references}}];
|
const resources: ResourceInfoWithReferences[] = [{...resource, ...{references: deleteResult.references}}];
|
||||||
const data = {
|
const data = {
|
||||||
@ -221,11 +226,13 @@ export class JsLibraryTableConfigResolver {
|
|||||||
data
|
data
|
||||||
}).afterClosed().subscribe((resources) => {
|
}).afterClosed().subscribe((resources) => {
|
||||||
if (resources) {
|
if (resources) {
|
||||||
this.resourceService.deleteResource(resource.id.id, true).subscribe(
|
this.resourceService.deleteResource(resource.id.id, true).subscribe(() => {
|
||||||
() => {
|
if (this.config.getEntityDetailsPage()) {
|
||||||
this.config.updateData();
|
this.config.getEntityDetailsPage().goBack();
|
||||||
|
} else {
|
||||||
|
this.config.updateData(true);
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -276,7 +283,7 @@ export class JsLibraryTableConfigResolver {
|
|||||||
message: this.translate.instant('javascript.javascript-resources-are-in-use-text'),
|
message: this.translate.instant('javascript.javascript-resources-are-in-use-text'),
|
||||||
deleteText: 'javascript.delete-javascript-resource-in-use-text',
|
deleteText: 'javascript.delete-javascript-resource-in-use-text',
|
||||||
selectedText: 'javascript.selected-javascript-resources',
|
selectedText: 'javascript.selected-javascript-resources',
|
||||||
datasource: new ResourcesDatasource(this.resourceService, resourcesWithReferences, entity => true),
|
datasource: new ResourcesDatasource(this.resourceService, resourcesWithReferences, () => true),
|
||||||
columns: ['select', 'title', 'references']
|
columns: ['select', 'title', 'references']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'delete')"
|
(click)="onEntityAction($event, 'deleteLibrary')"
|
||||||
[class.!hidden]="hideDelete() || isEdit">
|
[class.!hidden]="hideDelete() || isEdit">
|
||||||
{{ 'javascript.delete' | translate }}
|
{{ 'javascript.delete' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -34,7 +34,6 @@ import { startWith, takeUntil } from 'rxjs/operators';
|
|||||||
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
||||||
import { isDefinedAndNotNull } from '@core/utils';
|
import { isDefinedAndNotNull } from '@core/utils';
|
||||||
import { getCurrentAuthState } from '@core/auth/auth.selectors';
|
import { getCurrentAuthState } from '@core/auth/auth.selectors';
|
||||||
import { scadaSymbolGeneralStateHighlightRules } from '@home/pages/scada-symbol/scada-symbol-editor.models';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-js-resource',
|
selector: 'tb-js-resource',
|
||||||
@ -171,6 +170,4 @@ export class JsResourceComponent extends EntityComponent<Resource> implements On
|
|||||||
this.entityForm.get('content').enable({ emitEvent: false });
|
this.entityForm.get('content').enable({ emitEvent: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly highlightRules = scadaSymbolGeneralStateHighlightRules;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user