|
|
@ -32,10 +32,11 @@ import { ActivatedRoute, Router } from '@angular/router'; |
|
|
import { FormGroup } from '@angular/forms'; |
|
|
import { FormGroup } from '@angular/forms'; |
|
|
import { AssetId } from '@shared/models/id/asset-id'; |
|
|
import { AssetId } from '@shared/models/id/asset-id'; |
|
|
import { TranslateService } from '@ngx-translate/core'; |
|
|
import { TranslateService } from '@ngx-translate/core'; |
|
|
import { deepClone, mergeDeep } from '@core/utils'; |
|
|
import { deepClone } from '@core/utils'; |
|
|
import { BroadcastService } from '@core/services/broadcast.service'; |
|
|
import { BroadcastService } from '@core/services/broadcast.service'; |
|
|
import { EntityDetailsPanelComponent } from '@home/components/entity/entity-details-panel.component'; |
|
|
import { EntityDetailsPanelComponent } from '@home/components/entity/entity-details-panel.component'; |
|
|
import { DialogService } from '@core/services/dialog.service'; |
|
|
import { DialogService } from '@core/services/dialog.service'; |
|
|
|
|
|
import { IEntityDetailsPageComponent } from '@home/models/entity/entity-details-page-component.models'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'tb-entity-details-page', |
|
|
selector: 'tb-entity-details-page', |
|
|
@ -43,7 +44,7 @@ import { DialogService } from '@core/services/dialog.service'; |
|
|
styleUrls: ['./entity-details-page.component.scss'], |
|
|
styleUrls: ['./entity-details-page.component.scss'], |
|
|
changeDetection: ChangeDetectionStrategy.OnPush |
|
|
changeDetection: ChangeDetectionStrategy.OnPush |
|
|
}) |
|
|
}) |
|
|
export class EntityDetailsPageComponent extends EntityDetailsPanelComponent implements OnInit, OnDestroy { |
|
|
export class EntityDetailsPageComponent extends EntityDetailsPanelComponent implements IEntityDetailsPageComponent, OnInit, OnDestroy { |
|
|
|
|
|
|
|
|
headerTitle: string; |
|
|
headerTitle: string; |
|
|
headerSubtitle: string; |
|
|
headerSubtitle: string; |
|
|
@ -54,6 +55,7 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl |
|
|
if (this.entitiesTableConfigValue !== entitiesTableConfig) { |
|
|
if (this.entitiesTableConfigValue !== entitiesTableConfig) { |
|
|
this.entitiesTableConfigValue = entitiesTableConfig; |
|
|
this.entitiesTableConfigValue = entitiesTableConfig; |
|
|
if (this.entitiesTableConfigValue) { |
|
|
if (this.entitiesTableConfigValue) { |
|
|
|
|
|
this.entitiesTableConfigValue.setEntityDetailsPage(this); |
|
|
this.isEdit = false; |
|
|
this.isEdit = false; |
|
|
this.entity = null; |
|
|
this.entity = null; |
|
|
} |
|
|
} |
|
|
@ -81,9 +83,6 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.headerSubtitle = ''; |
|
|
this.headerSubtitle = ''; |
|
|
this.route.paramMap.subscribe( paramMap => { |
|
|
|
|
|
this.entityId = new AssetId(paramMap.get('entityId')); |
|
|
|
|
|
}); |
|
|
|
|
|
this.headerSubtitle = this.translate.instant(this.entitiesTableConfig.entityTranslations.details); |
|
|
this.headerSubtitle = this.translate.instant(this.entitiesTableConfig.entityTranslations.details); |
|
|
super.init(); |
|
|
super.init(); |
|
|
this.entityComponent.isDetailsPage = true; |
|
|
this.entityComponent.isDetailsPage = true; |
|
|
@ -92,6 +91,15 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl |
|
|
this.deleteEntity(action.event, action.entity); |
|
|
this.deleteEntity(action.event, action.entity); |
|
|
} |
|
|
} |
|
|
})); |
|
|
})); |
|
|
|
|
|
this.subscriptions.push(this.route.paramMap.subscribe( paramMap => { |
|
|
|
|
|
if (this.entitiesTableConfig) { |
|
|
|
|
|
const entityType = this.entitiesTableConfig.entityType; |
|
|
|
|
|
const id = paramMap.get('entityId'); |
|
|
|
|
|
this.currentEntityId = { id, entityType }; |
|
|
|
|
|
this.reload(); |
|
|
|
|
|
this.selectedTab = 0; |
|
|
|
|
|
} |
|
|
|
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnDestroy() { |
|
|
ngOnDestroy() { |
|
|
@ -99,20 +107,9 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
reload(): void { |
|
|
reload(): void { |
|
|
this.isEdit = false; |
|
|
this.reloadEntity().subscribe(() => { |
|
|
this.entitiesTableConfig.loadEntity(this.currentEntityId).subscribe( |
|
|
this.onUpdateEntity(); |
|
|
(entity) => { |
|
|
}); |
|
|
this.entity = entity; |
|
|
|
|
|
this.broadcast.broadcast('updateBreadcrumb'); |
|
|
|
|
|
this.isReadOnly = this.entitiesTableConfig.detailsReadonly(entity); |
|
|
|
|
|
this.headerTitle = this.entitiesTableConfig.entityTitle(entity); |
|
|
|
|
|
this.entityComponent.entity = entity; |
|
|
|
|
|
this.entityComponent.isEdit = false; |
|
|
|
|
|
if (this.entityTabsComponent) { |
|
|
|
|
|
this.entityTabsComponent.entity = entity; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onToggleDetailsEditMode() { |
|
|
onToggleDetailsEditMode() { |
|
|
@ -136,29 +133,23 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onApplyDetails() { |
|
|
onApplyDetails() { |
|
|
if (this.detailsForm && this.detailsForm.valid) { |
|
|
this.saveEntity(false).subscribe((entity) => { |
|
|
const editingEntity = {...this.editingEntity, ...this.entityComponent.entityFormValue()}; |
|
|
if (entity) { |
|
|
if (this.editingEntity.hasOwnProperty('additionalInfo')) { |
|
|
this.onUpdateEntity(); |
|
|
editingEntity.additionalInfo = |
|
|
|
|
|
mergeDeep((this.editingEntity as any).additionalInfo, this.entityComponent.entityFormValue()?.additionalInfo); |
|
|
|
|
|
} |
|
|
} |
|
|
this.entitiesTableConfig.saveEntity(editingEntity, this.editingEntity).subscribe( |
|
|
}); |
|
|
(entity) => { |
|
|
|
|
|
this.entity = entity; |
|
|
|
|
|
this.entityComponent.entity = entity; |
|
|
|
|
|
if (this.entityTabsComponent) { |
|
|
|
|
|
this.entityTabsComponent.entity = entity; |
|
|
|
|
|
} |
|
|
|
|
|
this.isEdit = false; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
confirmForm(): FormGroup { |
|
|
confirmForm(): FormGroup { |
|
|
return this.detailsForm; |
|
|
return this.detailsForm; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private onUpdateEntity() { |
|
|
|
|
|
this.broadcast.broadcast('updateBreadcrumb'); |
|
|
|
|
|
this.isReadOnly = this.entitiesTableConfig.detailsReadonly(this.entity); |
|
|
|
|
|
this.headerTitle = this.entitiesTableConfig.entityTitle(this.entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private deleteEntity($event: Event, entity: BaseData<HasId>) { |
|
|
private deleteEntity($event: Event, entity: BaseData<HasId>) { |
|
|
if ($event) { |
|
|
if ($event) { |
|
|
$event.stopPropagation(); |
|
|
$event.stopPropagation(); |
|
|
|