Commit a1826765 authored by Anton's avatar Anton

Allow multiple specs in CellEditor

parent d56e1231
......@@ -12,23 +12,23 @@
template(v-if="index > 0")
q-item-separator
q-item
q-item(v-if="cell.type in itemSpecs", v-for="spec in itemSpecs[cell.type]")
q-field(
v-if="cell.type in itemSpecs",
:icon="typeToIconName[cell.type]",
:helper="itemSpecs[cell.type].help",
:error="itemSpecs[cell.type].error",
:error-label="itemSpecs[cell.type].errorMessage",
:helper="spec.help",
:error="spec.error",
:error-label="spec.errorMessage",
style="width: 100%")
q-input(
:float-label="itemSpecs[cell.type].label",
:type="itemSpecs[cell.type].inputType",
:float-label="spec.label",
:type="spec.inputType",
:min-rows="1",
:max-height="500",
:value="cell.content",
@change="value => {handleItemChanged(value, cell)}")
:value="cell[spec.path]",
@change="value => handleItemChanged(value, cell, spec.path)")
q-field(v-else) This cell type is not supported yet: {{ cell.type }}
q-item(v-else)
q-field This cell type is not supported yet: {{ cell.type }}
</template>
<script>
......@@ -45,69 +45,118 @@
'Title': 'title'
},
itemSpecs: {
'Title': {
'Title': [{
inputType: 'text',
type: 'Title',
label: 'Title Cell',
help: '',
error: false,
errorMessage: '',
value: ''
},
'Text': {
value: '',
path: 'content'
}],
'Text': [{
inputType: 'textarea',
type: 'Text',
label: 'Text Cell',
help: '',
error: false,
errorMessage: '',
value: ''
},
'Video': {
value: '',
path: 'content'
}],
'Video': [{
inputType: 'url',
type: 'Video',
label: 'Video Cell',
help: 'Insert a URL to: a video file or a Vimeo / YouTube video page',
error: false,
errorMessage: 'Needs to be a valid URL',
value: ''
value: '',
path: 'content'
}
/*
{
inputType: 'number',
type: 'Video',
label: 'Start',
help: 'Set start point (seconds)',
error: false,
errorMessage: 'Needs to be a valid number',
value: 0,
path: 'start'
},
'Image': {
{
inputType: 'number',
type: 'Video',
label: 'Duration',
help: 'Set duration (seconds)',
error: false,
errorMessage: 'Needs to be a valid number',
value: 0,
path: 'duration'
} */],
'Image': [{
inputType: 'url',
type: 'Image',
label: 'Image Cell',
help: 'Insert a URL to an image file',
error: false,
errorMessage: 'Needs to be a valid URL',
value: ''
},
'Internal-Link': {
value: '',
path: 'content'
}],
'Internal-Link': [{
inputType: 'url',
type: 'Internal-Link',
label: 'Link Cell',
help: 'Insert a URL to a page in this system',
error: false,
errorMessage: 'Needs to be a valid URL',
value: ''
},
'IFrame': {
value: '',
path: 'content'
}],
'IFrame': [{
inputType: 'url',
type: 'IFrame',
label: 'IFrame Cell',
help: 'Insert some URL',
error: false,
errorMessage: 'Needs to be a valid URL',
value: ''
},
'Annotation-List': {
value: '',
path: 'content'
}],
'Annotation-List': [{
inputType: 'text',
type: 'Annotation-List',
label: 'Annotation List Cell',
help: 'Insert a Video UUID',
error: false,
errorMessage: '',
value: ''
value: '',
path: 'content'
}
/*
{
inputType: 'number',
type: 'Video',
label: 'Start',
help: 'Filter from video start point (seconds)',
error: false,
errorMessage: 'Needs to be a valid number',
value: 0,
path: 'start'
},
{
inputType: 'number',
type: 'Video',
label: 'Duration',
help: 'Filter duration (seconds)',
error: false,
errorMessage: 'Needs to be a valid number',
value: 0,
path: 'duration'
} */]
}
}
},
......@@ -115,18 +164,18 @@
// console.log(this.$props.cells)
// },
methods: {
handleItemChanged (value, cell) {
handleItemChanged (value, cell, path) {
if (cell.inputType !== 'url') {
this.updateCellContent(value, cell)
this.updateCellContent(value, cell, path)
}
else {
cell.error = !(/^http[s]?:\/\/.+/.test(value))
if (!cell.error) {
this.updateCellContent(value, cell)
this.updateCellContent(value, cell, path)
}
}
},
updateCellContent (value, cell) {
updateCellContent (value, cell, path) {
const _this = this
// can't remember why the extra sourceUuid is needed …
// maybe if this is an annotation made in piecemaker (video),
......@@ -136,7 +185,7 @@
this.$store.dispatch('annotations/find', { 'uuid': destUuid })
.then(annotations => {
const a = annotations.items.shift()
cell.content = value
cell[path] = value
a.body.value = JSON.stringify(cell)
_this.$store.dispatch('annotations/patch', [destUuid, { body: a.body, target: a.target }])
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment