Skip to content

Commit

Permalink
134 show datatype level plugins in datatype view (#135)
Browse files Browse the repository at this point in the history
* added datatype plugin
* added PluginTabItems to datatype-details
* reworked tab interfaces
  • Loading branch information
Julian-Mueller-GIP authored Dec 13, 2024
1 parent 7042cb1 commit 96799bd
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 60 deletions.
90 changes: 53 additions & 37 deletions document/datatype/datatype-details/datatype-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Injector, Input, OnDestroy, Optional } from '@angular/core';

import { PluginService } from '@pmod/document/plugin.service';
import { XoDataType } from '@pmod/xo/data-type.model';
import { XoDetailsItem } from '@pmod/xo/details-item.model';
import { I18nService } from '@zeta/i18n';
import { XcTabBarItem } from '@zeta/xc';
import { XoBaseDefinition, XoDefinitionBundle } from '@zeta/xc/xc-form/definitions/xo/base-definition.model';

import { BehaviorSubject, Subject } from 'rxjs';
import { BehaviorSubject, combineLatest, map, Observable, of, Subject } from 'rxjs';

import { XoRuntimeContext } from '../../../xo/runtime-context.model';
import { ComponentMappingService } from '../../component-mapping.service';
import { DocumentService } from '../../document.service';
import { WorkflowDetailLevelService } from '../../workflow-detail-level.service';
import { ModellingItemComponent } from '../../workflow/shared/modelling-object.component';
import { BaseTabData, DataTypeTabData, DocumentationTabData, DocumentTabData, MetaTabData } from '../tabs/datatype-tab.component';
import { DocumentationTabData, DocumentTabData, MetaTabData, PluginTabData } from '../tabs/datatype-tab.component';
import { DataTypePluginTabComponent } from '../tabs/datatype/datatype-plugin-tab.component';
import { DataTypeStorableTabComponent } from '../tabs/datatype/datatype-storable-tab.component';
import { DocumentationTabComponent } from '../tabs/shared/documentation-tab.component';
import { MetaTabComponent } from '../tabs/shared/meta-tab.component';
Expand All @@ -50,7 +53,6 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements
set isStorable(value: boolean) {
if (value !== this._isStorable) {
this._isStorable = value;
this.updateTabBarItemList();
}
}

Expand All @@ -62,9 +64,9 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements
set dataType(value: XoDataType) {
this.setModel(value);
if (value) {
this.updateTabBarItemList();
this.refreshTabs();
}
this.cdr.markForCheck();
}

@Input()
Expand All @@ -77,9 +79,7 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements

private _isStorable = false;

docTabUpdate: Subject<DocumentationTabData> = new BehaviorSubject(this.buildDocTabData());
metaTabUpdate: Subject<MetaTabData> = new BehaviorSubject(this.buildMetaTabData());
dataTypeTabUpdate: Subject<DataTypeTabData> = new BehaviorSubject(this.buildDataTypeTabData());
tabUpdate: Subject<XoDataType> = new BehaviorSubject(this.dataType);

readonly documentationTabItem: XcTabBarItem<DocumentTabData<DocumentationTabData>> = {
closable: false,
Expand All @@ -88,7 +88,8 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements
data: <DocumentTabData<DocumentationTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
update: this.docTabUpdate.asObservable()
readonly: this.readonly,
update: this.tabUpdate.asObservable().pipe(map(dataType => this.buildDocTabData(dataType)))
}
};

Expand All @@ -99,42 +100,42 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements
data: <DocumentTabData<MetaTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
update: this.metaTabUpdate.asObservable()
readonly: this.readonly,
update: this.tabUpdate.asObservable().pipe(map(dataType => this.buildMetaTabData(dataType)))
}
};

readonly storableTabItem: XcTabBarItem<DocumentTabData<DataTypeTabData>> = {
readonly storableTabItem: XcTabBarItem<DocumentTabData<XoDataType>> = {
closable: false,
component: DataTypeStorableTabComponent,
name: 'ODS Information',
data: <DocumentTabData<DataTypeTabData>>{
data: <DocumentTabData<XoDataType>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
update: this.dataTypeTabUpdate.asObservable()
readonly: this.readonly,
update: this.tabUpdate.asObservable()
}
};

tabBarSelection: XcTabBarItem<DocumentTabData<BaseTabData>>;
tabBarItems: XcTabBarItem<DocumentTabData<BaseTabData>>[];
tabBarSelection: XcTabBarItem<DocumentTabData<any>>;
tabBarItems: XcTabBarItem<DocumentTabData<any>>[];

constructor(
elementRef: ElementRef,
componentMappingService: ComponentMappingService,
documentService: DocumentService,
detailLevelService: WorkflowDetailLevelService,
private readonly pluginService: PluginService,
private readonly i18nService: I18nService,
private readonly cdr: ChangeDetectorRef,
@Optional() injector: Injector
) {
super(elementRef, componentMappingService, documentService, detailLevelService, injector);
this.tabBarSelection = this.documentationTabItem;
this.updateTabBarItemList();
}

ngOnDestroy() {
this.docTabUpdate.complete();
this.metaTabUpdate.complete();
this.dataTypeTabUpdate.complete();
this.tabUpdate.complete();
super.ngOnDestroy();
}

Expand All @@ -143,26 +144,17 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements
}


