Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Create new datatype configuration directly #2100

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,18 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
${when(
dataTypesEntries.length > 0,
() =>
html` <h5 class="choice-type-headline">Available configurations</h5>
html` <h5 class="choice-type-headline">
<umb-localize key="contentTypeEditor_searchResultSettings">Available configurations</umb-localize>
</h5>
${this._renderDataTypes()}${this.#renderLoadMore()}`,
)}
${when(
editorUIEntries.length > 0,
() =>
html` <h5 class="choice-type-headline">Create a new configuration</h5>
${this._renderUIs()}`,
html` <h5 class="choice-type-headline">
<umb-localize key="contentTypeEditor_searchResultEditors">Create a new configuration</umb-localize>
</h5>
${this._renderUIs(true)}`,
)}
`;
}
Expand All @@ -298,41 +302,54 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
);
}

private _renderUIs() {
private _renderUIs(createAsNewOnPick?: boolean) {
if (!this._groupedPropertyEditorUIs) return nothing;

const entries = Object.entries(this._groupedPropertyEditorUIs);

return entries.map(
([key, value]) =>
html` <h5 class="category-name">${key === 'undefined' ? 'Uncategorized' : key}</h5>
${this._renderGroupUIs(value)}`,
${this._renderGroupUIs(value, createAsNewOnPick)}`,
);
}

private _renderGroupUIs(uis: Array<ManifestPropertyEditorUi>) {
private _renderGroupUIs(uis: Array<ManifestPropertyEditorUi>, createAsNewOnPick?: boolean) {
return html` <ul id="item-grid">
${this._dataTypePickerModalRouteBuilder
? repeat(
uis,
(propertyEditorUI) => propertyEditorUI.alias,
(propertyEditorUI) =>
html` <li class="item">
<uui-button
type="button"
label="${propertyEditorUI.meta.label || propertyEditorUI.name}"
href=${this._dataTypePickerModalRouteBuilder!({ uiAlias: propertyEditorUI.alias })}>
<div class="item-content">
<umb-icon name="${propertyEditorUI.meta.icon}" class="icon"></umb-icon>
${propertyEditorUI.meta.label || propertyEditorUI.name}
</div>
</uui-button>
</li>`,
(propertyEditorUI) => {
return html` <li class="item">${this._renderDataTypeButton(propertyEditorUI, createAsNewOnPick)}</li>`;
},
)
: ''}
</ul>`;
}

private _renderDataTypeButton(propertyEditorUI: ManifestPropertyEditorUi, createAsNewOnPick?: boolean) {
if (createAsNewOnPick) {
return html` <uui-button
label="${propertyEditorUI.meta.label || propertyEditorUI.name}"
@click=${() => this._createDataType(propertyEditorUI.alias)}>
${this._renderItemContent(propertyEditorUI)}
</uui-button>`;
} else {
return html` <uui-button
label="${propertyEditorUI.meta.label || propertyEditorUI.name}"
href=${this._dataTypePickerModalRouteBuilder!({ uiAlias: propertyEditorUI.alias })}>
${this._renderItemContent(propertyEditorUI)}
</uui-button>`;
}
}
private _renderItemContent(propertyEditorUI: ManifestPropertyEditorUi) {
return html`<div class="item-content">
<umb-icon name="${propertyEditorUI.meta.icon}" class="icon"></umb-icon>
${propertyEditorUI.meta.label || propertyEditorUI.name}
</div>`;
}

private _renderGroupDataTypes(dataTypes: Array<UmbDataTypeItemModel>) {
return html` <ul id="item-grid">
${repeat(
Expand Down
Loading