Parcourir la source

fix(grid): Delete all functionality

version-14
Suraj Shetty il y a 3 ans
Parent
révision
47b0117eec
1 fichiers modifiés avec 9 ajouts et 8 suppressions
  1. +9
    -8
      frappe/public/js/frappe/form/grid.js

+ 9
- 8
frappe/public/js/frappe/form/grid.js Voir le fichier

@@ -212,13 +212,12 @@ export default class Grid {


delete_all_rows() { delete_all_rows() {
frappe.confirm(__("Are you sure you want to delete all rows?"), () => { frappe.confirm(__("Are you sure you want to delete all rows?"), () => {
this.grid_rows.forEach(row => {
row.remove();
});
this.frm.script_manager.trigger(this.df.fieldname + "_delete", this.doctype);

this.wrapper.find('.grid-heading-row .grid-row-check:checked:first').prop('checked', 0);
this.frm.doc[this.df.fieldname] = [];
$(this.parent).find('.rows').empty();
this.grid_rows = [];
this.refresh(); this.refresh();
this.frm && this.frm.script_manager.trigger(this.df.fieldname + "_delete", this.doctype);
this.frm && this.frm.dirty();
this.scroll_to_top(); this.scroll_to_top();
}); });
} }
@@ -244,8 +243,10 @@ export default class Grid {


this.remove_rows_button.toggleClass('hidden', this.remove_rows_button.toggleClass('hidden',
this.wrapper.find('.grid-body .grid-row-check:checked:first').length ? false : true); this.wrapper.find('.grid-body .grid-row-check:checked:first').length ? false : true);
this.remove_all_rows_button.toggleClass('hidden',
this.wrapper.find('.grid-heading-row .grid-row-check:checked:first').length ? false : true);

let select_all_checkbox_checked = this.wrapper.find('.grid-heading-row .grid-row-check:checked:first').length;
let show_delete_all_btn = select_all_checkbox_checked && this.data.length > this.get_selected_children().length;
this.remove_all_rows_button.toggleClass('hidden', !show_delete_all_btn);
} }


get_selected() { get_selected() {


Chargement…
Annuler
Enregistrer