name prop for workspace context
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { css, html } from 'lit';
|
||||
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { distinctUntilChanged } from 'rxjs';
|
||||
import type { UmbWorkspaceContentContext } from '../../workspace-content.context';
|
||||
import type { DocumentDetails, MediaDetails } from '@umbraco-cms/models';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
@@ -36,8 +35,8 @@ export class UmbWorkspaceViewContentInfoElement extends UmbLitElement {
|
||||
private _observeContent() {
|
||||
if (!this._workspaceContext) return;
|
||||
|
||||
this.observe(this._workspaceContext.data.pipe(distinctUntilChanged()), (node) => {
|
||||
this._nodeName = node.name as string;
|
||||
this.observe(this._workspaceContext.name, (name) => {
|
||||
this._nodeName = name || '';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { UmbContextConsumerController } from 'src/core/context-api/consume/conte
|
||||
import { UmbObserverController } from '@umbraco-cms/observable-api';
|
||||
import { UmbContextProviderController } from 'src/core/context-api/provide/context-provider.controller';
|
||||
import { EntityTreeItem } from '@umbraco-cms/backend-api';
|
||||
import { UniqueBehaviorSubject } from 'src/core/observable-api/unique-behavior-subject';
|
||||
import { CreateObservablePart, UniqueBehaviorSubject } from 'src/core/observable-api/unique-behavior-subject';
|
||||
|
||||
// TODO: Consider if its right to have this many class-inheritance of WorkspaceContext
|
||||
// TODO: Could we extract this code into a 'Manager' of its own, which will be instantiated by the concrete Workspace Context. This will be more transparent and 'reuseable'
|
||||
@@ -21,8 +21,9 @@ export abstract class UmbWorkspaceContentContext<
|
||||
|
||||
// TODO: figure out how fine grained we want to make our observables.
|
||||
// TODO: add interface
|
||||
protected _data!:UniqueBehaviorSubject<ContentTypeType>;
|
||||
public readonly data: Observable<ContentTypeType>;
|
||||
protected _data;
|
||||
public readonly data;
|
||||
public readonly name;
|
||||
|
||||
protected _notificationService?: UmbNotificationService;
|
||||
|
||||
@@ -45,6 +46,7 @@ export abstract class UmbWorkspaceContentContext<
|
||||
|
||||
this._data = new UniqueBehaviorSubject<ContentTypeType>(defaultData);
|
||||
this.data = this._data.asObservable();
|
||||
this.name = CreateObservablePart(this._data, data => data.name);
|
||||
|
||||
|
||||
this.entityType = entityType;
|
||||
|
||||
Reference in New Issue
Block a user