date uses localize.date now
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { HistoryTagStyleAndText } from './utils.js';
|
||||
import { HistoryTagStyleAndText, TimeOptions } from './utils.js';
|
||||
import { UmbAuditLogRepository } from '@umbraco-cms/backoffice/audit-log';
|
||||
import {
|
||||
css,
|
||||
@@ -24,7 +24,6 @@ import { UmbCurrentUserContext } from '@umbraco-cms/backoffice/current-user';
|
||||
export class UmbDocumentWorkspaceViewInfoHistoryElement extends UmbLitElement {
|
||||
#logRepository: UmbAuditLogRepository;
|
||||
#itemsPerPage = 10;
|
||||
#userIsoCode = 'en-US';
|
||||
|
||||
@property()
|
||||
documentUnique = '';
|
||||
@@ -41,10 +40,6 @@ export class UmbDocumentWorkspaceViewInfoHistoryElement extends UmbLitElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.#logRepository = new UmbAuditLogRepository(this);
|
||||
const context = new UmbCurrentUserContext(this);
|
||||
this.observe(context.languageIsoCode, (IsoCode) => {
|
||||
this.#userIsoCode = IsoCode;
|
||||
});
|
||||
}
|
||||
|
||||
protected firstUpdated(): void {
|
||||
@@ -110,7 +105,7 @@ export class UmbDocumentWorkspaceViewInfoHistoryElement extends UmbLitElement {
|
||||
<umb-history-list>
|
||||
${repeat(
|
||||
this._items,
|
||||
(item) => item.timestamp + this.#userIsoCode,
|
||||
(item) => item.timestamp,
|
||||
(item) => {
|
||||
const { text, style } = HistoryTagStyleAndText(item.logType);
|
||||
return html`<umb-history-item
|
||||
@@ -118,14 +113,7 @@ export class UmbDocumentWorkspaceViewInfoHistoryElement extends UmbLitElement {
|
||||
src=${ifDefined(
|
||||
Array.isArray(item.userAvatars) ? item.userAvatars[item.userAvatars.length - 1] : undefined,
|
||||
)}
|
||||
detail=${new Date(item.timestamp).toLocaleString(this.#userIsoCode, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
second: 'numeric',
|
||||
})}>
|
||||
detail=${this.localize.date(item.timestamp, TimeOptions)}>
|
||||
<span class="log-type">
|
||||
<uui-tag look=${style.look} color=${style.color}> ${this.localize.term(text.label)} </uui-tag>
|
||||
${this.localize.term(text.desc, item.parameters)}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { TimeOptions } from './utils.js';
|
||||
import { css, html, customElement, state, repeat } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
|
||||
import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace';
|
||||
@@ -7,6 +8,7 @@ import './document-workspace-view-info-history.element.js';
|
||||
import './document-workspace-view-info-reference.element.js';
|
||||
import { UmbDocumentWorkspaceContext } from '@umbraco-cms/backoffice/document';
|
||||
import { ContentUrlInfoModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbCurrentUserContext } from '@umbraco-cms/backoffice/current-user';
|
||||
|
||||
@customElement('umb-document-workspace-view-info')
|
||||
export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
@@ -27,6 +29,9 @@ export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
@state()
|
||||
private _urls?: Array<ContentUrlInfoModel>;
|
||||
|
||||
@state()
|
||||
private _createDate = 'Unknown';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -60,8 +65,9 @@ export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
this._documentUnique = unique!;
|
||||
});
|
||||
|
||||
const something = (this._workspaceContext as UmbDocumentWorkspaceContext).getData();
|
||||
console.log(something);
|
||||
this.observe((this._workspaceContext as UmbDocumentWorkspaceContext).variants, (variants) => {
|
||||
this._createDate = Array.isArray(variants) ? variants[0].createDate : 'Unknown';
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -116,7 +122,9 @@ export class UmbDocumentWorkspaceViewInfoElement extends UmbLitElement {
|
||||
</div>
|
||||
<div class="general-item">
|
||||
<strong><umb-localize key="content_createDate"></umb-localize></strong>
|
||||
<span><umb-localize-date .date="${new Date()}"></umb-localize-date></span>
|
||||
<span>
|
||||
<umb-localize-date .date=${this._createDate} .options=${TimeOptions}></umb-localize-date>
|
||||
</span>
|
||||
</div>
|
||||
<div class="general-item">
|
||||
<strong><umb-localize key="content_documentType"></umb-localize></strong>
|
||||
|
||||
@@ -67,3 +67,12 @@ export function HistoryTagStyleAndText(type: AuditTypeModel): HistoryData {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const TimeOptions: Intl.DateTimeFormatOptions = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
second: 'numeric',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user