Merge branch 'release/15.0' into v15/hotfix/export-types
This commit is contained in:
@@ -77,15 +77,17 @@ export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase<never>
|
||||
|
||||
if (variantIds.length) {
|
||||
const publishingRepository = new UmbDocumentPublishingRepository(this._host);
|
||||
await publishingRepository.unpublish(this.args.unique, variantIds);
|
||||
const { error } = await publishingRepository.unpublish(this.args.unique, variantIds);
|
||||
|
||||
const actionEventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbRequestReloadStructureForEntityEvent({
|
||||
unique: this.args.unique,
|
||||
entityType: this.args.entityType,
|
||||
});
|
||||
if (!error) {
|
||||
const actionEventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbRequestReloadStructureForEntityEvent({
|
||||
unique: this.args.unique,
|
||||
entityType: this.args.entityType,
|
||||
});
|
||||
|
||||
actionEventContext.dispatchEvent(event);
|
||||
actionEventContext.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { UmbDocumentTreeItemModel, UmbDocumentTreeItemVariantModel } from '../types.js';
|
||||
import { DocumentVariantStateModel } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
import { css, html, nothing, customElement, state, classMap } from '@umbraco-cms/backoffice/external/lit';
|
||||
import type { UmbAppLanguageContext } from '@umbraco-cms/backoffice/language';
|
||||
import { UMB_APP_LANGUAGE_CONTEXT } from '@umbraco-cms/backoffice/language';
|
||||
@@ -31,7 +32,7 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
|
||||
#observeAppCulture() {
|
||||
this.observe(this.#appLanguageContext!.appLanguageCulture, (value) => {
|
||||
this._currentCulture = value;
|
||||
this._variant = this.#getVariant(value);
|
||||
this._variant = this.#findVariant(value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
|
||||
});
|
||||
}
|
||||
|
||||
#getVariant(culture: string | undefined) {
|
||||
#findVariant(culture: string | undefined) {
|
||||
return this.item?.variants.find((x) => x.culture === culture);
|
||||
}
|
||||
|
||||
@@ -56,16 +57,22 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
|
||||
return this._item?.variants[0].name;
|
||||
}
|
||||
|
||||
const fallbackName = this.#getVariant(this._defaultCulture)?.name ?? this._item?.variants[0].name ?? 'Unknown';
|
||||
// ensure we always have the correct variant data
|
||||
this._variant = this.#findVariant(this._currentCulture);
|
||||
|
||||
const fallbackName = this.#findVariant(this._defaultCulture)?.name ?? this._item?.variants[0].name ?? 'Unknown';
|
||||
return this._variant?.name ?? `(${fallbackName})`;
|
||||
}
|
||||
|
||||
#isDraft() {
|
||||
if (this.#isInvariant()) {
|
||||
return this._item?.variants[0].state === 'Draft';
|
||||
return this._item?.variants[0].state === DocumentVariantStateModel.DRAFT;
|
||||
}
|
||||
|
||||
return this._variant?.state === 'Draft';
|
||||
// ensure we always have the correct variant data
|
||||
this._variant = this.#findVariant(this._currentCulture);
|
||||
|
||||
return this._variant?.state === DocumentVariantStateModel.DRAFT;
|
||||
}
|
||||
|
||||
override renderIconContainer() {
|
||||
|
||||
@@ -712,18 +712,20 @@ export class UmbDocumentWorkspaceContext
|
||||
|
||||
await this.#performSaveOrCreate(variantIds, saveData);
|
||||
|
||||
await this.publishingRepository.publish(
|
||||
const { error } = await this.publishingRepository.publish(
|
||||
unique,
|
||||
variantIds.map((variantId) => ({ variantId })),
|
||||
);
|
||||
|
||||
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbRequestReloadStructureForEntityEvent({
|
||||
unique: this.getUnique()!,
|
||||
entityType: this.getEntityType(),
|
||||
});
|
||||
if (!error) {
|
||||
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbRequestReloadStructureForEntityEvent({
|
||||
unique: this.getUnique()!,
|
||||
entityType: this.getEntityType(),
|
||||
});
|
||||
|
||||
eventContext.dispatchEvent(event);
|
||||
eventContext.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
async #handleSave() {
|
||||
@@ -826,6 +828,12 @@ export class UmbDocumentWorkspaceContext
|
||||
}
|
||||
|
||||
public async publishWithDescendants() {
|
||||
const unique = this.getUnique();
|
||||
if (!unique) throw new Error('Unique is missing');
|
||||
|
||||
const entityType = this.getEntityType();
|
||||
if (!entityType) throw new Error('Entity type is missing');
|
||||
|
||||
const { options, selected } = await this.#determineVariantOptions();
|
||||
|
||||
const modalManagerContext = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
|
||||
@@ -847,13 +855,30 @@ export class UmbDocumentWorkspaceContext
|
||||
|
||||
if (!variantIds.length) return;
|
||||
|
||||
const unique = this.getUnique();
|
||||
if (!unique) throw new Error('Unique is missing');
|
||||
await this.publishingRepository.publishWithDescendants(
|
||||
const { error } = await this.publishingRepository.publishWithDescendants(
|
||||
unique,
|
||||
variantIds,
|
||||
result.includeUnpublishedDescendants ?? false,
|
||||
);
|
||||
|
||||
if (!error) {
|
||||
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
|
||||
// request reload of this entity
|
||||
const structureEvent = new UmbRequestReloadStructureForEntityEvent({
|
||||
entityType,
|
||||
unique,
|
||||
});
|
||||
|
||||
// request reload of the children
|
||||
const childrenEvent = new UmbRequestReloadChildrenOfEntityEvent({
|
||||
entityType,
|
||||
unique,
|
||||
});
|
||||
|
||||
eventContext.dispatchEvent(structureEvent);
|
||||
eventContext.dispatchEvent(childrenEvent);
|
||||
}
|
||||
}
|
||||
|
||||
async delete() {
|
||||
|
||||
@@ -206,7 +206,6 @@ export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
|
||||
#renderGeneralSection() {
|
||||
const editDocumentTypePath = this._routeBuilder?.({ entityType: 'document-type' }) ?? '';
|
||||
const editTemplatePath = this._routeBuilder?.({ entityType: 'template' }) ?? '';
|
||||
|
||||
return html`
|
||||
<div class="general-item">
|
||||
@@ -224,6 +223,20 @@ export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
<umb-icon slot="icon" name=${ifDefined(this._documentTypeIcon)}></umb-icon>
|
||||
</uui-ref-node-document-type>
|
||||
</div>
|
||||
${this.#renderTemplateInput()}
|
||||
<div class="general-item">
|
||||
<strong><umb-localize key="template_id">Id</umb-localize></strong>
|
||||
<span>${this._documentUnique}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
#renderTemplateInput() {
|
||||
if (this._allowedTemplates?.length === 0) return nothing;
|
||||
|
||||
const editTemplatePath = this._routeBuilder?.({ entityType: 'template' }) ?? '';
|
||||
|
||||
return html`
|
||||
<div class="general-item">
|
||||
<strong><umb-localize key="template_template">Template</umb-localize></strong>
|
||||
${this._templateUnique
|
||||
@@ -247,10 +260,6 @@ export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
@click=${this.#openTemplatePicker}></uui-button>
|
||||
`}
|
||||
</div>
|
||||
<div class="general-item">
|
||||
<strong><umb-localize key="template_id">Id</umb-localize></strong>
|
||||
<span>${this._documentUnique}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +393,6 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
|
||||
}
|
||||
|
||||
#matchlist {
|
||||
display: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: var(--uui-color-surface);
|
||||
@@ -403,6 +402,7 @@ export class UmbTagsInputElement extends UUIFormControlMixin(UmbLitElement, '')
|
||||
top: var(--uui-size-space-6);
|
||||
border-radius: var(--uui-border-radius);
|
||||
border: 1px solid var(--uui-color-border);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
#matchlist label {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { UmbUserRepositoryBase } from '../user-repository-base.js';
|
||||
import { UmbUserItemRepository } from '../item/index.js';
|
||||
import { UmbDisableUserServerDataSource } from './disable-user.server.data-source.js';
|
||||
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UserStateModel } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
|
||||
export class UmbDisableUserRepository extends UmbUserRepositoryBase {
|
||||
#disableSource: UmbDisableUserServerDataSource;
|
||||
#localize = new UmbLocalizationController(this);
|
||||
#userItemRepository = new UmbUserItemRepository(this);
|
||||
|
||||
constructor(host: UmbControllerHost) {
|
||||
super(host);
|
||||
@@ -18,11 +22,22 @@ export class UmbDisableUserRepository extends UmbUserRepositoryBase {
|
||||
const { data, error } = await this.#disableSource.disable(ids);
|
||||
|
||||
if (!error) {
|
||||
const { data: items } = await this.#userItemRepository.requestItems(ids);
|
||||
if (!items) throw new Error('Could not load user item');
|
||||
|
||||
// TODO: get state from item when available
|
||||
ids.forEach((id) => {
|
||||
this.detailStore?.updateItem(id, { state: UserStateModel.DISABLED });
|
||||
});
|
||||
|
||||
const notification = { data: { message: `User disabled` } };
|
||||
let message = this.#localize.term('speechBubbles_disableUsersSuccess', items.length);
|
||||
|
||||
if (items.length === 1) {
|
||||
const names = items?.map((item) => item.name).join(', ');
|
||||
message = this.#localize.term('speechBubbles_disableUserSuccess', names);
|
||||
}
|
||||
|
||||
const notification = { data: { message } };
|
||||
this.notificationContext?.peek('positive', notification);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { UmbUserRepositoryBase } from '../user-repository-base.js';
|
||||
import { UmbUserItemRepository } from '../item/index.js';
|
||||
import { UmbEnableUserServerDataSource } from './enable-user.server.data-source.js';
|
||||
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UserStateModel } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
|
||||
export class UmbEnableUserRepository extends UmbUserRepositoryBase {
|
||||
#enableSource: UmbEnableUserServerDataSource;
|
||||
#localize = new UmbLocalizationController(this);
|
||||
#userItemRepository = new UmbUserItemRepository(this);
|
||||
|
||||
constructor(host: UmbControllerHost) {
|
||||
super(host);
|
||||
@@ -18,11 +22,22 @@ export class UmbEnableUserRepository extends UmbUserRepositoryBase {
|
||||
const { data, error } = await this.#enableSource.enable(ids);
|
||||
|
||||
if (!error) {
|
||||
const { data: items } = await this.#userItemRepository.requestItems(ids);
|
||||
if (!items) throw new Error('Could not load user item');
|
||||
|
||||
// TODO: get state from item when available
|
||||
ids.forEach((id) => {
|
||||
this.detailStore?.updateItem(id, { state: UserStateModel.ACTIVE });
|
||||
});
|
||||
|
||||
const notification = { data: { message: `User disabled` } };
|
||||
let message = this.#localize.term('speechBubbles_enableUsersSuccess', items.length);
|
||||
|
||||
if (items.length === 1) {
|
||||
const names = items?.map((item) => item.name).join(', ');
|
||||
message = this.#localize.term('speechBubbles_enableUserSuccess', names);
|
||||
}
|
||||
|
||||
const notification = { data: { message } };
|
||||
this.notificationContext?.peek('positive', notification);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user