fix: create option to load more entries
This commit is contained in:
parent
c43bddd8d8
commit
303ba2daa3
1 changed files with 39 additions and 33 deletions
|
|
@ -27,6 +27,7 @@ export default class WebFormList {
|
|||
() => this.get_list_view_fields(),
|
||||
() => this.get_data(),
|
||||
() => this.make_table(),
|
||||
() => this.create_more()
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -52,10 +53,12 @@ export default class WebFormList {
|
|||
only_select: true,
|
||||
label: __(field.label),
|
||||
onchange: (event) => {
|
||||
$('#more').remove();
|
||||
this.add_filter(field.fieldname, input.value, field.fieldtype)
|
||||
}
|
||||
},
|
||||
parent: col,
|
||||
value: field.default,
|
||||
render_input: 1,
|
||||
})
|
||||
this.filter_input.push(input)
|
||||
|
|
@ -186,13 +189,12 @@ export default class WebFormList {
|
|||
|
||||
make_actions() {
|
||||
const actions = document.querySelector(".list-view-actions");
|
||||
const footer = document.querySelector(".list-view-footer");
|
||||
|
||||
addButton(actions, "delete-rows", "danger", true, "Delete", () =>
|
||||
this.addButton(actions, "delete-rows", "danger", true, "Delete", () =>
|
||||
this.delete_rows()
|
||||
);
|
||||
|
||||
addButton(
|
||||
this.addButton(
|
||||
actions,
|
||||
"new",
|
||||
"primary",
|
||||
|
|
@ -200,41 +202,45 @@ export default class WebFormList {
|
|||
"New",
|
||||
() => (window.location.href = window.location.pathname + "?new=1")
|
||||
);
|
||||
}
|
||||
|
||||
if (this.rows.length > this.page_length) {
|
||||
addButton(footer, "more", "secondary", false, "More", () => this.more());
|
||||
addButton(wrapper, id, type, hidden, name, action) {
|
||||
if (document.getElementById(id)) return;
|
||||
const button = document.createElement("button");
|
||||
if (type == "secondary") {
|
||||
button.classList.add(
|
||||
"btn",
|
||||
"btn-secondary",
|
||||
"btn-sm",
|
||||
"ml-2",
|
||||
"text-white"
|
||||
);
|
||||
}
|
||||
else if (type == "danger") {
|
||||
button.classList.add(
|
||||
"btn",
|
||||
"btn-danger",
|
||||
"button-delete",
|
||||
"btn-sm",
|
||||
"ml-2"
|
||||
);
|
||||
}
|
||||
else {
|
||||
button.classList.add("btn", "btn-primary", "btn-sm", "ml-2");
|
||||
}
|
||||
|
||||
function addButton(wrapper, id, type, hidden, name, action) {
|
||||
const button = document.createElement("button");
|
||||
if (type == "secondary") {
|
||||
button.classList.add(
|
||||
"btn",
|
||||
"btn-secondary",
|
||||
"btn-sm",
|
||||
"ml-2",
|
||||
"text-white"
|
||||
);
|
||||
}
|
||||
else if (type == "danger") {
|
||||
button.classList.add(
|
||||
"btn",
|
||||
"btn-danger",
|
||||
"button-delete",
|
||||
"btn-sm",
|
||||
"ml-2"
|
||||
);
|
||||
}
|
||||
else {
|
||||
button.classList.add("btn", "btn-primary", "btn-sm", "ml-2");
|
||||
}
|
||||
button.id = id;
|
||||
button.innerText = name;
|
||||
button.hidden = hidden;
|
||||
|
||||
button.id = id;
|
||||
button.innerText = name;
|
||||
button.hidden = hidden;
|
||||
button.onclick = action;
|
||||
wrapper.appendChild(button);
|
||||
}
|
||||
|
||||
button.onclick = action;
|
||||
wrapper.appendChild(button);
|
||||
create_more() {
|
||||
if (this.rows.length >= this.page_length) {
|
||||
const footer = document.querySelector(".list-view-footer");
|
||||
this.addButton(footer, "more", "secondary", false, "More", () => this.more());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue