Changeset - dd9cb0a5aba3
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 7 years ago 2018-05-20 22:07:36
thomas.de_schampheleire@nokia.com
admin: hooks: restore delete functionality as intended

Commit 9d34bea3059d9abd0d912f37a2475ee67c8e2918 ("style: various minor-ish
markup changes, preparing for Bootstrap") partially broke the delete
functionality of hooks. When clicking the delete button, the hook is deleted
via AJAX and then the corresponding form group is intended to be removed
visually. This relies on an 'id' attribute on the form-group div.

The mentioned commit moved the div with the 'id' attribute outside the loop
iterating over the different hooks, so that there no longer is a div with
the id expected by the delete button. The hook would still be deleted, but
the page visually still looks the same until refresh/Save.

Move the diff back into the loop. This causes a little more visual
separation between the different hooks, but still looks OK.
The layout of the built-in hooks (that can't be removed) is left untouched.
Making the same change there would be possible but there the extra vertical
whitespace seems somewhat unnecessary, although this is personal.
1 file changed with 14 insertions and 14 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/admin/settings/settings_hooks.html
Show inline comments
 
@@ -15,23 +15,23 @@
 
% if c.visual.allow_custom_hooks_settings:
 
${h.form(url('admin_settings_hooks'), method='post')}
 
<div class="form">
 
        <div class="form-group form-inline" id="${'id%s' % hook.ui_id }">
 
        <h4>${_('Custom Hooks')}</h4>
 
        %for hook in c.custom_hooks:
 
            <% input_id = hook.ui_key.replace('.', '_') %>
 
                <label class="control-label" for="${input_id}">${hook.ui_key}</label>
 
                <div>
 
                    ${h.hidden('hook_ui_key',hook.ui_key,id='hook_ui_key_'+input_id)}
 
                    ${h.hidden('hook_ui_value',hook.ui_value,id='hook_ui_value_'+input_id)}
 
                    ${h.text('hook_ui_value_new',hook.ui_value,id=input_id,size=60,class_='form-control')}
 
                    <button type="button" class="btn btn-default btn-xs"
 
                        onclick="delete_hook(${hook.ui_id},'${'id%s' % hook.ui_id }')">
 
                        <i class="icon-trashcan"></i>
 
                        ${_('Delete')}
 
                    </button>
 
                </div>
 
            <div class="form-group form-inline" id="${'id%s' % hook.ui_id }">
 
                <% input_id = hook.ui_key.replace('.', '_') %>
 
                    <label class="control-label" for="${input_id}">${hook.ui_key}</label>
 
                    <div>
 
                        ${h.hidden('hook_ui_key',hook.ui_key,id='hook_ui_key_'+input_id)}
 
                        ${h.hidden('hook_ui_value',hook.ui_value,id='hook_ui_value_'+input_id)}
 
                        ${h.text('hook_ui_value_new',hook.ui_value,id=input_id,size=60,class_='form-control')}
 
                        <button type="button" class="btn btn-default btn-xs"
 
                            onclick="delete_hook(${hook.ui_id},'${'id%s' % hook.ui_id }')">
 
                            <i class="icon-trashcan"></i>
 
                            ${_('Delete')}
 
                        </button>
 
                    </div>
 
            </div>
 
        %endfor
 
        </div>
 

	
 
        <div class="form-group form-inline">
 
            <label>
0 comments (0 inline, 0 general)