1
- import { UMB_DATA_TYPE_WORKSPACE_CONTEXT } from './data-type-workspace.context-token.js' ;
2
- import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui' ;
3
- import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui' ;
4
- import { css , html , customElement , property , state } from '@umbraco-cms/backoffice/external/lit' ;
5
- import { UmbLitElement , umbFocus } from '@umbraco-cms/backoffice/lit-element' ;
6
- import type { ManifestWorkspace } from '@umbraco-cms/backoffice/workspace' ;
7
- import { umbBindToValidation } from '@umbraco-cms/backoffice/validation' ;
1
+ import { css , html , customElement } from '@umbraco-cms/backoffice/external/lit' ;
2
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
8
3
/**
9
4
* @element umb-data-type-workspace-editor
10
5
* @description - Element for displaying the Data Type Workspace edit route.
11
6
*/
12
7
@customElement ( 'umb-data-type-workspace-editor' )
13
8
export class UmbDataTypeWorkspaceEditorElement extends UmbLitElement {
14
- @property ( { attribute : false } )
15
- manifest ?: ManifestWorkspace ;
16
-
17
- @state ( )
18
- private _dataTypeName = '' ;
19
-
20
- #workspaceContext?: typeof UMB_DATA_TYPE_WORKSPACE_CONTEXT . TYPE ;
21
-
22
- constructor ( ) {
23
- super ( ) ;
24
-
25
- this . consumeContext ( UMB_DATA_TYPE_WORKSPACE_CONTEXT , ( workspaceContext ) => {
26
- this . #workspaceContext = workspaceContext ;
27
- this . #workspaceContext. createPropertyDatasetContext ( this ) ;
28
- this . #observeName( ) ;
29
- } ) ;
30
- }
31
-
32
- #observeName( ) {
33
- if ( ! this . #workspaceContext) return ;
34
- this . observe ( this . #workspaceContext. name , ( dataTypeName ) => {
35
- if ( dataTypeName !== this . _dataTypeName ) {
36
- this . _dataTypeName = dataTypeName ?? '' ;
37
- }
38
- } ) ;
39
- }
40
-
41
- // TODO. find a way where we don't have to do this for all Workspaces.
42
- #handleInput( event : UUIInputEvent ) {
43
- if ( event instanceof UUIInputEvent ) {
44
- const target = event . composedPath ( ) [ 0 ] as UUIInputElement ;
45
-
46
- if ( typeof target ?. value === 'string' ) {
47
- this . #workspaceContext?. setName ( target . value ) ;
48
- }
49
- }
50
- }
51
-
52
9
override render ( ) {
53
10
return html `
54
11
<umb- wor kspace- edito r alias= "Umb.Workspace.DataType" >
55
- <uui- input
56
- slot= "header"
57
- id = "nameInput"
58
- .value = ${ this . _dataTypeName ?? '' }
59
- @input = "${ this . #handleInput} "
60
- required
61
- ${ umbBindToValidation ( this , `$.name` , this . _dataTypeName ) }
62
- ${ umbFocus ( ) } > </ uui- input>
12
+ <umb- wor kspace- name slot= "header" > </ umb- wor kspace- name>
63
13
</ umb- wor kspace- edito r>
64
14
` ;
65
15
}
@@ -71,10 +21,6 @@ export class UmbDataTypeWorkspaceEditorElement extends UmbLitElement {
71
21
width : 100% ;
72
22
height : 100% ;
73
23
}
74
-
75
- # nameInput {
76
- flex : 1 1 auto;
77
- }
78
24
` ,
79
25
] ;
80
26
}
0 commit comments