private buildDocTabData(): DocumentationTabData {
return <DocumentationTabData> {
documentationArea: this.dataType?.documentationArea,
readonly: this.readonly
private buildDocTabData(dataType: XoDataType): DocumentationTabData {
return <DocumentationTabData>{
documentationArea: dataType.documentationArea
};
}

private buildMetaTabData(): MetaTabData {
return <MetaTabData> {
metaTagArea: this.dataType?.metaTagArea,
private buildMetaTabData(dataType: XoDataType): MetaTabData {
return <MetaTabData>{
metaTagArea: dataType.metaTagArea,
objectIdKey: '',
objectId: '',
readonly: this.readonly
};
}

private buildDataTypeTabData(): DataTypeTabData {
return <DataTypeTabData> {
dataType: this.dataType,
readonly: this.readonly
objectId: ''
};
}

Expand All @@ -171,12 +163,36 @@ export class DataTypeDetailsComponent extends ModellingItemComponent implements
if (this._isStorable) {
this.tabBarItems.push(this.storableTabItem);
}
if (this.dataType.plugin?.guiDefiningWorkflow) {
combineLatest(
this.dataType.plugin?.guiDefiningWorkflow.data.map(
value => this.pluginService.getFromCacheOrCallWorkflow(value)
)
).subscribe(bundles => {
bundles.forEach(bundle => {
bundle.data.push(this.dataType.plugin.context);
this.tabBarItems.push(this.createPluginTabItem(bundle, (bundle.definition as XoBaseDefinition).label));
});
});
}
this.cdr.markForCheck();
}

private refreshTabs() {
this.docTabUpdate.next(this.buildDocTabData());
this.metaTabUpdate.next(this.buildMetaTabData());
this.dataTypeTabUpdate.next(this.buildDataTypeTabData());
this.tabUpdate.next(this.dataType);
}

private createPluginTabItem(bundle: XoDefinitionBundle, tabName: string): XcTabBarItem<PluginTabData> {
return <XcTabBarItem<PluginTabData>> {
closable: false,
component: DataTypePluginTabComponent,
name: tabName || 'Plugin',
data: <PluginTabData>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
update: of() as Observable<XoDataType>,
bundle: bundle
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ComponentMappingService } from '../../component-mapping.service';
import { DocumentService } from '../../document.service';
import { WorkflowDetailLevelService } from '../../workflow-detail-level.service';
import { ModellingItemComponent } from '../../workflow/shared/modelling-object.component';
import { BaseTabData, DocumentationTabData, DocumentTabData } from '../tabs/datatype-tab.component';
import { DocumentationTabData, DocumentTabData } from '../tabs/datatype-tab.component';
import { DocumentationTabComponent } from '../tabs/shared/documentation-tab.component';


Expand Down Expand Up @@ -70,12 +70,13 @@ export class ExceptionTypeDetailsComponent extends ModellingItemComponent implem
data: <DocumentTabData<DocumentationTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
readonly: this.readonly,
update: this.docTabUpdate.asObservable()
}
};

tabBarSelection: XcTabBarItem<DocumentTabData<BaseTabData>>;
tabBarItems: XcTabBarItem<DocumentTabData<BaseTabData>>[];
tabBarSelection: XcTabBarItem<DocumentTabData<any>>;
tabBarItems: XcTabBarItem<DocumentTabData<any>>[];

constructor(
elementRef: ElementRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { XoRuntimeContext } from '../../../xo/runtime-context.model';
import { ComponentMappingService } from '../../component-mapping.service';
import { DocumentService } from '../../document.service';
import { ModellingItemComponent } from '../../workflow/shared/modelling-object.component';
import { BaseTabData, DocumentTabData, MetaTabData, VariableTabData } from '../tabs/datatype-tab.component';
import { DocumentTabData, MetaTabData, VariableTabData } from '../tabs/datatype-tab.component';
import { MemberVariableBaseTabComponent } from '../tabs/member-variable/member-variable-base-tab.component';
import { MemberVariableStorableTabComponent } from '../tabs/member-variable/member-variable-storable-tab.component';
import { MetaTabComponent } from '../tabs/shared/meta-tab.component';
Expand Down Expand Up @@ -78,6 +78,7 @@ export class MemberVariableDetailsComponent extends ModellingItemComponent imple
data: <DocumentTabData<VariableTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
readonly: this.readonly,
update: this.memberTabUpdate.asObservable()
}
};
Expand All @@ -89,6 +90,7 @@ export class MemberVariableDetailsComponent extends ModellingItemComponent imple
data: <DocumentTabData<MetaTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
readonly: this.readonly,
update: this.metaTabUpdate.asObservable()
}
};
Expand All @@ -100,12 +102,13 @@ export class MemberVariableDetailsComponent extends ModellingItemComponent imple
data: <DocumentTabData<VariableTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
readonly: this.readonly,
update: this.memberTabUpdate.asObservable()
}
};

