Skip to content

Render Property "vary by segment"-toggle #18813

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

Merged
merged 7 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
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
10 changes: 0 additions & 10 deletions src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1705,16 +1705,6 @@ export default {
compositionUsageHeading: 'Where is this composition used?',
compositionUsageSpecification:
'This composition is currently used in the composition of the following\n Content Types:\n ',
variantsHeading: 'Allow variations',
cultureVariantHeading: 'Allow vary by culture',
segmentVariantHeading: 'Allow segmentation',
cultureVariantLabel: 'Vary by culture',
segmentVariantLabel: 'Vary by segments',
variantsDescription: 'Allow editors to create content of this type in different languages.',
cultureVariantDescription: 'Allow editors to create content of different languages.',
segmentVariantDescription: 'Allow editors to create segments of this content.',
allowVaryByCulture: 'Allow varying by culture',
allowVaryBySegment: 'Allow segmentation',
elementType: 'Element Type',
elementHeading: 'Is an Element Type',
elementDescription:
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Web.UI.Client/src/assets/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1735,11 +1735,11 @@ export default {
compositionUsageHeading: 'Where is this composition used?',
compositionUsageSpecification:
'This composition is currently used in the composition of the following\n Content Types:\n ',
variantsHeading: 'Allow variations',
variantsHeading: 'Variation',
cultureVariantHeading: 'Allow vary by culture',
segmentVariantHeading: 'Allow segmentation',
cultureVariantLabel: 'Vary by culture',
segmentVariantLabel: 'Vary by segments',
segmentVariantLabel: 'Vary by segment',
variantsDescription: 'Allow editors to create content of this type in different languages.',
cultureVariantDescription: 'Allow editors to create content of different languages.',
segmentVariantDescription: 'Allow editors to create segments of this content.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement {
<uui-icon name="icon-shuffle"></uui-icon> ${this.localize.term('contentTypeEditor_cultureVariantLabel')}
</uui-tag>`
: nothing}
${this.property.variesBySegment
? html`<uui-tag look="default">
<uui-icon name="icon-shuffle"></uui-icon> ${this.localize.term('contentTypeEditor_segmentVariantLabel')}
</uui-tag>`
: nothing}
${this.property.appearance?.labelOnTop == true
? html`<uui-tag look="default">
<span>${this.localize.term('contentTypeEditor_displaySettingsLabelOnTop')}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,12 @@

#onVaryByCultureChange(event: UUIBooleanInputEvent) {
const variesByCulture = event.target.checked;
this.updateValue({
variesByCulture,
});
this.updateValue({ variesByCulture });
}

#onVaryBySegmentChange(event: UUIBooleanInputEvent) {
const variesBySegment = event.target.checked;
this.updateValue({ variesBySegment });
}

override render() {
Expand Down Expand Up @@ -266,15 +269,12 @@
<umb-localize key="validation_customValidation">Custom validation</umb-localize>
</p>
${this.#renderCustomValidation()}
</div>
<hr />
${this.#renderVariationControls()}
<div class="container">
<b style="margin-bottom: var(--uui-size-space-3)">
<umb-localize key="contentTypeEditor_displaySettingsHeadline">Appearance</umb-localize>
</b>
<div id="appearances">${this.#renderAlignLeftIcon()} ${this.#renderAlignTopIcon()}</div>
</div>
<umb-property-layout label="#contentTypeEditor_displaySettingsHeadline" orientation="vertical">
<div id="appearances" slot="editor">${this.#renderAlignLeftIcon()} ${this.#renderAlignTopIcon()}</div>
</umb-property-layout>

Check notice on line 277 in src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/views/settings/property-workspace-view-settings.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

✅ No longer an issue: Large Method

UmbPropertyTypeWorkspaceViewSettingsElement.render is no longer above the threshold for lines of code
${this.#renderMemberTypeOptions()}
</uui-box>
`;
Expand Down Expand Up @@ -405,18 +405,35 @@

#renderVariationControls() {
return this._contentTypeVariesByCulture || this._contentTypeVariesBySegment
? html` <div class="container">
<b><umb-localize key="contentTypeEditor_variantsHeading">Allow variations</umb-localize></b>
${this._contentTypeVariesByCulture ? this.#renderVaryByCulture() : ''}
</div>
<hr />`
? html` <umb-property-layout label="#contentTypeEditor_variantsHeading" orientation="vertical">
<umb-stack slot="editor" look="compact">
${this._contentTypeVariesByCulture ? this.#renderVaryByCulture() : nothing}
${this._contentTypeVariesBySegment ? this.#renderVaryBySegment() : nothing}
</umb-stack>
</umb-property-layout>`
: '';
}

#renderVaryByCulture() {
return html`<uui-toggle
@change=${this.#onVaryByCultureChange}
.checked=${this._data?.variesByCulture ?? false}
label=${this.localize.term('contentTypeEditor_cultureVariantLabel')}></uui-toggle> `;
return html`
<div>
<uui-toggle
@change=${this.#onVaryByCultureChange}
.checked=${this._data?.variesByCulture ?? false}
label=${this.localize.term('contentTypeEditor_cultureVariantLabel')}></uui-toggle>
</div>
`;
}

Check warning on line 426 in src/Umbraco.Web.UI.Client/src/packages/core/property-type/workspace/views/settings/property-workspace-view-settings.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Code Duplication

The module contains 4 functions with similar structure: UmbPropertyTypeWorkspaceViewSettingsElement.renderAlignLeftIcon,UmbPropertyTypeWorkspaceViewSettingsElement.renderAlignTopIcon,UmbPropertyTypeWorkspaceViewSettingsElement.renderVaryByCulture,UmbPropertyTypeWorkspaceViewSettingsElement.renderVaryBySegment. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

#renderVaryBySegment() {
return html`
<div>
<uui-toggle
@change=${this.#onVaryBySegmentChange}
.checked=${this._data?.variesBySegment ?? false}
label=${this.localize.term('contentTypeEditor_segmentVariantLabel')}></uui-toggle>
</div>
`;
}

static override styles = [
Expand Down
Loading