use of shared workspace-action-node-save

This commit is contained in:
Niels Lyngsø
2022-12-20 20:56:47 +01:00
parent 2629edefe0
commit 838fa1328b
5 changed files with 10 additions and 63 deletions

View File

@@ -1,53 +0,0 @@
import { css, html, LitElement } from 'lit';
import { customElement, state } from 'lit/decorators.js';
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
import type { UUIButtonState } from '@umbraco-ui/uui';
import type { UmbWorkspaceDataTypeContext } from '../../workspace-data-type.context';
import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
@customElement('umb-workspace-action-data-type-save')
export class UmbWorkspaceActionDataTypeSaveElement extends UmbContextConsumerMixin(LitElement) {
static styles = [UUITextStyles, css``];
@state()
private _saveButtonState?: UUIButtonState;
private _workspaceContext?: UmbWorkspaceDataTypeContext;
constructor() {
super();
this.consumeContext('umbWorkspaceContext', (instance) => {
this._workspaceContext = instance;
}
);
}
private async _handleSave() {
if (!this._workspaceContext) return;
this._saveButtonState = 'waiting';
await this._workspaceContext.save().then(() => {
this._saveButtonState = 'success';
}).catch(() => {
this._saveButtonState = 'failed';
})
}
render() {
return html`<uui-button
@click=${this._handleSave}
look="primary"
color="positive"
label="save"
.state="${this._saveButtonState}"></uui-button>`;
}
}
export default UmbWorkspaceActionDataTypeSaveElement;
declare global {
interface HTMLElementTagNameMap {
'umb-workspace-action-data-type-save': UmbWorkspaceActionDataTypeSaveElement;
}
}

View File

@@ -124,7 +124,7 @@ export class UmbWorkspaceDocumentTypeElement extends UmbContextProviderMixin(
type: 'workspaceAction',
alias: 'Umb.WorkspaceAction.DocumentType.Save',
name: 'Save Document Type Workspace Action',
loader: () => import('./actions/save/workspace-action-document-type-save.element'),
loader: () => import('../shared/actions/save/workspace-action-node-save.element'),
meta: {
workspaces: ['Umb.Workspace.DocumentType'],
},

View File

@@ -2,18 +2,18 @@ import { css, html, LitElement } from 'lit';
import { customElement, state } from 'lit/decorators.js';
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
import type { UUIButtonState } from '@umbraco-ui/uui';
import type { UmbWorkspaceDocumentTypeContext } from '../../workspace-document-type.context';
import type { UmbWorkspaceNodeContext } from '../../workspace-context/workspace-node.context';
import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
@customElement('umb-workspace-action-document-type-save')
export class UmbWorkspaceActionDocumentTypeSaveElement extends UmbContextConsumerMixin(LitElement) {
export class UmbWorkspaceActionNodeSaveElement extends UmbContextConsumerMixin(LitElement) {
static styles = [UUITextStyles, css``];
@state()
private _saveButtonState?: UUIButtonState;
private _workspaceContext?: UmbWorkspaceDocumentTypeContext;
private _workspaceContext?: UmbWorkspaceNodeContext;
constructor() {
super();
@@ -45,10 +45,10 @@ export class UmbWorkspaceActionDocumentTypeSaveElement extends UmbContextConsume
}
}
export default UmbWorkspaceActionDocumentTypeSaveElement;
export default UmbWorkspaceActionNodeSaveElement;
declare global {
interface HTMLElementTagNameMap {
'umb-workspace-action-document-type-save': UmbWorkspaceActionDocumentTypeSaveElement;
'umb-workspace-action-node-save': UmbWorkspaceActionNodeSaveElement;
}
}

View File

@@ -244,8 +244,8 @@ export class UmbWorkspaceUserGroupElement extends UmbContextProviderMixin(
{
type: 'workspaceAction',
alias: 'Umb.WorkspaceAction.UserGroup.Save',
name: 'WorkspaceActionUserGroupSave',
loader: () => import('./actions/workspace-action-user-group-save.element'),
name: 'Save User Group Workspace Action',
loader: () => import('../shared/actions/save/workspace-action-node-save.element'),
meta: {
workspaces: ['Umb.Workspace.UserGroup'],
},

View File

@@ -161,8 +161,8 @@ export class UmbWorkspaceUserElement extends UmbContextProviderMixin(
{
type: 'workspaceAction',
alias: 'Umb.WorkspaceAction.User.Save',
name: 'WorkspaceActionUserSave',
loader: () => import('./actions/workspace-action-user-save.element'),
name: 'Save User Workspace Action',
loader: () => import('../shared/actions/save/workspace-action-node-save.element'),
meta: {
workspaces: ['Umb.Workspace.User'],
},