Skip to content

Commit f43c949

Browse files
authored
Merge pull request #2100 from umbraco/v14/bugfix/create-new-datatype-config-directly
Bugfix: Create new datatype configuration directly
2 parents e3ef676 + 31ccc56 commit f43c949

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

src/packages/data-type/modals/data-type-picker-flow/data-type-picker-flow-modal.element.ts

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,18 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
268268
${when(
269269
dataTypesEntries.length > 0,
270270
() =>
271-
html` <h5 class="choice-type-headline">Available configurations</h5>
271+
html` <h5 class="choice-type-headline">
272+
<umb-localize key="contentTypeEditor_searchResultSettings">Available configurations</umb-localize>
273+
</h5>
272274
${this._renderDataTypes()}${this.#renderLoadMore()}`,
273275
)}
274276
${when(
275277
editorUIEntries.length > 0,
276278
() =>
277-
html` <h5 class="choice-type-headline">Create a new configuration</h5>
278-
${this._renderUIs()}`,
279+
html` <h5 class="choice-type-headline">
280+
<umb-localize key="contentTypeEditor_searchResultEditors">Create a new configuration</umb-localize>
281+
</h5>
282+
${this._renderUIs(true)}`,
279283
)}
280284
`;
281285
}
@@ -298,41 +302,54 @@ export class UmbDataTypePickerFlowModalElement extends UmbModalBaseElement<
298302
);
299303
}
300304

301-
private _renderUIs() {
305+
private _renderUIs(createAsNewOnPick?: boolean) {
302306
if (!this._groupedPropertyEditorUIs) return nothing;
303307

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

306310
return entries.map(
307311
([key, value]) =>
308312
html` <h5 class="category-name">${key === 'undefined' ? 'Uncategorized' : key}</h5>
309-
${this._renderGroupUIs(value)}`,
313+
${this._renderGroupUIs(value, createAsNewOnPick)}`,
310314
);
311315
}
312316

313-
private _renderGroupUIs(uis: Array<ManifestPropertyEditorUi>) {
317+
private _renderGroupUIs(uis: Array<ManifestPropertyEditorUi>, createAsNewOnPick?: boolean) {
314318
return html` <ul id="item-grid">
315319
${this._dataTypePickerModalRouteBuilder
316320
? repeat(
317321
uis,
318322
(propertyEditorUI) => propertyEditorUI.alias,
319-
(propertyEditorUI) =>
320-
html` <li class="item">
321-
<uui-button
322-
type="button"
323-
label="${propertyEditorUI.meta.label || propertyEditorUI.name}"
324-
href=${this._dataTypePickerModalRouteBuilder!({ uiAlias: propertyEditorUI.alias })}>
325-
<div class="item-content">
326-
<umb-icon name="${propertyEditorUI.meta.icon}" class="icon"></umb-icon>
327-
${propertyEditorUI.meta.label || propertyEditorUI.name}
328-
</div>
329-
</uui-button>
330-
</li>`,
323+
(propertyEditorUI) => {
324+
return html` <li class="item">${this._renderDataTypeButton(propertyEditorUI, createAsNewOnPick)}</li>`;
325+
},
331326
)
332327
: ''}
333328
</ul>`;
334329
}
335330

331+
private _renderDataTypeButton(propertyEditorUI: ManifestPropertyEditorUi, createAsNewOnPick?: boolean) {
332+
if (createAsNewOnPick) {
333+
return html` <uui-button
334+
label="${propertyEditorUI.meta.label || propertyEditorUI.name}"
335+
@click=${() => this._createDataType(propertyEditorUI.alias)}>
336+
${this._renderItemContent(propertyEditorUI)}
337+
</uui-button>`;
338+
} else {
339+
return html` <uui-button
340+
label="${propertyEditorUI.meta.label || propertyEditorUI.name}"
341+
href=${this._dataTypePickerModalRouteBuilder!({ uiAlias: propertyEditorUI.alias })}>
342+
${this._renderItemContent(propertyEditorUI)}
343+
</uui-button>`;
344+
}
345+
}
346+
private _renderItemContent(propertyEditorUI: ManifestPropertyEditorUi) {
347+
return html`<div class="item-content">
348+
<umb-icon name="${propertyEditorUI.meta.icon}" class="icon"></umb-icon>
349+
${propertyEditorUI.meta.label || propertyEditorUI.name}
350+
</div>`;
351+
}
352+
336353
private _renderGroupDataTypes(dataTypes: Array<UmbDataTypeItemModel>) {
337354
return html` <ul id="item-grid">
338355
${repeat(

0 commit comments

Comments
 (0)