1+ import { getQuerySnippet } from '../../utils/index.js' ;
2+ import { UMB_TEMPLATE_QUERY_BUILDER_MODAL } from '../modals/query-builder/index.js' ;
13import { UMB_TEMPLATING_SECTION_PICKER_MODAL } from '../../modals/templating-section-picker/templating-section-picker-modal.token.js' ;
24import type { UmbTemplatingInsertMenuElement } from '../../local-components/insert-menu/insert-menu.element.js' ;
3- import { UMB_TEMPLATE_QUERY_BUILDER_MODAL } from '../modals/query-builder/index.js' ;
4- import { getQuerySnippet } from '../../utils/index.js' ;
55import { UMB_TEMPLATE_WORKSPACE_CONTEXT } from './template-workspace.context-token.js' ;
6- import { toCamelCase } from '@umbraco-cms/backoffice/utils' ;
7- import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui' ;
8- import { css , html , customElement , query , state , nothing , ifDefined } from '@umbraco-cms/backoffice/external/lit' ;
9- import type { UmbModalManagerContext } from '@umbraco-cms/backoffice/modal' ;
10- import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal' ;
6+ import { css , customElement , html , nothing , query , state } from '@umbraco-cms/backoffice/external/lit' ;
117import { UmbLitElement , umbFocus } from '@umbraco-cms/backoffice/lit-element' ;
12- import { Subject , debounceTime } from '@umbraco-cms/backoffice/external/rxjs' ;
13- import type { UmbCodeEditorElement } from '@umbraco-cms/backoffice/code-editor' ;
8+ import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal' ;
149import { UMB_TEMPLATE_PICKER_MODAL } from '@umbraco-cms/backoffice/template' ;
10+ import type { UmbCodeEditorElement } from '@umbraco-cms/backoffice/code-editor' ;
11+ import type { UmbInputWithAliasElement } from '@umbraco-cms/backoffice/components' ;
12+ import type { UmbModalManagerContext } from '@umbraco-cms/backoffice/modal' ;
1513
1614import '@umbraco-cms/backoffice/code-editor' ;
1715import '../../local-components/insert-menu/index.js' ;
@@ -21,13 +19,13 @@ export class UmbTemplateWorkspaceEditorElement extends UmbLitElement {
2119 #modalContext?: UmbModalManagerContext ;
2220
2321 @state ( )
24- private _name ?: string | null = '' ;
22+ private _name ?: string = '' ;
2523
2624 @state ( )
2725 private _content ?: string | null = '' ;
2826
2927 @state ( )
30- private _alias ?: string | null = '' ;
28+ private _alias ?: string = '' ;
3129
3230 @state ( )
3331 private _masterTemplateName ?: string | null = null ;
@@ -40,9 +38,6 @@ export class UmbTemplateWorkspaceEditorElement extends UmbLitElement {
4038
4139 #masterTemplateUnique: string | null = null ;
4240
43- // TODO: Revisit this code, to not use RxJS directly:
44- private inputQuery$ = new Subject < string > ( ) ;
45-
4641 constructor ( ) {
4742 super ( ) ;
4843
@@ -72,25 +67,12 @@ export class UmbTemplateWorkspaceEditorElement extends UmbLitElement {
7267 this . observe ( this . #templateWorkspaceContext. isNew , ( isNew ) => {
7368 this . #isNew = ! ! isNew ;
7469 } ) ;
75-
76- this . inputQuery$ . pipe ( debounceTime ( 250 ) ) . subscribe ( ( nameInputValue ) => {
77- this . #templateWorkspaceContext?. setName ( nameInputValue ) ;
78- if ( this . #isNew) this . #templateWorkspaceContext?. setAlias ( toCamelCase ( nameInputValue ) ) ;
79- } ) ;
8070 } ) ;
8171 }
8272
83- #onNameInput( event : Event ) {
84- const target = event . target as UUIInputElement ;
85- const value = target . value as string ;
86- this . inputQuery$ . next ( value ) ;
87- }
88-
89- #onAliasInput( event : Event ) {
90- event . stopPropagation ( ) ;
91- const target = event . target as UUIInputElement ;
92- const value = target . value as string ;
93- this . #templateWorkspaceContext?. setAlias ( value ) ;
73+ #onNameAndAliasChange( event : InputEvent & { target : UmbInputWithAliasElement } ) {
74+ this . #templateWorkspaceContext?. setName ( event . target . value ?? '' ) ;
75+ this . #templateWorkspaceContext?. setAlias ( event . target . alias ?? '' ) ;
9476 }
9577
9678 #onCodeEditorInput( event : Event ) {
@@ -179,15 +161,17 @@ export class UmbTemplateWorkspaceEditorElement extends UmbLitElement {
179161 // TODO: add correct UI elements
180162 return html `
181163 <umb- wor kspace- edito r alias= "Umb.Workspace.Template" >
182- <uui- input
183- placeholder= ${ this . localize . term ( 'placeholders_entername' ) }
164+ <umb- input- with- alias
184165 slot= "header"
166+ id = "name"
167+ label= ${ this . localize . term ( 'placeholders_entername' ) }
168+ placeholder= ${ this . localize . term ( 'placeholders_entername' ) }
185169 .value = ${ this . _name }
186- @input = ${ this . #onNameInput}
187- label= ${ this . localize . term ( 'template_template' ) }
170+ .alias = ${ this . _alias }
171+ ?auto - generate-alias= ${ this . #isNew}
172+ @change = ${ this . #onNameAndAliasChange}
188173 ${ umbFocus ( ) } >
189- <uui- input- lock slot= "append" value = ${ ifDefined ( this . _alias ! ) } @input = ${ this . #onAliasInput} > </ uui- input- lock>
190- </ uui- input>
174+ </ umb- input- with- alias>
191175
192176 <uui- box>
193177 <div slot= "header" id = "code-edito r- menu- container"> ${ this . #renderMasterTemplatePicker( ) } </ div>
@@ -251,9 +235,8 @@ export class UmbTemplateWorkspaceEditorElement extends UmbLitElement {
251235 --uui-color-divider-standalone : transparent;
252236 }
253237
254- uui -input {
238+ umb -input-with-alias {
255239 width : 100% ;
256- margin : 1em ;
257240 }
258241
259242 # code-editor-menu-container uui-icon : not ([name = 'icon-delete' ]) {
0 commit comments