Move "delete results" logic for master grid
should be easier to customize this way..? previous way seemed to be broken
This commit is contained in:
parent
03c8d3409a
commit
4c5b01f287
|
@ -244,16 +244,6 @@ let TailboneGrid = {
|
|||
this.$emit('deleteActionClicked', event.target.href)
|
||||
},
|
||||
|
||||
deleteResults(event) {
|
||||
|
||||
// submit form if user confirms
|
||||
// TODO: how/where to get/show "plural model title" here?
|
||||
// if (confirm("You are about to delete " + this.total + " ${grid.model_title_plural}.\n\nAre you sure?")) {
|
||||
if (confirm("You are about to delete " + this.total.toLocaleString('en') + " objects.\n\nAre you sure?")) {
|
||||
event.target.form.submit()
|
||||
}
|
||||
},
|
||||
|
||||
checkedRowUUIDs() {
|
||||
let uuids = []
|
||||
for (let row of this.$data.checkedRows) {
|
||||
|
|
|
@ -233,21 +233,24 @@
|
|||
|
||||
## delete search results
|
||||
% if master.bulk_deletable and request.has_perm('{}.bulk_delete'.format(permission_prefix)):
|
||||
${h.form(url('{}.bulk_delete'.format(route_prefix)), name='bulk-delete', class_='control')}
|
||||
${h.csrf_token(request)}
|
||||
% if use_buefy:
|
||||
${h.form(url('{}.bulk_delete'.format(route_prefix)), ref='delete_results_form', class_='control')}
|
||||
${h.csrf_token(request)}
|
||||
<b-button type="is-danger"
|
||||
:disabled="! total"
|
||||
:disabled="deleteResultsDisabled"
|
||||
:title="total ? null : 'There are no results to delete'"
|
||||
@click="deleteResults"
|
||||
@click="deleteResultsSubmit()"
|
||||
icon-pack="fas"
|
||||
icon-left="trash">
|
||||
Delete Results
|
||||
{{ deleteResultsText }}
|
||||
</b-button>
|
||||
% else:
|
||||
<button type="button">Delete Results</button>
|
||||
% endif
|
||||
${h.end_form()}
|
||||
% else:
|
||||
${h.form(url('{}.bulk_delete'.format(route_prefix)), name='bulk-delete', class_='control')}
|
||||
${h.csrf_token(request)}
|
||||
<button type="button">Delete Results</button>
|
||||
${h.end_form()}
|
||||
% endif
|
||||
% endif
|
||||
|
||||
</%def>
|
||||
|
@ -396,6 +399,34 @@
|
|||
}
|
||||
% endif
|
||||
|
||||
% if master.bulk_deletable and master.has_perm('bulk_delete'):
|
||||
|
||||
TailboneGridData.deleteResultsSubmitting = false
|
||||
TailboneGridData.deleteResultsText = "Delete Results"
|
||||
|
||||
TailboneGrid.computed.deleteResultsDisabled = function() {
|
||||
if (this.deleteResultsSubmitting) {
|
||||
return true
|
||||
}
|
||||
if (!this.total) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
TailboneGrid.methods.deleteResultsSubmit = function() {
|
||||
// TODO: show "plural model title" here?
|
||||
if (!confirm("You are about to delete " + this.total.toLocaleString('en') + " objects.\n\nAre you sure?")) {
|
||||
return
|
||||
}
|
||||
|
||||
this.deleteResultsSubmitting = true
|
||||
this.deleteResultsText = "Working, please wait..."
|
||||
this.$refs.delete_results_form.submit()
|
||||
}
|
||||
|
||||
% endif
|
||||
|
||||
% if master.mergeable and master.has_perm('merge'):
|
||||
|
||||
TailboneGridData.mergeFormButtonText = "Merge 2 ${model_title_plural}"
|
||||
|
|
Loading…
Reference in a new issue