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',
 | 
					    template: '#tailbone-form-template',
 | 
				
			||||||
    methods: {}
 | 
					    methods: {}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let FormPage = {
 | 
				
			||||||
 | 
					    template: '#form-page-template',
 | 
				
			||||||
 | 
					    methods: {}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,10 +75,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Vue.component('tailbone-form', TailboneForm)
 | 
					    Vue.component('tailbone-form', TailboneForm)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const FormPage = {
 | 
					 | 
				
			||||||
        template: '#form-page-template'
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Vue.component('form-page', FormPage)
 | 
					    Vue.component('form-page', FormPage)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    new Vue({
 | 
					    new Vue({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,9 +5,16 @@
 | 
				
			||||||
  % if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)):
 | 
					  % if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)):
 | 
				
			||||||
      % if master.delete_confirm == 'simple':
 | 
					      % if master.delete_confirm == 'simple':
 | 
				
			||||||
          <li>
 | 
					          <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)}
 | 
					            ${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}
 | 
					              Delete this ${model_title}
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
            ${h.end_form()}
 | 
					            ${h.end_form()}
 | 
				
			||||||
| 
						 | 
					@ -19,4 +26,20 @@
 | 
				
			||||||
  % endif
 | 
					  % endif
 | 
				
			||||||
</%def>
 | 
					</%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()}
 | 
					${parent.body()}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue