Replaced hardcoded edit path with constant helper

This commit is contained in:
leekelleher
2024-05-01 09:27:49 +01:00
parent 9662cc5b50
commit e398b3adea
2 changed files with 8 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import { getPropertyValueByAlias } from '../index.js';
import { UMB_EDIT_DOCUMENT_WORKSPACE_PATH_PATTERN } from '../../../paths.js';
import type { UmbCollectionColumnConfiguration } from '../../../../../core/collection/types.js';
import type { UmbDocumentCollectionFilterModel, UmbDocumentCollectionItemModel } from '../../types.js';
import { css, customElement, html, nothing, repeat, state, when } from '@umbraco-cms/backoffice/external/lit';
@@ -75,10 +76,12 @@ export class UmbDocumentGridCollectionViewElement extends UmbLitElement {
);
}
#onOpen(event: Event, id: string) {
#onOpen(event: Event, unique: string) {
event.preventDefault();
event.stopPropagation();
window.history.pushState(null, '', this._editDocumentPath + 'edit/' + id);
const url = this._editDocumentPath + UMB_EDIT_DOCUMENT_WORKSPACE_PATH_PATTERN.generateLocal({ unique });
window.history.pushState(null, '', url);
}
#onSelect(item: UmbDocumentCollectionItemModel) {

View File

@@ -1,4 +1,5 @@
import { getPropertyValueByAlias } from '../index.js';
import { UMB_EDIT_DOCUMENT_WORKSPACE_PATH_PATTERN } from '../../../paths.js';
import type { UmbCollectionColumnConfiguration } from '../../../../../core/collection/types.js';
import type { UmbDocumentCollectionItemModel } from '../../types.js';
import type { UmbDocumentCollectionContext } from '../../document-collection.context.js';
@@ -150,7 +151,8 @@ export class UmbDocumentTableCollectionViewElement extends UmbLitElement {
const data =
this._tableColumns?.map((column) => {
const editPath = this.#routeBuilder
? this.#routeBuilder({ entityType: item.entityType }) + `edit/${item.unique}`
? this.#routeBuilder({ entityType: item.entityType }) +
UMB_EDIT_DOCUMENT_WORKSPACE_PATH_PATTERN.generateLocal({ unique: item.unique })
: '';
return {