Collection view test: update changes for v17 (#20812)
update extension for collection view test Co-authored-by: Lan Nguyen Thuy <lnt@umbraco.dk>
This commit is contained in:
@@ -1,217 +1,106 @@
|
||||
import { UMB_DOCUMENT_COLLECTION_CONTEXT as T, UMB_EDIT_DOCUMENT_WORKSPACE_PATH_PATTERN as P } from "@umbraco-cms/backoffice/document";
|
||||
import { css as D, state as d, customElement as x, html as n } from "@umbraco-cms/backoffice/external/lit";
|
||||
import { UmbLitElement as E } from "@umbraco-cms/backoffice/lit-element";
|
||||
import { UmbTextStyles as A } from "@umbraco-cms/backoffice/style";
|
||||
import { fromCamelCase as O } from "@umbraco-cms/backoffice/utils";
|
||||
var S = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, y = (e) => {
|
||||
throw TypeError(e);
|
||||
}, c = (e, t, a, s) => {
|
||||
for (var r = s > 1 ? void 0 : s ? $(t, a) : t, p = e.length - 1, m; p >= 0; p--)
|
||||
(m = e[p]) && (r = (s ? m(t, a, r) : m(r)) || r);
|
||||
return s && r && S(t, a, r), r;
|
||||
}, f = (e, t, a) => t.has(e) || y("Cannot " + a), u = (e, t, a) => (f(e, t, "read from private field"), t.get(e)), _ = (e, t, a) => t.has(e) ? y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), I = (e, t, a, s) => (f(e, t, "write to private field"), t.set(e, a), a), h = (e, t, a) => (f(e, t, "access private method"), a), b, o, l, w, g, v, C;
|
||||
let i = class extends E {
|
||||
import { css as u, state as d, customElement as _, html as n } from "@umbraco-cms/backoffice/external/lit";
|
||||
import { UmbLitElement as f } from "@umbraco-cms/backoffice/lit-element";
|
||||
import { UMB_DOCUMENT_COLLECTION_CONTEXT as v } from "@umbraco-cms/backoffice/document";
|
||||
var y = Object.defineProperty, w = Object.getOwnPropertyDescriptor, h = (t) => {
|
||||
throw TypeError(t);
|
||||
}, m = (t, e, a, s) => {
|
||||
for (var i = s > 1 ? void 0 : s ? w(e, a) : e, o = t.length - 1, l; o >= 0; o--)
|
||||
(l = t[o]) && (i = (s ? l(e, a, i) : l(i)) || i);
|
||||
return s && i && y(e, a, i), i;
|
||||
}, b = (t, e, a) => e.has(t) || h("Cannot " + a), C = (t, e, a) => e.has(t) ? h("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), E = (t, e, a) => (b(t, e, "access private method"), a), c, p;
|
||||
let r = class extends f {
|
||||
constructor() {
|
||||
super(), _(this, l), this._tableColumns = [], _(this, b, [
|
||||
{
|
||||
name: this.localize.term("general_name"),
|
||||
alias: "name",
|
||||
elementName: "umb-document-table-column-name",
|
||||
allowSorting: !0
|
||||
},
|
||||
{
|
||||
name: this.localize.term("content_publishStatus"),
|
||||
alias: "state",
|
||||
elementName: "umb-document-table-column-state",
|
||||
allowSorting: !1
|
||||
}
|
||||
]), this._tableItems = [], _(this, o), this.consumeContext(T, (e) => {
|
||||
I(this, o, e), e?.setupView(this), this.observe(
|
||||
e?.workspacePathBuilder,
|
||||
(t) => {
|
||||
this._workspacePathBuilder = t, u(this, o) && h(this, l, v).call(this, u(this, o).getItems());
|
||||
},
|
||||
"observePath"
|
||||
), h(this, l, w).call(this);
|
||||
super(), C(this, c), this._columns = [], this._items = [], this.consumeContext(v, (t) => {
|
||||
t?.setupView(this), this.observe(t?.userDefinedProperties, (e) => {
|
||||
E(this, c, p).call(this, e);
|
||||
}), this.observe(t?.items, (e) => {
|
||||
this._items = e;
|
||||
});
|
||||
});
|
||||
}
|
||||
render() {
|
||||
return n`
|
||||
<table class="doc-table">
|
||||
return this._items === void 0 ? n`<p>Not found...</p>` : n`
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
${this._tableColumns.map(
|
||||
(e) => n`<th style="text-align:${e.align ?? "left"}">${e.name}</th>`
|
||||
)}
|
||||
${this._columns.map((t) => n`<th style="text-align:${t.align ?? "left"}">${t.name}</th>`)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${this._tableItems.map(
|
||||
(e) => n`
|
||||
${this._items.map(
|
||||
(t) => n`
|
||||
<tr>
|
||||
${this._tableColumns.map((t) => {
|
||||
const s = e.data.find((r) => r.columnAlias === t.alias)?.value ?? "";
|
||||
return t.alias === "name" && s?.item ? n`<td><a href=${s.editPath || "#"}>${s.item.name}</a></td>` : t.alias === "state" && s?.item ? n`<td>${s.item.state}</td>` : t.alias === "entityActions" ? n`<td style="text-align:right;">⋮</td>` : n`<td>${s}</td>`;
|
||||
${this._columns.map((e) => {
|
||||
switch (e.alias) {
|
||||
case "name":
|
||||
return n`<td><a href="#">${t.variants[0].name}</a></td>`;
|
||||
case "entityActions":
|
||||
return n`<td style="text-align:right;">⋮</td>`;
|
||||
default:
|
||||
const a = t.values.find((s) => s.alias === e.alias)?.value ?? "";
|
||||
return n`<td>${a}</td>`;
|
||||
}
|
||||
})}
|
||||
</tr>
|
||||
`
|
||||
)}
|
||||
</tbody>
|
||||
</table>`;
|
||||
</table>
|
||||
`;
|
||||
}
|
||||
};
|
||||
b = /* @__PURE__ */ new WeakMap();
|
||||
o = /* @__PURE__ */ new WeakMap();
|
||||
l = /* @__PURE__ */ new WeakSet();
|
||||
w = function() {
|
||||
u(this, o) && (this.observe(
|
||||
u(this, o).userDefinedProperties,
|
||||
(e) => {
|
||||
this._userDefinedProperties = e, h(this, l, g).call(this);
|
||||
},
|
||||
"_observeUserDefinedProperties"
|
||||
), this.observe(
|
||||
u(this, o).items,
|
||||
(e) => {
|
||||
this._items = e, h(this, l, v).call(this, this._items);
|
||||
},
|
||||
"_observeItems"
|
||||
));
|
||||
c = /* @__PURE__ */ new WeakSet();
|
||||
p = function(t = []) {
|
||||
const e = [
|
||||
{ name: "Name", alias: "name" },
|
||||
{ name: "State", alias: "state" }
|
||||
], a = t.map((s) => ({
|
||||
name: s.nameTemplate ?? s.alias,
|
||||
alias: s.alias
|
||||
}));
|
||||
this._columns = [...e, ...a, { name: "", alias: "entityActions", align: "right" }];
|
||||
};
|
||||
g = function() {
|
||||
if (this._userDefinedProperties && this._userDefinedProperties.length > 0) {
|
||||
const e = this._userDefinedProperties.map((t) => ({
|
||||
name: this.localize.string(t.header),
|
||||
alias: t.alias,
|
||||
elementName: t.elementName,
|
||||
labelTemplate: t.nameTemplate,
|
||||
allowSorting: !0
|
||||
}));
|
||||
this._tableColumns = [
|
||||
...u(this, b),
|
||||
...e,
|
||||
{ name: "", alias: "entityActions", align: "right" }
|
||||
];
|
||||
}
|
||||
};
|
||||
v = function(e) {
|
||||
this._tableItems = e.map((t) => {
|
||||
if (!t.unique) throw new Error("Item id is missing.");
|
||||
const a = this._tableColumns?.map((s) => {
|
||||
if (s.alias === "entityActions")
|
||||
return {
|
||||
columnAlias: "entityActions",
|
||||
value: n`<umb-document-entity-actions-table-column-view
|
||||
.value=${t}></umb-document-entity-actions-table-column-view>`
|
||||
};
|
||||
const r = t.unique && this._workspacePathBuilder ? this._workspacePathBuilder({ entityType: t.entityType }) + P.generateLocal({
|
||||
unique: t.unique
|
||||
}) : "";
|
||||
return {
|
||||
columnAlias: s.alias,
|
||||
value: s.elementName ? { item: t, editPath: r } : h(this, l, C).call(this, t, s.alias)
|
||||
};
|
||||
}) ?? [];
|
||||
return {
|
||||
id: t.unique,
|
||||
icon: t.documentType.icon,
|
||||
entityType: "document",
|
||||
data: a
|
||||
};
|
||||
});
|
||||
};
|
||||
C = function(e, t) {
|
||||
switch (t) {
|
||||
case "contentTypeAlias":
|
||||
return e.contentTypeAlias;
|
||||
case "createDate":
|
||||
return e.createDate.toLocaleString();
|
||||
case "creator":
|
||||
case "owner":
|
||||
return e.creator;
|
||||
case "name":
|
||||
return e.name;
|
||||
case "state":
|
||||
return O(e.state);
|
||||
case "published":
|
||||
return e.state !== "Draft" ? "True" : "False";
|
||||
case "sortOrder":
|
||||
return e.sortOrder;
|
||||
case "updateDate":
|
||||
return e.updateDate.toLocaleString();
|
||||
case "updater":
|
||||
return e.updater;
|
||||
default:
|
||||
return e.values.find((a) => a.alias === t)?.value ?? "";
|
||||
}
|
||||
};
|
||||
i.styles = [
|
||||
A,
|
||||
D`
|
||||
:host {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
padding: var(--uui-size-space-3) 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:host {
|
||||
r.styles = u`
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 14px;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #ddd;
|
||||
white-space: nowrap;
|
||||
}
|
||||
th {
|
||||
background: #f8f8f8;
|
||||
font-weight: 600;
|
||||
}
|
||||
a {
|
||||
color: var(--uui-color-interactive, #0366d6);
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
`
|
||||
];
|
||||
c([
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #ddd;
|
||||
white-space: nowrap;
|
||||
}
|
||||
th {
|
||||
background: #f8f8f8;
|
||||
font-weight: 600;
|
||||
}
|
||||
a {
|
||||
color: var(--uui-color-interactive, #0366d6);
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
`;
|
||||
m([
|
||||
d()
|
||||
], i.prototype, "_workspacePathBuilder", 2);
|
||||
c([
|
||||
], r.prototype, "_columns", 2);
|
||||
m([
|
||||
d()
|
||||
], i.prototype, "_userDefinedProperties", 2);
|
||||
c([
|
||||
d()
|
||||
], i.prototype, "_items", 2);
|
||||
c([
|
||||
d()
|
||||
], i.prototype, "_tableColumns", 2);
|
||||
c([
|
||||
d()
|
||||
], i.prototype, "_tableItems", 2);
|
||||
i = c([
|
||||
x("my-document-table-collection-view")
|
||||
], i);
|
||||
const z = i;
|
||||
], r.prototype, "_items", 2);
|
||||
r = m([
|
||||
_("my-document-table-collection-view")
|
||||
], r);
|
||||
const O = r;
|
||||
export {
|
||||
i as MyDocumentTableCollectionViewElement,
|
||||
z as default
|
||||
r as MyDocumentTableCollectionViewElement,
|
||||
O as default
|
||||
};
|
||||
//# sourceMappingURL=my-collection-view.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"$schema": "../../umbraco-package-schema.json",
|
||||
"name": "My Collection View",
|
||||
"version": "0.1.0",
|
||||
|
||||
Reference in New Issue
Block a user