playlist editor draft

This commit is contained in:
bkfox
2022-12-10 03:27:27 +01:00
parent 80cd5baa18
commit cfc0e45439
35 changed files with 13605 additions and 56 deletions

View File

@ -1,7 +1,74 @@
{% comment %}Inline block to edit playlists{% endcomment %}
{% load static i18n %}
{% load aircox aircox_admin static i18n %}
{% with inline_admin_formset.formset.instance as playlist %}
{% include "adminsortable2/edit_inline/tabular-django-4.1.html" %}
{# include "adminsortable2/edit_inline/tabular-django-4.1.html" #}
{% with inline_admin_formset as admin_formset %}
{% with admin_formset.formset as formset %}
<div id="inline-tracks" class="box mb-5">
<h5 class="title is-4">{% trans "Playlist" %}</h5>
<script id="{{ formset.prefix }}-init-data">{
"items": [
{% for form in formset.forms %}
{{ form.initial|json }}
{% if not forloop.last %},{% endif %}
{% endfor %}
]
}
</script>
{{ admin_formset.non_form_errors }}
<a-playlist-editor>
<template v-slot:top="{items}">
<input type="hidden" name="{{ formset.prefix }}-TOTAL_FORMS"
:value="items.length || 0"/>
<input type="hidden" name="{{ formset.prefix }}-INITIAL_FORMS"
value="{{ formset.initial_form_count }}"/>
<input type="hidden" name="{{ formset.prefix }}-MIN_NUM_FORMS"
value="{{ formset.min_num }}"/>
<input type="hidden" name="{{ formset.prefix }}-MAX_NUM_FORMS"
value="{{ formset.max_num }}"/>
</template>
<template #rows-header-head>
<th style="max-width:2em" title="{% trans "Track Position" %}"
aria-description="{% trans "Track Position" %}">
<span class="icon">
<i class="fa fa-arrow-down-1-9"></i>
</span>
</th>
</template>
<template v-slot:row-head="{item,row}">
<td>
[[ row+1 ]]
<input type="hidden"
:name="'{{ formset.prefix }}-' + row + '-position'"
:value="row"/>
<input t-if="item.data.id" type="hidden"
:name="'{{ formset.prefix }}-' + row + '-id'"
:value="item.data.id"/>
{% for field in admin_formset.fields %}
{% if field.name != 'position' and field.widget.is_hidden %}
<input type="hidden"
:name="'{{ formset.prefix }}-' + row + '-{{ field.name }}'"
v-model="item.data[attr]"/>
{% endif %}
{% endfor %}
</td>
</template>
{% for field in admin_formset.fields %}
{% if not field.widget.is_hidden and not field.is_readonly %}
<template v-slot:row-{{ field.name }}="{item,col,row,value,attr,emit}">
<div class="control">
<input type="{{ widget.type }}" class="input half-field"
:name="'{{ formset.prefix }}-' + row + '-{{ field.name }}'"
v-model="item.data[attr]"
@change="emit('change', col)"/>
</div>
</template>
{% endif %}
{% endfor %}
</a-playlist-editor>
</div>
{% endwith %}
{% endwith %}

View File

@ -44,6 +44,9 @@
{% if not init_app %}
initBuilder: false,
{% endif %}
{% if init_el %}
el: "{{ init_el }}",
{% endif %}
})
{% endblock %}
})