1
- import type { UmbLanguageDetailModel } from '../../types.js' ;
2
1
import { UMB_LANGUAGE_WORKSPACE_CONTEXT } from './language-workspace.context-token.js' ;
3
- import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui' ;
4
- import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui' ;
5
- import { css , html , customElement , state , ifDefined } from '@umbraco-cms/backoffice/external/lit' ;
6
- import { UmbLitElement , umbFocus } from '@umbraco-cms/backoffice/lit-element' ;
2
+ import { html , customElement , state } from '@umbraco-cms/backoffice/external/lit' ;
3
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
7
4
import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
8
5
@customElement ( 'umb-language-workspace-editor' )
9
6
export class UmbLanguageWorkspaceEditorElement extends UmbLitElement {
10
7
#workspaceContext?: typeof UMB_LANGUAGE_WORKSPACE_CONTEXT . TYPE ;
11
8
12
- @state ( )
13
- _language ?: UmbLanguageDetailModel ;
14
-
15
9
@state ( )
16
10
_isNew ?: boolean ;
17
11
@@ -20,73 +14,21 @@ export class UmbLanguageWorkspaceEditorElement extends UmbLitElement {
20
14
21
15
this . consumeContext ( UMB_LANGUAGE_WORKSPACE_CONTEXT , ( context ) => {
22
16
this . #workspaceContext = context ;
23
- this . #observeData ( ) ;
17
+ this . observe ( this . #workspaceContext . isNew , ( isNew ) => ( this . _isNew = isNew ) ) ;
24
18
} ) ;
25
19
}
26
20
27
- #observeData( ) {
28
- if ( ! this . #workspaceContext) return ;
29
- this . observe ( this . #workspaceContext. data , ( data ) => {
30
- this . _language = data ;
31
- } ) ;
32
- this . observe ( this . #workspaceContext. isNew , ( isNew ) => {
33
- this . _isNew = isNew ;
34
- } ) ;
35
- }
36
-
37
- #handleInput( event : UUIInputEvent ) {
38
- if ( event instanceof UUIInputEvent ) {
39
- const target = event . composedPath ( ) [ 0 ] as UUIInputElement ;
40
-
41
- if ( typeof target ?. value === 'string' ) {
42
- this . #workspaceContext?. setName ( target . value ) ;
43
- }
44
- }
45
- }
46
-
47
21
override render ( ) {
48
22
return html `< umb-workspace-editor
49
23
alias ="Umb.Workspace.Language "
50
24
back-path ="section/settings/workspace/language-root ">
51
- <div id= "header" slot = "header" >
52
- ${ this . _isNew
53
- ? html `<strong> Add language </ strong> `
54
- : html `<uui- input
55
- label= "Language name"
56
- value = ${ ifDefined ( this . _language ?. name ) }
57
- @input = "${ this . #handleInput} "
58
- ${ umbFocus ( ) } > </ uui- input> ` }
59
- </ div>
25
+ ${ this . _isNew
26
+ ? html `< h3 slot ="header "> Add language</ h3 > `
27
+ : html `< umb-workspace-name slot ="header "> </ umb-workspace-name > ` }
60
28
</ umb-workspace-editor > ` ;
61
29
}
62
30
63
- static override styles = [
64
- UmbTextStyles ,
65
- css `
66
- # header {
67
- display : flex;
68
- gap : var (--uui-size-space-4 );
69
- width : 100% ;
70
- }
71
-
72
- uui-input {
73
- width : 100% ;
74
- }
75
-
76
- strong {
77
- display : flex;
78
- align-items : center;
79
- }
80
-
81
- # footer-into {
82
- padding : 0 var (--uui-size-layout-1 );
83
- }
84
-
85
- uui-input : not (: focus ) {
86
- border : 1px solid transparent;
87
- }
88
- ` ,
89
- ] ;
31
+ static override styles = [ UmbTextStyles ] ;
90
32
}
91
33
92
34
export default UmbLanguageWorkspaceEditorElement ;
0 commit comments