Skip to content

Commit 5ede87a

Browse files
committed
use workspace name in dictionary workspace
1 parent f06f538 commit 5ede87a

File tree

2 files changed

+8
-57
lines changed

2 files changed

+8
-57
lines changed

src/packages/dictionary/workspace/dictionary-workspace-editor.element.ts

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,15 @@
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';
63

74
@customElement('umb-dictionary-workspace-editor')
85
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-
396
override render() {
407
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>
5010
</umb-workspace-editor>
5111
`;
5212
}
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-
];
6613
}
6714

6815
export default UmbDictionaryWorkspaceEditorElement;

src/packages/dictionary/workspace/dictionary-workspace.context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export class UmbDictionaryWorkspaceContext
5656
this._data.updateCurrent({ name });
5757
}
5858

59+
getName() {
60+
return this._data.getCurrent()?.name;
61+
}
62+
5963
setPropertyValue(isoCode: string, translation: string) {
6064
const currentData = this._data.getCurrent();
6165
if (!currentData) return;

0 commit comments

Comments
 (0)