Add Buefy support for "simple" delete confirmation
This commit is contained in:
		
							parent
							
								
									796170100f
								
							
						
					
					
						commit
						e715794f04
					
				
					 3 changed files with 30 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -3,3 +3,8 @@ let TailboneForm = {
 | 
			
		|||
    template: '#tailbone-form-template',
 | 
			
		||||
    methods: {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let FormPage = {
 | 
			
		||||
    template: '#form-page-template',
 | 
			
		||||
    methods: {}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,10 +75,6 @@
 | 
			
		|||
 | 
			
		||||
    Vue.component('tailbone-form', TailboneForm)
 | 
			
		||||
 | 
			
		||||
    const FormPage = {
 | 
			
		||||
        template: '#form-page-template'
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Vue.component('form-page', FormPage)
 | 
			
		||||
 | 
			
		||||
    new Vue({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,9 +5,16 @@
 | 
			
		|||
  % if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)):
 | 
			
		||||
      % if master.delete_confirm == 'simple':
 | 
			
		||||
          <li>
 | 
			
		||||
            ${h.form(action_url('delete', instance))}
 | 
			
		||||
            ## note, the `ref` here is for buefy only
 | 
			
		||||
            ${h.form(action_url('delete', instance), ref='deleteObjectForm')}
 | 
			
		||||
            ${h.csrf_token(request)}
 | 
			
		||||
            <a href="#" class="delete-instance">
 | 
			
		||||
            <a href="#"
 | 
			
		||||
               % if use_buefy:
 | 
			
		||||
               @click.prevent="deleteObject"
 | 
			
		||||
               % else:
 | 
			
		||||
               class="delete-instance"
 | 
			
		||||
               % endif
 | 
			
		||||
               >
 | 
			
		||||
              Delete this ${model_title}
 | 
			
		||||
            </a>
 | 
			
		||||
            ${h.end_form()}
 | 
			
		||||
| 
						 | 
				
			
			@ -19,4 +26,20 @@
 | 
			
		|||
  % endif
 | 
			
		||||
</%def>
 | 
			
		||||
 | 
			
		||||
<%def name="modify_tailbone_form()">
 | 
			
		||||
  ${parent.modify_tailbone_form()}
 | 
			
		||||
  % if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
 | 
			
		||||
      <script type="text/javascript">
 | 
			
		||||
 | 
			
		||||
        FormPage.methods.deleteObject = function() {
 | 
			
		||||
            if (confirm("Are you sure you wish to delete this ${model_title}?")) {
 | 
			
		||||
                this.$refs.deleteObjectForm.submit()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      </script>
 | 
			
		||||
  % endif
 | 
			
		||||
</%def>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
${parent.body()}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue