workspace context for property type modal
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbBaseController } from '@umbraco-cms/backoffice/class-api';
|
||||
|
||||
/**
|
||||
* This is a very simplified workspace context, just to serve one for the imitated property type workspace. (As its not a real workspace)
|
||||
*/
|
||||
export class UmbPropertyTypeWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface {
|
||||
#id: string;
|
||||
|
||||
constructor(host: UmbControllerHostElement, id: string) {
|
||||
// TODO: We don't need a repo here, so maybe we should not require this of the UmbEditableWorkspaceContextBase
|
||||
super(host, 'UmbWorkspaceContext');
|
||||
this.#id = id;
|
||||
}
|
||||
|
||||
get workspaceAlias() {
|
||||
return 'UmbWorkspaceContext';
|
||||
}
|
||||
|
||||
getEntityId() {
|
||||
return this.#id;
|
||||
}
|
||||
|
||||
getEntityType() {
|
||||
return 'property-type';
|
||||
}
|
||||
}
|
||||
|
||||
export default UmbPropertyTypeWorkspaceContext;
|
||||
|
||||
export const UMB_PROPERTY_TYPE_WORKSPACE_CONTEXT = new UmbContextToken<
|
||||
UmbWorkspaceContextInterface,
|
||||
UmbPropertyTypeWorkspaceContext
|
||||
>(
|
||||
'UmbWorkspaceContext',
|
||||
undefined,
|
||||
(context): context is UmbPropertyTypeWorkspaceContext => context.getEntityType() === 'property-type',
|
||||
);
|
||||
@@ -1,3 +1,4 @@
|
||||
import { UmbPropertyTypeWorkspaceContext } from './property-settings-modal.context.js';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { UUIBooleanInputEvent, UUIInputEvent, UUISelectEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { PropertyValueMap, css, html, nothing, customElement, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
@@ -10,7 +11,6 @@ import { generateAlias } from '@umbraco-cms/backoffice/utils';
|
||||
import { UMB_DOCUMENT_TYPE_DETAIL_STORE_CONTEXT } from '@umbraco-cms/backoffice/document-type';
|
||||
import { DocumentTypeResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
// TODO: Could base take a token to get its types?.
|
||||
// TODO: Missing a workspace context... unless this should not be a workspace any way.
|
||||
@customElement('umb-property-settings-modal')
|
||||
export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
UmbPropertySettingsModalData,
|
||||
@@ -52,7 +52,8 @@ export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
// TODO: This is actually not good enough, we need to be able to get to the DOCUMENT_WORKSPACE_CONTEXT, so we can have a look at the draft/runtime version of the document. Otherwise 'Vary by culture' is first updated when saved.
|
||||
// NEXT THING TO LOOK AT:
|
||||
// TODO: This is actually not good enough, we need to be able to get to the DOCUMENT_TYPE_WORKSPACE_CONTEXT, so we can have a look at the draft/runtime version of the document. Otherwise 'Vary by culture' is first updated when saved.
|
||||
this.consumeContext(UMB_DOCUMENT_TYPE_DETAIL_STORE_CONTEXT, (instance) => {
|
||||
if (!this.data?.documentTypeId) return;
|
||||
|
||||
@@ -67,6 +68,7 @@ export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
});
|
||||
|
||||
this._originalPropertyData = this.value;
|
||||
new UmbPropertyTypeWorkspaceContext(this, this.value.id);
|
||||
|
||||
const regEx = this.value.validation?.regEx ?? null;
|
||||
if (regEx) {
|
||||
@@ -213,14 +215,14 @@ export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: This would conceptually be a Property Editor Workspace, should be changed at one point in the future.
|
||||
// TODO: This would conceptually be a Property Type Workspace, should be changed at one point in the future.
|
||||
// For now this is hacky made available by giving the element an fixed alias.
|
||||
// This would allow for workspace views and workspace actions.
|
||||
render() {
|
||||
return html`
|
||||
<uui-form>
|
||||
<form @submit="${this.#onSubmit}">
|
||||
<umb-workspace-editor alias="Umb.Workspace.PropertyEditor" headline="Property settings">
|
||||
<umb-workspace-editor alias="Umb.Workspace.PropertyType" headline="Property settings">
|
||||
<div id="content">
|
||||
<uui-box>
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user