save settings
This commit is contained in:
parent
07983d7378
commit
339ba9a55a
|
@ -58,6 +58,7 @@ class SoundCreateForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = models.Sound
|
||||
fields = ["name", "program", "file", "broadcast", "is_public", "is_downloadable"]
|
||||
widgets = {"program": forms.HiddenInput()}
|
||||
|
||||
|
||||
TrackFormSet = modelformset_factory(
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@ Context:
|
|||
{% endcomment %}
|
||||
{% load aircox %}
|
||||
|
||||
{% if field.is_hidden or hidden %}
|
||||
{% if field.widget.is_hidden or hidden %}
|
||||
<input type="hidden" name="{{ name }}" value="{{ value|default:"" }}">
|
||||
{% elif field|is_checkbox %}
|
||||
<input type="checkbox" class="checkbox" name="{{ name }}" {% if value %}checked{% endif %}>
|
||||
|
|
|
@ -28,7 +28,7 @@ sound-delete-url="{% url "api:sound-detail" pk=123 %}"
|
|||
<template #upload-form>
|
||||
{% for field in sound_form %}
|
||||
{% with field.name as name %}
|
||||
{% if name in "episode" %}
|
||||
{% if name in "program" %}
|
||||
{% include "./form_field.html" with value=field.initial field=field.field hidden=True %}
|
||||
{% elif name != "file" %}
|
||||
<div class="field is-horizontal">
|
||||
|
|
|
@ -9,7 +9,7 @@ Context:
|
|||
{% endcomment %}
|
||||
{% load aircox %}
|
||||
|
||||
{% if field.is_hidden or hidden %}
|
||||
{% if field.widget.is_hidden or hidden %}
|
||||
<input type="hidden" :name="{{ name }}" :value="{{ value|default:"" }}">
|
||||
{% elif field|is_checkbox %}
|
||||
<input type="checkbox" class="checkbox" :name="{{ name }}" v-model="{{ value }}">
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<a-rows ref="rows" :set="set"
|
||||
:columns="visibleFields" :columnsOrderable="columnsOrderable"
|
||||
:orderable="orderable" @move="moveItem" @colmove="onMoveColumn"
|
||||
:orderable="orderable" @move="moveItem" @colmove="onColumnMove"
|
||||
@cell="e => $emit('cell', e)">
|
||||
|
||||
<template #header-head>
|
||||
|
@ -149,7 +149,7 @@
|
|||
|
||||
methods: {
|
||||
onCellEvent(event) { this.$emit('cell', event) },
|
||||
onMoveColumn(event) { this.$emit('colmove', event) },
|
||||
onColumnMove(event) { this.$emit('colmove', event) },
|
||||
onActionAdd() {
|
||||
if(this.actionAdd)
|
||||
return this.actionAdd(this)
|
||||
|
|
|
@ -47,6 +47,9 @@ import ARow from './ARow.vue'
|
|||
const Component = {
|
||||
extends: AList,
|
||||
components: { ARow },
|
||||
//! Event:
|
||||
//! - cell(event): an event occured inside cell
|
||||
//! - colmove({from,to}), colmove(): columns moved
|
||||
emits: ['cell', 'colmove'],
|
||||
|
||||
props: {
|
||||
|
@ -83,6 +86,14 @@ const Component = {
|
|||
},
|
||||
|
||||
methods: {
|
||||
// TODO: use in tracklist
|
||||
sortColumns(names) {
|
||||
const ordered = names.map(n => this.columns_.find(c => c.name == n)).filter(c => !!c);
|
||||
const remaining = this.columns_.filter(c => names.indexOf(c.name) == -1)
|
||||
this.columns_ = [...ordered, ...remaining]
|
||||
this.$emit('colmove')
|
||||
},
|
||||
|
||||
/**
|
||||
* Move column using provided event object (as `{from, to}`)
|
||||
*/
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
:form-data="formData" :initials="initData.items"
|
||||
:columnsOrderable="true" :labels="labels"
|
||||
order-by="position"
|
||||
@load="updateInput" @colmove="updateInput" @move="updateInput"
|
||||
@load="updateInput" @colmove="onColumnMove" @move="updateInput"
|
||||
@cell="onCellEvent">
|
||||
<template v-for="[name,slot] of rowsSlots" :key="slot"
|
||||
v-slot:[slot]="data">
|
||||
|
@ -195,18 +195,8 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
formatMove({from, to}) {
|
||||
this.$refs.formset.rows.columnMove({from, to})
|
||||
/*this.settings.tracklist_editor_columns.splice(from, 1)
|
||||
this.settings.tracklist_editor_columns.splice(to, 0, value)*/
|
||||
},
|
||||
|
||||
moveItem({from, to, set}) {
|
||||
set.move(from, to);
|
||||
this.updateInput()
|
||||
},
|
||||
|
||||
onColumnMove() {
|
||||
this.settings.tracklist_editor_columns = this.$refs.formset.rows.columnNames
|
||||
if(this.page == this.Page.List)
|
||||
this.updateInput()
|
||||
else
|
||||
|
@ -289,20 +279,14 @@ export default {
|
|||
this.$refs.settings.close()
|
||||
this.savedSettings = cloneDeep(this.settings)
|
||||
},
|
||||
|
||||
/**
|
||||
* Load initial data
|
||||
*/
|
||||
/*loadData({items=[], settings=null}, reset=false) {
|
||||
if(settings)
|
||||
this.settingsSaved(settings)
|
||||
this.updateInput()
|
||||
},*/
|
||||
},
|
||||
|
||||
mounted() {
|
||||
//this.initData && this.initData.settings &&
|
||||
//this.initData && this.loadData(this.initData)
|
||||
const settings = this.initData && this.initData.settings
|
||||
if(settings) {
|
||||
this.settingsSaved(settings)
|
||||
this.rows.sortColumns(settings.tracklist_editor_columns)
|
||||
}
|
||||
this.page = this.initData.items.length ? Page.List : Page.Text
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user