web/elements: allow app.model names for ak-object-changelog
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
0948e0ee1c
commit
80364b04a9
|
@ -27,19 +27,38 @@ export class ObjectChangelog extends Table<Event> {
|
|||
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<AKResponse<Event>> {
|
||||
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(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<T> 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<T> extends LitElement {
|
|||
}
|
||||
|
||||
firstUpdated(): void {
|
||||
const params = getURLParams();
|
||||
if ("search" in params) {
|
||||
this.search = params.search;
|
||||
}
|
||||
this.fetch();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue