fix create new data type modal flow

This commit is contained in:
Niels Lyngsø
2023-12-06 11:45:43 +01:00
parent 1f46d62cbc
commit 9667b5f7d8
4 changed files with 6 additions and 24 deletions

View File

@@ -63,7 +63,6 @@ export class UmbInputDataTypeElement extends FormControlMixin(UmbLitElement) {
};
})
.onSubmit((submitData) => {
console.log('submit Data');
// TODO: we maybe should set the alias to null, if no selection?
this.value = submitData?.selection.join(',') ?? '';
this.dispatchEvent(new UmbChangeEvent());

View File

@@ -33,9 +33,6 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
@state()
private _groupedPropertyEditorUIs: GroupedItems<ManifestPropertyEditorUi> = {};
@state()
private _selection: Array<string> = [];
@state()
private _submitLabel = 'Select';
@@ -82,7 +79,7 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
return { data: { entityType: 'data-type', preset: { propertyEditorUiAlias: params.uiAlias } } };
})
.onSubmit((value) => {
this._select(value?.id);
this._select(value?.unique);
this._submitModal();
});
@@ -116,16 +113,6 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
});
}
connectedCallback(): void {
super.connectedCallback();
if (this.modalContext) {
this.observe(this.modalContext.value, (value) => {
this._selection = value?.selection ?? [];
});
}
}
private _handleDataTypeClick(dataType: EntityTreeItemResponseModel) {
if (dataType.id) {
this._select(dataType.id);
@@ -134,7 +121,7 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
}
private _select(id: string | undefined) {
this._selection = id ? [id] : [];
this._value = { selection: id ? [id] : [] };
}
private _handleFilterInput(event: UUIInputEvent) {
@@ -284,7 +271,7 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
dataTypes,
(dataType) => dataType.id,
(dataType) =>
html`<li class="item" ?selected=${this._selection.includes(dataType.id!)}>
html`<li class="item" ?selected=${this._value.selection.includes(dataType.id!)}>
<uui-button .label=${dataType.name} type="button" @click="${() => this._handleDataTypeClick(dataType)}">
<div class="item-content">
<uui-icon name="${'icon-bug'}" class="icon"></uui-icon>

View File

@@ -123,10 +123,8 @@ export class UmbDataTypeWorkspaceContext
}
private _mergeConfigProperties() {
console.log('schema properties', this._propertyEditorSchemaConfigProperties);
console.log('ui properties', this._propertyEditorUISettingsProperties);
if (this._propertyEditorSchemaConfigProperties && this._propertyEditorUISettingsProperties) {
// TODO: Consider the ability to to omit a schema config if a UI config has same alias. Otherwise we should make an error when this case happens.
this.#properties.next([
...this._propertyEditorSchemaConfigProperties,
...this._propertyEditorUISettingsProperties,
@@ -203,8 +201,6 @@ export class UmbDataTypeWorkspaceContext
async propertyValueByAlias<ReturnType = unknown>(propertyAlias: string) {
await this.#getDataPromise;
// TODO: Merge map..
return combineLatest([
this.#data.asObservablePart((data) => data?.values?.find((x) => x.alias === propertyAlias)?.value as ReturnType),
this.#defaults.asObservablePart(
@@ -215,7 +211,6 @@ export class UmbDataTypeWorkspaceContext
return value ?? defaultValue;
}),
);
//return this.#data.asObservablePart((data) => data?.values?.find((x) => x.alias === propertyAlias)?.value ?? this.getPropertyDefaultValue(propertyAlias) as ReturnType);
}
getPropertyValue<ReturnType = unknown>(propertyAlias: string) {

View File

@@ -6,9 +6,10 @@ export interface UmbWorkspaceData {
preset: Partial<CreateDataTypeRequestModel>;
}
// TODO: It would be good with a WorkspaceValueBaseType, to avoid the hardcoded type for unique here:
export type UmbWorkspaceValue =
| {
id: string;
unique: string;
}
| undefined;