diff --git a/aircox/templates/aircox/dashboard/v_form_field.html b/aircox/templates/aircox/dashboard/v_form_field.html
index 29e6882..d2809a1 100644
--- a/aircox/templates/aircox/dashboard/v_form_field.html
+++ b/aircox/templates/aircox/dashboard/v_form_field.html
@@ -9,7 +9,7 @@ Context:
{% endcomment %}
{% load aircox %}
-{% if field.is_hidden or hidden %}
+{% if field.widget.is_hidden or hidden %}
{% elif field|is_checkbox %}
diff --git a/assets/src/components/AFormSet.vue b/assets/src/components/AFormSet.vue
index b1d58ae..fcf03fb 100644
--- a/assets/src/components/AFormSet.vue
+++ b/assets/src/components/AFormSet.vue
@@ -8,7 +8,7 @@
$emit('cell', e)">
@@ -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)
diff --git a/assets/src/components/ARows.vue b/assets/src/components/ARows.vue
index 92cedfb..d31c054 100644
--- a/assets/src/components/ARows.vue
+++ b/assets/src/components/ARows.vue
@@ -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}`)
*/
diff --git a/assets/src/components/ATrackListEditor.vue b/assets/src/components/ATrackListEditor.vue
index fc49ecf..18ca6d3 100644
--- a/assets/src/components/ATrackListEditor.vue
+++ b/assets/src/components/ATrackListEditor.vue
@@ -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">
@@ -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
},
}