multiple layers for edits too

This commit is contained in:
j 2021-11-24 11:53:13 +01:00
parent 83228a5ead
commit db6a2f25bd

View file

@ -300,24 +300,22 @@ async function loadClips(annotations) {
}
function loadAnnotations(config) {
var layers = config.layer
if (!Array.isArray(layers)) {
layers = [layers]
}
if (config.item) {
pandoraAPI('get', {id: config.item, keys: [
'layers'
]}).then(response => {
var annotations = []
if (Array.isArray(config.layer)) {
config.layer.forEach(layer => {
response.data.layers[layer].forEach(annotation => {
if (!(config.user && annotation.user != config.user)) {
annotations.push(annotation)
}
})
layers.forEach(layer => {
response.data.layers[layer].forEach(annotation => {
if (!(config.user && annotation.user != config.user)) {
annotations.push(annotation)
}
})
} else {
annotations = response.data.layers[config.layer].filter(annotation => {
return !(config.user && annotation.user != config.user)
})
}
})
loadClips(annotations).then(annotations => {
config.annotations = annotations.filter(annotation => {
if (config.only_e) {
@ -344,24 +342,26 @@ function loadAnnotations(config) {
director: clip.director,
id: clip.item
}
clip.layers[config.layer].forEach(annotation => {
if (config.user && annotation.user != config.user) {
return
}
;['title', 'director', 'date'].forEach(key => {
annotation[key] = clip[key]
layers.forEach(layer => {
clip.layers[layer].forEach(annotation => {
if (config.user && annotation.user != config.user) {
return
}
;['title', 'director', 'date'].forEach(key => {
annotation[key] = clip[key]
})
if (config.only_e) {
if (annotation.value.slice(0, 2) == 'E:') {
annotation.value = annotation.value.slice(2).trim()
annotations.push(annotation)
}
} else {
if (annotation.value.slice(0, 2) != 'E:') {
annotations.push(annotation)
}
}
})
if (config.only_e) {
if (annotation.value.slice(0, 2) == 'E:') {
annotation.value = annotation.value.slice(2).trim()
annotations.push(annotation)
}
} else {
if (annotation.value.slice(0, 2) != 'E:') {
annotations.push(annotation)
}
}
})
}
})
loadClips(annotations).then(annotations => {
config.annotations = annotations