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