Merge remote-tracking branch 'origin/main' into feature/language-workspace

This commit is contained in:
Jesper Møller Jensen
2023-01-31 05:14:19 +01:00
5 changed files with 27 additions and 23 deletions

View File

@@ -25,7 +25,6 @@ export class UmbDocumentDetailStore extends UmbStoreBase implements UmbContentSt
}
getByKey(key: string) {
console.log("document getByKey", key)
// TODO: use backend cli when available.
fetch(`/umbraco/management/api/v1/document/details/${key}`)
.then((res) => res.json())

View File

@@ -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 { repeat } from 'lit/directives/repeat.js';
import type { UmbWorkspaceEntityContextInterface } from '../../../workspace-context/workspace-entity-context.interface';
import type { ContentProperty, ContentPropertyData, DocumentDetails, MediaDetails } from '@umbraco-cms/models';
@@ -47,19 +46,21 @@ export class UmbWorkspaceViewContentEditElement extends UmbLitElement {
/*
TODO: Property-Context: This observer gets all changes, We need to fix this. it should be simpler.
It should look at length and aliases? as long as they are identical nothing should change.
As they would update them selfs?
An idea to optimize this would be for this to only care about layout, meaning to property data should be watched here.
As the properties could handle their own data on their own?
Should use a Observable for this._workspaceContext.properties
Should use a Observable for example: this._workspaceContext.properties
*/
this.observe(this._workspaceContext.data.pipe(distinctUntilChanged()), (content) => {
this._properties = content.properties;
this._data = content.data;
this.observe(this._workspaceContext.data, (content) => {
this._properties = content?.properties || [];
this._data = content?.data || [];
/*
Maybe we should not give the value, but the umb-content-property should get the context and observe its own data.
Maybe we should not give the value(Data), but the umb-content-property should get the context and observe its own data.
This would become a more specific Observer therefor better performance?.. Note to self: Debate with Mads how he sees this perspective.
*/
});
}, 'observeWorkspaceContextData');
}
render() {

View File

@@ -71,34 +71,34 @@ export class UmbEntityWorkspaceManager<StoreType extends UmbEntityDetailStore<En
}
}
getEntityType() {
getEntityType = () => {
return this._entityType;
}
getEntityKey(): string {
getEntityKey = (): string => {
return this._entityKey;
}
getStore() {
getStore = () => {
return this._store;
}
getData() {
getData = () => {
return this.state.getValue();
}
load(entityKey: string) {
load = (entityKey: string) => {
this.#isNew = false;
this._entityKey = entityKey;
this._observeStore();
}
create(parentKey: string | null) {
create = (parentKey: string | null) => {
this.#isNew = true;
this._entityKey = uuidv4();
this._createAtParentKey = parentKey;
}
save(): Promise<void> {
save = (): Promise<void> => {
if (!this._store) {
// TODO: add a more beautiful error:
@@ -125,7 +125,7 @@ export class UmbEntityWorkspaceManager<StoreType extends UmbEntityDetailStore<En
}
public destroy(): void {
public destroy = (): void => {
this.state.unsubscribe();
}

View File

@@ -1,14 +1,18 @@
import { UmbContextProviderController } from '@umbraco-cms/context-api';
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
/*
TODO: We need to figure out if we like to keep using same alias for all workspace contexts.
If so we need to align on a interface that all of these implements. otherwise consumers cant trust the workspace-context.
*/
export abstract class UmbWorkspaceContext {
protected _host: UmbControllerHostInterface;
constructor(host: UmbControllerHostInterface) {
this._host = host;
new UmbContextProviderController(host, 'UmbWorkspaceContext', this);
new UmbContextProviderController(host, 'umbWorkspaceContext', this);
}
}

View File

@@ -22,10 +22,10 @@ export class UmbPropertyEditorUINumberRangeElement extends UmbLitElement {
public get value() {
return this._value;
}
public set value(value: ValueType) {
this._value = value;
this._minValue = value.min;
this._maxValue = value.max;
public set value(value: ValueType | undefined) {
this._value = value || { min: undefined, max: undefined };
this._minValue = value?.min;
this._maxValue = value?.max;
}
@property({ type: Array, attribute: false })