fix: add multiple goes to last page
This commit is contained in:
parent
e455fd5b52
commit
5772bfc782
2 changed files with 23 additions and 11 deletions
|
|
@ -84,8 +84,7 @@ export default class Grid {
|
|||
</button>
|
||||
<!-- hack to allow firefox include this in tabs -->
|
||||
<button type="reset"
|
||||
class="btn btn-xs btn-default grid-add-row"
|
||||
data-action="add_row">
|
||||
class="btn btn-xs btn-default grid-add-row">
|
||||
${__("Add Row")}
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -111,6 +110,8 @@ export default class Grid {
|
|||
|
||||
this.form_grid = this.wrapper.find('.form-grid');
|
||||
|
||||
this.setup_add_row();
|
||||
|
||||
this.setup_grid_pagination();
|
||||
|
||||
this.custom_buttons = {};
|
||||
|
|
@ -546,19 +547,18 @@ export default class Grid {
|
|||
}
|
||||
}
|
||||
|
||||
add_row() {
|
||||
let total_pages = this.grid_pagination.total_pages;
|
||||
if (this.data.length == this.page_length*total_pages) {
|
||||
this.grid_pagination.go_to_page(total_pages + 1);
|
||||
} else {
|
||||
this.grid_pagination.go_to_page(total_pages);
|
||||
}
|
||||
this.add_new_row(null, null, true);
|
||||
this.set_focus_on_row();
|
||||
setup_add_row() {
|
||||
this.wrapper.find(".grid-add-row").click(() => {
|
||||
this.add_new_row(null, null, true);
|
||||
this.set_focus_on_row();
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
add_new_row(idx, callback, show, copy_doc) {
|
||||
if (this.is_editable()) {
|
||||
this.grid_pagination.go_to_last_page();
|
||||
if (this.frm) {
|
||||
var d = frappe.model.add_child(this.frm.doc, this.df.options, this.df.fieldname, idx);
|
||||
if (copy_doc) {
|
||||
|
|
@ -720,6 +720,7 @@ export default class Grid {
|
|||
|
||||
set_multiple_add(link, qty) {
|
||||
if (this.multiple_set) return;
|
||||
|
||||
var link_field = frappe.meta.get_docfield(this.df.options, link);
|
||||
var btn = $(this.wrapper).find(".grid-add-multiple-rows");
|
||||
|
||||
|
|
@ -735,6 +736,7 @@ export default class Grid {
|
|||
target: this,
|
||||
txt: ""
|
||||
});
|
||||
this.grid_pagination.go_to_last_page();
|
||||
return false;
|
||||
});
|
||||
this.multiple_set = true;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,16 @@ export default class GridPagination {
|
|||
this.update_page_numbers();
|
||||
}
|
||||
|
||||
go_to_last_page() {
|
||||
let total_pages = this.total_pages;
|
||||
let page_length = this.page_length;
|
||||
if (this.grid.data.length == page_length*total_pages) {
|
||||
this.go_to_page(total_pages + 1);
|
||||
} else {
|
||||
this.go_to_page(total_pages);
|
||||
}
|
||||
}
|
||||
|
||||
get_result_length() {
|
||||
return this.grid.data.length < this.page_index*this.page_length
|
||||
? this.grid.data.length
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue