Add Buefy support for "delete w/ simple confirm" from index grid
This commit is contained in:
parent
3775c53df3
commit
f727c87b56
6 changed files with 71 additions and 9 deletions
|
@ -145,7 +145,12 @@
|
|||
% if grid.main_actions or grid.more_actions:
|
||||
<b-table-column field="actions" label="Actions">
|
||||
% for action in grid.main_actions:
|
||||
<a :href="props.row._action_url_${action.key}"><i class="fas fa-${action.icon}"></i>
|
||||
<a :href="props.row._action_url_${action.key}"
|
||||
% if action.click_handler:
|
||||
@click.prevent="${action.click_handler}"
|
||||
% endif
|
||||
>
|
||||
<i class="fas fa-${action.icon}"></i>
|
||||
${action.label}
|
||||
</a>
|
||||
|
||||
|
@ -224,7 +229,3 @@
|
|||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id="tailbone-grid-app">
|
||||
<tailbone-grid></tailbone-grid>
|
||||
</div>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
## note, the `ref` here is for buefy only
|
||||
${h.form(action_url('delete', instance), ref='deleteObjectForm')}
|
||||
${h.csrf_token(request)}
|
||||
<a href="#"
|
||||
<a href="${action_url('delete', instance)}"
|
||||
% if use_buefy:
|
||||
@click.prevent="deleteObject"
|
||||
% else:
|
||||
|
|
|
@ -224,9 +224,24 @@
|
|||
|
||||
Vue.component('tailbone-grid', TailboneGrid)
|
||||
|
||||
% if master.deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
|
||||
|
||||
GridPage.methods.deleteObject = function(url) {
|
||||
|
||||
if (confirm("Are you sure you wish to delete this ${model_title}?")) {
|
||||
let form = this.$refs.deleteObjectForm
|
||||
form.action = url
|
||||
form.submit()
|
||||
}
|
||||
}
|
||||
|
||||
% endif
|
||||
|
||||
Vue.component('grid-page', GridPage)
|
||||
|
||||
new Vue({
|
||||
el: '#tailbone-grid-app'
|
||||
});
|
||||
el: '#grid-page-app'
|
||||
})
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
@ -235,6 +250,27 @@
|
|||
% if use_buefy:
|
||||
## TODO: stop using |n filter
|
||||
${grid.render_buefy(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n}
|
||||
|
||||
<script type="text/x-template" id="grid-page-template">
|
||||
<div>
|
||||
<tailbone-grid
|
||||
% if master.deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
|
||||
@deleteActionClicked="deleteObject"
|
||||
% endif
|
||||
>
|
||||
</tailbone-grid>
|
||||
% if master.deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
|
||||
${h.form('#', ref='deleteObjectForm')}
|
||||
${h.csrf_token(request)}
|
||||
${h.end_form()}
|
||||
% endif
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<div id="grid-page-app">
|
||||
<grid-page></grid-page>
|
||||
</div>
|
||||
|
||||
${self.make_tailbone_grid_app()}
|
||||
|
||||
% else:
|
||||
|
|
|
@ -112,6 +112,11 @@ ${self.render_form_complete()}
|
|||
<br /><br />
|
||||
## TODO: stop using |n filter
|
||||
${rows_grid.render_buefy(allow_save_defaults=False, tools=capture(self.render_row_grid_tools))|n}
|
||||
|
||||
<div id="tailbone-grid-app">
|
||||
<tailbone-grid></tailbone-grid>
|
||||
</div>
|
||||
|
||||
${self.make_tailbone_grid_app()}
|
||||
% else:
|
||||
## no buefy, so do the traditional thing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue