`;
}
+ */
static styles = [
UmbTextStyles,
css`
+ /*
:host {
display: block;
color: var(--uui-color-text);
@@ -133,11 +237,35 @@ export class UmbTemplatingSectionPickerModalElement extends UmbModalBaseElement<
#main umb-insert-section-checkbox:not(:last-of-type) {
margin-bottom: var(--uui-size-space-5);
}
+ */
+
code {
background-color: var(--uui-color-surface-alt);
border: 1px solid var(--uui-color-border);
border-radius: var(--uui-border-radius);
}
+
+ #main {
+ display: grid;
+ grid-gap: var(--uui-size-space-5);
+ }
+
+ .section {
+ display: grid;
+ }
+
+ uui-button {
+ text-align: left;
+ }
+
+ uui-button p {
+ margin-top: 0;
+ }
+
+ uui-input,
+ small {
+ margin-block: var(--uui-size-space-2) var(--uui-size-space-6);
+ }
`,
];
}
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/types.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/types.ts
index 30d70c464b..46069918b5 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/types.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/templating/types.ts
@@ -3,3 +3,9 @@ export enum CodeSnippetType {
dictionaryItem = 'dictionaryItem',
pageField = 'pageField',
}
+
+export enum TemplatingSectionType {
+ renderChildTemplate = 'RenderChildTemplate',
+ renderANamedSection = 'RenderANamedSection',
+ defineANamedSection = 'DefineANamedSection',
+}
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/utils/index.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/utils/index.ts
index 57c84ea4bf..43446d5e20 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/utils/index.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/templating/utils/index.ts
@@ -45,7 +45,7 @@ export const getUmbracoFieldSnippet = (field: string, defaultValue: string | nul
const value = `${field !== null ? `@Model.Value("${field}"` : ''}${
fallback !== null ? `, fallback: ${fallback}` : ''
- }${defaultValue !== null ? `, defaultValue: new HtmlString("${defaultValue}")` : ''}${field ? ')' : ''}`;
+ }${defaultValue !== null ? `, defaultValue: new HtmlString("${defaultValue}")` : ''}${field ? ')' : ')'}`;
return value;
};
From 5149633865c12c16493d2623f05e8d145b14bf24 Mon Sep 17 00:00:00 2001
From: Lone Iversen <108085781+loivsen@users.noreply.github.com>
Date: Mon, 19 Feb 2024 13:09:39 +0100
Subject: [PATCH 3/5] changes
---
.../templating-item-picker-modal.element.ts | 2 +-
...lating-page-field-builder-modal.element.ts | 2 +-
.../modals/templating-section-picker/index.ts | 2 +-
...templating-section-picker-input.element.ts | 150 ---------------
...templating-section-picker-modal.element.ts | 181 +++++-------------
.../template-workspace-editor.element.ts | 1 +
6 files changed, 52 insertions(+), 286 deletions(-)
delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-input.element.ts
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-item-picker/templating-item-picker-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-item-picker/templating-item-picker-modal.element.ts
index de6a71cf18..c535cf824c 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-item-picker/templating-item-picker-modal.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-item-picker/templating-item-picker-modal.element.ts
@@ -96,7 +96,7 @@ export class UmbTemplatingItemPickerModalElement extends UmbModalBaseElement<
@click=${this.#openTemplatingPageFieldModal}
look="placeholder"
label=${this.localize.term('template_insert')}>
- Value (Not implemented)
+ Value
Displays the value of a named field from the current page, with options to modify the value or fallback to
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-page-field-builder/templating-page-field-builder-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-page-field-builder/templating-page-field-builder-modal.element.ts
index e930c3b981..53f73c1416 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-page-field-builder/templating-page-field-builder-modal.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-page-field-builder/templating-page-field-builder-modal.element.ts
@@ -78,7 +78,7 @@ export class UmbTemplatingPageFieldBuilderModalElement extends UmbModalBaseEleme
@click=${this._submit}
color="positive"
look="primary"
- label=${this.localize.term('general_close')}>
+ label=${this.localize.term('general_submit')}>
`;
}
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/index.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/index.ts
index 5bb66c95b5..d5571f146d 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/index.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/index.ts
@@ -1,2 +1,2 @@
-export * from './templating-section-picker-input.element.js';
export * from './templating-section-picker-modal.element.js';
+export * from './templating-section-picker-modal.token.js';
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-input.element.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-input.element.ts
deleted file mode 100644
index c8cf5632d1..0000000000
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-input.element.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui';
-import { UUIBooleanInputElement } from '@umbraco-cms/backoffice/external/uui';
-import { css, html, customElement, property, query } from '@umbraco-cms/backoffice/external/lit';
-import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
-
-@customElement('umb-insert-section-checkbox')
-export class UmbInsertSectionCheckboxElement extends UUIBooleanInputElement {
- renderCheckbox() {
- return html``;
- }
-
- @property({ type: Boolean, attribute: 'show-mandatory' })
- showMandatory = false;
-
- @property({ type: Boolean, attribute: 'show-input' })
- showInput = false;
-
- @query('uui-input')
- input?: UUIInputElement;
-
- @query('form')
- form?: HTMLFormElement;
-
- @query('uui-checkbox')
- checkbox?: HTMLFormElement;
-
- get snippet() {
- if (!this.snippetMethod) return '';
- const snippet = this.snippetMethod(this.inputValue as string, this.isMandatory) ?? '';
- return snippet;
- }
-
- @property({ attribute: false })
- snippetMethod?: (value: string, isMandatory: boolean) => string;
-
- validate() {
- if (!this.form) return true;
-
- this.form.requestSubmit();
- return this.form.checkValidity();
- }
-
- #preventDefault(event: Event) {
- event.preventDefault();
- }
-
- get inputValue() {
- return this.input?.value;
- }
-
- get isMandatory() {
- return this.checkbox?.checked;
- }
-
- /* eslint-disable lit-a11y/click-events-have-key-events */
- render() {
- return html`
- ${super.render()}
-
- ${this.checked ? html`` : ''}${this.label}
-
-
-
here goes some description
-
- ${this.checked && this.showInput
- ? html`
-
- `
- : ''}
- `;
- }
- /* eslint-enable lit-a11y/click-events-have-key-events */
-
- static styles = [
- ...UUIBooleanInputElement.styles,
- UmbTextStyles,
- css`
- :host {
- display: block;
- border-style: dashed;
- background-color: transparent;
- color: var(--uui-color-default-standalone, rgb(28, 35, 59));
- border-color: var(--uui-color-border-standalone, #c2c2c2);
- border-radius: var(--uui-border-radius, 3px);
- border-width: 1px;
- line-height: normal;
- padding: 6px 18px;
- }
-
- :host(:hover),
- :host(:focus),
- :host(:focus-within) {
- background-color: var(--uui-button-background-color-hover, transparent);
- color: var(--uui-color-default-emphasis, #3544b1);
- border-color: var(--uui-color-default-emphasis, #3544b1);
- }
-
- uui-icon {
- background-color: var(--uui-color-positive-emphasis);
- border-radius: 50%;
- padding: 0.2em;
- margin-right: 1ch;
- color: var(--uui-color-positive-contrast);
- font-size: 0.7em;
- }
-
- ::slotted(*) {
- line-height: normal;
- }
-
- .label {
- display: none;
- }
-
- h3,
- p {
- text-align: left;
- }
-
- uui-input {
- width: 100%;
- }
- `,
- ];
-}
-
-export default UmbInsertSectionCheckboxElement;
-
-declare global {
- interface HTMLElementTagNameMap {
- 'umb-insert-section-input': UmbInsertSectionCheckboxElement;
- }
-}
diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-modal.element.ts
index f85df1e65e..fd92e4c79c 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-modal.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/templating-section-picker/templating-section-picker-modal.element.ts
@@ -4,70 +4,50 @@ import type {
UmbTemplatingSectionPickerModalData,
UmbTemplatingSectionPickerModalValue,
} from './templating-section-picker-modal.token.js';
-import type { UmbInsertSectionCheckboxElement } from './templating-section-picker-input.element.js';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
-import { css, html, customElement, queryAll, state } from '@umbraco-cms/backoffice/external/lit';
+import { css, html, customElement, state, query } from '@umbraco-cms/backoffice/external/lit';
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
-import './templating-section-picker-input.element.js';
+import type { UUIBooleanInputElement, UUIInputElement } from '@umbraco-cms/backoffice/external/uui';
@customElement('umb-templating-section-picker-modal')
export class UmbTemplatingSectionPickerModalElement extends UmbModalBaseElement<
UmbTemplatingSectionPickerModalData,
UmbTemplatingSectionPickerModalValue
> {
- /*
- @queryAll('umb-insert-section-checkbox')
- checkboxes!: NodeListOf;
+ @query('#render-named-section-name')
+ private _renderNamedSectionNameInput?: UUIInputElement;
+
+ @query('#define-named-section-name')
+ private _defineNamedSectionNameInput?: UUIInputElement;
+
+ @query('#render-named-section-is-mandatory')
+ private _renderNamedSectionIsMandatoryCheckbox?: UUIBooleanInputElement;
@state()
- selectedCheckbox?: UmbInsertSectionCheckboxElement | null = null;
-
- @state()
- snippet = '';
-*/
- /*
- #chooseSection(event: Event) {
- const target = event.target as UmbInsertSectionCheckboxElement;
- const checkboxes = Array.from(this.checkboxes);
- if (checkboxes.every((checkbox) => checkbox.checked === false)) {
- this.selectedCheckbox = null;
- return;
- }
- if (target.checked) {
- this.selectedCheckbox = target;
- this.snippet = this.selectedCheckbox.snippet ?? '';
- checkboxes.forEach((checkbox) => {
- if (checkbox !== target) {
- checkbox.checked = false;
- }
- });
- }
- }
- */
-
- /*
- firstUpdated() {
- this.selectedCheckbox = this.checkboxes[0];
- }
- */
-
- //snippetMethods = [getRenderBodySnippet, getRenderSectionSnippet, getAddSectionSnippet];
-
- @state()
- private _pickedSection?: TemplatingSectionType;
+ private _pickedSection: TemplatingSectionType = TemplatingSectionType.renderChildTemplate;
#close() {
this.modalContext?.reject();
}
#submit() {
- /*
- const value = this.selectedCheckbox?.snippet;
- if (this.selectedCheckbox?.validate()) {
- this.value = { value: value ?? '' };
- this.modalContext?.submit();
+ switch (this._pickedSection) {
+ case TemplatingSectionType.renderChildTemplate:
+ this.value = { value: getRenderBodySnippet() };
+ break;
+ case TemplatingSectionType.renderANamedSection:
+ this.value = {
+ value: getRenderSectionSnippet(
+ this._renderNamedSectionNameInput?.value as string,
+ this._renderNamedSectionIsMandatoryCheckbox?.checked ?? false,
+ ),
+ };
+ break;
+ case TemplatingSectionType.defineANamedSection:
+ this.value = { value: getAddSectionSnippet(this._defineNamedSectionNameInput?.value as string) };
+ break;
}
- */
+ this.modalContext?.submit();
}
render() {
@@ -81,8 +61,12 @@ export class UmbTemplatingSectionPickerModalElement extends UmbModalBaseElement<