diff --git a/web/src/elements/events/ObjectChangelog.ts b/web/src/elements/events/ObjectChangelog.ts index 275f56e80..11672a47a 100644 --- a/web/src/elements/events/ObjectChangelog.ts +++ b/web/src/elements/events/ObjectChangelog.ts @@ -27,19 +27,38 @@ export class ObjectChangelog extends Table { targetModelPk!: string | number; @property() - targetModelApp!: string; + targetModelApp?: string; + + private _targetModelName: string = ""; @property() - targetModelName!: string; + set targetModelName(value: string) { + this._targetModelName = value; + this.fetch(); + } + + get targetModelName(): string { + return this._targetModelName; + } async apiEndpoint(page: number): Promise> { + let modelName = this._targetModelName; + let appName = this.targetModelApp; + if (this._targetModelName.indexOf(".") !== -1) { + const parts = this._targetModelName.split("."); + appName = parts[0]; + modelName = parts[1]; + } + if (this._targetModelName === "") { + return Promise.reject(); + } return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ action: "model_", page: page, ordering: this.order, pageSize: (await uiConfig()).pagination.perPage, - contextModelApp: this.targetModelApp, - contextModelName: this.targetModelName, + contextModelApp: appName, + contextModelName: modelName, contextModelPk: this.targetModelPk.toString(), }); } diff --git a/web/src/elements/table/Table.ts b/web/src/elements/table/Table.ts index 6f57e853e..7753f3f62 100644 --- a/web/src/elements/table/Table.ts +++ b/web/src/elements/table/Table.ts @@ -19,7 +19,7 @@ import { groupBy } from "../../utils"; import "../EmptyState"; import "../chips/Chip"; import "../chips/ChipGroup"; -import { getURLParams, updateURLParams } from "../router/RouteMatch"; +import { getURLParam, updateURLParams } from "../router/RouteMatch"; import "./TablePagination"; import "./TableSearch"; @@ -116,7 +116,7 @@ export abstract class Table extends LitElement { order?: string; @property({ type: String }) - search?: string; + search: string = getURLParam("search", ""); @property({ type: Boolean }) checkbox = false; @@ -397,10 +397,6 @@ export abstract class Table extends LitElement { } firstUpdated(): void { - const params = getURLParams(); - if ("search" in params) { - this.search = params.search; - } this.fetch(); }