fix lots of stuff, migrate to new client api
This commit is contained in:
parent
4e9fd55093
commit
710460cc88
19 changed files with 384 additions and 224 deletions
|
@ -145,7 +145,7 @@
|
|||
{% if field.modify %}
|
||||
<template id='{{field.name}}-template' data-fieldlist-name="{{ field.name }}" data-fieldlist-next-id="{{ field | length }}">
|
||||
<li class="list-group-item">
|
||||
{{ _render_form(field.get_template(), horizontal=true) }}
|
||||
{{ _render_field(field.get_template(), horizontal=true) }}
|
||||
<a class="btn btn-danger" onclick="fieldlist.remove(this)">{{ ('Remove') }}</a>
|
||||
</li>
|
||||
</template>
|
||||
|
@ -174,6 +174,8 @@
|
|||
{{ render_password_field(f, **kwargs) }}
|
||||
{% elif f.type == 'DecimalRangeField' %}
|
||||
{{ render_range_field(f, **kwargs) }}
|
||||
{% elif f.type == 'URLField' %}
|
||||
{{ render_field(f, **kwargs) }}
|
||||
{% elif f.type == 'SubmitField' %}
|
||||
{{ render_submit_field(f, **kwargs) }}
|
||||
{% elif f.type == 'FormField' %}
|
||||
|
|
|
@ -34,6 +34,26 @@
|
|||
<script type="application/javascript" src="/static/main.js?v={{ GIT_HASH }}" ></script>
|
||||
<script type="application/javascript" >
|
||||
{% block script_js %}{% endblock %}
|
||||
window.fieldlist = {
|
||||
add: function(linkTag) {
|
||||
|
||||
var templateTag = linkTag.parentNode.querySelector('template');
|
||||
var name = templateTag.dataset['fieldlistName'];
|
||||
var template = templateTag.content.cloneNode(true);
|
||||
var id = templateTag.dataset['fieldlistNextId']++;
|
||||
for(let tag of template.querySelectorAll('[name], [id]')){
|
||||
tag.name = tag.name.replace(/^custom-/, name+'-'+id+'-')
|
||||
tag.id = tag.id.replace(/^custom-/, name+'-'+id+'-')
|
||||
};
|
||||
templateTag.parentNode.querySelector('ul').appendChild(template);
|
||||
|
||||
return false;
|
||||
},
|
||||
remove: function(base) {
|
||||
base.parentElement.remove()
|
||||
return false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue