dictionary
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
import { UmbDictionaryWorkspaceContext } from './dictionary-workspace.context.js';
|
||||
import { UUIInputElement, UUIInputEvent, UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
import { UMB_DICTIONARY_WORKSPACE_CONTEXT } from './dictionary-workspace.context';
|
||||
@customElement('umb-dictionary-workspace-editor')
|
||||
export class UmbDictionaryWorkspaceEditorElement extends UmbLitElement {
|
||||
@state()
|
||||
private _name?: string | null = '';
|
||||
|
||||
#workspaceContext?: UmbDictionaryWorkspaceContext;
|
||||
#workspaceContext?: typeof UMB_DICTIONARY_WORKSPACE_CONTEXT.TYPE;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.consumeContext(UMB_WORKSPACE_CONTEXT, (instance) => {
|
||||
this.#workspaceContext = instance as UmbDictionaryWorkspaceContext;
|
||||
this.consumeContext(UMB_DICTIONARY_WORKSPACE_CONTEXT, (instance) => {
|
||||
this.#workspaceContext = instance;
|
||||
this.#observeName();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { UmbEntityWorkspaceContextInterface, UmbWorkspaceContext } from '@umbrac
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { DictionaryItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
|
||||
export class UmbDictionaryWorkspaceContext
|
||||
extends UmbWorkspaceContext<UmbDictionaryRepository, DictionaryItemResponseModel>
|
||||
@@ -83,3 +84,9 @@ export class UmbDictionaryWorkspaceContext
|
||||
this.#data.complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const UMB_DICTIONARY_WORKSPACE_CONTEXT = new UmbContextToken<UmbEntityWorkspaceContextInterface, UmbDictionaryWorkspaceContext>(
|
||||
'UmbWorkspaceContext',
|
||||
(context): context is UmbDictionaryWorkspaceContext => context.getEntityType?.() === 'dictionary-item'
|
||||
);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { UmbDictionaryWorkspaceContext } from '../../dictionary-workspace.context.js';
|
||||
import { UMB_DICTIONARY_WORKSPACE_CONTEXT } from '../../dictionary-workspace.context.js';
|
||||
import { UmbDictionaryRepository } from '../../../repository/dictionary.repository.js';
|
||||
import { UUITextStyles, UUITextareaElement, UUITextareaEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, customElement, state, repeat, ifDefined } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
import { DictionaryItemResponseModel, LanguageResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
@customElement('umb-workspace-view-dictionary-editor')
|
||||
export class UmbWorkspaceViewDictionaryEditorElement extends UmbLitElement {
|
||||
@state()
|
||||
@@ -15,7 +14,7 @@ export class UmbWorkspaceViewDictionaryEditorElement extends UmbLitElement {
|
||||
@state()
|
||||
private _languages: Array<LanguageResponseModel> = [];
|
||||
|
||||
#workspaceContext!: UmbDictionaryWorkspaceContext;
|
||||
#workspaceContext!: typeof UMB_DICTIONARY_WORKSPACE_CONTEXT.TYPE;
|
||||
|
||||
async connectedCallback() {
|
||||
super.connectedCallback();
|
||||
@@ -23,8 +22,8 @@ export class UmbWorkspaceViewDictionaryEditorElement extends UmbLitElement {
|
||||
this.#repo = new UmbDictionaryRepository(this);
|
||||
this._languages = await this.#repo.getLanguages();
|
||||
|
||||
this.consumeContext(UMB_WORKSPACE_CONTEXT, (_instance) => {
|
||||
this.#workspaceContext = _instance as UmbDictionaryWorkspaceContext;
|
||||
this.consumeContext(UMB_DICTIONARY_WORKSPACE_CONTEXT, (_instance) => {
|
||||
this.#workspaceContext = _instance;
|
||||
this.#observeDictionary();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user