|
1 |
| -import { UMB_DICTIONARY_WORKSPACE_CONTEXT } from './dictionary-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, state } from '@umbraco-cms/backoffice/external/lit'; |
5 |
| -import { UmbLitElement, umbFocus } from '@umbraco-cms/backoffice/lit-element'; |
| 1 | +import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; |
| 2 | +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; |
6 | 3 |
|
7 | 4 | @customElement('umb-dictionary-workspace-editor')
|
8 | 5 | export class UmbDictionaryWorkspaceEditorElement extends UmbLitElement {
|
9 |
| - @state() |
10 |
| - private _name?: string | null = ''; |
11 |
| - |
12 |
| - #workspaceContext?: typeof UMB_DICTIONARY_WORKSPACE_CONTEXT.TYPE; |
13 |
| - |
14 |
| - constructor() { |
15 |
| - super(); |
16 |
| - |
17 |
| - this.consumeContext(UMB_DICTIONARY_WORKSPACE_CONTEXT, (instance) => { |
18 |
| - this.#workspaceContext = instance; |
19 |
| - this.#observeName(); |
20 |
| - }); |
21 |
| - } |
22 |
| - |
23 |
| - #observeName() { |
24 |
| - if (!this.#workspaceContext) return; |
25 |
| - this.observe(this.#workspaceContext.name, (name) => (this._name = name)); |
26 |
| - } |
27 |
| - |
28 |
| - // TODO. find a way where we don't have to do this for all workspaces. |
29 |
| - #handleInput(event: UUIInputEvent) { |
30 |
| - if (event instanceof UUIInputEvent) { |
31 |
| - const target = event.composedPath()[0] as UUIInputElement; |
32 |
| - |
33 |
| - if (typeof target?.value === 'string') { |
34 |
| - this.#workspaceContext?.setName(target.value); |
35 |
| - } |
36 |
| - } |
37 |
| - } |
38 |
| - |
39 | 6 | override render() {
|
40 | 7 | return html`
|
41 |
| - <umb-workspace-editor alias="Umb.Workspace.Dictionary" back-path="section/dictionary/dashboard"> |
42 |
| - <div id="header" slot="header"> |
43 |
| - <uui-input |
44 |
| - placeholder=${this.localize.term('placeholders_entername')} |
45 |
| - .value=${this._name ?? ''} |
46 |
| - @input="${this.#handleInput}" |
47 |
| - label="${this.localize.term('general_dictionary')} ${this.localize.term('general_name')}" |
48 |
| - ${umbFocus()}></uui-input> |
49 |
| - </div> |
| 8 | + <umb-workspace-editor back-path="section/dictionary/dashboard"> |
| 9 | + <umb-workspace-name slot="header"></umb-workspace-name> |
50 | 10 | </umb-workspace-editor>
|
51 | 11 | `;
|
52 | 12 | }
|
53 |
| - |
54 |
| - static override styles = [ |
55 |
| - css` |
56 |
| - #header { |
57 |
| - display: flex; |
58 |
| - gap: var(--uui-size-space-4); |
59 |
| - width: 100%; |
60 |
| - } |
61 |
| - uui-input { |
62 |
| - width: 100%; |
63 |
| - } |
64 |
| - `, |
65 |
| - ]; |
66 | 13 | }
|
67 | 14 |
|
68 | 15 | export default UmbDictionaryWorkspaceEditorElement;
|
|
0 commit comments