tabBarSelection: XcTabBarItem<DocumentTabData<BaseTabData>>;
tabBarItems: XcTabBarItem<DocumentTabData<BaseTabData>>[];
tabBarSelection: XcTabBarItem<DocumentTabData<any>>;
tabBarItems: XcTabBarItem<DocumentTabData<any>>[];

constructor(
elementRef: ElementRef,
Expand Down
8 changes: 5 additions & 3 deletions document/datatype/method-details/method-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { XoMethod } from '../../../xo/method.model';
import { ComponentMappingService } from '../../component-mapping.service';
import { DocumentService } from '../../document.service';
import { ModellingItemComponent } from '../../workflow/shared/modelling-object.component';
import { BaseTabData, DocumentTabData, MetaTabData, MethodTabData } from '../tabs/datatype-tab.component';
import { DocumentTabData, MetaTabData, MethodTabData } from '../tabs/datatype-tab.component';
import { MethodBaseTabComponent } from '../tabs/method/method-base-tab.component';
import { MethodImplementationTabComponent } from '../tabs/method/method-implementation-tab.component';
import { MetaTabComponent } from '../tabs/shared/meta-tab.component';
Expand Down Expand Up @@ -66,6 +66,7 @@ export class MethodDetailsComponent extends ModellingItemComponent implements On
data: <DocumentTabData<MethodTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
readonly: this.readonly,
update: this.methodTabUpdate.asObservable()
}
};
Expand All @@ -77,6 +78,7 @@ export class MethodDetailsComponent extends ModellingItemComponent implements On
data: <DocumentTabData<MetaTabData>>{
documentModel: this.documentModel,
performAction: this.performAction.bind(this),
readonly: this.readonly,
update: this.metaTabUpdate.asObservable()
}
};
Expand All @@ -92,8 +94,8 @@ export class MethodDetailsComponent extends ModellingItemComponent implements On
}
};

tabBarSelection: XcTabBarItem<DocumentTabData<BaseTabData>>;
tabBarItems: XcTabBarItem<DocumentTabData<BaseTabData>>[];
tabBarSelection: XcTabBarItem<DocumentTabData<any>>;
tabBarItems: XcTabBarItem<DocumentTabData<any>>[];


constructor(
Expand Down
25 changes: 12 additions & 13 deletions document/datatype/tabs/datatype-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,39 @@ import { XoStaticMethod } from '@pmod/xo/static-method.model';
import { XoTextArea } from '@pmod/xo/text-area.model';
import { FullQualifiedName } from '@zeta/api';
import { XcTabComponent } from '@zeta/xc';
import { XoDefinitionBundle } from '@zeta/xc/xc-form/definitions/xo/base-definition.model';

import { Observable, Subject, takeUntil } from 'rxjs';


export interface DocumentTabData<D> {
documentModel: DocumentModel<DocumentItem>;
performAction: (action: TriggeredAction) => void;
readonly: boolean;
update: Observable<D>;
}

export interface BaseTabData {
readonly: boolean;
}

export interface DocumentationTabData extends BaseTabData {
export interface DocumentationTabData {
documentationArea: XoTextArea;
}

export interface MetaTabData extends BaseTabData {
export interface MetaTabData {
metaTagArea: XoMetaTagArea;
objectIdKey: string;
objectId: string;
}

export interface DataTypeTabData extends BaseTabData {
dataType: XoDataType;
export interface PluginTabData extends DocumentTabData<XoDataType> {
bundle: XoDefinitionBundle;
}

export interface VariableTabData extends BaseTabData {
export interface VariableTabData {
variable: XoMemberVariable;
dataTypeRTC: XoRuntimeContext;
}

export interface MethodTabData extends BaseTabData {
export interface MethodTabData {
method: XoMethod;
}

Expand All @@ -81,13 +80,13 @@ export interface MethodTabData extends BaseTabData {
@Component({
template: ''
})
export abstract class DatatypeTabComponent<D extends BaseTabData> extends XcTabComponent<void, DocumentTabData<D>> implements OnDestroy {
export abstract class DatatypeTabComponent<D, E extends DocumentTabData<D> = DocumentTabData<D>> extends XcTabComponent<void, E> implements OnDestroy {

private readonly destroySubject = new Subject<void>();
protected tabData: D;

get readonly(): boolean {
return this.tabData?.readonly;
return this.injectedData.readonly;
}

get documentModel(): DocumentModel<DocumentItem> {
Expand Down Expand Up @@ -126,11 +125,11 @@ export abstract class DatatypeTabComponent<D extends BaseTabData> extends XcTabC
@Component({
template: ''
})
export abstract class DatatypeDetailsTabComponent extends DatatypeTabComponent<DataTypeTabData> {
export abstract class DatatypeDetailsTabComponent extends DatatypeTabComponent<XoDataType> {


get dataType(): XoDataType {
return this.tabData?.dataType;
return this.tabData;
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<xc-definition-proxy
[xc-base-definition]="definition"
[xc-base-definition-data]="data"
[xc-definition-observer]="pluginService"
></xc-definition-proxy>
Loading

0 comments on commit 96799bd

Please sign in to comment.