Implements correct sortOrder property
Removes the faux sort order value.
This commit is contained in:
@@ -43,6 +43,7 @@ export class UmbDocumentCollectionServerDataSource implements UmbCollectionDataS
|
||||
creator: item.creator,
|
||||
icon: item.documentType.icon,
|
||||
name: variant.name,
|
||||
sortOrder: item.sortOrder,
|
||||
state: variant.state,
|
||||
updateDate: new Date(variant.updateDate),
|
||||
updater: item.updater,
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface UmbDocumentCollectionItemModel {
|
||||
creator?: string | null;
|
||||
icon: string;
|
||||
name: string;
|
||||
sortOrder: number;
|
||||
state: string;
|
||||
updateDate: Date;
|
||||
updater?: string | null;
|
||||
|
||||
@@ -96,14 +96,13 @@ export class UmbDocumentGridCollectionViewElement extends UmbLitElement {
|
||||
${repeat(
|
||||
this._items,
|
||||
(item) => item.unique,
|
||||
(item, index) => this.#renderCard(index, item),
|
||||
(item) => this.#renderCard(item),
|
||||
)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
#renderCard(index: number, item: UmbDocumentCollectionItemModel) {
|
||||
const sortOrder = this._skip + index;
|
||||
#renderCard(item: UmbDocumentCollectionItemModel) {
|
||||
return html`
|
||||
<uui-card-content-node
|
||||
.name=${item.name ?? 'Unnamed Document'}
|
||||
@@ -114,7 +113,7 @@ export class UmbDocumentGridCollectionViewElement extends UmbLitElement {
|
||||
@selected=${() => this.#onSelect(item)}
|
||||
@deselected=${() => this.#onDeselect(item)}>
|
||||
<umb-icon slot="icon" name=${item.icon}></umb-icon>
|
||||
${this.#renderState(item)} ${this.#renderProperties(sortOrder, item)}
|
||||
${this.#renderState(item)} ${this.#renderProperties(item)}
|
||||
</uui-card-content-node>
|
||||
`;
|
||||
}
|
||||
@@ -142,15 +141,14 @@ export class UmbDocumentGridCollectionViewElement extends UmbLitElement {
|
||||
}
|
||||
}
|
||||
|
||||
#renderProperties(sortOrder: number, item: UmbDocumentCollectionItemModel) {
|
||||
#renderProperties(item: UmbDocumentCollectionItemModel) {
|
||||
if (!this._userDefinedProperties) return;
|
||||
return html`
|
||||
<ul>
|
||||
${repeat(
|
||||
this._userDefinedProperties,
|
||||
(column) => column.alias,
|
||||
(column) =>
|
||||
html`<li><span>${column.header}:</span> ${getPropertyValueByAlias(sortOrder, item, column.alias)}</li>`,
|
||||
(column) => html`<li><span>${column.header}:</span> ${getPropertyValueByAlias(item, column.alias)}</li>`,
|
||||
)}
|
||||
</ul>
|
||||
`;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { fromCamelCase } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export { UMB_DOCUMENT_GRID_COLLECTION_VIEW_ALIAS, UMB_DOCUMENT_TABLE_COLLECTION_VIEW_ALIAS } from './manifests.js';
|
||||
|
||||
export function getPropertyValueByAlias(sortOrder: number, item: UmbDocumentCollectionItemModel, alias: string) {
|
||||
export function getPropertyValueByAlias(item: UmbDocumentCollectionItemModel, alias: string) {
|
||||
switch (alias) {
|
||||
case 'contentTypeAlias':
|
||||
return item.contentTypeAlias;
|
||||
@@ -19,7 +19,7 @@ export function getPropertyValueByAlias(sortOrder: number, item: UmbDocumentColl
|
||||
case 'published':
|
||||
return item.state !== 'Draft' ? 'True' : 'False';
|
||||
case 'sortOrder':
|
||||
return sortOrder;
|
||||
return item.sortOrder;
|
||||
case 'updateDate':
|
||||
return item.updateDate.toLocaleString();
|
||||
case 'updater':
|
||||
|
||||
@@ -126,16 +126,14 @@ export class UmbDocumentTableCollectionViewElement extends UmbLitElement {
|
||||
}
|
||||
|
||||
#createTableItems(items: Array<UmbDocumentCollectionItemModel>) {
|
||||
this._tableItems = items.map((item, rowIndex) => {
|
||||
this._tableItems = items.map((item) => {
|
||||
if (!item.unique) throw new Error('Item id is missing.');
|
||||
|
||||
const sortOrder = this._skip + rowIndex;
|
||||
|
||||
const data =
|
||||
this._tableColumns?.map((column) => {
|
||||
return {
|
||||
columnAlias: column.alias,
|
||||
value: column.elementName ? item : getPropertyValueByAlias(sortOrder, item, column.alias),
|
||||
value: column.elementName ? item : getPropertyValueByAlias(item, column.alias),
|
||||
};
|
||||
}) ?? [];
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ export class UmbMediaCollectionServerDataSource implements UmbCollectionDataSour
|
||||
creator: item.creator,
|
||||
icon: item.mediaType.icon,
|
||||
name: variant.name,
|
||||
sortOrder: item.sortOrder,
|
||||
updateDate: new Date(variant.updateDate),
|
||||
values: item.values.map((item) => {
|
||||
return { alias: item.alias, value: item.value as string };
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface UmbMediaCollectionItemModel {
|
||||
creator?: string | null;
|
||||
icon: string;
|
||||
name: string;
|
||||
sortOrder: number;
|
||||
updateDate: Date;
|
||||
values: Array<{ alias: string; value: string }>;
|
||||
}
|
||||
|
||||
@@ -124,16 +124,14 @@ export class UmbMediaTableCollectionViewElement extends UmbLitElement {
|
||||
this.#createTableHeadings();
|
||||
}
|
||||
|
||||
this._tableItems = items.map((item, rowIndex) => {
|
||||
this._tableItems = items.map((item) => {
|
||||
if (!item.unique) throw new Error('Item id is missing.');
|
||||
|
||||
const sortOrder = this._skip + rowIndex;
|
||||
|
||||
const data =
|
||||
this._tableColumns?.map((column) => {
|
||||
return {
|
||||
columnAlias: column.alias,
|
||||
value: column.elementName ? item : this.#getPropertyValueByAlias(sortOrder, item, column.alias),
|
||||
value: column.elementName ? item : this.#getPropertyValueByAlias(item, column.alias),
|
||||
};
|
||||
}) ?? [];
|
||||
|
||||
@@ -145,7 +143,7 @@ export class UmbMediaTableCollectionViewElement extends UmbLitElement {
|
||||
});
|
||||
}
|
||||
|
||||
#getPropertyValueByAlias(sortOrder: number, item: UmbMediaCollectionItemModel, alias: string) {
|
||||
#getPropertyValueByAlias(item: UmbMediaCollectionItemModel, alias: string) {
|
||||
switch (alias) {
|
||||
case 'createDate':
|
||||
return item.createDate.toLocaleString();
|
||||
@@ -155,7 +153,7 @@ export class UmbMediaTableCollectionViewElement extends UmbLitElement {
|
||||
case 'owner':
|
||||
return item.creator;
|
||||
case 'sortOrder':
|
||||
return sortOrder;
|
||||
return item.sortOrder;
|
||||
case 'updateDate':
|
||||
return item.updateDate.toLocaleString();
|
||||
default:
|
||||
|
||||
@@ -89,7 +89,7 @@ const propertyEditorUiManifest: ManifestPropertyEditorUi = {
|
||||
],
|
||||
},
|
||||
{ alias: 'pageSize', value: 10 },
|
||||
{ alias: 'orderBy', value: 'updateDate' },
|
||||
{ alias: 'orderBy', value: 'sortOrder' },
|
||||
{ alias: 'orderDirection', value: 'desc' },
|
||||
{
|
||||
alias: 'bulkActionPermissions',
|
||||
|
||||
Reference in New Issue
Block a user